aboutsummaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorAaron Durbin <adurbin@chromium.org>2014-02-18 21:55:02 -0600
committerAaron Durbin <adurbin@google.com>2014-03-03 21:47:27 +0100
commit4904802efc8eee37f95163f60823509e2a208af4 (patch)
tree919d78b05dc1a4edd7ab1ec6af74bbea533580a6 /src/include
parentc7db28c580785b62b9fc67b7526c87d4f0073883 (diff)
coreboot: introduce notion of bootmem for memory map at boot
The write_coreboot_table() in coreboot_table.c was already using struct memrange for managing and building up the entries that eventually go into the lb_memory table. Abstract that concept out to a bootmem memory map. The bootmem concept can then be used as a basis for loading payloads, for example. Change-Id: I7edbbca6bbd0568f658fde39ca93b126cab88367 Signed-off-by: Aaron Durbin <adurbin@chromium.org> Reviewed-on: http://review.coreboot.org/5302 Tested-by: build bot (Jenkins) Reviewed-by: Edward O'Callaghan <eocallaghan@alterapraxis.com> Reviewed-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
Diffstat (limited to 'src/include')
-rw-r--r--src/include/boot/coreboot_tables.h3
-rw-r--r--src/include/bootmem.h48
-rw-r--r--src/include/cbmem.h5
3 files changed, 50 insertions, 6 deletions
diff --git a/src/include/boot/coreboot_tables.h b/src/include/boot/coreboot_tables.h
index 6243d4589c..9b87f3d190 100644
--- a/src/include/boot/coreboot_tables.h
+++ b/src/include/boot/coreboot_tables.h
@@ -338,9 +338,6 @@ unsigned long write_coreboot_table(
unsigned long low_table_start, unsigned long low_table_end,
unsigned long rom_table_start, unsigned long rom_table_end);
-void lb_add_memory_range(struct lb_memory *mem,
- uint32_t type, uint64_t start, uint64_t size);
-
/* Routines to extract part so the coreboot table or information
* from the coreboot table.
*/
diff --git a/src/include/bootmem.h b/src/include/bootmem.h
new file mode 100644
index 0000000000..656769f8db
--- /dev/null
+++ b/src/include/bootmem.h
@@ -0,0 +1,48 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2014 Google Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef BOOTMEM_H
+#define BOOTMEM_H
+
+#include <memrange.h>
+#include <stdint.h>
+#include <boot/coreboot_tables.h>
+
+/*
+ * Initialize the memory address space prior to payload loading. The bootmem
+ * serves as the source for the lb_mem table.
+ */
+void bootmem_init(void);
+
+/* Add a range of a given type to the bootmem address space. */
+void bootmem_add_range(uint64_t start, uint64_t size, uint32_t type);
+
+/* Write memory coreboot table. */
+void bootmem_write_memory_table(struct lb_memory *mem);
+
+/* Print current range map of boot memory. */
+void bootmem_dump_ranges(void);
+
+/* Return 1 if region targets usable RAM, 0 otherwise. */
+int bootmem_region_targets_usable_ram(uint64_t start, uint64_t size);
+
+/* Allocate a temporary buffer from the unused RAM areas. */
+void *bootmem_allocate_buffer(size_t size);
+
+#endif /* BOOTMEM_H */
diff --git a/src/include/cbmem.h b/src/include/cbmem.h
index eb307d49bb..7cb12b261f 100644
--- a/src/include/cbmem.h
+++ b/src/include/cbmem.h
@@ -174,9 +174,8 @@ void *cbmem_find(u32 id);
#ifndef __PRE_RAM__
/* Ramstage only functions. */
-/* Add the cbmem memory used to the memory tables. */
-struct lb_memory;
-void cbmem_add_lb_mem(struct lb_memory *mem);
+/* Add the cbmem memory used to the memory map at boot. */
+void cbmem_add_bootmem(void);
void cbmem_list(void);
void cbmem_arch_init(void);
void cbmem_print_entry(int n, u32 id, u64 start, u64 size);