Add type field to memranges, and fill it from the source data.
type field contains e820 type ids, which are used by coreboot and multiboot (the two source formats), so they can be used as-is. 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 <patrick.georgi@coresystems.de> Acked-by: Peter Stuge <peter@stuge.se> git-svn-id: svn://svn.coreboot.org/coreboot/trunk@4291 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
This commit is contained in:
parent
56ae8fcb6f
commit
c9a6f0f442
|
@ -57,8 +57,10 @@ static void cb_parse_memory(unsigned char *ptr, struct sysinfo_t *info)
|
||||||
struct cb_memory_range *range =
|
struct cb_memory_range *range =
|
||||||
(struct cb_memory_range *)MEM_RANGE_PTR(mem, i);
|
(struct cb_memory_range *)MEM_RANGE_PTR(mem, i);
|
||||||
|
|
||||||
|
#if MEMMAP_RAM_ONLY
|
||||||
if (range->type != CB_MEM_RAM)
|
if (range->type != CB_MEM_RAM)
|
||||||
continue;
|
continue;
|
||||||
|
#endif
|
||||||
|
|
||||||
info->memrange[info->n_memranges].base =
|
info->memrange[info->n_memranges].base =
|
||||||
UNPACK_CB64(range->start);
|
UNPACK_CB64(range->start);
|
||||||
|
@ -66,6 +68,8 @@ static void cb_parse_memory(unsigned char *ptr, struct sysinfo_t *info)
|
||||||
info->memrange[info->n_memranges].size =
|
info->memrange[info->n_memranges].size =
|
||||||
UNPACK_CB64(range->size);
|
UNPACK_CB64(range->size);
|
||||||
|
|
||||||
|
info->memrange[info->n_memranges].type = range->type;
|
||||||
|
|
||||||
info->n_memranges++;
|
info->n_memranges++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,15 +45,20 @@ static void mb_parse_mmap(struct multiboot_header *table,
|
||||||
while(ptr < (start + table->mmap_length)) {
|
while(ptr < (start + table->mmap_length)) {
|
||||||
struct multiboot_mmap *mmap = (struct multiboot_mmap *) ptr;
|
struct multiboot_mmap *mmap = (struct multiboot_mmap *) ptr;
|
||||||
|
|
||||||
|
#if MEMMAP_RAM_ONLY
|
||||||
/* 1 == normal RAM. Ignore everything else for now */
|
/* 1 == normal RAM. Ignore everything else for now */
|
||||||
|
|
||||||
if (mmap->type == 1) {
|
if (mmap->type == 1) {
|
||||||
|
#endif
|
||||||
info->memrange[info->n_memranges].base = mmap->addr;
|
info->memrange[info->n_memranges].base = mmap->addr;
|
||||||
info->memrange[info->n_memranges].size = mmap->length;
|
info->memrange[info->n_memranges].size = mmap->length;
|
||||||
|
info->memrange[info->n_memranges].type = mmap->type;
|
||||||
|
|
||||||
if (++info->n_memranges == SYSINFO_MAX_MEM_RANGES)
|
if (++info->n_memranges == SYSINFO_MAX_MEM_RANGES)
|
||||||
return;
|
return;
|
||||||
|
#if MEMMAP_RAM_ONLY
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
ptr += (mmap->size + sizeof(mmap->size));
|
ptr += (mmap->size + sizeof(mmap->size));
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
|
|
||||||
#include <libpayload-config.h>
|
#include <libpayload-config.h>
|
||||||
#include <libpayload.h>
|
#include <libpayload.h>
|
||||||
|
#include <coreboot_tables.h>
|
||||||
#include <multiboot_tables.h>
|
#include <multiboot_tables.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -63,9 +64,13 @@ void lib_get_sysinfo(void)
|
||||||
if (!lib_sysinfo.n_memranges) {
|
if (!lib_sysinfo.n_memranges) {
|
||||||
/* If we can't get a good memory range, use the default. */
|
/* If we can't get a good memory range, use the default. */
|
||||||
lib_sysinfo.n_memranges = 2;
|
lib_sysinfo.n_memranges = 2;
|
||||||
|
|
||||||
lib_sysinfo.memrange[0].base = 0;
|
lib_sysinfo.memrange[0].base = 0;
|
||||||
lib_sysinfo.memrange[0].size = 640 * 1024;
|
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].base = 1024 * 1024;
|
||||||
lib_sysinfo.memrange[1].size = 31 * 1024 * 1024;
|
lib_sysinfo.memrange[1].size = 31 * 1024 * 1024;
|
||||||
|
lib_sysinfo.memrange[1].type = CB_MEM_RAM;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,6 +42,7 @@ struct sysinfo_t {
|
||||||
struct memrange {
|
struct memrange {
|
||||||
unsigned long long base;
|
unsigned long long base;
|
||||||
unsigned long long size;
|
unsigned long long size;
|
||||||
|
unsigned int type;
|
||||||
} memrange[SYSINFO_MAX_MEM_RANGES];
|
} memrange[SYSINFO_MAX_MEM_RANGES];
|
||||||
|
|
||||||
struct cb_cmos_option_table *option_table;
|
struct cb_cmos_option_table *option_table;
|
||||||
|
|
Loading…
Reference in New Issue