update mips emulator for routerboard Reference: /n/atom/patch/applied2013/viupd Date: Wed Jul 31 17:25:36 CES 2013 Signed-off-by: quanstro@quanstro.net --- /sys/src/cmd/vi/vi.c Wed Jul 31 17:25:19 2013 +++ /sys/src/cmd/vi/vi.c Wed Jul 31 17:25:19 2013 @@ -2,6 +2,7 @@ #include #include #include +#include #define Extern #include "mips.h" @@ -291,12 +292,22 @@ initstk(int argc, char *argv[]) { ulong size; - ulong sp, ap; + ulong 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 mips 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; @@ -306,7 +317,7 @@ sp -= size; sp &= ~3; reg.r[29] = sp; - reg.r[1] = STACKTOP-4; /* Plan 9 profiling clock */ + reg.r[1] = tos; /* Plan 9 profiling clock, etc. */ /* Push argc */ putmem_w(sp, argc+1); --- /sys/src/cmd/vi/mips.h Wed Jul 31 17:25:20 2013 +++ /sys/src/cmd/vi/mips.h Wed Jul 31 17:25:21 2013 @@ -229,7 +229,7 @@ Extern int rtrace; /* Plan9 Kernel constants */ -#define BY2PG 4096 +#define BY2PG (16*1024) #define BY2WD 4 #define UTZERO 0x1000 #define STACKTOP 0x80000000 --- /sys/src/cmd/8l/elf.h Wed Jul 31 17:25:21 2013 +++ /sys/src/cmd/8l/elf.h Wed Jul 31 17:25:22 2013 @@ -45,6 +45,7 @@ I860 = 7, /* Intel i860 */ MIPS = 8, /* Mips R2000 */ S370 = 9, /* Amdhal */ + MIPSR4K = 10, /* Mips R4000 */ SPARC64 = 18, /* Sun SPARC v9 */ POWER = 20, /* PowerPC */ POWER64 = 21, /* PowerPC64 */