1 // SPDX-License-Identifier: GPL-2.0+ 2 /* 3 * Support for booting from coreboot 4 * 5 * Copyright 2021 Google LLC 6 */ 7 8 #include <common.h> 9 #include <asm/cb_sysinfo.h> 10 #include <asm/e820.h> 11 cb_install_e820_map(unsigned int max_entries,struct e820_entry * entries)12unsigned int cb_install_e820_map(unsigned int max_entries, 13 struct e820_entry *entries) 14 { 15 unsigned int num_entries; 16 int i; 17 18 num_entries = min((unsigned int)lib_sysinfo.n_memranges, max_entries); 19 if (num_entries < lib_sysinfo.n_memranges) { 20 printf("Warning: Limiting e820 map to %d entries\n", 21 num_entries); 22 } 23 for (i = 0; i < num_entries; i++) { 24 struct memrange *memrange = &lib_sysinfo.memrange[i]; 25 26 entries[i].addr = memrange->base; 27 entries[i].size = memrange->size; 28 29 /* 30 * coreboot has some extensions (type 6 & 16) to the E820 types. 31 * When we detect this, mark it as E820_RESERVED. 32 */ 33 if (memrange->type == CB_MEM_VENDOR_RSVD || 34 memrange->type == CB_MEM_TABLE) 35 entries[i].type = E820_RESERVED; 36 else 37 entries[i].type = memrange->type; 38 } 39 40 return num_entries; 41 } 42