another wack at taming the type mess in the pc kernel. correct the type signatures of the umbmalloc-style functions, and use explit-width types for the crn registers. correct the dependent print formats, but there are likely misused ulongs in these drivers still. Reference: /n/atom/patch/applied/pctypecorr Date: Sat Jan 11 22:24:11 CET 2014 Signed-off-by: quanstro@quanstro.net --- /sys/src/9/pc/dat.h Sat Jan 11 22:19:05 2014 +++ /sys/src/9/pc/dat.h Sat Jan 11 22:19:05 2014 @@ -177,7 +177,7 @@ struct Mach { int machno; /* physical id of processor (KNOWN TO ASSEMBLY) */ - ulong splpc; /* pc of last caller to splhi */ + uintptr splpc; /* pc of last caller to splhi */ PTE* pdb; /* kernel region page directory base for this processor (va) */ Tss* tss; /* tss for this processor */ @@ -277,10 +277,10 @@ }; struct Cpuidreg { - ulong ax; - ulong bx; - ulong cx; - ulong dx; + u32int ax; + u32int bx; + u32int cx; + u32int dx; }; /* cpuid instruction result register bits */ @@ -318,8 +318,8 @@ int irq; ulong dma; ulong mem; - ulong size; - ulong freq; + usize size; + int freq; uint tbdf; int nopt; --- /sys/src/9/pc/fns.h Sat Jan 11 22:19:05 2014 +++ /sys/src/9/pc/fns.h Sat Jan 11 22:19:05 2014 @@ -32,11 +32,11 @@ void fpoff(void); void fprestore(FPsave*); void fpsave(FPsave*); -ulong fpstatus(void); -ulong getcr0(void); -ulong getcr2(void); -ulong getcr3(void); -ulong getcr4(void); +u32int fpstatus(void); +u32int getcr0(void); +u32int getcr2(void); +u32int getcr3(void); +u32int getcr4(void); char* getconf(char*); void guesscpuhz(int); void halt(void); @@ -63,15 +63,15 @@ void idlehands(void); int inb(int); void insb(int, void*, int); -ushort ins(int); +u16int ins(int); void inss(int, void*, int); -ulong inl(int); +u32int inl(int); void insl(int, void*, int); int intrdisable(int, void (*)(Ureg *, void *), void*, int, char*); int intrenable(int, void (*)(Ureg*, void*), void*, int, char*); void introff(void); void intron(void); -void invlpg(ulong); +void invlpg(uintptr); void iofree(int); void ioinit(void); int iounused(int, int); @@ -86,7 +86,7 @@ void lgdt(ushort[3]); void lidt(ushort[3]); void links(void); -void ltr(ulong); +void ltr(u32int); void mach0init(void); void mathinit(void); void mb386(void); @@ -103,10 +103,10 @@ void outsb(int, void*, int); void outs(int, ushort); void outss(int, void*, int); -void outl(int, ulong); +void outl(int, u32int); void outsl(int, void*, int); uintmem paddr(void*); -ulong pcibarsize(Pcidev*, int); +u32int pcibarsize(Pcidev*, int); void pcibussize(Pcidev*, ulong*, ulong*); int pcicap(Pcidev*, int); int pcicfgr8(Pcidev*, int); @@ -142,9 +142,9 @@ void procrestore(Proc*); void procsave(Proc*); void procsetup(Proc*); -void putcr0(ulong); -void putcr3(ulong); -void putcr4(ulong); +void putcr0(u32int); +void putcr3(u32int); +void putcr4(u32int); void* rampage(void); void rdmsr(int, vlong*); void realmode(Ureg*); @@ -153,8 +153,8 @@ void sfence(void); int strtotbdf(char*, char**, int); void syncclock(void); -void syscallfmt(int syscallno, ulong pc, va_list list); -void sysretfmt(int syscallno, va_list list, long ret, uvlong start, uvlong stop); +void syscallfmt(int, uintptr, va_list); +void sysretfmt(int, va_list, long, uvlong, uvlong); void* tmpmap(Page*); void tmpunmap(void*); void touser(void*); @@ -163,13 +163,13 @@ void trapinit0(void); int tas(void*); uvlong tscticks(uvlong*); -ulong umbmalloc(ulong, int, int); -void umbfree(ulong, int); -ulong umbrwmalloc(ulong, int, int); -void umbrwfree(ulong, int); -ulong upaalloc(int, int); -void upafree(ulong, int); -void upareserve(ulong, int); +uintptr umbmalloc(uintmem, int, int); +void umbfree(uintptr, int); +uintptr umbrwmalloc(uintmem, int, int); +void umbrwfree(uintptr, int); +uintmem upaalloc(int, int); +void upafree(uintmem, int); +void upareserve(uintmem, int); #define userureg(ur) (((ur)->cs & 0xFFFF) == UESEL) void vectortable(void); void* vmap(uintmem, usize); --- /sys/src/9/pc/devlm78.c Sat Jan 11 22:19:05 2014 +++ /sys/src/9/pc/devlm78.c Sat Jan 11 22:19:05 2014 @@ -173,7 +173,7 @@ config = lm78rdreg(Rconfig); config = (config | Bstart) & ~(Bintclr|Binit); lm78wrreg(Rconfig, config); -pprint("Rvidfan %2.2ux\n", lm78rdreg(Rconfig), lm78rdreg(Rvidfan)); +pprint("Rconf %.2ux Rvidfan %.2ux\n", lm78rdreg(Rconfig), lm78rdreg(Rvidfan)); } lm78.probed = 1; } @@ -310,7 +310,6 @@ lm78wrreg(Rvalue+off, *va++); return va - (uchar*)a; } - return 0; } extern Dev lm78devtab; --- /sys/src/9/pc/ether2114x.c Sat Jan 11 22:19:05 2014 +++ /sys/src/9/pc/ether2114x.c Sat Jan 11 22:19:05 2014 @@ -345,7 +345,7 @@ l += snprint(p+l, READSTR-l, "Loss of Carrier: %lud\n", ctlr->lo); l += snprint(p+l, READSTR-l, "Transmit Jabber Timeout: %lud\n", ctlr->to); - l += snprint(p+l, READSTR-l, "csr6: %luX %uX\n", csr32r(ctlr, 6), + l += snprint(p+l, READSTR-l, "csr6: %ux %ux\n", csr32r(ctlr, 6), ctlr->csr6); snprint(p+l, READSTR-l, "ntqmax: %d\n", ctlr->ntqmax); ctlr->ntqmax = 0; @@ -925,7 +925,7 @@ csr6 |= Fd; if(ctlr->ttm & x) csr6 |= Ttm; - debug("csr6 0x%8.8uX 0x%8.8uX 0x%8.8luX\n", + debug("csr6 %#.8ux %#.8ux %#.8ux\n", csr6, ctlr->csr6, csr32r(ctlr, 6)); if(csr6 != ctlr->csr6){ ctlr->csr6 = csr6; @@ -1257,13 +1257,13 @@ for(timeo = 0; timeo < 30; timeo++){ if(!(csr32r(ctlr, 12) & 0x0002)){ - debug("media21041: ok: csr12 %4.4luX timeo %d\n", + debug("media21041: ok: csr12 %.4ux timeo %d\n", csr32r(ctlr, 12), timeo); return 10; } delay(100); } - debug("media21041: !ok: csr12 %4.4luX\n", csr32r(ctlr, 12)); + debug("media21041: !ok: csr12 %.4ux\n", csr32r(ctlr, 12)); return -1; } @@ -1710,9 +1710,9 @@ * the SROM will be read in anyway so the value there * can be used directly. */ - debug("csr25 %8.8luX csr26 %8.8luX\n", + debug("csr25 %.8ux csr26 %.8ux\n", inl(ctlr->port+0xA4), inl(ctlr->port+0xA8)); - debug("phyidr1 %4.4luX phyidr2 %4.4luX\n", + debug("phyidr1 %.4ux phyidr2 %.4ux\n", inl(ctlr->port+0xBC), inl(ctlr->port+0xC0)); break; } --- /sys/src/9/pc/ether8139.c Sat Jan 11 22:19:05 2014 +++ /sys/src/9/pc/ether8139.c Sat Jan 11 22:19:05 2014 @@ -324,7 +324,7 @@ ctlr->rec += csr16r(ctlr, Rec); l += snprint(p+l, READSTR-l, "rec %d\n", ctlr->rec); - l += snprint(p+l, READSTR-l, "Tcr %#8.8lux\n", csr32r(ctlr, Tcr)); + l += snprint(p+l, READSTR-l, "Tcr %#.8ux\n", csr32r(ctlr, Tcr)); l += snprint(p+l, READSTR-l, "Config0 %#2.2ux\n", csr8r(ctlr, Config0)); l += snprint(p+l, READSTR-l, "Config1 %#2.2ux\n", csr8r(ctlr, Config1)); l += snprint(p+l, READSTR-l, "Msr %#2.2ux\n", csr8r(ctlr, Msr)); --- /sys/src/9/pc/ether83815.c Sat Jan 11 22:19:05 2014 +++ /sys/src/9/pc/ether83815.c Sat Jan 11 22:19:05 2014 @@ -311,7 +311,7 @@ int i; for(i=0; i<=0x5C; i+=4) - print("%2.2ux %8.8lux\n", i, csr32r(ctlr, i)); + print("%2.2ux %.8ux\n", i, csr32r(ctlr, i)); } static void --- /sys/src/9/pc/etherga620.c Sat Jan 11 22:19:05 2014 +++ /sys/src/9/pc/etherga620.c Sat Jan 11 22:19:05 2014 @@ -578,7 +578,7 @@ * 3rd arg of 1 selects gigabit only; 2 10/100 only. */ ga620command(ctlr, 0x0B, 0x00, 0x00); - print("#l%d: ga620: port %8.8uX: firmware is up\n", + print("#l%d: ga620: port %.8lux: firmware is up\n", edev->ctlrno, ctlr->port); break; case 0x04: /* statistics updated */ --- /sys/src/9/pc/mmu.c Sat Jan 11 22:19:05 2014 +++ /sys/src/9/pc/mmu.c Sat Jan 11 22:19:05 2014 @@ -579,7 +579,7 @@ if(old&PTEVALID) flushpg(va); if(getcr3() != up->mmupdb->pa) - print("bad cr3 %#.8lux %#P\n", getcr3(), up->mmupdb->pa); + print("bad cr3 %#.8ux %#P\n", getcr3(), up->mmupdb->pa); splx(s); } --- /sys/src/9/pc/trap.c Sat Jan 11 22:19:06 2014 +++ /sys/src/9/pc/trap.c Sat Jan 11 22:19:06 2014 @@ -259,7 +259,7 @@ "alignment check", "machine check", "SIMD exception", - "virtulization exception", + "20 (reserved)", "21 (reserved)", "22 (reserved)", "23 (reserved)", @@ -504,10 +504,10 @@ * CR4. If there is a CR4 and machine check extensions, read the machine * check address and machine check type registers if RDMSR supported. */ - iprint(" CR0 %8.8lux CR2 %8.8lux CR3 %8.8lux", + iprint(" CR0 %.8ux CR2 %.8ux CR3 %.8ux", getcr0(), getcr2(), getcr3()); if(m->cpuiddx & (Mce|Tsc|Pse|Vmex)){ - iprint(" CR4 %8.8lux", getcr4()); + iprint(" CR4 %.8ux", getcr4()); if((m->cpuiddx & (Mce|Cpumsr)) == (Mce|Cpumsr)){ rdmsr(0x00, &mca); rdmsr(0x01, &mct);