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