fns.h (6097B)
1 #include "portfns.h" 2 3 void aamloop(int); 4 Dirtab* addarchfile(char*, int, long(*)(Chan*,void*,long,vlong), long(*)(Chan*,void*,long,vlong)); 5 void archinit(void); 6 void bootargs(void*); 7 ulong cankaddr(ulong); 8 void clockintr(Ureg*, void*); 9 int (*cmpswap)(long*, long, long); 10 int cmpswap486(long*, long, long); 11 int oscmpswap(long*, long, long); 12 void (*coherence)(void); 13 void cpuid(int, ulong regs[]); 14 int cpuidentify(void); 15 void cpuidprint(void); 16 void (*cycles)(uvlong*); 17 void delay(int); 18 int dmacount(int); 19 int dmadone(int); 20 void dmaend(int); 21 int dmainit(int, int); 22 long dmasetup(int, void*, long, int); 23 #define evenaddr(x) /* x86 doesn't care */ 24 void fpclear(void); 25 void fpenv(FPsave*); 26 void fpinit(void); 27 void fpoff(void); 28 void fprestore(FPsave*); 29 void fpsave(FPsave*); 30 ulong fpstatus(void); 31 ulong getcr0(void); 32 ulong getcr2(void); 33 ulong getcr3(void); 34 ulong getcr4(void); 35 char* getconf(char*); 36 void guesscpuhz(int); 37 void halt(void); 38 int i8042auxcmd(int); 39 int i8042auxcmds(uchar*, int); 40 void i8042auxenable(void (*)(int, int)); 41 void i8042reset(void); 42 void i8250console(void); 43 void* i8250alloc(int, int, int); 44 void i8250mouse(char*, int (*)(Queue*, int), int); 45 void i8250setmouseputc(char*, int (*)(Queue*, int)); 46 void i8253enable(void); 47 void i8253init(void); 48 void i8253link(void); 49 uvlong i8253read(uvlong*); 50 void i8253timerset(uvlong); 51 int i8259disable(int); 52 int i8259enable(Vctl*); 53 void i8259init(void); 54 int i8259isr(int); 55 void i8259on(void); 56 void i8259off(void); 57 int i8259vecno(int); 58 void idle(void); 59 void idlehands(void); 60 int inb(int); 61 void insb(int, void*, int); 62 ushort ins(int); 63 void inss(int, void*, int); 64 ulong inl(int); 65 void insl(int, void*, int); 66 int intrdisable(int, void (*)(Ureg *, void *), void*, int, char*); 67 void intrenable(int, void (*)(Ureg*, void*), void*, int, char*); 68 void introff(void); 69 void intron(void); 70 void invlpg(ulong); 71 void iofree(int); 72 void ioinit(void); 73 int iounused(int, int); 74 int ioalloc(int, int, int, char*); 75 int ioreserve(int, int, int, char*); 76 int iprint(char*, ...); 77 int isaconfig(char*, int, ISAConf*); 78 void* kaddr(ulong); 79 void kbdenable(void); 80 void kbdinit(void); 81 #define kmapinval() 82 void lgdt(ushort[3]); 83 void lidt(ushort[3]); 84 void links(void); 85 void ltr(ulong); 86 void mach0init(void); 87 void mathinit(void); 88 void mb386(void); 89 void mb586(void); 90 void meminit(void); 91 void memorysummary(void); 92 #define mmuflushtlb(pdb) putcr3(pdb) 93 void mmuinit(void); 94 ulong* mmuwalk(ulong*, ulong, int, int); 95 int mtrr(uvlong, uvlong, char *); 96 void mtrrclock(void); 97 int mtrrprint(char *, long); 98 uchar nvramread(int); 99 void nvramwrite(int, uchar); 100 void outb(int, int); 101 void outsb(int, void*, int); 102 void outs(int, ushort); 103 void outss(int, void*, int); 104 void outl(int, ulong); 105 void outsl(int, void*, int); 106 ulong paddr(void*); 107 void pcireset(void); 108 void pcmcisread(PCMslot*); 109 int pcmcistuple(int, int, int, void*, int); 110 PCMmap* pcmmap(int, ulong, int, int); 111 int pcmspecial(char*, ISAConf*); 112 int (*_pcmspecial)(char *, ISAConf *); 113 void pcmspecialclose(int); 114 void (*_pcmspecialclose)(int); 115 void pcmunmap(int, PCMmap*); 116 int pdbmap(ulong*, ulong, ulong, int); 117 void procrestore(Proc*); 118 void procsave(Proc*); 119 void procsetup(Proc*); 120 void putcr0(ulong); 121 void putcr3(ulong); 122 void putcr4(ulong); 123 void* rampage(void); 124 void rdmsr(int, vlong*); 125 void realmode(Ureg*); 126 void screeninit(void); 127 void (*screenputs)(char*, int); 128 void syncclock(void); 129 void* tmpmap(Page*); 130 void tmpunmap(void*); 131 void touser(void*); 132 void trapenable(int, void (*)(Ureg*, void*), void*, char*); 133 void trapinit(void); 134 void trapinit0(void); 135 int tas(void*); 136 uvlong tscticks(uvlong*); 137 ulong umbmalloc(ulong, int, int); 138 void umbfree(ulong, int); 139 ulong umbrwmalloc(ulong, int, int); 140 void umbrwfree(ulong, int); 141 ulong upaalloc(int, int); 142 void upafree(ulong, int); 143 void upareserve(ulong, int); 144 #define userureg(ur) (((ur)->cs & 0xFFFF) == UESEL) 145 void vectortable(void); 146 void* vmap(ulong, int); 147 int vmapsync(ulong); 148 void vunmap(void*, int); 149 void wbinvd(void); 150 void wrmsr(int, vlong); 151 int xchgw(ushort*, int); 152 153 #define waserror() (up->nerrlab++, setlabel(&up->errlab[up->nerrlab-1])) 154 #define KADDR(a) kaddr(a) 155 #define PADDR(a) paddr((void*)(a)) 156 157 #define dcflush(a, b) 158 159 // Plan 9 VX additions 160 void bootinit(void); 161 void gotolabel(Label*); 162 int isuaddr(void*); 163 void labelinit(Label *l, ulong pc, ulong sp); 164 void latin1putc(int, void(*)(int)); 165 void makekprocdev(Dev*); 166 void newmach(void); 167 void oserror(void); 168 void oserrstr(void); 169 void restoretty(void); 170 int setlabel(Label*); 171 void setsigsegv(int invx32); 172 int tailkmesg(char*, int); 173 void trap(Ureg*); 174 void uartecho(char*, int); 175 void uartinit(int); 176 void *uvalidaddr(ulong addr, ulong len, int write); 177 178 #define GSHORT(p) (((p)[1]<<8)|(p)[0]) 179 #define GLONG(p) ((GSHORT(p+2)<<16)|GSHORT(p)) 180 181 void __plock(Psleep*); 182 void __punlock(Psleep*); 183 void __pwakeup(Psleep*); 184 void __psleep(Psleep*); 185 186 extern int tracelock; 187 188 #define lockfngen(type) __ ## type 189 190 #define lockgen(type, arg) \ 191 do { \ 192 if (tracelock) { \ 193 iprint("%s %p %s %d\n", (#type), (arg), __FILE__, __LINE__); \ 194 lockfngen(type)((arg)); \ 195 } else { \ 196 lockfngen(type)((arg)); \ 197 } \ 198 } while (0) 199 200 #define qlock(x) lockgen(qlock, (x)) 201 #define qunlock(x) lockgen(qunlock, (x)) 202 #define rlock(x) lockgen(rlock, (x)) 203 #define runlock(x) lockgen(runlock, (x)) 204 #define wlock(x) lockgen(wlock, (x)) 205 #define wunlock(x) lockgen(wunlock, (x)) 206 #define plock(x) lockgen(plock, (x)) 207 #define punlock(x) lockgen(punlock, (x)) 208 #define pwakeup(x) lockgen(pwakeup, (x)) 209 #define psleep(x) lockgen(psleep, (x)) 210 // #define lock(x) lockgen(lock, (x)) 211 // #define unlock(x) lockgen(unlock, (x)) 212 #define lock(x) __lock(x) 213 #define unlock(x) __unlock(x) 214 #define canqlock __canqlock 215 #define canrlock __canrlock 216 217 #define LOCK(x) lock(&((x)->lk)) 218 #define UNLOCK(x) unlock(&((x)->lk)) 219 #define CANQLOCK(x) canqlock(&((x)->qlock)) 220 #define QLOCK(x) qlock(&((x)->qlock)) 221 #define QUNLOCK(x) qunlock(&((x)->qlock)) 222 #define CANRLOCK(x) canrlock(&((x)->rwlock)) 223 #define RLOCK(x) rlock(&((x)->rwlock)) 224 #define RUNLOCK(x) runlock(&((x)->rwlock)) 225 #define WLOCK(x) wlock(&((x)->rwlock)) 226 #define WUNLOCK(x) wunlock(&((x)->rwlock))