ref: 0a6439a1f564de17bfad7a327178e47483a86e1a
parent: 81e0d6e988289c983445f855583496048fb4c61b
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Fri Oct 17 22:01:58 EDT 2014
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().
--- a/sys/src/9/pc/archacpi.c
+++ b/sys/src/9/pc/archacpi.c
@@ -645,11 +645,17 @@
static int
identify(void)
{
+ uintptr pa;
char *cp;
if((cp = getconf("*acpi")) == nil)
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;
if(checksum(rsd, 20) && checksum(rsd, 36))
return 1;
--- a/sys/src/9/pc/main.c
+++ b/sys/src/9/pc/main.c
@@ -146,8 +146,9 @@
cpuidentify();
meminit();
confinit();
- archinit();
xinit();
+ archinit();
+ bootscreeninit();
if(i8237alloc != nil)
i8237alloc();
trapinit();
@@ -154,7 +155,6 @@
printinit();
cpuidprint();
mmuinit();
- bootscreeninit();
if(arch->intrinit) /* launches other processors on an mp */
arch->intrinit();
timersinit();
--- a/sys/src/9/pc/mmu.c
+++ b/sys/src/9/pc/mmu.c
@@ -59,7 +59,6 @@
[KESEG16] EXEC16SEGM(0), /* kernel code 16-bit */
};
-static int didmmuinit;
static void taskswitch(ulong, ulong);
static void memglobal(void);
@@ -79,8 +78,6 @@
ulong x, *p;
ushort ptr[3];
- didmmuinit = 1;
-
if(0) print("vpt=%#.8ux vpd=%#p kmap=%#.8ux\n",
VPT, vpd, KMAP);
@@ -523,7 +520,7 @@
* memory.c if we haven't set up the xalloc
* tables yet.
*/
- if(didmmuinit)
+ if(conf.mem[0].npage != 0)
map = xspanalloc(BY2PG, BY2PG, 0);
else
map = rampage();
--- a/sys/src/9/pc64/main.c
+++ b/sys/src/9/pc64/main.c
@@ -32,6 +32,7 @@
uchar *sp; /* user stack of init proc */
extern void (*i8237alloc)(void);
+extern void bootscreeninit(void);
static void
multibootargs(void)
@@ -506,8 +507,9 @@
cpuidentify();
meminit();
confinit();
- archinit();
xinit();
+ archinit();
+ bootscreeninit();
if(i8237alloc != nil)
i8237alloc();
trapinit();
--- a/sys/src/9/pc64/memory.c
+++ b/sys/src/9/pc64/memory.c
@@ -371,6 +371,34 @@
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;
struct Emap
{
@@ -561,6 +589,7 @@
uintptr lost;
umbscan();
+ lowraminit();
e820scan();
/*
--- a/sys/src/9/pc64/mmu.c
+++ b/sys/src/9/pc64/mmu.c
@@ -23,8 +23,6 @@
[UESEG] EXECSEGM(3), /* user code */
};
-static int didmmuinit = 0;
-
static struct {
Lock;
MMU *free;
@@ -79,8 +77,6 @@
vlong v;
int i;
- didmmuinit = 1;
-
/* zap double map done by l.s */
m->pml4[512] = 0;
m->pml4[0] = 0;
@@ -242,7 +238,7 @@
up->kmapcount++;
}
page = p->page;
- } else if(didmmuinit) {
+ } else if(conf.mem[0].npage != 0) {
page = mallocalign(PTSZ, BY2PG, 0, 0);
} else {
page = rampage();