pc, pc64: allow passing RSDT pointer in *acpi= boot parameter, early bootscreeninit(), fix rampage() usage

rampage() cannot be used after meminit(), so test for
conf.mem[0].npage != 0 and use xalloc()/mallocalign()
instead. this allows us to use vmap() early before
mmuinit() which is needed for bootscreeninit() and
acpi.

to get memory for page tables, pc64 needs a lowraminit().

with EFI, the RSDT pointer is passed in *acpi= parameter
from the efi loader. as the RSDT is ususally at the end of
the physical address space (and not to be found in
bios areas), we cannot KMAP() it so we need to vmap().
This commit is contained in:
cinap_lenrek 2014-10-18 02:01:58 +02:00
parent 81e0d6e988
commit 0a6439a1f5
6 changed files with 43 additions and 13 deletions

View file

@ -645,11 +645,17 @@ readtbls(Chan*, void *v, long n, vlong o)
static int static int
identify(void) identify(void)
{ {
uintptr pa;
char *cp; char *cp;
if((cp = getconf("*acpi")) == nil) if((cp = getconf("*acpi")) == nil)
return 1; return 1;
if((rsd = sigsearch("RSD PTR ")) == nil) pa = (uintptr)strtoull(cp, nil, 16);
if(pa <= 1)
rsd = sigsearch("RSD PTR ");
else
rsd = vmap(pa, sizeof(Rsd));
if(rsd == nil)
return 1; return 1;
if(checksum(rsd, 20) && checksum(rsd, 36)) if(checksum(rsd, 20) && checksum(rsd, 36))
return 1; return 1;

View file

@ -146,15 +146,15 @@ main(void)
cpuidentify(); cpuidentify();
meminit(); meminit();
confinit(); confinit();
archinit();
xinit(); xinit();
archinit();
bootscreeninit();
if(i8237alloc != nil) if(i8237alloc != nil)
i8237alloc(); i8237alloc();
trapinit(); trapinit();
printinit(); printinit();
cpuidprint(); cpuidprint();
mmuinit(); mmuinit();
bootscreeninit();
if(arch->intrinit) /* launches other processors on an mp */ if(arch->intrinit) /* launches other processors on an mp */
arch->intrinit(); arch->intrinit();
timersinit(); timersinit();

View file

@ -59,7 +59,6 @@ Segdesc gdt[NGDT] =
[KESEG16] EXEC16SEGM(0), /* kernel code 16-bit */ [KESEG16] EXEC16SEGM(0), /* kernel code 16-bit */
}; };
static int didmmuinit;
static void taskswitch(ulong, ulong); static void taskswitch(ulong, ulong);
static void memglobal(void); static void memglobal(void);
@ -79,8 +78,6 @@ mmuinit(void)
ulong x, *p; ulong x, *p;
ushort ptr[3]; ushort ptr[3];
didmmuinit = 1;
if(0) print("vpt=%#.8ux vpd=%#p kmap=%#.8ux\n", if(0) print("vpt=%#.8ux vpd=%#p kmap=%#.8ux\n",
VPT, vpd, KMAP); VPT, vpd, KMAP);
@ -523,7 +520,7 @@ mmuwalk(ulong* pdb, ulong va, int level, int create)
* memory.c if we haven't set up the xalloc * memory.c if we haven't set up the xalloc
* tables yet. * tables yet.
*/ */
if(didmmuinit) if(conf.mem[0].npage != 0)
map = xspanalloc(BY2PG, BY2PG, 0); map = xspanalloc(BY2PG, BY2PG, 0);
else else
map = rampage(); map = rampage();

View file

@ -32,6 +32,7 @@ int idle_spin;
uchar *sp; /* user stack of init proc */ uchar *sp; /* user stack of init proc */
extern void (*i8237alloc)(void); extern void (*i8237alloc)(void);
extern void bootscreeninit(void);
static void static void
multibootargs(void) multibootargs(void)
@ -506,8 +507,9 @@ main()
cpuidentify(); cpuidentify();
meminit(); meminit();
confinit(); confinit();
archinit();
xinit(); xinit();
archinit();
bootscreeninit();
if(i8237alloc != nil) if(i8237alloc != nil)
i8237alloc(); i8237alloc();
trapinit(); trapinit();

View file

@ -371,6 +371,34 @@ sigsearch(char* signature)
return sigscan(KADDR(0xe0000), 0x20000, signature); return sigscan(KADDR(0xe0000), 0x20000, signature);
} }
static void
lowraminit(void)
{
uintptr pa, x;
uchar *bda;
/*
* Initialise the memory bank information for conventional memory
* (i.e. less than 640KB). The base is the first location after the
* bootstrap processor MMU information and the limit is obtained from
* the BIOS data area.
*/
x = PADDR(CPU0END);
bda = (uchar*)KADDR(0x400);
pa = ((bda[0x14]<<8)|bda[0x13])*KB;
if(x < pa){
mapfree(&rmapram, x, pa-x);
memset(KADDR(x), 0, pa-x); /* keep us honest */
}
x = PADDR(PGROUND((uintptr)end));
pa = MemMin;
if(x > pa)
panic("kernel too big");
mapfree(&rmapram, x, pa-x);
memset(KADDR(x), 0, pa-x); /* keep us honest */
}
typedef struct Emap Emap; typedef struct Emap Emap;
struct Emap struct Emap
{ {
@ -561,6 +589,7 @@ meminit(void)
uintptr lost; uintptr lost;
umbscan(); umbscan();
lowraminit();
e820scan(); e820scan();
/* /*

View file

@ -23,8 +23,6 @@ Segdesc gdt[NGDT] =
[UESEG] EXECSEGM(3), /* user code */ [UESEG] EXECSEGM(3), /* user code */
}; };
static int didmmuinit = 0;
static struct { static struct {
Lock; Lock;
MMU *free; MMU *free;
@ -79,8 +77,6 @@ mmuinit(void)
vlong v; vlong v;
int i; int i;
didmmuinit = 1;
/* zap double map done by l.s */ /* zap double map done by l.s */
m->pml4[512] = 0; m->pml4[512] = 0;
m->pml4[0] = 0; m->pml4[0] = 0;
@ -242,7 +238,7 @@ mmucreate(uintptr *table, uintptr va, int level, int index)
up->kmapcount++; up->kmapcount++;
} }
page = p->page; page = p->page;
} else if(didmmuinit) { } else if(conf.mem[0].npage != 0) {
page = mallocalign(PTSZ, BY2PG, 0, 0); page = mallocalign(PTSZ, BY2PG, 0, 0);
} else { } else {
page = rampage(); page = rampage();