make room for big Tos structure. this prevents *init* from dying with invalid memory references. Reference: /n/atom/patch/applied2013/9tossize Date: Sat Sep 21 20:39:48 CES 2013 Signed-off-by: quanstro@quanstro.net --- /sys/src/9/bitsy/main.c Sat Sep 21 20:39:12 2013 +++ /sys/src/9/bitsy/main.c Sat Sep 21 20:39:13 2013 @@ -145,7 +145,7 @@ * trap.c's syscall() work even when we have less than the * max number of args. */ - sp = (uchar*)base + BY2PG - sizeof(Sargs); + sp = (uchar*)base + BY2PG - Ustkheadroom; bootpath = pusharg("/boot/boot"); ac = 0; --- /sys/src/9/kw/main.c Sat Sep 21 20:39:14 2013 +++ /sys/src/9/kw/main.c Sat Sep 21 20:39:15 2013 @@ -7,6 +7,7 @@ #include "init.h" #include "arm.h" #include +#include #include "reboot.h" @@ -23,6 +24,14 @@ #define MAXCONF 64 #define MAXCONFLINE 160 +enum { + Maxmem = 512*MB, /* limited by address ranges */ + Minmem = 256*MB, /* conservative default */ + + /* space for syscall args, return PC, top-of-stack struct */ + Ustkheadroom = sizeof(Sargs) + sizeof(uintptr) + sizeof(Tos), +}; + #define isascii(c) ((uchar)(c) > 0 && (uchar)(c) < 0177) uintptr kseg0 = KZERO; @@ -224,13 +233,19 @@ { Spiregs *rp = (Spiregs *)soc.spi; + if (probeaddr(soc.spi) < 0) + return; rp->ictl |= Csnact; coherence(); rp->icfg |= Dirrdcmd | 3<<8; /* fast reads, 4-byte addresses */ rp->icfg &= ~Bytelen; /* one-byte reads */ coherence(); -// print("spi flash at %#ux: memory reads enabled\n", PHYSSPIFLASH); + print("spi flash ignored: ctlr %#p, data %#ux", rp, PHYSSPIFLASH); + mmuidmap(PHYSSPIFLASH, 1); + if (probeaddr(PHYSSPIFLASH) < 0) + print(" (no response)"); + print(": memory reads enabled\n"); } void archconsole(void); --- /sys/src/9/kw/fns.h Sat Sep 21 20:39:16 2013 +++ /sys/src/9/kw/fns.h Sat Sep 21 20:39:17 2013 @@ -57,6 +57,7 @@ extern void l2cacheuwbse(void*, int); extern void lastresortprint(char *buf, long bp); extern int log2(ulong); +extern void mmuidmap(uintptr phys, int mbs); extern void mmuinvalidate(void); /* 'mmu' or 'tlb'? */ extern void mmuinvalidateaddr(u32int); /* 'mmu' or 'tlb'? */ extern u32int pidget(void); @@ -86,6 +87,7 @@ extern void mmuinit(void); extern void touser(uintptr); extern void trapinit(void); +extern vlong probeaddr(uintptr); extern int fpiarm(Ureg*); extern void fpuinit(void); --- /sys/src/9/kw/mem.h Sat Sep 21 20:39:18 2013 +++ /sys/src/9/kw/mem.h Sat Sep 21 20:39:18 2013 @@ -130,12 +130,12 @@ /* from 0x80000000 up is uncached by L2 (see archkw.c) */ #define PHYSCESASRAM 0xc8010000 -// #define PHYSSPIFLASH 0xe8000000 /* ignore spi flash */ +#define PHYSNAND2 0xd8000000 /* guru */ +#define PHYSSPIFLASH 0xe8000000 /* optional spi flash (dream) */ /* this address is configured by u-boot, and is 0xd0000000 at reset */ #define PHYSIO 0xf1000000 /* internal registers */ #define PHYSCONS (PHYSIO + 0x12000) /* uart */ #define PHYSNAND1 0xf9000000 /* sheeva/openrd (remapped) */ -#define PHYSNAND2 0xd8000000 /* guru */ #define PHYSBOOTROM 0xffff0000 /* boot rom */ #define FLASHSIZE (512*MiB) /* but not addressed linearly */ --- /sys/src/9/omap/main.c Sat Sep 21 20:39:20 2013 +++ /sys/src/9/omap/main.c Sat Sep 21 20:39:21 2013 @@ -7,6 +7,7 @@ #include "init.h" #include +#include #include "reboot.h" @@ -25,6 +26,9 @@ enum { Minmem = 256*MB, /* conservative default */ + + /* space for syscall args, return PC, top-of-stack struct */ + Ustkheadroom = sizeof(Sargs) + sizeof(uintptr) + sizeof(Tos), }; #define isascii(c) ((uchar)(c) > 0 && (uchar)(c) < 0177) @@ -485,7 +489,7 @@ * of the argument list checked in syscall. */ i = oargblen+1; - p = UINT2PTR(STACKALIGN(base + BY2PG - sizeof(up->s.args) - i)); + p = UINT2PTR(STACKALIGN(base + BY2PG - Ustkheadroom - i)); memmove(p, oargb, i); /* --- /sys/src/9/teg2/main.c Sat Sep 21 20:39:22 2013 +++ /sys/src/9/teg2/main.c Sat Sep 21 20:39:24 2013 @@ -7,6 +7,7 @@ #include "init.h" #include +#include #include "arm.h" #include "reboot.h" @@ -24,6 +25,9 @@ enum { Minmem = 256*MB, /* conservative default */ + + /* space for syscall args, return PC, top-of-stack struct */ + Ustkheadroom = sizeof(Sargs) + sizeof(uintptr) + sizeof(Tos), }; #define isascii(c) ((uchar)(c) > 0 && (uchar)(c) < 0177) @@ -714,7 +718,7 @@ * of the argument list checked in syscall. */ i = oargblen+1; - p = UINT2PTR(STACKALIGN(base + BY2PG - sizeof(up->s.args) - i)); + p = UINT2PTR(STACKALIGN(base + BY2PG - Ustkheadroom)); memmove(p, oargb, i); /*