int dram_init(void) { phys_size_t ram_size = 0; const struct hob_header *hdr; struct hob_res_desc *res_desc; hdr = gd->arch.hob_list; while (!end_of_hob(hdr)) { if (hdr->type == HOB_TYPE_RES_DESC) { res_desc = (struct hob_res_desc *)hdr; if (res_desc->type == RES_SYS_MEM || res_desc->type == RES_MEM_RESERVED) { ram_size += res_desc->len; } } hdr = get_next_hob(hdr); } gd->ram_size = ram_size; post_code(POST_DRAM); #ifdef CONFIG_ENABLE_MRC_CACHE gd->arch.mrc_output = fsp_get_nvs_data(gd->arch.hob_list, &gd->arch.mrc_output_len); #endif return 0; }
static int do_hob(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { const struct hob_header *hdr; uint type; char *desc; int i = 0; hdr = gd->arch.hob_list; printf("HOB list address: 0x%08x\n\n", (unsigned int)hdr); printf("# | Address | Type | Len | "); printf("%42s\n", "GUID"); printf("---|----------|-----------|------|-"); printf("------------------------------------------\n"); while (!end_of_hob(hdr)) { printf("%02x | %08x | ", i, (unsigned int)hdr); type = hdr->type; if (type == HOB_TYPE_UNUSED) desc = "*Unused*"; else if (type == HOB_TYPE_EOH) desc = "*EOH*"; else if (type >= 0 && type <= ARRAY_SIZE(hob_type)) desc = hob_type[type]; else desc = "*Invalid*"; printf("%-9s | %04x | ", desc, hdr->len); if (type == HOB_TYPE_MEM_ALLOC || type == HOB_TYPE_RES_DESC || type == HOB_TYPE_GUID_EXT) { struct efi_guid *guid = (struct efi_guid *)(hdr + 1); int j; printf("%08x-%04x-%04x", guid->data1, guid->data2, guid->data3); for (j = 0; j < ARRAY_SIZE(guid->data4); j++) printf("-%02x", guid->data4[j]); } else { printf("%42s", "Not Available"); } printf("\n"); hdr = get_next_hob(hdr); i++; } return 0; }
unsigned int install_e820_map(unsigned int max_entries, struct e820_entry *entries) { unsigned int num_entries = 0; const struct hob_header *hdr; struct hob_res_desc *res_desc; hdr = gd->arch.hob_list; while (!end_of_hob(hdr)) { if (hdr->type == HOB_TYPE_RES_DESC) { res_desc = (struct hob_res_desc *)hdr; entries[num_entries].addr = res_desc->phys_start; entries[num_entries].size = res_desc->len; if (res_desc->type == RES_SYS_MEM) entries[num_entries].type = E820_RAM; else if (res_desc->type == RES_MEM_RESERVED) entries[num_entries].type = E820_RESERVED; num_entries++; } hdr = get_next_hob(hdr); } /* Mark PCIe ECAM address range as reserved */ entries[num_entries].addr = CONFIG_PCIE_ECAM_BASE; entries[num_entries].size = CONFIG_PCIE_ECAM_SIZE; entries[num_entries].type = E820_RESERVED; num_entries++; #ifdef CONFIG_HAVE_ACPI_RESUME /* * Everything between U-Boot's stack and ram top needs to be * reserved in order for ACPI S3 resume to work. */ entries[num_entries].addr = gd->start_addr_sp - CONFIG_STACK_SIZE; entries[num_entries].size = gd->ram_top - gd->start_addr_sp + \ CONFIG_STACK_SIZE; entries[num_entries].type = E820_RESERVED; num_entries++; #endif return num_entries; }