X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=cmd%2Fefidebug.c;h=58018f700cd401a36e25d188f9722aa75e7c8535;hb=HEAD;hp=02ef019694433fdbad9bd28220fc74a6b24f34a3;hpb=525fc06744b0942dc95dbbf982a90badcfa8aa14;p=oweals%2Fu-boot.git diff --git a/cmd/efidebug.c b/cmd/efidebug.c index 02ef019694..58018f700c 100644 --- a/cmd/efidebug.c +++ b/cmd/efidebug.c @@ -11,13 +11,13 @@ #include #include #include +#include #include #include #include #include #define BS systab.boottime -#define RT systab.runtime /** * efi_get_device_handle_info() - get information of UEFI device @@ -61,15 +61,15 @@ static const char sep[] = "================"; * Implement efidebug "devices" sub-command. * Show all UEFI devices and their information. */ -static int do_efi_show_devices(cmd_tbl_t *cmdtp, int flag, - int argc, char * const argv[]) +static int do_efi_show_devices(struct cmd_tbl *cmdtp, int flag, + int argc, char *const argv[]) { efi_handle_t *handles; efi_uintn_t num, i; u16 *dev_path_text; efi_status_t ret; - ret = EFI_CALL(BS->locate_handle_buffer(ALL_HANDLES, NULL, NULL, + ret = EFI_CALL(efi_locate_handle_buffer(ALL_HANDLES, NULL, NULL, &num, &handles)); if (ret != EFI_SUCCESS) return CMD_RET_FAILURE; @@ -86,7 +86,7 @@ static int do_efi_show_devices(cmd_tbl_t *cmdtp, int flag, } } - EFI_CALL(BS->free_pool(handles)); + efi_free_pool(handles); return CMD_RET_SUCCESS; } @@ -140,15 +140,15 @@ static int efi_get_driver_handle_info(efi_handle_t handle, u16 **driver_name, * Implement efidebug "drivers" sub-command. * Show all UEFI drivers and their information. */ -static int do_efi_show_drivers(cmd_tbl_t *cmdtp, int flag, - int argc, char * const argv[]) +static int do_efi_show_drivers(struct cmd_tbl *cmdtp, int flag, + int argc, char *const argv[]) { efi_handle_t *handles; efi_uintn_t num, i; u16 *driver_name, *image_path_text; efi_status_t ret; - ret = EFI_CALL(BS->locate_handle_buffer( + ret = EFI_CALL(efi_locate_handle_buffer( BY_PROTOCOL, &efi_guid_driver_binding_protocol, NULL, &num, &handles)); if (ret != EFI_SUCCESS) @@ -170,12 +170,12 @@ static int do_efi_show_drivers(cmd_tbl_t *cmdtp, int flag, else printf("%p %-20ls \n", handles[i], driver_name); - EFI_CALL(BS->free_pool(driver_name)); - EFI_CALL(BS->free_pool(image_path_text)); + efi_free_pool(driver_name); + efi_free_pool(image_path_text); } } - EFI_CALL(BS->free_pool(handles)); + efi_free_pool(handles); return CMD_RET_SUCCESS; } @@ -312,8 +312,8 @@ static const char *get_guid_text(const void *guid) * Show all UEFI handles and their information, currently all protocols * added to handle. */ -static int do_efi_show_handles(cmd_tbl_t *cmdtp, int flag, - int argc, char * const argv[]) +static int do_efi_show_handles(struct cmd_tbl *cmdtp, int flag, + int argc, char *const argv[]) { efi_handle_t *handles; efi_guid_t **guid; @@ -321,7 +321,7 @@ static int do_efi_show_handles(cmd_tbl_t *cmdtp, int flag, const char *guid_text; efi_status_t ret; - ret = EFI_CALL(BS->locate_handle_buffer(ALL_HANDLES, NULL, NULL, + ret = EFI_CALL(efi_locate_handle_buffer(ALL_HANDLES, NULL, NULL, &num, &handles)); if (ret != EFI_SUCCESS) return CMD_RET_FAILURE; @@ -355,7 +355,7 @@ static int do_efi_show_handles(cmd_tbl_t *cmdtp, int flag, putc('\n'); } - EFI_CALL(BS->free_pool(handles)); + efi_free_pool(handles); return CMD_RET_SUCCESS; } @@ -372,8 +372,8 @@ static int do_efi_show_handles(cmd_tbl_t *cmdtp, int flag, * Implement efidebug "images" sub-command. * Show all UEFI loaded images and their information. */ -static int do_efi_show_images(cmd_tbl_t *cmdtp, int flag, - int argc, char * const argv[]) +static int do_efi_show_images(struct cmd_tbl *cmdtp, int flag, + int argc, char *const argv[]) { efi_print_image_infos(NULL); @@ -395,6 +395,7 @@ static const char * const efi_mem_type_string[] = { [EFI_MMAP_IO] = "IO", [EFI_MMAP_IO_PORT] = "IO PORT", [EFI_PAL_CODE] = "PAL", + [EFI_PERSISTENT_MEMORY_TYPE] = "PERSISTENT", }; static const struct efi_mem_attrs { @@ -413,6 +414,7 @@ static const struct efi_mem_attrs { {EFI_MEMORY_NV, "NV"}, {EFI_MEMORY_MORE_RELIABLE, "REL"}, {EFI_MEMORY_RO, "RO"}, + {EFI_MEMORY_SP, "SP"}, {EFI_MEMORY_RUNTIME, "RT"}, }; @@ -453,8 +455,8 @@ static void print_memory_attributes(u64 attributes) * Implement efidebug "memmap" sub-command. * Show UEFI memory map. */ -static int do_efi_show_memmap(cmd_tbl_t *cmdtp, int flag, - int argc, char * const argv[]) +static int do_efi_show_memmap(struct cmd_tbl *cmdtp, int flag, + int argc, char *const argv[]) { struct efi_mem_desc *memmap = NULL, *map; efi_uintn_t map_size = 0; @@ -462,18 +464,17 @@ static int do_efi_show_memmap(cmd_tbl_t *cmdtp, int flag, int i; efi_status_t ret; - ret = EFI_CALL(BS->get_memory_map(&map_size, memmap, NULL, NULL, NULL)); + ret = efi_get_memory_map(&map_size, memmap, NULL, NULL, NULL); if (ret == EFI_BUFFER_TOO_SMALL) { map_size += sizeof(struct efi_mem_desc); /* for my own */ - ret = EFI_CALL(BS->allocate_pool(EFI_LOADER_DATA, - map_size, (void *)&memmap)); + ret = efi_allocate_pool(EFI_LOADER_DATA, map_size, + (void *)&memmap); if (ret != EFI_SUCCESS) return CMD_RET_FAILURE; - ret = EFI_CALL(BS->get_memory_map(&map_size, memmap, - NULL, NULL, NULL)); + ret = efi_get_memory_map(&map_size, memmap, NULL, NULL, NULL); } if (ret != EFI_SUCCESS) { - EFI_CALL(BS->free_pool(memmap)); + efi_free_pool(memmap); return CMD_RET_FAILURE; } @@ -481,8 +482,13 @@ static int do_efi_show_memmap(cmd_tbl_t *cmdtp, int flag, EFI_PHYS_ADDR_WIDTH - 5, spc, EFI_PHYS_ADDR_WIDTH - 3, spc); printf("================ %.*s %.*s ==========\n", EFI_PHYS_ADDR_WIDTH, sep, EFI_PHYS_ADDR_WIDTH, sep); + /* + * Coverity check: dereferencing null pointer "map." + * This is a false positive as memmap will always be + * populated by allocate_pool() above. + */ for (i = 0, map = memmap; i < map_size / sizeof(*map); map++, i++) { - if (map->type < EFI_MAX_MEMORY_TYPE) + if (map->type < ARRAY_SIZE(efi_mem_type_string)) type = efi_mem_type_string[map->type]; else type = "(unknown)"; @@ -500,7 +506,7 @@ static int do_efi_show_memmap(cmd_tbl_t *cmdtp, int flag, putc('\n'); } - EFI_CALL(BS->free_pool(memmap)); + efi_free_pool(memmap); return CMD_RET_SUCCESS; } @@ -517,8 +523,8 @@ static int do_efi_show_memmap(cmd_tbl_t *cmdtp, int flag, * Implement efidebug "tables" sub-command. * Show UEFI configuration tables. */ -static int do_efi_show_tables(cmd_tbl_t *cmdtp, int flag, - int argc, char * const argv[]) +static int do_efi_show_tables(struct cmd_tbl *cmdtp, int flag, + int argc, char *const argv[]) { efi_uintn_t i; const char *guid_str; @@ -547,8 +553,8 @@ static int do_efi_show_tables(cmd_tbl_t *cmdtp, int flag, * * efidebug boot add