| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
#include <stddef.h> |
| 5 |
#include <stdint.h> |
| 6 |
#include <boot/coreboot_tables.h> |
| 7 |
#include <bootstate.h> |
| 8 |
#include <console/console.h> |
| 9 |
#include <cbmem.h> |
| 10 |
#include "chromeos.h" |
| 11 |
|
| 12 |
static void ramoops_alloc(void *arg) |
| 13 |
{ |
| 14 |
const size_t size = CONFIG_CHROMEOS_RAMOOPS_RAM_SIZE; |
| 15 |
void *ram_oops; |
| 16 |
|
| 17 |
if (size == 0) |
| 18 |
return; |
| 19 |
|
| 20 |
ram_oops = cbmem_add(CBMEM_ID_RAM_OOPS, size); |
| 21 |
if (ram_oops == NULL) { |
| 22 |
printk(BIOS_ERR, "Could not allocate RAMOOPS buffer\n"); |
| 23 |
return; |
| 24 |
} |
| 25 |
|
| 26 |
if (CONFIG(CHROMEOS_NVS)) |
| 27 |
chromeos_set_ramoops(ram_oops, size); |
| 28 |
} |
| 29 |
|
| 30 |
BOOT_STATE_INIT_ENTRY(BS_DEV_INIT_CHIPS, BS_ON_ENTRY, ramoops_alloc, NULL); |
| 31 |
|
| 32 |
void lb_ramoops(struct lb_header *header) |
| 33 |
{ |
| 34 |
void *buffer = cbmem_find(CBMEM_ID_RAM_OOPS); |
| 35 |
|
| 36 |
if (buffer == NULL) |
| 37 |
return; |
| 38 |
|
| 39 |
struct lb_range *ramoops; |
| 40 |
ramoops = (struct lb_range *)lb_new_record(header); |
| 41 |
ramoops->tag = LB_TAG_RAM_OOPS; |
| 42 |
ramoops->size = sizeof(*ramoops); |
| 43 |
ramoops->range_start = (uintptr_t)buffer; |
| 44 |
ramoops->range_size = CONFIG_CHROMEOS_RAMOOPS_RAM_SIZE; |
| 45 |
} |