From 4f33c88a51587681b7be1ae57cfbc43b627c6bc4 Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Mon, 30 Jul 2012 19:11:16 +0200 Subject: import updated compilers from sources --- sys/src/cmd/qi/qi.c | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) (limited to 'sys/src/cmd/qi') diff --git a/sys/src/cmd/qi/qi.c b/sys/src/cmd/qi/qi.c index ebccc5e46..a76356e72 100644 --- a/sys/src/cmd/qi/qi.c +++ b/sys/src/cmd/qi/qi.c @@ -2,6 +2,7 @@ #include #include #include +#include #define Extern #include "power.h" @@ -51,6 +52,12 @@ main(int argc, char **argv) cmd(); } +/* + * we're rounding segment boundaries to the nearest 1MB on power now, + * and mach->pgsize is actually what to round segment boundaries up to. + */ +#define SEGROUND mach->pgsize + void initmap(void) { @@ -58,10 +65,10 @@ initmap(void) ulong t, d, b, bssend; Segment *s; - t = (fhdr.txtaddr+fhdr.txtsz+(BY2PG-1)) & ~(BY2PG-1); - d = (t + fhdr.datsz + (BY2PG-1)) & ~(BY2PG-1); + t = (fhdr.txtaddr+fhdr.txtsz+(SEGROUND-1)) & ~(SEGROUND-1); + d = (t + fhdr.datsz + (SEGROUND-1)) & ~(SEGROUND-1); bssend = t + fhdr.datsz + fhdr.bsssz; - b = (bssend + (BY2PG-1)) & ~(BY2PG-1); + b = (bssend + (SEGROUND-1)) & ~(SEGROUND-1); s = &memory.seg[Text]; s->type = Text; @@ -278,12 +285,22 @@ reset(void) 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 power 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); @@ -293,7 +310,7 @@ initstk(int argc, char *argv[]) sp -= size; sp &= ~7; reg.r[1] = sp; - reg.r[3] = STACKTOP-4; /* Plan 9 profiling clock */ + reg.r[3] = tos; /* Plan 9 profiling clock, etc. */ /* Push argc */ putmem_w(sp, argc+1); -- cgit v1.2.3