portfns.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438
  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 decrypt(void*, void*, int);
  64. void delay(int);
  65. void delconsdevs(void);
  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 devtabread(Chan*, void*, int32_t, int64_t);
  89. void devtabreset(void);
  90. void devtabshutdown(void);
  91. Walkqid* devwalk(Chan*, Chan*, char**, int, Dirtab*, int, Devgen*);
  92. int32_t devwstat(Chan*, unsigned char*, int32_t);
  93. int devzread(Chan*, Kzio*, int, usize, int64_t);
  94. int devzwrite(Chan*, Kzio*, int, int64_t);
  95. void drawactive(int);
  96. void drawcmap(void);
  97. void dumpaproc(Proc*);
  98. void dumpregs(Ureg*);
  99. void dumpstack(void);
  100. void dumpzseg(Segment*);
  101. Fgrp* dupfgrp(Fgrp*);
  102. int duppage(Page*);
  103. Segment* dupseg(Segment**, int, int);
  104. void dupswap(Page*);
  105. char* edfadmit(Proc*);
  106. void edfinit(Proc*);
  107. int edfready(Proc*);
  108. void edfrecord(Proc*);
  109. void edfrun(Proc*, int);
  110. void edfstop(Proc*);
  111. void edfyield(void);
  112. int emptystr(char*);
  113. int encrypt(void*, void*, int);
  114. void envcpy(Egrp*, Egrp*);
  115. int eqchanddq(Chan*, int, uint, Qid, int);
  116. int eqqid(Qid, Qid);
  117. void error(char*);
  118. void exhausted(char*);
  119. void exit(int);
  120. uint64_t fastticks(uint64_t*);
  121. uint64_t fastticks2ns(uint64_t);
  122. uint64_t fastticks2us(uint64_t);
  123. int fault(uintptr_t, int);
  124. void fdclose(int, int);
  125. Chan* fdtochan(int, int, int, int);
  126. int findmount(Chan**, Mhead**, int, uint, Qid);
  127. int fixfault(Segment*, uintptr_t, int, int, int);
  128. void fmtinit(void);
  129. void forceclosefgrp(void);
  130. void free(void*);
  131. void freeb(Block*);
  132. void freeblist(Block*);
  133. int freebroken(void);
  134. void freepte(Segment*, Pte*);
  135. void getcolor(uint32_t, uint32_t*, uint32_t*, uint32_t*);
  136. char* getconfenv(void);
  137. int getpgszi(uint32_t);
  138. Segment* getzkseg(void);
  139. void gotolabel(Label*);
  140. int haswaitq(void*);
  141. void hexdump(void *v, int length);
  142. void pahexdump(uintptr_t pa, int len);
  143. void hnputl(void*, uint);
  144. void hnputs(void*, uint16_t);
  145. void hnputv(void*, uint64_t);
  146. int32_t hostdomainwrite(char*, int32_t);
  147. int32_t hostownerwrite(char*, int32_t);
  148. void hzsched(void);
  149. Block* iallocb(int);
  150. void iallocsummary(void);
  151. void initmark(Watermark *, int, char *);
  152. void ilock(Lock*);
  153. void initimage(void);
  154. int iprint(char*, ...);
  155. void isdir(Chan*);
  156. int iseve(void);
  157. int islo(void);
  158. Segment* isoverlap(Proc*, uintptr_t, usize);
  159. int isphysseg(char*);
  160. void iunlock(Lock*);
  161. void ixsummary(void);
  162. int kbdcr2nl(Queue*, int);
  163. int kbdgetmap(int, int*, int*, Rune*);
  164. int kbdputc(Queue*, int);
  165. void kbdputmap(uint16_t, uint16_t, Rune);
  166. void kickpager(int, int);
  167. void killbig(char*);
  168. void kproc(char*, void(*)(void*), void*);
  169. void kprocchild(Proc*, void (*)(void*), void*);
  170. void (*kproftimer)(uintptr_t);
  171. void ksetenv(char*, char*, int);
  172. void kstrcpy(char*, char*, int);
  173. void kstrdup(char**, char*);
  174. int32_t latin1(Rune*, int);
  175. int lock(Lock*);
  176. void log(Log*, int, char*, ...);
  177. void logclose(Log*);
  178. char* logctl(Log*, int, char**, Logflag*);
  179. void logn(Log*, int, void*, int);
  180. void logopen(Log*);
  181. int32_t logread(Log*, void*, uint32_t, int32_t);
  182. Page* lookpage(Image*, uint32_t);
  183. Cmdtab* lookupcmd(Cmdbuf*, Cmdtab*, int);
  184. void mallocinit(void);
  185. int32_t mallocreadsummary(Chan*, void*, int32_t, int32_t);
  186. void mallocsummary(void);
  187. Block* mem2bl(unsigned char*, int);
  188. void (*mfcinit)(void);
  189. void (*mfcopen)(Chan*);
  190. int (*mfcread)(Chan*, unsigned char*, int, int64_t);
  191. void (*mfcupdate)(Chan*, unsigned char*, int, int64_t);
  192. void (*mfcwrite)(Chan*, unsigned char*, int, int64_t);
  193. void mfreeseg(Segment*, uintptr_t, int);
  194. void microdelay(int);
  195. uint64_t mk64fract(uint64_t, uint64_t);
  196. void mkqid(Qid*, int64_t, uint32_t, int);
  197. void mmuflush(void);
  198. void mmuput(uintptr_t, Page*, uint);
  199. void mmurelease(Proc*);
  200. void mmuswitch(Proc*);
  201. Chan* mntauth(Chan*, char*);
  202. usize mntversion(Chan*, uint32_t, char*, usize);
  203. void mountfree(Mount*);
  204. uint64_t ms2fastticks(uint32_t);
  205. #define MS2NS(n) (((int64_t)(n))*1000000LL)
  206. uint32_t ms2tk(uint32_t);
  207. void mul64fract(uint64_t*, uint64_t, uint64_t);
  208. void muxclose(Mnt*);
  209. void (*mwait)(void *);
  210. Chan* namec(char*, int, int, int);
  211. void nameerror(char*, char*);
  212. Chan* newchan(void);
  213. int newfd(Chan*);
  214. Mhead* newmhead(Chan*);
  215. Mount* newmount(Mhead*, Chan*, int, char*);
  216. Page* newpage(int, Segment **, uintptr_t, usize, int);
  217. Path* newpath(char*);
  218. Pgrp* newpgrp(void);
  219. Proc* newproc(void);
  220. Rgrp* newrgrp(void);
  221. Segment* newseg(int, uintptr_t, uint64_t);
  222. void newzmap(Segment*);
  223. void nexterror(void);
  224. void notemark(Watermark *, int);
  225. uint nhgetl(void*);
  226. uint16_t nhgets(void*);
  227. uint64_t nhgetv(void*);
  228. void nixprepage(int);
  229. int nrand(int);
  230. uint64_t ns2fastticks(uint64_t);
  231. int okaddr(uintptr_t, int32_t, int);
  232. int openmode(int);
  233. Block* packblock(Block*);
  234. Block* padblock(Block*, int);
  235. void pagechainhead(Page*);
  236. void pageinit(void);
  237. uint32_t pagenumber(Page*);
  238. uint64_t pagereclaim(Image*);
  239. void pagersummary(void);
  240. void pageunchain(Page*);
  241. void panic(char*, ...);
  242. Cmdbuf* parsecmd(char *a, int n);
  243. void pathclose(Path*);
  244. uint32_t perfticks(void);
  245. void pexit(char*, int);
  246. Page* pgalloc(usize, int);
  247. void pgfree(Page*);
  248. void pgrpcpy(Pgrp*, Pgrp*);
  249. void pgrpnote(uint32_t, char*, int32_t, int);
  250. uintmem physalloc(uint64_t, int*, void*);
  251. void physdump(void);
  252. void physfree(uintmem, uint64_t);
  253. void physinit(uintmem, uint64_t);
  254. void* phystag(uintmem);
  255. void pio(Segment*, uintptr_t, uint32_t, Page**, int);
  256. #define poperror() m->externup->nerrlab--
  257. void portmwait(void*);
  258. int postnote(Proc*, int, char*, int);
  259. int pprint(char*, ...);
  260. int preempted(void);
  261. void prflush(void);
  262. void printinit(void);
  263. uint32_t procalarm(uint32_t);
  264. void procctl(Proc*);
  265. void procdump(void);
  266. int procfdprint(Chan*, int, int, char*, int);
  267. void procflushseg(Segment*);
  268. void procinit0(void);
  269. void procpriority(Proc*, int, int);
  270. void procrestore(Proc*);
  271. void procsave(Proc*);
  272. void (*proctrace)(Proc*, int, int64_t);
  273. void proctracepid(Proc*);
  274. void procwired(Proc*, int);
  275. void psdecref(Proc*);
  276. Proc* psincref(int);
  277. int psindex(int);
  278. void psinit(int);
  279. Pte* ptealloc(Segment*);
  280. Pte* ptecpy(Segment*,Pte*);
  281. int pullblock(Block**, int);
  282. Block* pullupblock(Block*, int);
  283. Block* pullupqueue(Queue*, int);
  284. void putimage(Image*);
  285. void putmhead(Mhead*);
  286. void putpage(Page*);
  287. void putseg(Segment*);
  288. void putstrn(char*, int);
  289. void putswap(Page*);
  290. int pwait(Waitmsg*);
  291. void qaddlist(Queue*, Block*);
  292. Block* qbread(Queue*, int);
  293. int32_t qbwrite(Queue*, Block*);
  294. int32_t qibwrite(Queue*, Block*);
  295. Queue* qbypass(void (*)(void*, Block*), void*);
  296. int qcanread(Queue*);
  297. void qclose(Queue*);
  298. int qconsume(Queue*, void*, int);
  299. Block* qcopy(Queue*, int, uint32_t);
  300. int qdiscard(Queue*, int);
  301. void qflush(Queue*);
  302. void qfree(Queue*);
  303. int qfull(Queue*);
  304. Block* qget(Queue*);
  305. void qhangup(Queue*, char*);
  306. int qisclosed(Queue*);
  307. int qiwrite(Queue*, void*, int);
  308. int qlen(Queue*);
  309. void qlock(QLock*);
  310. void qnoblock(Queue*, int);
  311. Queue* qopen(int, int, void (*)(void*), void*);
  312. int qpass(Queue*, Block*);
  313. int qpassnolim(Queue*, Block*);
  314. int qproduce(Queue*, void*, int);
  315. void qputback(Queue*, Block*);
  316. int32_t qread(Queue*, void*, int);
  317. Block* qremove(Queue*);
  318. void qreopen(Queue*);
  319. void qsetlimit(Queue*, int);
  320. void qunlock(QLock*);
  321. int qwindow(Queue*);
  322. int qwrite(Queue*, void*, int);
  323. int rand(void);
  324. void randominit(void);
  325. uint32_t randomread(void*, uint32_t);
  326. uint32_t urandomread(void*, uint32_t);
  327. void rdb(void);
  328. int readnum(uint32_t, char*, uint32_t, uint32_t, int);
  329. int32_t readstr(int32_t, char*, int32_t, char*);
  330. void ready(Proc*);
  331. int32_t readzio(Kzio[], int, void*, int32_t);
  332. void reboot(void*, void*, int32_t);
  333. void rebootcmd(int, char**);
  334. void relocateseg(Segment*, uintptr_t);
  335. void renameuser(char*, char*);
  336. void resched(char*);
  337. void resrcwait(char*);
  338. int return0(void*);
  339. void rlock(RWlock*);
  340. int32_t rtctime(void);
  341. int runac(Mach *m, void(*func)(void), int flushtlb, void *a,
  342. int32_t n);
  343. void runlock(RWlock*);
  344. Proc* runproc(void);
  345. void sched(void);
  346. void scheddump(void);
  347. void schedinit(void);
  348. int32_t seconds(void);
  349. Segment* seg(Proc*, uintptr_t, int);
  350. void segclock(uintptr_t);
  351. Sem* segmksem(Segment*, int*);
  352. void segpage(Segment*, Page*);
  353. char* seprintmark(char *, char *, Watermark *);
  354. uintmem segppn(Segment*, uintmem);
  355. int semadec(int*);
  356. int semainc(int*);
  357. char* seprintpagestats(char*, char*);
  358. char* seprintphysstats(char*, char*);
  359. int setcolor(uint32_t, uint32_t, uint32_t, uint32_t);
  360. void setkernur(Ureg*, Proc*);
  361. int setlabel(Label*);
  362. void setregisters(Ureg*, char*, char*, int);
  363. char* skipslash(char*);
  364. void sleep(Rendez*, int (*)(void*), void*);
  365. void* smalloc(uint32_t);
  366. char* srvname(Chan*);
  367. void startwaitstats(int);
  368. int swapcount(uint32_t);
  369. void swapinit(void);
  370. void syscallfmt(int, ...);
  371. void sysretfmt(int, Ar0*, uint64_t, uint64_t, ...);
  372. void sysrforkchild(Proc*, Proc*);
  373. void timeradd(Timer*);
  374. void timerdel(Timer*);
  375. void timerintr(Ureg*, int64_t);
  376. void timerset(uint64_t);
  377. void timersinit(void);
  378. uint32_t tk2ms(uint32_t);
  379. #define TK2MS(x) ((x)*(1000/HZ))
  380. uint64_t tod2fastticks(int64_t);
  381. int64_t todget(int64_t*);
  382. void todinit(void);
  383. void todset(int64_t, int64_t, int);
  384. void todsetfreq(int64_t);
  385. Block* trimblock(Block*, int, int);
  386. void tsleep(Rendez*, int (*)(void*), void*, int32_t);
  387. Uart* uartconsole(int, char*);
  388. int uartctl(Uart*, char*);
  389. int uartgetc(void);
  390. void uartkick(void*);
  391. void uartputc(int);
  392. void uartputs(char*, int);
  393. void uartrecv(Uart*, char);
  394. int uartstageoutput(Uart*);
  395. void unbreak(Proc*);
  396. void uncachepage(Page*);
  397. void unlock(Lock*);
  398. void userinit(void);
  399. uintptr_t userpc(Ureg*);
  400. int32_t userwrite(char*, int32_t);
  401. void* validaddr(void*, int32_t, int);
  402. void validname(char*, int);
  403. char* validnamedup(char*, int);
  404. void validstat(unsigned char*, usize);
  405. void* vmemchr(void*, int, int);
  406. Proc* wakeup(Rendez*);
  407. int walk(Chan**, char**, int, int, int*);
  408. void wlock(RWlock*);
  409. void wunlock(RWlock*);
  410. /* xalloc */
  411. void* xalloc(uint32_t);
  412. void* xallocz(uint32_t, int);
  413. void xfree(void*);
  414. void xhole(uintmem, uint32_t);
  415. void xinit(void);
  416. int xmerge(void*, void*);
  417. void* xspanalloc(uint32_t, int, uint32_t);
  418. void xsummary(void);
  419. /* end xalloc */
  420. void yield(void);
  421. uintptr_t zgetaddr(Segment*);
  422. void zgrow(Segment*);
  423. int ziofmt(Fmt*);
  424. int zputaddr(Segment*, uintptr_t);
  425. uint32_t ms(void);
  426. #pragma varargck argpos iprint 1
  427. #pragma varargck argpos panic 1
  428. #pragma varargck argpos pprint 1
  429. /* profiling. */
  430. void oprofile_control_trace(int onoff);
  431. int oprofread(void *va, int n);
  432. void oprof_alarm_handler(Ureg *u);
  433. void oprofile_add_backtrace(uintptr_t pc, uintptr_t fp);
  434. void oprofile_add_userpc(uintptr_t pc);
  435. int alloc_cpu_buffers(void);