diff options
author | Aaron Durbin <adurbin@chromium.org> | 2015-03-05 21:18:33 -0600 |
---|---|---|
committer | Aaron Durbin <adurbin@chromium.org> | 2015-04-22 22:56:31 +0200 |
commit | 0dff57dd7ab9e4863d464f54f68dbd75a8f4d96a (patch) | |
tree | f8465903807b5a0362895efd932c0f79981943a4 /src/lib/cbmem_common.c | |
parent | cfba6099d65de55d4e34bb670380897d9e3cd18d (diff) | |
download | coreboot-0dff57dd7ab9e4863d464f54f68dbd75a8f4d96a.tar.xz |
cbmem: switch over to imd-based cbmem
By design, the imd library still provdes dynamic growth so that
feature is consistent. The imd-based cbmem packs small allocations
into a larger entry using a tiered imd. The following examples show
the reduced fragmentation and reduced memory usage.
Before with dynamic cbmem:
CBMEM ROOT 0. 023ff000 00001000
aaaabbbb 1. 023fe000 00001000
aaaabbbc 2. 023fd000 00001000
aaaabbbe 3. 023fc000 00001000
aaaacccc 4. 023fa000 00002000
aaaacccd 5. 023f9000 00001000
ROMSTAGE 6. 023f8000 00001000
CONSOLE 7. 023d8000 00020000
COREBOOT 8. 023d6000 00002000
After with tiered imd:
IMD ROOT 0. 023ff000 00001000
IMD SMALL 1. 023fe000 00001000
aaaacccc 2. 023fc000 00001060
aaaacccd 3. 023fb000 000007cf
CONSOLE 4. 023db000 00020000
COREBOOT 5. 023d9000 00002000
IMD small region:
IMD ROOT 0. 023fec00 00000400
aaaabbbb 1. 023febe0 00000020
aaaabbbc 2. 023feba0 00000040
aaaabbbe 3. 023feb20 00000080
ROMSTAGE 4. 023feb00 00000004
Side note: this CL provides a basis for what hoops one needs to
jump through when there are not writeable global variables on
a particular platform in the early stages.
Change-Id: If770246caa64b274819e45a26e100b62b9f8d2db
Signed-off-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-on: http://review.coreboot.org/9169
Tested-by: build bot (Jenkins)
Reviewed-by: Marc Jones <marc.jones@se-eng.com>
Diffstat (limited to 'src/lib/cbmem_common.c')
-rw-r--r-- | src/lib/cbmem_common.c | 46 |
1 files changed, 18 insertions, 28 deletions
diff --git a/src/lib/cbmem_common.c b/src/lib/cbmem_common.c index c3e838388d..6d581c40b2 100644 --- a/src/lib/cbmem_common.c +++ b/src/lib/cbmem_common.c @@ -18,39 +18,16 @@ */ #include <console/console.h> #include <cbmem.h> -#include <stdlib.h> +#include <bootstate.h> +#include <rules.h> +#if IS_ENABLED(CONFIG_ARCH_X86) && !IS_ENABLED(CONFIG_EARLY_CBMEM_INIT) +#include <arch/acpi.h> +#endif /* FIXME: Remove after CBMEM_INIT_HOOKS. */ #include <console/cbmem_console.h> #include <timestamp.h> -#ifndef __PRE_RAM__ - -static const struct cbmem_id_to_name cbmem_ids[] = { CBMEM_ID_TO_NAME_TABLE }; - -void cbmem_print_entry(int n, u32 id, u64 base, u64 size) -{ - int i; - const char *name; - - name = NULL; - for (i = 0; i < ARRAY_SIZE(cbmem_ids); i++) { - if (cbmem_ids[i].id == id) { - name = cbmem_ids[i].name; - break; - } - } - - if (name == NULL) - printk(BIOS_DEBUG, "%08x ", id); - else - printk(BIOS_DEBUG, "%s", name); - printk(BIOS_DEBUG, "%2d. ", n); - printk(BIOS_DEBUG, "%08llx ", base); - printk(BIOS_DEBUG, "%08llx\n", size); -} - -#endif /* !__PRE_RAM__ */ /* FIXME: Replace with CBMEM_INIT_HOOKS API. */ #if !IS_ENABLED(CONFIG_ARCH_X86) @@ -67,3 +44,16 @@ void __attribute__((weak)) cbmem_fail_resume(void) { } #endif + +#if ENV_RAMSTAGE && !IS_ENABLED(CONFIG_EARLY_CBMEM_INIT) +static void init_cbmem_post_device(void *unused) +{ + if (acpi_is_wakeup()) + cbmem_initialize(); + else + cbmem_initialize_empty(); +} + +BOOT_STATE_INIT_ENTRY(BS_POST_DEVICE, BS_ON_ENTRY, + init_cbmem_post_device, NULL); +#endif |