soc/amd/stoneyridge: remove LIDS field from global NVS
[coreboot.git] / src / include / bootmem.h
blob6ccdd884aab30a294b0feb5a24a02a4ee392a1c4
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #ifndef BOOTMEM_H
4 #define BOOTMEM_H
6 #include <boot/coreboot_tables.h>
7 #include <memrange.h>
8 #include <types.h>
10 /**
11 * Bootmem types match to LB_MEM tags, except for the following:
12 * BM_MEM_RAMSTAGE : Memory where any kind of boot firmware resides and that
13 * should not be touched by bootmem (by example: stack,
14 * TTB, program, ...).
15 * BM_MEM_PAYLOAD : Memory where any kind of payload resides and that should
16 * not be touched by bootmem.
17 * Start at 0x10000 to make sure that the caller doesn't provide LB_MEM tags.
19 enum bootmem_type {
20 BM_MEM_INVALID = 0, /* Invalid type (used in optional arguments). */
22 BM_MEM_FIRST = 0x10000, /* First entry in this list */
23 BM_MEM_RAM, /* Memory anyone can use */
24 BM_MEM_RESERVED, /* Don't use this memory region */
25 BM_MEM_ACPI, /* ACPI Tables */
26 BM_MEM_NVS, /* ACPI NVS Memory */
27 BM_MEM_UNUSABLE, /* Unusable address space */
28 BM_MEM_VENDOR_RSVD, /* Vendor Reserved */
29 BM_MEM_OPENSBI, /* Risc-V OpenSBI */
30 BM_MEM_BL31, /* Arm64 BL31 executable */
31 BM_MEM_TABLE, /* Ram configuration tables are kept in */
32 /* Tags below this point are ignored for the OS table. */
33 BM_MEM_OS_CUTOFF = BM_MEM_TABLE,
34 BM_MEM_RAMSTAGE,
35 BM_MEM_PAYLOAD,
36 BM_MEM_LAST, /* Last entry in this list */
39 /**
40 * Write memory coreboot table. Current resource map is serialized into
41 * memtable (LB_MEM_* types). bootmem library is unusable until this function
42 * is called first in the write tables path before payload is loaded.
44 * Bootmem types match to LB_MEM tags, except for the following:
45 * BM_MEM_RAMSTAGE : Translates to LB_MEM_RAM.
46 * BM_MEM_PAYLOAD : Translates to LB_MEM_RAM.
47 * BM_MEM_BL31 : Translates to LB_MEM_RESERVED.
49 void bootmem_write_memory_table(struct lb_memory *mem);
51 /* Architecture hook to add bootmem areas the architecture controls when
52 * bootmem_write_memory_table() is called. */
53 void bootmem_arch_add_ranges(void);
55 /* Platform hook to add bootmem areas the platform / board controls. */
56 void bootmem_platform_add_ranges(void);
58 /* Add a range of a given type to the bootmem address space. */
59 void bootmem_add_range(uint64_t start, uint64_t size,
60 const enum bootmem_type tag);
62 /* Print current range map of boot memory. */
63 void bootmem_dump_ranges(void);
65 typedef bool (*range_action_t)(const struct range_entry *r, void *arg);
67 /**
68 * Walk memory tables from OS point of view and call the provided function,
69 * for every region. The caller has to return false to break out of the loop any
70 * time, or return true to continue.
72 * @param action The function to call for each memory range.
73 * @param arg Pointer passed to function @action. Set to NULL if unused.
74 * @return true if the function 'action' returned false.
76 bool bootmem_walk_os_mem(range_action_t action, void *arg);
78 /**
79 * Walk memory tables and call the provided function, for every region.
80 * The caller has to return false to break out of the loop any time, or
81 * return true to continue.
83 * @param action The function to call for each memory range.
84 * @param arg Pointer passed to function @action. Set to NULL if unused.
85 * @return true if the function 'action' returned false.
87 bool bootmem_walk(range_action_t action, void *arg);
89 /* Returns 1 if the requested memory range is all tagged as type dest_type.
90 * Otherwise returns 0.
92 int bootmem_region_targets_type(uint64_t start, uint64_t size,
93 enum bootmem_type dest_type);
95 /* Allocate a temporary buffer from the unused RAM areas. */
96 void *bootmem_allocate_buffer(size_t size);
98 #endif /* BOOTMEM_H */