Am 17.05.2009 15:14, schrieb Peter Stuge:
bifferos wrote:
Somebody's getting their memory ranges muddled up.
Patrick, in r95 you're using a type member in struct memrange
(itself a member of libpayload sysinfo_t) but the type member only
exists in the coreboot table, not in libpayload's sysinfo_t.memrange.
What is the good fix? Add the type member to libpayload
sysinfo_t.memrange, work with coreboot tables directly or ignore
everything but than CB_MEM_RAM when copying entires from coreboot
table into sysinfo_t.memrange, making the changes in r95 no longer
neccessary?
I extracted the type field support from our repo. See attached patch.
The MEMMAP_RAM_ONLY define is a way to allow a payload to opt for only
having CB_MEM_RAM type fields, which might be helpful to support older
payloads easily (just add the define, and it won't encounter "weird" fields)
Signed-off-by: Patrick Georgi <[email protected]>
Sorry for the mess,
Patrick
===================================================================
--- i386/multiboot.c
+++ i386/multiboot.c
@@ -45,15 +45,20 @@
while(ptr < (start + table->mmap_length)) {
struct multiboot_mmap *mmap = (struct multiboot_mmap *) ptr;
+#if MEMMAP_RAM_ONLY
/* 1 == normal RAM. Ignore everything else for now */
if (mmap->type == 1) {
+#endif
info->memrange[info->n_memranges].base = mmap->addr;
info->memrange[info->n_memranges].size = mmap->length;
+ info->memrange[info->n_memranges].type = mmap->type;
if (++info->n_memranges == SYSINFO_MAX_MEM_RANGES)
return;
+#if MEMMAP_RAM_ONLY
}
+#endif
ptr += (mmap->size + sizeof(mmap->size));
}
===================================================================
--- i386/sysinfo.c
+++ i386/sysinfo.c
@@ -29,6 +29,7 @@
#include <libpayload-config.h>
#include <libpayload.h>
+#include <coreboot_tables.h>
#include <multiboot_tables.h>
/**
@@ -63,9 +64,13 @@
if (!lib_sysinfo.n_memranges) {
/* If we can't get a good memory range, use the default. */
lib_sysinfo.n_memranges = 2;
+
lib_sysinfo.memrange[0].base = 0;
lib_sysinfo.memrange[0].size = 640 * 1024;
+ lib_sysinfo.memrange[0].type = CB_MEM_RAM;
+
lib_sysinfo.memrange[1].base = 1024 * 1024;
lib_sysinfo.memrange[1].size = 31 * 1024 * 1024;
+ lib_sysinfo.memrange[1].type = CB_MEM_RAM;
}
}
===================================================================
--- i386/coreboot.c
+++ i386/coreboot.c
@@ -57,8 +57,10 @@
struct cb_memory_range *range =
(struct cb_memory_range *)MEM_RANGE_PTR(mem, i);
+#if MEMMAP_RAM_ONLY
if (range->type != CB_MEM_RAM)
continue;
+#endif
info->memrange[info->n_memranges].base =
UNPACK_CB64(range->start);
@@ -66,6 +68,8 @@
info->memrange[info->n_memranges].size =
UNPACK_CB64(range->size);
+ info->memrange[info->n_memranges].type = range->type;
+
info->n_memranges++;
}
}
===================================================================
--- include/sysinfo.h
+++ include/sysinfo.h
@@ -42,6 +42,7 @@
struct memrange {
unsigned long long base;
unsigned long long size;
+ unsigned int type;
} memrange[SYSINFO_MAX_MEM_RANGES];
struct cb_cmos_option_table *option_table;
--
coreboot mailing list: [email protected]
http://www.coreboot.org/mailman/listinfo/coreboot