sync up with sources; fix initstk() to account for Tos Reference: /n/atom/patch/applied2013/kisync Date: Wed Jun 19 02:18:51 CES 2013 Signed-off-by: quanstro@quanstro.net --- /sys/src/cmd/ki/ki.c Wed Jun 19 02:18:31 2013 +++ /sys/src/cmd/ki/ki.c Wed Jun 19 02:18:31 2013 @@ -2,6 +2,7 @@ #include #include #include +#include #define Extern #include "sparc.h" @@ -277,12 +278,22 @@ void initstk(int argc, char *argv[]) { - ulong size, sp, ap; + ulong size, sp, ap, tos; int i; char *p; initmap(); - sp = STACKTOP - 4; + tos = STACKTOP - sizeof(Tos)*2; /* we'll assume twice the host's is big enough */ + sp = tos; + for (i = 0; i < sizeof(Tos)*2; i++) + putmem_b(tos + i, 0); + + /* + * pid is second word from end of tos and needs to be set for nsec(). + * we know sparc is a 32-bit cpu, so we'll assume knowledge of the Tos + * struct for now, and use our pid. + */ + putmem_w(tos + 4*4 + 2*sizeof(ulong) + 3*sizeof(uvlong), getpid()); /* Build exec stack */ size = strlen(file)+1+BY2WD+BY2WD+(BY2WD*2); @@ -292,7 +303,7 @@ sp -= size; sp &= ~7; reg.r[1] = sp; - reg.r[7] = STACKTOP-4; /* Plan 9 profiling clock */ + reg.r[7] = tos; /* Plan 9 profiling clock, etc. */ /* Push argc */ putmem_w(sp, argc+1);