fns.h 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  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. #include "../port/portfns.h"
  10. /* assembly code support from asm.S */
  11. void startmach(void (*f)(void), void *m);
  12. Mach *machp(void);
  13. /* other functions */
  14. void intrac(Proc*);
  15. void acinit(void);
  16. int acpiinit(void);
  17. void actrapenable(int, char* (*)(Ureg*, void*), void*, char*);
  18. void apicipi(int);
  19. void apicpri(int);
  20. void acsysret(void);
  21. void actouser(void);
  22. void runacore(void);
  23. void aamloop(int);
  24. Dirtab* addarchfile(char*, int,
  25. int32_t(*)(Chan*,void*,int32_t,int64_t),
  26. int32_t(*)(Chan*,void*,int32_t,int64_t));
  27. void acmmuswitch(void);
  28. void acmodeset(int);
  29. void archfmtinstall(void);
  30. void archidle(void);
  31. int archmmu(void);
  32. int asmfree(uintmem, uintmem, int);
  33. uint64_t asmalloc(uintmem, uintmem, int, int);
  34. void asminit(void);
  35. void asmmapinit(uintmem, uintmem, int);
  36. extern void asmmodinit(uint32_t, uint32_t, char*);
  37. void noerrorsleft(void);
  38. void archinit(void);
  39. void archreset(void);
  40. int64_t archhz(void);
  41. int cgaprint(int off, char *fmt, ...);
  42. int cgaclearln(int off, int c);
  43. void cgaconsputs(char*, int);
  44. void cgainit(void);
  45. void cgapost(int);
  46. void checkpa(char*, uintmem);
  47. #define clearmmucache() /* x86 doesn't have one */
  48. void (*coherence)(void);
  49. int corecolor(int);
  50. uint32_t cpuid(uint32_t, uint32_t, uint32_t[4]);
  51. int dbgprint(char*, ...);
  52. int decref(Ref*);
  53. void delay(int);
  54. void dumpmmu(Proc*);
  55. void dumpmmuwalk(uint64_t pa);
  56. void dumpptepg(int lvl,uintptr_t pa);
  57. #define evenaddr(x) /* x86 doesn't care */
  58. int fpudevprocio(Proc*, void*, int32_t, uintptr_t, int);
  59. void fpuinit(void);
  60. void fpunoted(void);
  61. void fpunotify(Ureg*);
  62. void fpuprocrestore(Proc*);
  63. void fpuprocsave(Proc*);
  64. void fpusysprocsetup(Proc*);
  65. void fpusysrfork(Ureg*);
  66. void fpusysrforkchild(Proc*, Proc*);
  67. Mach* getac(Proc*, int);
  68. char* getconf(char*);
  69. void gdb2ureg(uintptr_t *g, Ureg *u);
  70. void halt(void);
  71. void hardhalt(void);
  72. void mouseenable(void);
  73. void i8042systemreset(void);
  74. int mousecmd(int);
  75. void mouseenable(void);
  76. void i8250console(char*);
  77. void* i8250alloc(int, int, int);
  78. int64_t i8254hz(uint32_t *info0, uint32_t *info1);
  79. void idlehands(void);
  80. void acidthandlers(void);
  81. void idthandlers(void);
  82. int inb(int);
  83. int incref(Ref*);
  84. void insb(int, void*, int);
  85. uint16_t ins(int);
  86. void inss(int, void*, int);
  87. uint32_t inl(int);
  88. void insl(int, void*, int);
  89. int intrdisable(void*);
  90. void* intrenable(int, void (*)(Ureg*, void*), void*, int, char*);
  91. void invlpg(uintptr_t);
  92. void iofree(int);
  93. void ioinit(void);
  94. int iounused(int, int);
  95. int ioalloc(int, int, int, char*);
  96. int ioreserve(int, int, int, char*);
  97. int iprint(char*, ...);
  98. int isaconfig(char*, int, ISAConf*);
  99. void kexit(Ureg*);
  100. void keybenable(void);
  101. void keybinit(void);
  102. #define kmapinval()
  103. void lfence(void);
  104. void links(void);
  105. void machinit(void);
  106. void mach0init(void);
  107. void mapraminit(uint64_t, uint64_t);
  108. void mapupainit(uint64_t, uint32_t);
  109. void meminit(void);
  110. void mfence(void);
  111. void mmuflushtlb(uint64_t);
  112. void mmuinit(void);
  113. uintptr_t mmukmap(uintptr_t, uintptr_t, usize);
  114. int mmukmapsync(uint64_t);
  115. uintmem mmuphysaddr(uintptr_t);
  116. int mmuwalk(PTE*, uintptr_t, int, PTE**, PTE (*)(usize));
  117. int multiboot(uint32_t, uint32_t, int);
  118. void ndnr(void);
  119. unsigned char nvramread(int);
  120. void nvramwrite(int, unsigned char);
  121. void optionsinit(char*);
  122. void outb(int, int);
  123. void outsb(int, void*, int);
  124. void outs(int, uint16_t);
  125. void outss(int, void*, int);
  126. void outl(int, uint32_t);
  127. void outsl(int, void*, int);
  128. void pcireset(void);
  129. int pickcore(int, int);
  130. void printcpufreq(void);
  131. void putac(Mach*);
  132. void runapcore(int);
  133. int screenprint(char*, ...); /* debugging */
  134. void sfence(void);
  135. void spldone(void);
  136. uint64_t splhi(void);
  137. uint64_t spllo(void);
  138. void splx(uint64_t);
  139. void splxpc(uint64_t);
  140. void kstackok(void); /* panic if kstack guards garbaged, works with and without externup */
  141. Stackframe *stackframe(void); /* asm.S */
  142. void stacksnippet(void);
  143. void stopac(void);
  144. void syncclock(void);
  145. void syscall(unsigned int scallnr, Ureg *ureg);
  146. void* sysexecregs(uintptr_t, uint32_t, void*);
  147. uintptr_t sysexecstack(uintptr_t, int);
  148. void sysprocsetup(Proc*);
  149. void tssrsp0(Mach *, uint64_t);
  150. void trapenable(int, void (*)(Ureg*, void*), void*, char*);
  151. void trapinit(void);
  152. void trap(Ureg*);
  153. void umeminit(void);
  154. void ureg2gdb(Ureg *u, uintptr_t *g);
  155. int userureg(Ureg*);
  156. void* vmap(uintptr_t, usize);
  157. void vsvminit(int, int, Mach *);
  158. void vunmap(void*, usize);
  159. extern uint64_t rootget(void);
  160. extern void rootput(uintptr_t);
  161. extern void idtput(int, uint64_t);
  162. extern uint64_t rdtsc(void);
  163. extern int islo(void);
  164. extern void spldone(void);
  165. extern Mpl splhi(void);
  166. extern Mpl spllo(void);
  167. extern void splx(Mpl);
  168. int cas32(void*, uint32_t, uint32_t);
  169. int cas64(void*, uint64_t, uint64_t);
  170. int tas32(void*);
  171. uint64_t fas64(uint64_t*, uint64_t);
  172. #define CASU(p, e, n) cas64((p), (uint64_t)(e), (uint64_t)(n))
  173. #define CASV(p, e, n) cas64((p), (uint64_t)(e), (uint64_t)(n))
  174. #define CASP(p, e, n) cas64((p), (uint64_t)(e), (uint64_t)(n))
  175. #define CASW(p, e, n) cas32((p), (e), (n))
  176. #define TAS(addr) tas32((addr))
  177. #define FASP(p, v) ((void*)fas64((uint64_t*)(p), (uint64_t)(v)))
  178. void touser(uintptr_t);
  179. void syscallentry(void);
  180. void acsyscallentry(void);
  181. void syscallreturn(void);
  182. void sysrforkret(void);
  183. #define waserror() setlabel(&up->errlab[up->nerrlab++])
  184. #define poperror() up->nerrlab--
  185. #define dcflush(a, b)
  186. #define PTR2UINT(p) ((uintptr_t)(p))
  187. #define UINT2PTR(i) ((void*)(i))
  188. void* KADDR(uintptr_t);
  189. uintmem PADDR(void*);
  190. #define BIOSSEG(a) KADDR(((uint)(a))<<4)
  191. /*
  192. * apic.c
  193. */
  194. extern int apiceoi(int);
  195. extern void apicipi(int);
  196. extern void apicinit(int, uintmem, int);
  197. extern int apicisr(int);
  198. extern int apiconline(void);
  199. extern void apicpri(int);
  200. extern void apicsipi(int, uintmem);
  201. extern void ioapicinit(int, uintmem);
  202. extern void ioapicintrinit(int, int, int, int, uint32_t);
  203. extern void ioapiconline(void);
  204. /*
  205. * archamd64.c
  206. */
  207. extern void millidelay(int);
  208. extern void k10mwait(void*);
  209. /*
  210. * i8259.c
  211. */
  212. extern int i8259init(int);
  213. extern int i8259irqdisable(int);
  214. extern int i8259irqenable(int);
  215. extern int i8259isr(int);
  216. /*
  217. * mp.c
  218. */
  219. extern void mpsinit(int);
  220. /*
  221. * sipi.c
  222. */
  223. extern void sipi(void);
  224. /*
  225. * debug
  226. */
  227. void HERE(void);
  228. void DONE(void);
  229. /* all these go to 0x3f8 */
  230. void hi(char *s);
  231. Mach *machp(void);
  232. Proc *externup(void);
  233. /* temporary. */
  234. void die(char *);
  235. void dumpgpr(Ureg* ureg);
  236. /* debug support. */
  237. int backtrace_list(uintptr_t pc, uintptr_t fp, uintptr_t *pcs, size_t nr_slots);
  238. /* horror */
  239. static inline void __clobber_callee_regs(void)
  240. {
  241. panic("FIX ME!");
  242. //asm volatile ("" : : : "rbx", "r12", "r13", "r14", "r15");
  243. }
  244. int slim_setlabel(Label*) __attribute__((returns_twice));
  245. #define setlabel(label) ({int err; \
  246. __clobber_callee_regs(); \
  247. err = slim_setlabel(label); \
  248. err;})