bcm, bcm64: preserve memsize across reboots, avoid trashing atags while parsing cmdline
we override atag memory on reboot, so preserve the memsize learned from atag as *maxmem plan9 variable. the global memsize variable is not needed anymore. avoid trashing the following atag when zero terminating the cmdline string. zero memory after plan9.ini variables.
This commit is contained in:
parent
157d7ebdbd
commit
3b36daa2bb
4 changed files with 25 additions and 25 deletions
|
@ -88,34 +88,37 @@ plan9iniinit(char *s, int cmdline)
|
|||
void
|
||||
bootargsinit(void)
|
||||
{
|
||||
static char maxmem[11];
|
||||
char x, *e;
|
||||
Atag *a;
|
||||
int n;
|
||||
|
||||
a = (Atag*)BOOTARGS;
|
||||
e = BOOTARGS;
|
||||
a = (Atag*)e;
|
||||
if(a->tag != AtagCore){
|
||||
plan9iniinit((char*)a, 0);
|
||||
plan9iniinit(e, 0);
|
||||
return;
|
||||
}
|
||||
while(a->tag != AtagNone && a->size != 0){
|
||||
while(a->tag != AtagNone){
|
||||
e += a->size * sizeof(u32int);
|
||||
if(a->size < 2 || e < (char*)a || e > &BOOTARGS[BOOTARGSLEN])
|
||||
break;
|
||||
switch(a->tag){
|
||||
case AtagMem:
|
||||
/* use only first bank */
|
||||
if(conf.mem[0].limit == 0 && a->mem.size != 0){
|
||||
memsize = a->mem.size;
|
||||
conf.mem[0].base = a->mem.base;
|
||||
conf.mem[0].limit = a->mem.base + memsize;
|
||||
if(findconf("*maxmem") < 0){
|
||||
snprint(maxmem, sizeof(maxmem), "%ud", a->mem.base+a->mem.size);
|
||||
addconf("*maxmem", maxmem);
|
||||
}
|
||||
break;
|
||||
case AtagCmdline:
|
||||
n = (a->size * sizeof(u32int)) - offsetof(Atag, cmdline[0]);
|
||||
if(a->cmdline + n < BOOTARGS + BOOTARGSLEN)
|
||||
a->cmdline[n] = 0;
|
||||
else
|
||||
BOOTARGS[BOOTARGSLEN-1] = 0;
|
||||
x = *e;
|
||||
*e = 0;
|
||||
plan9iniinit(a->cmdline, 1);
|
||||
*e = x;
|
||||
break;
|
||||
}
|
||||
a = (Atag*)((u32int*)a + a->size);
|
||||
if(e > &BOOTARGS[BOOTARGSLEN-8])
|
||||
break;
|
||||
a = (Atag*)e;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -164,6 +167,7 @@ writeconf(void)
|
|||
if(n >= BOOTARGSLEN)
|
||||
error("kernel configuration too large");
|
||||
memmove(BOOTARGS, p, n);
|
||||
memset(BOOTARGS+n, 0, BOOTARGSLEN-n);
|
||||
poperror();
|
||||
free(p);
|
||||
}
|
||||
|
|
|
@ -227,7 +227,6 @@ extern register Mach* m; /* R10 */
|
|||
extern register Proc* up; /* R9 */
|
||||
extern uintptr kseg0;
|
||||
extern Mach* machaddr[MAXMACH];
|
||||
extern ulong memsize;
|
||||
extern int normalprint;
|
||||
|
||||
/*
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
uintptr kseg0 = KZERO;
|
||||
Mach* machaddr[MAXMACH];
|
||||
Conf conf;
|
||||
ulong memsize = 128*1024*1024;
|
||||
|
||||
void
|
||||
machinit(void)
|
||||
|
@ -241,7 +240,7 @@ void
|
|||
confinit(void)
|
||||
{
|
||||
int i, userpcnt;
|
||||
ulong kpages;
|
||||
ulong kpages, memsize = 0;
|
||||
uintptr pa;
|
||||
char *p;
|
||||
|
||||
|
@ -257,12 +256,10 @@ confinit(void)
|
|||
else
|
||||
userpcnt = 0;
|
||||
|
||||
if((p = getconf("*maxmem")) != nil){
|
||||
if(p = getconf("*maxmem"))
|
||||
memsize = strtoul(p, 0, 0) - PHYSDRAM;
|
||||
if (memsize < 16*MB) /* sanity */
|
||||
memsize = 16*MB;
|
||||
}
|
||||
|
||||
if (memsize < 16*MB) /* sanity */
|
||||
memsize = 16*MB;
|
||||
getramsize(&conf.mem[0]);
|
||||
if(conf.mem[0].limit == 0){
|
||||
conf.mem[0].base = PHYSDRAM;
|
||||
|
|
|
@ -304,8 +304,8 @@ mmuuncache(void* v, usize size)
|
|||
uintptr
|
||||
cankaddr(uintptr pa)
|
||||
{
|
||||
if(pa < PHYSDRAM + memsize) /* assumes PHYSDRAM is 0 */
|
||||
return PHYSDRAM + memsize - pa;
|
||||
if(pa < PHYSDRAM+soc.dramsize)
|
||||
return PHYSDRAM+soc.dramsize - pa;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue