From patchwork Wed Aug 20 00:40:19 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 43 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1755650478; bh=88YdHabkxkMNhvtDfrGfXZMOUhQfYBJNIJyRUTHfWPE=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=IlrcaeBY3MG+1RFenG2lxxvtxOX4CFEuGpU2kSizNbAbySQ4DhlSMLeMVvVBChfg6 qeyxRxQVG+xVKMfLtGNT6b6WLzcyWcxP0YNok80aVwl7zvXDI3dDvdbCU7EXJI+QRm Z06qhsEg5t8wmBqaxGU98uZysSQZMPT9W7bdZi3XMgNSGEhi1sEseYtCZDJYM8sOF0 7GjmV3NQI1vDVkkF8R9bQI6h5v1hG+29zZ2G+crzdWypNJL7ajQHPj9SXxEzhWdACq HhkO+0y0dg4ERv+g1hz4n3DoSfdhvjOKlbrApJVbnHXz5KWZ+CtZIoqtOUQEYbyffq F2FUUkoshr4ew== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id B27306728E for ; Tue, 19 Aug 2025 18:41:18 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id yi6nH7XTh-6U for ; Tue, 19 Aug 2025 18:41:18 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1755650477; bh=88YdHabkxkMNhvtDfrGfXZMOUhQfYBJNIJyRUTHfWPE=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=Om+q09Ok6Aw4HoWaUNxnvprCAiOr3fYBnzc5C+PNQmlweYcGhMyQ7HNfdGEQo5muW /q+4roTgYyOID43y2bnPPWqNtn9xHpmSxjnb31xnpVlROo1hdl+YkobPHuOX9zAoR2 G39XMom8IycumMyaydN8i8rN8l85JCWr4Xvln7MdHI6DIv59877DbPOyUVdT7acHFY tVhESmEw6lm4xUbF7jd5sFOYytAITD8EhFIG2y/uF3VTpFzDvyMequysFdeRK3uPd2 JJtjXWfHt+AoKq9cNudg73evwem0393D5B86EC9UmhLuJ90yvtb5BiywXBxZzgzSFy 0u4Q5oVpMaT5Q== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id A1CFF675F5 for ; Tue, 19 Aug 2025 18:41:17 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1755650476; bh=I+dJsMOLbMtTIaf07XdJW7G+z2KzHHvci6fgjcKbjoE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KBBiJN+g+w17jWeZcOM1A/FUNJT8iWUgC55X5ZRZDmcFlKlhSedFV7Reb8MmDZEdk DzRc/MudbjgglmGW2SWd/SIBhGCum3RbaW8TLs7RYpqZLBPb8ckvi7wT2MPR3AyGDe IwuGlOapi78EXo1EKkCktbEw3JXFqz06iBmAgPIevmNRJoJ5bx2C5/8EKvBFilrKpM t1MU0HaKNW0uapG9b6SPmND7enc5bDcE+xs31J1zMlPK3QzPjXC6mIILN6FRxLoJ/N SYbHqeM8iulXxV/qrE2uuqmAJ33LQre7E/dYuFIoLMzX0i4QWHspS1GZCLeS1OvZgj nWFNGyBaqf5UA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 0BC2E6728E; Tue, 19 Aug 2025 18:41:16 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id Su0gPPGrW_cQ; Tue, 19 Aug 2025 18:41:15 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1755650474; bh=DgbKl0MALjB66321wQWLxQr8ayIAUMlRRVt5QG6Qbm8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cDC0oA9HwBpcV/2CzmfnnukZ6vpn07zcTLZO0T2SqMqc/apCNqjbXPGU5PbY8KSfU T1yaDXjiXL2WZNbqoyOT+CobkLYs03zuVYXqMlOHa26u4DwSCxGHPDkj/6p8MSjMWB kmFd9AiMuyjINoZB+x5ndM0Clk1Ga30b5vkaMNjwN0+DLXwuAiO9Jh2j/8858WhWa8 jefemxQZ4ZtfYZJhS3IlXVTsDcHY3klZ7OhW3l3ua9Wdq41noERA2p6ig0iJvgQ6e1 g5rTX1MZHzSx9AmiKHgSGdGDGZxPXXsCmdUNscsdAXKKb3L0xT3ZHLT3W9zywJQG9Z W9OqfQKIZefNw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 592F0675C0; Tue, 19 Aug 2025 18:41:14 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Tue, 19 Aug 2025 18:40:19 -0600 Message-ID: <20250820004039.3920254-6-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250820004039.3920254-1-sjg@u-boot.org> References: <20250820004039.3920254-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 3K74ZM2VUO7MPNYBBN7VBFW5HYWIXMMB X-Message-ID-Hash: 3K74ZM2VUO7MPNYBBN7VBFW5HYWIXMMB X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 05/18] efi: app: Support efidebug memmap List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass It is helpful to see the memory map in some cases, so enable this subcommand in the app. Unfortunately we cannot assume that desc_size is the same in the underlying EFI implementation, so use a variable for that. Signed-off-by: Simon Glass --- cmd/efidebug.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/cmd/efidebug.c b/cmd/efidebug.c index 2e156fef525..d93fa43b779 100644 --- a/cmd/efidebug.c +++ b/cmd/efidebug.c @@ -659,15 +659,24 @@ static int do_efi_show_memmap(struct cmd_tbl *cmdtp, int flag, struct efi_mem_desc *memmap, *map; efi_uintn_t map_size; const char *type; - int i; - efi_status_t ret; + int desc_size, i; + efi_status_t eret; + int ret; - if (app_not_supported("memmap")) - return CMD_RET_FAILURE; + if (IS_ENABLED(CONFIG_EFI_APP)) { + uint key, version; + int size; - ret = efi_get_memory_map_alloc(&map_size, &memmap); - if (ret != EFI_SUCCESS) - return CMD_RET_FAILURE; + ret = efi_get_mmap(&memmap, &size, &key, &desc_size, &version); + if (ret) + return CMD_RET_FAILURE; + map_size = size; + } else { + eret = efi_get_memory_map_alloc(&map_size, &memmap); + if (eret) + return CMD_RET_FAILURE; + desc_size = sizeof(*map); + } printf("Type Start%.*s End%.*s Attributes\n", EFI_PHYS_ADDR_WIDTH - 5, spc, EFI_PHYS_ADDR_WIDTH - 3, spc); @@ -678,7 +687,8 @@ static int do_efi_show_memmap(struct cmd_tbl *cmdtp, int flag, * 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++) { + for (i = 0, map = memmap; i < map_size / desc_size; + map = (void *)map + desc_size, i++) { if (map->type < ARRAY_SIZE(efi_mem_type_string)) type = efi_mem_type_string[map->type]; else