efi: Add a function to obtain the memory type as a string
It is sometimes useful to display the memory type in logs, etc. Add a function to convert it to a string, which is more user-friendly than a number. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
@@ -745,6 +745,13 @@ static inline bool efi_mem_is_boot_services(int type)
|
||||
type == EFI_BOOT_SERVICES_DATA;
|
||||
}
|
||||
|
||||
/**
|
||||
* efi_mem_type_name() - Get the name of a memory type
|
||||
*
|
||||
* Return: Name, or "<invalid>" if the type is not known
|
||||
*/
|
||||
const char *efi_mem_type_name(enum efi_memory_type type);
|
||||
|
||||
/**
|
||||
* efi_dump_mem_table() - Dump out the EFI memory map
|
||||
*
|
||||
|
||||
@@ -58,6 +58,11 @@ static struct attr_info {
|
||||
{ EFI_MEMORY_RUNTIME, "needs runtime mapping" }
|
||||
};
|
||||
|
||||
const char *efi_mem_type_name(enum efi_memory_type type)
|
||||
{
|
||||
return type < ARRAY_SIZE(type_name) ? type_name[type] : "<invalid>";
|
||||
}
|
||||
|
||||
void efi_dump_mem_table(struct efi_mem_desc *desc, int size, int desc_size,
|
||||
bool skip_bs)
|
||||
{
|
||||
@@ -76,7 +81,6 @@ void efi_dump_mem_table(struct efi_mem_desc *desc, int size, int desc_size,
|
||||
addr = 0;
|
||||
for (upto = 0; desc < end;
|
||||
upto++, desc = efi_get_next_mem_desc(desc, desc_size)) {
|
||||
const char *name;
|
||||
u64 size;
|
||||
|
||||
if (skip_bs && efi_mem_is_boot_services(desc->type))
|
||||
@@ -87,11 +91,9 @@ void efi_dump_mem_table(struct efi_mem_desc *desc, int size, int desc_size,
|
||||
}
|
||||
size = desc->num_pages << EFI_PAGE_SHIFT;
|
||||
|
||||
name = desc->type < ARRAY_SIZE(type_name) ?
|
||||
type_name[desc->type] : "<invalid>";
|
||||
printf("%2d %x:%-12s %010llx %010llx %010llx ", upto,
|
||||
desc->type, name, desc->physical_start,
|
||||
desc->virtual_start, size);
|
||||
desc->type, efi_mem_type_name(desc->type),
|
||||
desc->physical_start, desc->virtual_start, size);
|
||||
if (desc->attribute & EFI_MEMORY_RUNTIME)
|
||||
putc('r');
|
||||
printf("%llx", desc->attribute & ~EFI_MEMORY_RUNTIME);
|
||||
|
||||
Reference in New Issue
Block a user