portfns.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432
  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. Proc* dequeueproc(Sched*, Schedq*, Proc*);
  66. Chan* devattach(int, char*);
  67. Block* devbread(Chan*, int32_t, int64_t);
  68. int32_t devbwrite(Chan*, Block*, int64_t);
  69. Chan* devclone(Chan*);
  70. int devconfig(int, char *, DevConf *);
  71. void devcreate(Chan*, char*, int, int);
  72. void devdir(Chan*, Qid, char*, int64_t, char*, int32_t, Dir*);
  73. int32_t devdirread(Chan*, char*, int32_t, Dirtab*, int,
  74. Devgen*);
  75. Devgen devgen;
  76. void devinit(void);
  77. Chan* devopen(Chan*, int, Dirtab*, int, Devgen*);
  78. void devpermcheck(char*, int, int);
  79. void devpower(int);
  80. void devremove(Chan*);
  81. void devreset(void);
  82. void devshutdown(void);
  83. int32_t devstat(Chan*, unsigned char*, int32_t, Dirtab*, int,
  84. Devgen*);
  85. Dev* devtabget(int, int);
  86. void devtabinit(void);
  87. int32_t devtabread(Chan*, void*, int32_t, int64_t);
  88. void devtabreset(void);
  89. void devtabshutdown(void);
  90. Walkqid* devwalk(Chan*, Chan*, char**, int, Dirtab*, int, Devgen*);
  91. int32_t devwstat(Chan*, unsigned char*, int32_t);
  92. int devzread(Chan*, Kzio*, int, usize, int64_t);
  93. int devzwrite(Chan*, Kzio*, int, int64_t);
  94. void drawactive(int);
  95. void drawcmap(void);
  96. void dumpaproc(Proc*);
  97. void dumpregs(Ureg*);
  98. void dumpstack(void);
  99. void dumpzseg(Segment*);
  100. Fgrp* dupfgrp(Fgrp*);
  101. int duppage(Page*);
  102. Segment* dupseg(Segment**, int, int);
  103. void dupswap(Page*);
  104. char* edfadmit(Proc*);
  105. void edfinit(Proc*);
  106. int edfready(Proc*);
  107. void edfrecord(Proc*);
  108. void edfrun(Proc*, int);
  109. void edfstop(Proc*);
  110. void edfyield(void);
  111. int elf64ldseg(Chan *c, uintptr_t *entryp, Ldseg **rp, char *mach, uint32_t minpgsz);
  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, 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 fortuna_get_bytes(unsigned len, uint8_t *dst);
  131. void fortuna_add_entropy(const uint8_t *data, unsigned len);
  132. void free(void*);
  133. void freeb(Block*);
  134. void freeblist(Block*);
  135. int freebroken(void);
  136. void freepte(Segment*, Pte*);
  137. void getcolor(uint32_t, uint32_t*, uint32_t*, uint32_t*);
  138. char* getconfenv(void);
  139. int getpgszi(uint32_t);
  140. Segment* getzkseg(void);
  141. void gotolabel(Label*);
  142. int haswaitq(void*);
  143. void hexdump(void *v, int length);
  144. void pahexdump(uintptr_t pa, int len);
  145. void hnputl(void*, uint);
  146. void hnputs(void*, uint16_t);
  147. void hnputv(void*, uint64_t);
  148. int32_t hostdomainwrite(char*, int32_t);
  149. int32_t hostownerwrite(char*, int32_t);
  150. void hzsched(void);
  151. Block* iallocb(int);
  152. void iallocsummary(void);
  153. void initmark(Watermark *, int, char *);
  154. void ilock(Lock*);
  155. void initimage(void);
  156. int iprint(char*, ...);
  157. void isdir(Chan*);
  158. int iseve(void);
  159. int islo(void);
  160. Segment* isoverlap(Proc*, uintptr_t, usize);
  161. int isphysseg(char*);
  162. void iunlock(Lock*);
  163. void ixsummary(void);
  164. int kbdcr2nl(Queue*, int);
  165. int kbdgetmap(int, int*, int*, Rune*);
  166. int kbdputc(Queue*, int);
  167. void kbdputmap(uint16_t, uint16_t, Rune);
  168. void kickpager(int, int);
  169. void killbig(char*);
  170. void kproc(char*, void(*)(void*), void*);
  171. void kprocchild(Proc*, void (*)(void*), void*);
  172. void (*kproftimer)(uintptr_t);
  173. void ksetenv(char*, char*, int);
  174. void kstrcpy(char*, char*, int);
  175. void kstrdup(char**, char*);
  176. int32_t latin1(Rune*, int);
  177. int lock(Lock*);
  178. void log(Log*, int, char*, ...);
  179. void logclose(Log*);
  180. char* logctl(Log*, int, char**, Logflag*);
  181. void logn(Log*, int, void*, int);
  182. void logopen(Log*);
  183. int32_t logread(Log*, void*, int32_t, int64_t);
  184. Page* lookpage(Image*, uint32_t);
  185. Cmdtab* lookupcmd(Cmdbuf*, Cmdtab*, int);
  186. void mallocinit(void);
  187. int32_t mallocreadsummary(Chan*, void*, int32_t, int32_t);
  188. void mallocsummary(void);
  189. Block* mem2bl(unsigned char*, int);
  190. void (*mfcinit)(void);
  191. void (*mfcopen)(Chan*);
  192. int (*mfcread)(Chan*, unsigned char*, int, int64_t);
  193. void (*mfcupdate)(Chan*, unsigned char*, int, int64_t);
  194. void (*mfcwrite)(Chan*, unsigned char*, int, int64_t);
  195. void mfreeseg(Segment*, uintptr_t, int);
  196. void microdelay(int);
  197. uint64_t mk64fract(uint64_t, uint64_t);
  198. void mkqid(Qid*, int64_t, uint32_t, int);
  199. void mmuflush(void);
  200. void mmuput(uintptr_t, Page*, uint);
  201. void mmurelease(Proc*);
  202. void mmuswitch(Proc*);
  203. Chan* mntauth(Chan*, char*);
  204. usize mntversion(Chan*, uint32_t, char*, usize);
  205. void mountfree(Mount*);
  206. uint64_t ms2fastticks(uint32_t);
  207. #define MS2NS(n) (((int64_t)(n))*1000000LL)
  208. uint32_t ms2tk(uint32_t);
  209. void mul64fract(uint64_t*, uint64_t, uint64_t);
  210. void muxclose(Mnt*);
  211. void (*mwait)(void *);
  212. Chan* namec(char*, int, int, int);
  213. void nameerror(char*, char*);
  214. Chan* newchan(void);
  215. int newfd(Chan*);
  216. Mhead* newmhead(Chan*);
  217. Mount* newmount(Mhead*, Chan*, int, char*);
  218. Page* newpage(int, Segment **, uintptr_t, usize, int);
  219. Path* newpath(char*);
  220. Pgrp* newpgrp(void);
  221. Proc* newproc(void);
  222. Rgrp* newrgrp(void);
  223. Segment* newseg(int, uintptr_t, uint64_t);
  224. void newzmap(Segment*);
  225. void nexterror(void);
  226. void notemark(Watermark *, int);
  227. uint nhgetl(void*);
  228. uint16_t nhgets(void*);
  229. uint64_t nhgetv(void*);
  230. void nixprepage(int);
  231. int nrand(int);
  232. uint64_t ns2fastticks(uint64_t);
  233. int okaddr(uintptr_t, int32_t, int);
  234. int openmode(int);
  235. Block* packblock(Block*);
  236. Block* padblock(Block*, int);
  237. void pagechainhead(Page*);
  238. void pageinit(void);
  239. uint32_t pagenumber(Page*);
  240. uint64_t pagereclaim(Image*);
  241. void pagersummary(void);
  242. void pageunchain(Page*);
  243. void panic(char*, ...);
  244. Cmdbuf* parsecmd(char *a, int n);
  245. void pathclose(Path*);
  246. uint32_t perfticks(void);
  247. void pexit(char*, int);
  248. Page* pgalloc(usize, int);
  249. void pgfree(Page*);
  250. void pgrpcpy(Pgrp*, Pgrp*);
  251. void pgrpnote(uint32_t, char*, int32_t, int);
  252. uintmem physalloc(uint64_t, int*, void*);
  253. void physdump(void);
  254. void physfree(uintmem, uint64_t);
  255. void physinit(uintmem, uint64_t);
  256. void* phystag(uintmem);
  257. void pio(Segment*, uintptr_t, uint32_t, Page**, int);
  258. void portmwait(void*);
  259. int postnote(Proc*, int, char*, int);
  260. int pprint(char*, ...);
  261. int preempted(void);
  262. void prflush(void);
  263. void printinit(void);
  264. uint32_t procalarm(uint32_t);
  265. void procctl(Proc*);
  266. void procdump(void);
  267. int procfdprint(Chan*, int, int, char*, int);
  268. void procflushseg(Segment*);
  269. void procinit0(void);
  270. void procpriority(Proc*, int, int);
  271. void procrestore(Proc*);
  272. void procsave(Proc*);
  273. void (*proctrace)(Proc*, int, int64_t);
  274. void proctracepid(Proc*);
  275. void procwired(Proc*, int);
  276. void psdecref(Proc*);
  277. Proc* psincref(int);
  278. int psindex(int);
  279. void psinit(int);
  280. Pte* ptealloc(Segment*);
  281. Pte* ptecpy(Segment*,Pte*);
  282. int pullblock(Block**, int);
  283. Block* pullupblock(Block*, int);
  284. Block* pullupqueue(Queue*, int);
  285. void putimage(Image*);
  286. void putmhead(Mhead*);
  287. void putpage(Page*);
  288. void putseg(Segment*);
  289. void putstrn(char*, int);
  290. void putswap(Page*);
  291. int pwait(Waitmsg*);
  292. void qaddlist(Queue*, Block*);
  293. Block* qbread(Queue*, int);
  294. int32_t qbwrite(Queue*, Block*);
  295. int32_t qibwrite(Queue*, Block*);
  296. Queue* qbypass(void (*)(void*, Block*), void*);
  297. int qcanread(Queue*);
  298. void qclose(Queue*);
  299. int qconsume(Queue*, void*, int);
  300. Block* qcopy(Queue*, int, uint32_t);
  301. int qdiscard(Queue*, int);
  302. void qflush(Queue*);
  303. void qfree(Queue*);
  304. int qfull(Queue*);
  305. Block* qget(Queue*);
  306. void qhangup(Queue*, char*);
  307. int qisclosed(Queue*);
  308. int qiwrite(Queue*, void*, int);
  309. int qlen(Queue*);
  310. void qlock(QLock*);
  311. void qnoblock(Queue*, int);
  312. Queue* qopen(int, int, void (*)(void*), void*);
  313. int qpass(Queue*, Block*);
  314. int qpassnolim(Queue*, Block*);
  315. int qproduce(Queue*, void*, int);
  316. void qputback(Queue*, Block*);
  317. int32_t qread(Queue*, void*, int);
  318. Block* qremove(Queue*);
  319. void qreopen(Queue*);
  320. void qsetlimit(Queue*, int);
  321. void qunlock(QLock*);
  322. int qwindow(Queue*);
  323. int qwrite(Queue*, void*, int);
  324. int rand(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. int32_t readmem(int32_t, void*, int32_t, void*, int32_t);
  331. void ready(Proc*);
  332. int32_t readzio(Kzio[], int, void*, int32_t);
  333. void reboot(void*, void*, int32_t);
  334. void rebootcmd(int, char**);
  335. void relocateseg(Segment*, uintptr_t);
  336. void renameuser(char*, char*);
  337. void resched(char*);
  338. void resrcwait(char*);
  339. int return0(void*);
  340. void rlock(RWlock*);
  341. int32_t rtctime(void);
  342. int runac(Mach *m, void(*func)(void), int flushtlb, void *a,
  343. int32_t n);
  344. void runlock(RWlock*);
  345. Proc* runproc(void);
  346. void sched(void);
  347. void scheddump(void);
  348. void schedinit(void);
  349. int32_t seconds(void);
  350. Segment* seg(Proc*, uintptr_t, int);
  351. void segclock(uintptr_t);
  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. // The horror. But, well, it does make a BIG performance difference. We're told.
  362. int slim_setlabel(Label*);
  363. void setregisters(Ureg*, char*, char*, int);
  364. char* skipslash(char*);
  365. void sleep(Rendez*, int (*)(void*), void*);
  366. void* smalloc(uint32_t);
  367. char* srvname(Chan*);
  368. void startwaitstats(int);
  369. int swapcount(uint32_t);
  370. void swapinit(void);
  371. void syscallfmt(uint8_t, 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. void yield(void);
  411. uintptr_t zgetaddr(Segment*);
  412. void zgrow(Segment*);
  413. int ziofmt(Fmt*);
  414. int zputaddr(Segment*, uintptr_t);
  415. uint32_t ms(void);
  416. #pragma varargck argpos iprint 1
  417. #pragma varargck argpos panic 1
  418. #pragma varargck argpos pprint 1
  419. /* profiling. */
  420. void oprofile_control_trace(int onoff);
  421. int oprofread(void *va, int n);
  422. void oprof_alarm_handler(Ureg *u);
  423. void oprofile_add_backtrace(uintptr_t pc, uintptr_t fp);
  424. void oprofile_add_userpc(uintptr_t pc);
  425. int alloc_cpu_buffers(void);
  426. #define I_AM_HERE print("Core 0 is in %s() at %s:%d\n", \
  427. __FUNCTION__, __FILE__, __LINE__);