feat(hob): add boot-time prints for cactus-stmm HOB list
At boot time, print HOB headers and contents.
Signed-off-by: Kathleen Capella <kathleen.capella@arm.com>
Change-Id: Ic634f045cacdbc8e318836eba85982a93f55fc0f
diff --git a/include/lib/hob/hob.h b/include/lib/hob/hob.h
index 5c217e3..4e96cbb 100644
--- a/include/lib/hob/hob.h
+++ b/include/lib/hob/hob.h
@@ -95,6 +95,7 @@
* Interfaces. *
*****************************************************************************/
-void tftf_dump_hob_generic_header(struct efi_hob_generic_header h);
+void dump_hob_list(struct efi_hob_handoff_info_table *hob_list);
+void dump_hob_generic_header(struct efi_hob_generic_header *header);
#endif /* HOB_H */
diff --git a/include/lib/hob/hob_guid.h b/include/lib/hob/hob_guid.h
index 65d3dbf..507b2e9 100644
--- a/include/lib/hob/hob_guid.h
+++ b/include/lib/hob/hob_guid.h
@@ -7,6 +7,7 @@
#ifndef HOB_GUID_H
#define HOB_GUID_H
+#include <stdint.h>
#include <lib/hob/efi_types.h>
/**
@@ -23,9 +24,9 @@
0xf00497e3, 0xbfa2, 0x41a1, {0x9d, 0x29, 0x54, 0xc2, 0xe9, 0x37, 0x21, 0xc5 } \
}
-#define MM_MP_INFORMATION_GUID \
-{ \
- 0xba33f15d, 0x4000, 0x45c1, {0x8e, 0x88, 0xf9, 0x16, 0x92, 0xd4, 0x57, 0xe3} \
-}
+struct mm_comm_buffer_desc {
+ efi_physical_address_t physical_start;
+ uint64_t number_of_pages;
+};
#endif /* HOB_GUID_H */
diff --git a/lib/hob/hob.c b/lib/hob/hob.c
index ce35e2f..4fa3cf3 100644
--- a/lib/hob/hob.c
+++ b/lib/hob/hob.c
@@ -4,17 +4,139 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
+#include <assert.h>
#include <stddef.h>
+#include <stdint.h>
#include <stdio.h>
+#include <debug.h>
#include <lib/hob/hob.h>
#include <lib/hob/hob_guid.h>
#include <lib/hob/mmram.h>
+#include <lib/utils/uuid_utils.h>
#include <lib/utils_def.h>
#define ALIGN_UP(x, a) ((x + (a - 1)) & ~(a - 1))
-void tftf_dump_hob_generic_header(struct efi_hob_generic_header h)
+void dump_hob_generic_header(struct efi_hob_generic_header *h)
{
- printf("Hob Type: 0x%x\n", h.hob_type);
- printf("Hob Length: 0x%x\n", h.hob_length);
+ assert(h != NULL);
+ INFO("Hob Type: 0x%x\n", h->hob_type);
+ INFO("Hob Length: 0x%x\n", h->hob_length);
+}
+
+void dump_efi_mmram_descriptor(struct efi_mmram_descriptor *m)
+{
+ INFO(" Physical start: 0x%llx\n", m->physical_start);
+ INFO(" CPU start: 0x%llx\n", m->cpu_start);
+ INFO(" Physical size: 0x%llx\n", m->physical_size);
+ INFO(" Region state: 0x%llx\n", m->region_state);
+}
+
+void dump_efi_hob_firmware_volume(struct efi_hob_firmware_volume *fv)
+{
+ dump_hob_generic_header(&fv->header);
+ INFO(" Base_address: 0x%llx\n", fv->base_address);
+ INFO(" Length: 0x%llx\n", fv->length);
+}
+
+static void dump_efi_guid(struct efi_guid guid)
+{
+ INFO(" Time low: 0x%x\n", guid.time_low);
+ INFO(" Time mid: 0x%x\n", guid.time_mid);
+ INFO(" Time hi and version: 0x%x\n", guid.time_hi_and_version);
+ INFO(" Clock_seq_and_node: [0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x]\n",
+ guid.clock_seq_and_node[0],
+ guid.clock_seq_and_node[1],
+ guid.clock_seq_and_node[2],
+ guid.clock_seq_and_node[3],
+ guid.clock_seq_and_node[4],
+ guid.clock_seq_and_node[5],
+ guid.clock_seq_and_node[6],
+ guid.clock_seq_and_node[7]);
+}
+
+static void dump_guid_hob_data(struct efi_hob_guid_type *guid_hob)
+{
+ union uuid_helper_t uuid_name = {.efi_guid = guid_hob->name};
+ union uuid_helper_t mmram_mem_resv_guid = {
+ .efi_guid = (struct efi_guid)MM_PEI_MMRAM_MEMORY_RESERVE_GUID};
+ union uuid_helper_t ns_buffer_guid = {
+ .efi_guid = (struct efi_guid)MM_NS_BUFFER_GUID};
+ uintptr_t guid_data = (uintptr_t)(&guid_hob->name + 1);
+
+ /* Dump GUID HOB data according to GUID type. */
+ if (uuid_equal(&uuid_name.uuid_struct,
+ &mmram_mem_resv_guid.uuid_struct)) {
+ struct efi_mmram_hob_descriptor_block *mmram_desc_block =
+ (struct efi_mmram_hob_descriptor_block *)guid_data;
+ INFO(" MM_PEI_MMRAM_MEMORY_RESERVE_GUID with %u regions\n",
+ mmram_desc_block->number_of_mm_reserved_regions);
+ for (uint32_t i = 0;
+ i < mmram_desc_block->number_of_mm_reserved_regions; i++) {
+ INFO(" MMRAM_DESC[%u]:\n", i);
+ dump_efi_mmram_descriptor(
+ &mmram_desc_block->descriptor[i]);
+ }
+ } else if (uuid_equal(&uuid_name.uuid_struct,
+ &ns_buffer_guid.uuid_struct)) {
+ INFO(" MM_NS_BUFFER_GUID\n");
+ dump_efi_mmram_descriptor(
+ (struct efi_mmram_descriptor *)guid_data);
+ }
+}
+
+static void dump_guid_hob(struct efi_hob_guid_type *guid_hob)
+{
+ dump_hob_generic_header(&guid_hob->header);
+ dump_efi_guid(guid_hob->name);
+ dump_guid_hob_data(guid_hob);
+}
+
+void dump_hob_list(struct efi_hob_handoff_info_table *hob_list)
+{
+ uintptr_t next_hob_addr;
+ struct efi_hob_generic_header *next;
+
+ assert(hob_list != NULL);
+ dump_hob_generic_header(&hob_list->header);
+ INFO(" Version: %u\n", hob_list->version);
+ INFO(" Boot Mode: %u\n", hob_list->boot_mode);
+ INFO(" EFI Memory Top: 0x%llx\n", hob_list->efi_memory_top);
+ INFO(" EFI Memory Bottom: 0x%llx\n", hob_list->efi_memory_bottom);
+ INFO(" EFI Free Memory Top: 0x%llx\n", hob_list->efi_free_memory_top);
+ INFO(" EFI Free Memory Bottom: 0x%llx\n", hob_list->efi_free_memory_bottom);
+ INFO(" EFI End of Hob List: 0x%llx\n", hob_list->efi_end_of_hob_list);
+
+ next_hob_addr = (uintptr_t)(hob_list) + (uintptr_t)hob_list->header.hob_length;
+ assert(next_hob_addr < (uintptr_t)hob_list->efi_end_of_hob_list);
+ next = (struct efi_hob_generic_header *)next_hob_addr;
+
+ while (next != NULL) {
+ assert(next->hob_type != 0x0);
+ switch (next->hob_type) {
+ case EFI_HOB_TYPE_GUID_EXTENSION:
+ dump_guid_hob((struct efi_hob_guid_type *)next);
+ break;
+ case EFI_HOB_TYPE_FV:
+ dump_efi_hob_firmware_volume((struct
+ efi_hob_firmware_volume *)next);
+ break;
+ default:
+ dump_hob_generic_header(next);
+ }
+
+ if (next->hob_type == EFI_HOB_TYPE_END_OF_HOB_LIST) {
+ break;
+ }
+
+ next_hob_addr = (uintptr_t)(next) + (uintptr_t)next->hob_length;
+
+ if (next_hob_addr >= (uintptr_t) hob_list->efi_end_of_hob_list) {
+ next = NULL;
+ } else {
+ assert(next_hob_addr < (uintptr_t)hob_list->efi_end_of_hob_list);
+ next = (struct efi_hob_generic_header *)next_hob_addr;
+ }
+ }
+
}
diff --git a/spm/cactus/cactus.mk b/spm/cactus/cactus.mk
index b50975c..7d39221 100644
--- a/spm/cactus/cactus.mk
+++ b/spm/cactus/cactus.mk
@@ -23,6 +23,7 @@
-Iinclude/common/${ARCH} \
-Iinclude/lib \
-Iinclude/lib/extensions \
+ -Iinclude/lib/hob \
-Iinclude/lib/${ARCH} \
-Iinclude/lib/utils \
-Iinclude/lib/xlat_tables \
@@ -74,6 +75,8 @@
drivers/arm/sp805/sp805.c \
lib/${ARCH}/cache_helpers.S \
lib/${ARCH}/misc_helpers.S \
+ lib/hob/hob.c \
+ lib/utils/uuid.c \
lib/smc/${ARCH}/asm_smc.S \
lib/smc/${ARCH}/smc.c \
lib/smc/${ARCH}/hvc.c \
diff --git a/spm/cactus/cactus_main.c b/spm/cactus/cactus_main.c
index 75b2fb0..0f54ef9 100644
--- a/spm/cactus/cactus_main.c
+++ b/spm/cactus/cactus_main.c
@@ -12,6 +12,7 @@
#include <drivers/arm/pl011.h>
#include <drivers/console.h>
#include <lib/aarch64/arch_helpers.h>
+#include <lib/hob/hob.h>
#include <lib/tftf_lib.h>
#include <lib/xlat_tables/xlat_mmu_helpers.h>
#include <lib/xlat_tables/xlat_tables_v2.h>
@@ -155,6 +156,15 @@
(void *)get_sp_tx_end(vm_id));
}
+static void cactus_print_hob_list(uint64_t hob_content_addr, size_t size)
+{
+ INFO("SP Hob List Contents: 0x%llx, size 0x%lx\n", hob_content_addr, size);
+ struct efi_hob_handoff_info_table *hob_list = (struct
+ efi_hob_handoff_info_table *) hob_content_addr;
+
+ dump_hob_list(hob_list);
+}
+
static void cactus_print_boot_info(struct ffa_boot_info_header *boot_info_header)
{
struct ffa_boot_info_desc *boot_info_desc;
@@ -191,6 +201,9 @@
ffa_boot_info_content_format(&boot_info_desc[i]));
VERBOSE(" Size: %u\n", boot_info_desc[i].size);
VERBOSE(" Value: %llx\n", boot_info_desc[i].content);
+ if (ffa_boot_info_type_id(&boot_info_desc[i]) == 1) {
+ cactus_print_hob_list(boot_info_desc[i].content, boot_info_desc[i].size);
+ }
}
}