portfns.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435
  1. /*
  2. * This file is part of the UCB release of Plan 9. It is subject to the license
  3. * terms in the LICENSE file found in the top-level directory of this
  4. * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
  5. * part of the UCB release of Plan 9, including this file, may be copied,
  6. * modified, propagated, or distributed except according to the terms contained
  7. * in the LICENSE file.
  8. */
  9. void _assert(char*);
  10. void accounttime(void);
  11. void acsched(void);
  12. void addbootfile(char*, unsigned char*, uint32_t);
  13. Timer* addclock0link(void (*)(void), int);
  14. int addconsdev(Queue*, void (*fn)(char*,int), int, int);
  15. int addkbdq(Queue*, int);
  16. int addphysseg(Physseg*);
  17. void addwaitstat(uintptr_t pc, uint64_t t0, int type);
  18. void addwatchdog(Watchdog*);
  19. int adec(int*);
  20. Block* adjustblock(Block*, int);
  21. int ainc(int*);
  22. void alarmkproc(void*);
  23. Block* allocb(int);
  24. void* alloczio(Segment*, int32_t);
  25. int anyhigher(void);
  26. int anyready(void);
  27. Image* attachimage(int, Chan*, int, uintptr_t, usize);
  28. Page* auxpage(usize);
  29. Block* bl2mem(unsigned char*, Block*, int);
  30. int blocklen(Block*);
  31. void bootlinks(void);
  32. void cachedel(Image*, uint32_t);
  33. void cachepage(Page*, Image*);
  34. void callwithureg(void (*)(Ureg*));
  35. int canlock(Lock*);
  36. int canpage(Proc*);
  37. int canqlock(QLock*);
  38. int canrlock(RWlock*);
  39. Chan* cclone(Chan*);
  40. void cclose(Chan*);
  41. void ccloseq(Chan*);
  42. void chanfree(Chan*);
  43. char* chanpath(Chan*);
  44. void checkalarms(void);
  45. void checkb(Block*, char*);
  46. void clearwaitstats(void);
  47. void closeegrp(Egrp*);
  48. void closefgrp(Fgrp*);
  49. void closepgrp(Pgrp*);
  50. void closergrp(Rgrp*);
  51. void cmderror(Cmdbuf*, char*);
  52. int cmount(Chan**, Chan*, int, char*);
  53. Block* concatblock(Block*);
  54. void confinit(void);
  55. int consactive(void);
  56. void (*consdebug)(void);
  57. void (*consputs)(char*, int);
  58. Block* copyblock(Block*, int);
  59. void copypage(Page*, Page*);
  60. void cunmount(Chan*, Chan*);
  61. Segment* data2txt(Segment*);
  62. uintptr_t dbgpc(Proc*);
  63. int checkdc(int dc);
  64. int decrypt(void*, void*, int);
  65. void delay(int);
  66. Proc* dequeueproc(Sched*, Schedq*, Proc*);
  67. Chan* devattach(int, char*);
  68. Block* devbread(Chan*, int32_t, int64_t);
  69. int32_t devbwrite(Chan*, Block*, int64_t);
  70. Chan* devclone(Chan*);
  71. int devconfig(int, char *, DevConf *);
  72. void devcreate(Chan*, char*, int, int);
  73. void devdir(Chan*, Qid, char*, int64_t, char*, int32_t, Dir*);
  74. int32_t devdirread(Chan*, char*, int32_t, Dirtab*, int,
  75. Devgen*);
  76. Devgen devgen;
  77. void devinit(void);
  78. Chan* devopen(Chan*, int, Dirtab*, int, Devgen*);
  79. void devpermcheck(char*, int, int);
  80. void devpower(int);
  81. void devremove(Chan*);
  82. void devreset(void);
  83. void devshutdown(void);
  84. int32_t devstat(Chan*, unsigned char*, int32_t, Dirtab*, int,
  85. Devgen*);
  86. Dev* devtabget(int, int);
  87. void devtabinit(void);
  88. int32_t mtagsread(Chan*, void*, int32_t, int64_t);
  89. int32_t devtabread(Chan*, void*, int32_t, int64_t);
  90. void devtabreset(void);
  91. void devtabshutdown(void);
  92. Walkqid* devwalk(Chan*, Chan*, char**, int, Dirtab*, int, Devgen*);
  93. int32_t devwstat(Chan*, unsigned char*, int32_t);
  94. int devzread(Chan*, Kzio*, int, usize, int64_t);
  95. int devzwrite(Chan*, Kzio*, int, int64_t);
  96. void drawactive(int);
  97. void drawcmap(void);
  98. void dumpaproc(Proc*);
  99. void dumpregs(Ureg*);
  100. void dumpstack(void);
  101. void dumpzseg(Segment*);
  102. Fgrp* dupfgrp(Fgrp*);
  103. int duppage(Page*);
  104. Segment* dupseg(Segment**, int, int);
  105. void dupswap(Page*);
  106. char* edfadmit(Proc*);
  107. void edfinit(Proc*);
  108. int edfready(Proc*);
  109. void edfrecord(Proc*);
  110. void edfrun(Proc*, int);
  111. void edfstop(Proc*);
  112. void edfyield(void);
  113. int elf64ldseg(Chan *c, uintptr_t *entryp, Ldseg **rp, char *mach, uint32_t minpgsz);
  114. int emptystr(char*);
  115. int encrypt(void*, void*, int);
  116. void envcpy(Egrp*, Egrp*);
  117. int eqchanddq(Chan*, int, uint, Qid, int);
  118. int eqqid(Qid, Qid);
  119. void error(char*);
  120. void exhausted(char*);
  121. void exit(int);
  122. uint64_t fastticks(uint64_t*);
  123. uint64_t fastticks2ns(uint64_t);
  124. uint64_t fastticks2us(uint64_t);
  125. int fault(uintptr_t, uintptr_t, int);
  126. void fdclose(int, int);
  127. Chan* fdtochan(int, int, int, int);
  128. int findmount(Chan**, Mhead**, int, uint, Qid);
  129. int fixfault(Segment*, uintptr_t, int, int, int);
  130. void fmtinit(void);
  131. void forceclosefgrp(void);
  132. void fortuna_get_bytes(unsigned len, uint8_t *dst);
  133. void fortuna_add_entropy(const uint8_t *data, unsigned len);
  134. void free(void*);
  135. void freeb(Block*);
  136. void freeblist(Block*);
  137. int freebroken(void);
  138. void freepte(Segment*, Pte*);
  139. void getcolor(uint32_t, uint32_t*, uint32_t*, uint32_t*);
  140. char* getconfenv(void);
  141. int getpgszi(uint32_t);
  142. Segment* getzkseg(void);
  143. void gotolabel(Label*);
  144. int haswaitq(void*);
  145. void hexdump(void *v, int length);
  146. void pahexdump(uintptr_t pa, int len);
  147. void hnputl(void*, uint);
  148. void hnputs(void*, uint16_t);
  149. void hnputv(void*, uint64_t);
  150. int32_t hostdomainwrite(char*, int32_t);
  151. int32_t hostownerwrite(char*, int32_t);
  152. void hzsched(void);
  153. Block* iallocb(int);
  154. void iallocsummary(void);
  155. void initmark(Watermark *, int, char *);
  156. void ilock(Lock*);
  157. void initimage(void);
  158. int iprint(char*, ...);
  159. void isdir(Chan*);
  160. int iseve(void);
  161. int islo(void);
  162. Segment* isoverlap(Proc*, uintptr_t, usize);
  163. int isphysseg(char*);
  164. void iunlock(Lock*);
  165. void ixsummary(void);
  166. int kbdcr2nl(Queue*, int);
  167. int kbdgetmap(int, int*, int*, Rune*);
  168. int kbdputc(Queue*, int);
  169. void kbdputmap(uint16_t, uint16_t, Rune);
  170. void kickpager(int, int);
  171. void killbig(char*);
  172. int kmprint(char*, ...);
  173. void kproc(char*, void(*)(void*), void*);
  174. void kprocchild(Proc*, void (*)(void*), void*);
  175. void (*kproftimer)(uintptr_t);
  176. void ksetenv(char*, char*, int);
  177. void kstrcpy(char*, char*, int);
  178. void kstrdup(char**, char*);
  179. int32_t latin1(Rune*, int);
  180. int lock(Lock*);
  181. void log(Log*, int, char*, ...);
  182. void logclose(Log*);
  183. char* logctl(Log*, int, char**, Logflag*);
  184. void logn(Log*, int, void*, int);
  185. void logopen(Log*);
  186. int32_t logread(Log*, void*, int32_t, int64_t);
  187. Page* lookpage(Image*, uint32_t);
  188. Cmdtab* lookupcmd(Cmdbuf*, Cmdtab*, int);
  189. void mallocinit(void);
  190. int32_t mallocreadsummary(Chan*, void*, int32_t, int32_t);
  191. void mallocsummary(void);
  192. Block* mem2bl(unsigned char*, int);
  193. void (*mfcinit)(void);
  194. void (*mfcopen)(Chan*);
  195. int (*mfcread)(Chan*, unsigned char*, int, int64_t);
  196. void (*mfcupdate)(Chan*, unsigned char*, int, int64_t);
  197. void (*mfcwrite)(Chan*, unsigned char*, int, int64_t);
  198. void mfreeseg(Segment*, uintptr_t, int);
  199. void microdelay(int);
  200. uint64_t mk64fract(uint64_t, uint64_t);
  201. void mkqid(Qid*, int64_t, uint32_t, int);
  202. void mmuflush(void);
  203. void mmuput(uintptr_t, Page*, uint);
  204. void mmurelease(Proc*);
  205. void mmuswitch(Proc*);
  206. Chan* mntauth(Chan*, char*);
  207. usize mntversion(Chan*, uint32_t, char*, usize);
  208. void mountfree(Mount*);
  209. uint64_t ms2fastticks(uint32_t);
  210. #define MS2NS(n) (((int64_t)(n))*1000000LL)
  211. uint32_t ms2tk(uint32_t);
  212. void mul64fract(uint64_t*, uint64_t, uint64_t);
  213. void muxclose(Mnt*);
  214. void (*mwait)(void *);
  215. Chan* namec(char*, int, int, int);
  216. void nameerror(char*, char*);
  217. Chan* newchan(void);
  218. int newfd(Chan*);
  219. Mhead* newmhead(Chan*);
  220. Mount* newmount(Mhead*, Chan*, int, char*);
  221. Page* newpage(int, Segment **, uintptr_t, usize, int);
  222. Path* newpath(char*);
  223. Pgrp* newpgrp(void);
  224. Proc* newproc(void);
  225. Rgrp* newrgrp(void);
  226. Segment* newseg(int, uintptr_t, uint64_t);
  227. void newzmap(Segment*);
  228. void nexterror(void);
  229. void notemark(Watermark *, int);
  230. uint nhgetl(void*);
  231. uint16_t nhgets(void*);
  232. uint64_t nhgetv(void*);
  233. void nixprepage(int);
  234. int nrand(int);
  235. uint64_t ns2fastticks(uint64_t);
  236. int okaddr(uintptr_t, int32_t, int);
  237. int openmode(int);
  238. Block* packblock(Block*);
  239. Block* padblock(Block*, int);
  240. void pagechainhead(Page*);
  241. void pageinit(void);
  242. uint32_t pagenumber(Page*);
  243. uint64_t pagereclaim(Image*);
  244. void pagersummary(void);
  245. void pageunchain(Page*);
  246. void panic(char*, ...);
  247. Cmdbuf* parsecmd(char *a, int n);
  248. void pathclose(Path*);
  249. uint32_t perfticks(void);
  250. void pexit(char*, int);
  251. Page* pgalloc(usize, int);
  252. void pgfree(Page*);
  253. void pgrpcpy(Pgrp*, Pgrp*);
  254. void pgrpnote(uint32_t, char*, int32_t, int);
  255. uintmem physalloc(uint64_t, int*, void*);
  256. void physdump(void);
  257. void physfree(uintmem, uint64_t);
  258. void physinit(uintmem, uint64_t);
  259. void* phystag(uintmem);
  260. void pio(Segment*, uintptr_t, uint32_t, Page**, int);
  261. void portmwait(void*);
  262. int postnote(Proc*, int, char*, int);
  263. int pprint(char*, ...);
  264. int preempted(void);
  265. void prflush(void);
  266. void printinit(void);
  267. uint32_t procalarm(uint32_t);
  268. void procctl(Proc*);
  269. void procdump(void);
  270. int procfdprint(Chan*, int, int, char*, int);
  271. void procflushseg(Segment*);
  272. void procinit0(void);
  273. void procpriority(Proc*, int, int);
  274. void procrestore(Proc*);
  275. void procsave(Proc*);
  276. void (*proctrace)(Proc*, int, int64_t);
  277. void proctracepid(Proc*);
  278. void procwired(Proc*, int);
  279. void psdecref(Proc*);
  280. Proc* psincref(int);
  281. int psindex(int);
  282. void psinit(int);
  283. Pte* ptealloc(Segment*);
  284. Pte* ptecpy(Segment*,Pte*);
  285. int pullblock(Block**, int);
  286. Block* pullupblock(Block*, int);
  287. Block* pullupqueue(Queue*, int);
  288. void putimage(Image*);
  289. void putmhead(Mhead*);
  290. void putpage(Page*);
  291. void putseg(Segment*);
  292. void putstrn(char*, int);
  293. void putswap(Page*);
  294. int pwait(Waitmsg*);
  295. void qaddlist(Queue*, Block*);
  296. Block* qbread(Queue*, int);
  297. int32_t qbwrite(Queue*, Block*);
  298. int32_t qibwrite(Queue*, Block*);
  299. Queue* qbypass(void (*)(void*, Block*), void*);
  300. int qcanread(Queue*);
  301. void qclose(Queue*);
  302. int qconsume(Queue*, void*, int);
  303. Block* qcopy(Queue*, int, uint32_t);
  304. int qdiscard(Queue*, int);
  305. void qflush(Queue*);
  306. void qfree(Queue*);
  307. int qfull(Queue*);
  308. Block* qget(Queue*);
  309. void qhangup(Queue*, char*);
  310. int qisclosed(Queue*);
  311. int qiwrite(Queue*, void*, int);
  312. int qlen(Queue*);
  313. void qlock(QLock*);
  314. void qnoblock(Queue*, int);
  315. Queue* qopen(int, int, void (*)(void*), void*);
  316. int qpass(Queue*, Block*);
  317. int qpassnolim(Queue*, Block*);
  318. int qproduce(Queue*, void*, int);
  319. void qputback(Queue*, Block*);
  320. int32_t qread(Queue*, void*, int);
  321. Block* qremove(Queue*);
  322. void qreopen(Queue*);
  323. void qsetlimit(Queue*, int);
  324. void qunlock(QLock*);
  325. int qwindow(Queue*);
  326. int qwrite(Queue*, void*, int);
  327. int rand(void);
  328. uint32_t randomread(void*, uint32_t);
  329. uint32_t urandomread(void*, uint32_t);
  330. void rdb(void);
  331. int readnum(uint32_t, char*, uint32_t, uint32_t, int);
  332. int32_t readstr(int32_t, char*, int32_t, char*);
  333. int32_t readmem(int32_t, void*, int32_t, void*, int32_t);
  334. void ready(Proc*);
  335. int32_t readzio(Kzio[], int, void*, int32_t);
  336. void reboot(void*, void*, int32_t);
  337. void rebootcmd(int, char**);
  338. void relocateseg(Segment*, uintptr_t);
  339. void renameuser(char*, char*);
  340. void resched(char*);
  341. void resrcwait(char*);
  342. int return0(void*);
  343. void rlock(RWlock*);
  344. int32_t rtctime(void);
  345. int runac(Mach *m, void(*func)(void), int flushtlb, void *a,
  346. int32_t n);
  347. void runlock(RWlock*);
  348. Proc* runproc(void);
  349. void sched(void);
  350. void scheddump(void);
  351. void schedinit(void);
  352. int32_t seconds(void);
  353. Segment* seg(Proc*, uintptr_t, int);
  354. void segclock(uintptr_t);
  355. void segpage(Segment*, Page*);
  356. char* seprintmark(char *, char *, Watermark *);
  357. uintmem segppn(Segment*, uintmem);
  358. int semadec(int*);
  359. int semainc(int*);
  360. char* seprintpagestats(char*, char*);
  361. char* seprintphysstats(char*, char*);
  362. int setcolor(uint32_t, uint32_t, uint32_t, uint32_t);
  363. void setkernur(Ureg*, Proc*);
  364. // The horror. But, well, it does make a BIG performance difference. We're told.
  365. int slim_setlabel(Label*);
  366. void setregisters(Ureg*, char*, char*, int);
  367. char* skipslash(char*);
  368. void sleep(Rendez*, int (*)(void*), void*);
  369. void* smalloc(uint32_t);
  370. char* srvname(Chan*);
  371. void startwaitstats(int);
  372. int swapcount(uint32_t);
  373. void swapinit(void);
  374. void syscallfmt(uint8_t, int, Ar0*, uint64_t, uint64_t, ...);
  375. void sysrforkchild(Proc*, Proc*);
  376. void timeradd(Timer*);
  377. void timerdel(Timer*);
  378. void timerintr(Ureg*, int64_t);
  379. void timerset(uint64_t);
  380. void timersinit(void);
  381. uint32_t tk2ms(uint32_t);
  382. #define TK2MS(x) ((x)*(1000/HZ))
  383. uint64_t tod2fastticks(int64_t);
  384. int64_t todget(int64_t*);
  385. void todinit(void);
  386. void todset(int64_t, int64_t, int);
  387. void todsetfreq(int64_t);
  388. Block* trimblock(Block*, int, int);
  389. void tsleep(Rendez*, int (*)(void*), void*, int32_t);
  390. Uart* uartconsole(int, char*);
  391. int uartctl(Uart*, char*);
  392. int uartgetc(void);
  393. void uartkick(void*);
  394. void uartputc(int);
  395. void uartputs(char*, int);
  396. void uartrecv(Uart*, char);
  397. int uartstageoutput(Uart*);
  398. void unbreak(Proc*);
  399. void uncachepage(Page*);
  400. void unlock(Lock*);
  401. void userinit(void);
  402. uintptr_t userpc(Ureg*);
  403. int32_t userwrite(char*, int32_t);
  404. void* validaddr(void*, int32_t, int);
  405. void validname(char*, int);
  406. char* validnamedup(char*, int);
  407. void validstat(unsigned char*, usize);
  408. void* vmemchr(void*, int, int);
  409. Proc* wakeup(Rendez*);
  410. int walk(Chan**, char**, int, int, int*);
  411. void wlock(RWlock*);
  412. void wunlock(RWlock*);
  413. void yield(void);
  414. uintptr_t zgetaddr(Segment*);
  415. void zgrow(Segment*);
  416. int ziofmt(Fmt*);
  417. int zputaddr(Segment*, uintptr_t);
  418. uint32_t ms(void);
  419. #pragma varargck argpos iprint 1
  420. #pragma varargck argpos panic 1
  421. #pragma varargck argpos pprint 1
  422. /* profiling. */
  423. void oprofile_control_trace(int onoff);
  424. int oprofread(void *va, int n);
  425. void oprof_alarm_handler(Ureg *u);
  426. void oprofile_add_backtrace(uintptr_t pc, uintptr_t fp);
  427. void oprofile_add_userpc(uintptr_t pc);
  428. int alloc_cpu_buffers(void);
  429. #define I_AM_HERE print("Core 0 is in %s() at %s:%d\n", \
  430. __FUNCTION__, __FILE__, __LINE__);