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; }
EFIAPI get_first_hob( UINT16 type ) { VOID *hob_list; hob_list = get_hob_list(); return get_next_hob(type, hob_list); }
/* * Returns the next instance of the matching resource HOB from the starting HOB. */ void *get_next_resource_hob(const EFI_GUID *guid, const void *hob_start) { EFI_PEI_HOB_POINTERS hob; hob.Raw = (UINT8 *)hob_start; while ((hob.Raw = get_next_hob(EFI_HOB_TYPE_RESOURCE_DESCRIPTOR, hob.Raw)) != NULL) { if (compare_guid(guid, &hob.ResourceDescriptor->Owner)) break; hob.Raw = GET_NEXT_HOB(hob.Raw); } return hob.Raw; }
/* Returns the next instance of the matched GUID HOB from the starting HOB. */ void *get_next_guid_hob(const EFI_GUID * guid, const void *hob_start) { EFI_PEI_HOB_POINTERS hob; hob.Raw = (uint8_t *)hob_start; while ((hob.Raw = get_next_hob(EFI_HOB_TYPE_GUID_EXTENSION, hob.Raw)) != NULL) { if (compare_guid(guid, &hob.Guid->Name)) break; hob.Raw = GET_NEXT_HOB(hob.Raw); } return hob.Raw; }
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; }
EFIAPI get_next_guid_hob( CONST EFI_GUID * guid, CONST VOID *hob_start ) { EFI_PEI_HOB_POINTERS hob; hob.Raw = (UINT8 *)hob_start; while ((hob.Raw = get_next_hob(EFI_HOB_TYPE_GUID_EXTENSION, hob.Raw)) != NULL) { if (compare_guid(guid, &hob.Guid->Name)) break; hob.Raw = GET_NEXT_HOB(hob.Raw); } return hob.Raw; }
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; }
/* Returns the first instance of a HOB type among the whole HOB list. */ void *get_first_hob(uint16_t type) { return get_next_hob(type, get_hob_list()); }