blob: 10c8d51b77ce95b2aaa8c8c0504333492c57d7a4 [file] [log] [blame]
Aaron Durbin49048022014-02-18 21:55:02 -06001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2014 Google Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
Aaron Durbin49048022014-02-18 21:55:02 -060014 */
15
16#ifndef BOOTMEM_H
17#define BOOTMEM_H
18
19#include <memrange.h>
20#include <stdint.h>
21#include <boot/coreboot_tables.h>
22
23/*
24 * Initialize the memory address space prior to payload loading. The bootmem
25 * serves as the source for the lb_mem table.
26 */
27void bootmem_init(void);
28
Aaron Durbind4afa932016-04-19 17:25:59 -050029/* Architecture hook to add bootmem areas the architecture controls. */
30void bootmem_arch_add_ranges(void);
31
Aaron Durbin49048022014-02-18 21:55:02 -060032/* Add a range of a given type to the bootmem address space. */
33void bootmem_add_range(uint64_t start, uint64_t size, uint32_t type);
34
35/* Write memory coreboot table. */
36void bootmem_write_memory_table(struct lb_memory *mem);
37
38/* Print current range map of boot memory. */
39void bootmem_dump_ranges(void);
40
41/* Return 1 if region targets usable RAM, 0 otherwise. */
42int bootmem_region_targets_usable_ram(uint64_t start, uint64_t size);
43
44/* Allocate a temporary buffer from the unused RAM areas. */
45void *bootmem_allocate_buffer(size_t size);
46
47#endif /* BOOTMEM_H */