|
@@ -2,6 +2,7 @@
|
|
|
#include <libc.h>
|
|
|
#include <bio.h>
|
|
|
#include <mach.h>
|
|
|
+#include <tos.h>
|
|
|
#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);
|