From patchwork Wed Apr 23 21:31:42 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Ying-Chun Liu \(PaulLiu\)" X-Patchwork-Id: 883603 Delivered-To: patch@linaro.org Received: by 2002:a5d:474d:0:b0:38f:210b:807b with SMTP id o13csp3133994wrs; Wed, 23 Apr 2025 14:32:21 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWbuXwP4vrT8b63s7PRRmfwn5YjnolUe+uFej3ROEcDKanI805m1IzBgV7qeWX/RTJzZQutvA==@linaro.org X-Google-Smtp-Source: AGHT+IE6XTxCsQ+6W0MW5/oH/dlrDzwlH0lMybU/nfW9ot8xwhZIaNSRYzkPAx0I/1TvchsRg+cu X-Received: by 2002:a05:6000:2482:b0:39c:1f04:a646 with SMTP id ffacd0b85a97d-3a06cf53254mr54630f8f.13.1745443940978; Wed, 23 Apr 2025 14:32:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1745443940; cv=none; d=google.com; s=arc-20240605; b=b1fiudtPYOgyBIUO0sRJ8F6kmAbXJlgRMZpSxYjQIEMnTXMY8IHtZ/7wx0gO1XjPil UOSQEOBzS3at2GvOQ3H724a7B8EJrpSLkmvN5doDns/GHq32xitTSQHEyXGzXThaFoSB Q/qD3d56Ef0zgKH7lwOTaTags3LU1TKNpdX4CFm/QHP3B4pfhQ8+pxeKnGTZ6TnD9vop +T8+dJfU11489JDFy9gootXWNiAh22uR2XImZJ/9W/W7mh5R2qQb9FvNh5McbBrZM9v/ pr8I4/Z5sjbAsHjd4cbFUdwZNvCTAY8ISxyDyn8d97h9fZZCi8zDsuTd135fsY7oVYDv fkqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=naahOQfCQ9QFZUhdV0xqfJzvf7fY56aK2l8A56ypjVc=; fh=yXVQQdlQRM26TTYMoA2yrv//F921MlR4o2VBZ4jl39k=; b=eOzq5XKOQ2ZgipGZjbc5SKzEdwR0Bp/EU7pNDNouyJphPZy6L4grjKIGwm2IEy2mEH XslcxNxWlQsxnyuLkVY59jCTJZPTC3fqnhPVM478fZt928GV0CU/ycjeQRGz0r6IrztK 1T096kUnlr3NvXnFhoubg95MFWScCjv/eufbdCK0QJPhRVcq7WUlMFGCL9VrLIYdON6N 20RKO/6c9LQf5BaCP73ng9P1XNqqY8/RFjW2kVg3ejR0HeTnx+XeX8Y/AP9e+SIEek+C OzBH9JJiK30oNnLVNd5j9fU/A3co5MthxN19vwcmgyy8kZTSk+9BaEmFtA4GGO2/0CZP /gdg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20230601 header.b=KXT6l8+V; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dara=fail header.i=@linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id 5b1f17b1804b1-4409b95e41dsi1411615e9.57.2025.04.23.14.32.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Apr 2025 14:32:20 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20230601 header.b=KXT6l8+V; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dara=fail header.i=@linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id CF6DE81B4B; Wed, 23 Apr 2025 23:32:14 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=debian.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="KXT6l8+V"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id BBECD8059D; Wed, 23 Apr 2025 23:32:13 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 5EC568059A for ; Wed, 23 Apr 2025 23:32:11 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=debian.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=grandpaul@gmail.com Received: by mail-pj1-x102e.google.com with SMTP id 98e67ed59e1d1-301302a328bso422474a91.2 for ; Wed, 23 Apr 2025 14:32:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1745443929; x=1746048729; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=naahOQfCQ9QFZUhdV0xqfJzvf7fY56aK2l8A56ypjVc=; b=KXT6l8+V1PCmuM+ALwD/01tWZhYHjEzEJIapvi5FPwdVGQ2B9CqMtIDZzRwNtgpUPL roYCCgNtd9c0KOAHEUfs4VBospM6U7BYboBOkt++I/PeA8y5Apqe3VfSnzF8pSpMNJA1 SwrnwsRxmaHDfI8CNvLYwNf3dZEyVyhCsZQvOi4KO2kmch0HvTDdR8OFH025F19DuqBM yrSaxAFwevPHUJigTG0IY+WbbNH7EuPhpAA7sk7sLkQMeyv4fjLHorQdISmiz3UwKFc6 yfhGfgkAviEpJeyckeRSCMWXwM+iwZvjkXLVzyVTcYcNiruEDnAbaEYLTNtXIBWkm/M9 8foQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745443929; x=1746048729; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=naahOQfCQ9QFZUhdV0xqfJzvf7fY56aK2l8A56ypjVc=; b=dJH7eU8JIqbJWyZ3iPIrppcae9APAO+Q7d6npWgr6A4qV9xGZmwHNHe1K3xjpeatI0 dHufDHWYJWDWZrXjqx1Sb20oKrTVGtBLNuBOi4m/i7aWchtHviN9doyr/hPyDp8r+PkD cKclpWUFFR+zK/uptbij+IgMFPkcnvDCiQvEyKf6QNmR3zzUmYq6palYqKvKlDczMz4t NW59//ecEUNQnia+O6rCxyx/xOmgTwBXunU+ZuKpAb13T1e5MOQJfY5eAWb9YCLHpgVf FxJHnga4XsfOpM8kHHHvEpVl2IHUZAi1BPbHxDka3NqrULRrTGh+0dk5wwLoOxDrtwgL i2+Q== X-Gm-Message-State: AOJu0YwNeZoDnLXAYmWvuMzPtuluXYhSPySHFeIqq12xg5DAexnVQWDh +YXKTtKNcfwR+nd4OwOY73tEBXPDFoBfkVh4s2k7ZCXWzEm38hCOlJeUGA== X-Gm-Gg: ASbGncvfn9K8mSeJBvGn0YxZes5EMCze5Fe+ZEnCoudk3NqocKQgkoZCNa7k5y3JQM0 ykYdgth+q2iGhdBTZrCl8ennIVoEM7UdqunCGMR/7Atn6RzEs+DVbivEKLgGmABlh5Lu9PGk0ax MdYTaGjdP0vMUj1nTddqL8HY95FBfdkNy54NcOXgaev/y3OrH81/wxRnNonm5lAPAEsvCc8QGAv Rtgjd/NPcTrQMijM+5jGFkqTZ4G5JhkTKPK1SlfdarsC27tiMpZU9cnfoIs7O4S0s9GucVLzRGN gkEvFCSrPRumovi1yoDgO4ro869wdLVsRAwL X-Received: by 2002:a17:90b:45:b0:2ff:5016:7fd2 with SMTP id 98e67ed59e1d1-309ed35b230mr441030a91.24.1745443929218; Wed, 23 Apr 2025 14:32:09 -0700 (PDT) Received: from localhost ([61.71.79.124]) by smtp.gmail.com with UTF8SMTPSA id 98e67ed59e1d1-309df922267sm2182182a91.0.2025.04.23.14.32.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Apr 2025 14:32:08 -0700 (PDT) From: "Ying-Chun Liu (PaulLiu)" To: u-boot@lists.denx.de Cc: "Ying-Chun Liu (PaulLiu)" , Heinrich Schuchardt , Ilias Apalodimas Subject: [PATCH 1/3] efi: add EFI_SYSTEM_TABLE_POINTER for debug Date: Thu, 24 Apr 2025 05:31:42 +0800 Message-ID: <20250423213145.1959046-2-paulliu@debian.org> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250423213145.1959046-1-paulliu@debian.org> References: <20250423213145.1959046-1-paulliu@debian.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean From: "Ying-Chun Liu (PaulLiu)" Add EFI_SYSTEM_TABLE_POINTER structure for debugger to locate the address of EFI_SYSTEM_TABLE. This feature is described in UEFI SPEC version 2.10. Section 18.4.2. Signed-off-by: Ying-Chun Liu (PaulLiu) Cc: Heinrich Schuchardt Cc: Ilias Apalodimas --- include/efi_api.h | 6 +++++ include/efi_loader.h | 2 ++ lib/efi_loader/efi_boottime.c | 44 +++++++++++++++++++++++++++++++++++ lib/efi_loader/efi_setup.c | 7 ++++++ 4 files changed, 59 insertions(+) diff --git a/include/efi_api.h b/include/efi_api.h index eb61eafa028..5017d9037cd 100644 --- a/include/efi_api.h +++ b/include/efi_api.h @@ -259,6 +259,12 @@ struct efi_capsule_result_variable_header { efi_status_t capsule_status; } __packed; +struct efi_system_table_pointer { + u64 signature; + efi_physical_addr_t efi_system_table_base; + u32 crc32; +}; + struct efi_memory_range { efi_physical_addr_t address; u64 length; diff --git a/include/efi_loader.h b/include/efi_loader.h index 1d75d97ebbc..370bc042f70 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -615,6 +615,8 @@ efi_status_t efi_tcg2_measure_dtb(void *dtb); efi_status_t efi_root_node_register(void); /* Called by bootefi to initialize runtime */ efi_status_t efi_initialize_system_table(void); +/* Called by bootefi to initialize debug */ +efi_status_t efi_initialize_system_table_pointer(void); /* efi_runtime_detach() - detach unimplemented runtime functions */ void efi_runtime_detach(void); /* efi_convert_pointer() - convert pointer to virtual address */ diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index 5164cb15986..366bc0d2b1d 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -4001,6 +4001,8 @@ struct efi_system_table __efi_runtime_data systab = { .tables = NULL, }; +struct efi_system_table_pointer __efi_runtime_data * systab_pointer = NULL; + /** * efi_initialize_system_table() - Initialize system table * @@ -4035,3 +4037,45 @@ efi_status_t efi_initialize_system_table(void) return ret; } + +/** + * efi_initialize_system_table() - Initialize system table + * + * Return: status code + */ +efi_status_t efi_initialize_system_table_pointer(void) +{ + efi_status_t ret; + const int size_4MB = 0x00400000; + int pages = efi_size_in_pages(sizeof(struct efi_system_table_pointer)); + int alignment_mask = size_4MB - 1; + int real_pages = pages + efi_size_in_pages(size_4MB); + u64 addr; + u64 aligned_addr; + u32 crc32_value; + + /* Allocate configuration table array */ + ret = efi_allocate_pages(EFI_ALLOCATE_ANY_PAGES, + EFI_RUNTIME_SERVICES_DATA, + real_pages, + &addr); + + /* alignment to 4MB boundary */ + aligned_addr = (addr + alignment_mask) & ~alignment_mask; + + systab_pointer = (struct efi_system_table_pointer *)aligned_addr; + memset(systab_pointer, 0, sizeof(struct efi_system_table_pointer)); + + /* + * These entries will be set to NULL in ExitBootServices(). To avoid + * relocation in SetVirtualAddressMap(), set them dynamically. + */ + systab_pointer->signature = EFI_SYSTEM_TABLE_SIGNATURE; + systab_pointer->efi_system_table_base = (efi_physical_addr_t)&systab; + systab_pointer->crc32 = 0; + crc32_value = crc32(0, + (const unsigned char *)systab_pointer, + sizeof(struct efi_system_table_pointer)); + systab_pointer->crc32 = crc32_value; + return ret; +} diff --git a/lib/efi_loader/efi_setup.c b/lib/efi_loader/efi_setup.c index aa59bc7779d..073a08b1127 100644 --- a/lib/efi_loader/efi_setup.c +++ b/lib/efi_loader/efi_setup.c @@ -259,6 +259,13 @@ efi_status_t efi_init_obj_list(void) if (ret != EFI_SUCCESS) goto out; + /* Initialize system table */ + ret = efi_initialize_system_table_pointer(); + if (ret != EFI_SUCCESS) { + printf("EFI init system table pointer fail\n"); + goto out; + } + if (IS_ENABLED(CONFIG_EFI_ECPT)) { ret = efi_ecpt_register(); if (ret != EFI_SUCCESS) From patchwork Wed Apr 23 21:31:43 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Ying-Chun Liu \(PaulLiu\)" X-Patchwork-Id: 883604 Delivered-To: patch@linaro.org Received: by 2002:a5d:474d:0:b0:38f:210b:807b with SMTP id o13csp3134024wrs; Wed, 23 Apr 2025 14:32:27 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUVs0RexVLd+z+B3q1Gz0D3joe5VcheVpiAzyEhnaGlSRg+JHeD/UUj0BCuDKwpfcN5Llcmcg==@linaro.org X-Google-Smtp-Source: AGHT+IEaBKEhumZOKGsQV5+Pn1AnGasTsS/PmEcvjsU6IvnJXYtGRMg97mwKl8TdsepLoqwSdLvi X-Received: by 2002:a05:6000:178d:b0:39c:1257:dbab with SMTP id ffacd0b85a97d-3a06cfdb238mr32966f8f.59.1745443946833; Wed, 23 Apr 2025 14:32:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1745443946; cv=none; d=google.com; s=arc-20240605; b=kxA8h/K3Dl5haN5nUBbdehN0gA6utyulUtafv+IhaWv0TzIrwIfDl063ZfFSw6wOyP B0mqc/mhp0qcoQTcW1kjnsdRy/DF8YiP516yEAAdyN1RnOzqzvu/geD2GZUv0uS+As4H W9ZXVKRBWe5RANuWWZjRXsZpx110ca3JTsBpiyvjvN/tSDQTKSzRkDSxjXKa8AEHHKuo eZPA+JbOBoNxJExFLGDRO3uzB04m+BHlkFV1BbPpjyr4nIgrT9fRIQivfsgJsyZrWar0 j3bEj3vDlee3pe+jaxYIIaULikclK1TQrss0+phb7ekVOLuzwcatbtGrOY8Tig4khg8f W0nA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=jSX/9sQGbKqDWDDqeHEWYA9ns/DUT3sg+GNNs1iBoWM=; fh=yXVQQdlQRM26TTYMoA2yrv//F921MlR4o2VBZ4jl39k=; b=GgXREXx7BRlzcZu4+OhG5osEzo7WXlDuh8anEUbLvjz2T56h8AvlCRb07LtePnBBeC VtQXdtJho5gE3+CAWSrJn5eyZr+Y4tRJ6WUrBNLoT3c3bn3Ccfb8b9KewNFPNg6IBBi4 L7oPzm8bbcGAdP4l8WOO6u5tQ9VliSQna7i9RMaWAgP1cuVQpWMJ50J4vwg5fsSPKU5B OxWt0F+VyEYDULrGN36WWBPjwKOd5XRW6DJ8YVmSxbhoxWbI2T5vRceSznjSDUiZCREH nEU0lei6nwtM73eVs9H0yQUpCC8wt13ZTf+1vOljlPNhzQRzLhDJINvQWLRWZ3X7WyQC vmhg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20230601 header.b=lOE4Npnp; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dara=fail header.i=@linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id ffacd0b85a97d-39efa494591si8871969f8f.516.2025.04.23.14.32.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Apr 2025 14:32:26 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20230601 header.b=lOE4Npnp; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dara=fail header.i=@linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2CA9280F9C; Wed, 23 Apr 2025 23:32:18 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=debian.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="lOE4Npnp"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3A07581E72; Wed, 23 Apr 2025 23:32:16 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pg1-x536.google.com (mail-pg1-x536.google.com [IPv6:2607:f8b0:4864:20::536]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id D99388059A for ; Wed, 23 Apr 2025 23:32:13 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=debian.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=grandpaul@gmail.com Received: by mail-pg1-x536.google.com with SMTP id 41be03b00d2f7-af28bc68846so239405a12.1 for ; Wed, 23 Apr 2025 14:32:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1745443931; x=1746048731; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=jSX/9sQGbKqDWDDqeHEWYA9ns/DUT3sg+GNNs1iBoWM=; b=lOE4NpnpXJW10R+Cpu+oV4R9oxX6Wu7o8hI0/xuQ4E8p8T93rAb90dIkwHhpAdQRx6 Y301lOuykblaWrAjYm3fWr+uXMp2GSVjxwMJPcVKx4hQinD//BHfSya+KOTc0Mw2tcHt MnvW0BnFpzKQyj9SpDsyVmgVHLRBeqbwFjlNeiXrwYb+/4vi0UAtdAUn/Pq87x0noarP ywT4PTD+BAooj7omL3GdIJRQTN1ll2gHzJLaJjH/x92fxVDWV/3iJDDHogFPoxE7ASwD cMvS8p4NvcN5ZvMjOikb9G2iQ0SftQwLlC/Yf2RtGPk89oVaaTmXgi33jmgaWytYK/hI GfdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745443931; x=1746048731; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=jSX/9sQGbKqDWDDqeHEWYA9ns/DUT3sg+GNNs1iBoWM=; b=Kw+ivdU1cz5i4HfURaG8xlsQur2A2pEDL5cYAgKKqW7f2YDv6is7gfvVMFZw34PvHA gj1AIQLvYAqkyRQClj2PFp86r7SsWeSSGuLeESbmLxpc7FYxac334I/fTghzR2zrRez5 e9x+aMGTPYOOiudYgnOy9AH0j1lQLjA5znnwGDUpaGGjpng0QqYlKiZWCAvVyhZws42W oHQGJ/3k+SmulU7+oyYWXLUiHa1vaV3XJDBEhl9/IMoU0O9OFV0VhGhWUyn4jyfqwWjg 0jCyczp2K0Z78jK6CG29GpTFSJRs25Fir70SSaCy6aFy2rEv1AEwBPkEvtQQ3t3DTs0n RkJA== X-Gm-Message-State: AOJu0Yy1bXljSR4jhNlTvnJNZCxaZ9lNbFYJM1T8qrkVAFXhi3UAhwMw CGfg2GHFm+TtIAfpbEhyx3sGRjx3RRweSthPR5A16ERcHoiTjqqF6faWcg== X-Gm-Gg: ASbGncubpC5bh/POlNaQWGAkUOYz5WTSv1pgm51U0hg7WrgJZM0trF7MvjhmpYHKmV4 JhdhIlVNl1h5jdTAqQIa8pnM9tr94ku8vxaB/zweSVDrRGouPLCbfjiSZLWPZJ8zC2m6dFUouJw xYwiKu4YGRynCT2cZ6RMJRR4Y+Tawo/BcqrGrD0Vr3zRaEzfZUhvPZIdHy41xxqWpdq2V3MWAaR oklHog5RR4CNSt+5UJzlbdnYri7j2XolfPcZ3yfxjZhAx+4gCE871benZAymfSAL8Wt4EkQEkND eT29bt2AJgaXox+r/QpLYyaDj/cpJmv2lc0l X-Received: by 2002:a05:6a21:3996:b0:1f5:95a7:816e with SMTP id adf61e73a8af0-20444f09a4bmr142452637.23.1745443931597; Wed, 23 Apr 2025 14:32:11 -0700 (PDT) Received: from localhost ([61.71.79.124]) by smtp.gmail.com with UTF8SMTPSA id d2e1a72fcca58-73e259134ebsm49264b3a.27.2025.04.23.14.32.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Apr 2025 14:32:11 -0700 (PDT) From: "Ying-Chun Liu (PaulLiu)" To: u-boot@lists.denx.de Cc: "Ying-Chun Liu (PaulLiu)" , Heinrich Schuchardt , Ilias Apalodimas Subject: [PATCH 2/3] efi: add EFI_DEBUG_IMAGE_INFO_TABLE for debug Date: Thu, 24 Apr 2025 05:31:43 +0800 Message-ID: <20250423213145.1959046-3-paulliu@debian.org> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250423213145.1959046-1-paulliu@debian.org> References: <20250423213145.1959046-1-paulliu@debian.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean From: "Ying-Chun Liu (PaulLiu)" EFI_DEBUG_IMAGE_INFO_TABLE is used to store EFI_LOADED_IMAGE for debug purpose. This commit adds the table to the EFI_CONFIGURATION_TABLE. This feature is described in UEFI Spec version 2.10. Section 18.4. Signed-off-by: Ying-Chun Liu (PaulLiu) Cc: Heinrich Schuchardt Cc: Ilias Apalodimas --- include/efi_api.h | 24 ++++++++++++++++++++++++ lib/efi_loader/efi_boottime.c | 16 ++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/include/efi_api.h b/include/efi_api.h index 5017d9037cd..0f4245091f1 100644 --- a/include/efi_api.h +++ b/include/efi_api.h @@ -238,6 +238,10 @@ enum efi_reset_type { EFI_GUID(0xcce33c35, 0x74ac, 0x4087, 0xbc, 0xe7, \ 0x8b, 0x29, 0xb0, 0x2e, 0xeb, 0x27) +#define EFI_DEBUG_IMAGE_INFO_TABLE_GUID \ + EFI_GUID(0x49152e77, 0x1ada, 0x4764, 0xb7, 0xa2, \ + 0x7a, 0xfe, 0xfe, 0xd9, 0x5e, 0x8b) + struct efi_conformance_profiles_table { u16 version; u16 number_of_profiles; @@ -564,6 +568,26 @@ struct efi_loaded_image { efi_status_t (EFIAPI *unload)(efi_handle_t image_handle); }; +#define EFI_DEBUG_IMAGE_INFO_UPDATE_IN_PROGRESS 0x01 +#define EFI_DEBUG_IMAGE_INFO_TABLE_MODIFIED 0x02 + +struct efi_debug_image_info_normal { + u32 image_info_type; + struct efi_loaded_image *loaded_image_protocol_instance; + efi_handle_t image_handle; +}; + +union efi_debug_image_info { + u32 *image_info_type; + struct efi_debug_image_info_normal *normal_image; +}; + +struct efi_debug_image_info_table_header { + volatile u32 update_status; + u32 table_size; + union efi_debug_image_info *efi_debug_image_info_table; +}; + #define EFI_DEVICE_PATH_PROTOCOL_GUID \ EFI_GUID(0x09576e91, 0x6d3f, 0x11d2, \ 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b) diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index 366bc0d2b1d..e2665459e44 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -4038,6 +4038,16 @@ efi_status_t efi_initialize_system_table(void) return ret; } +struct efi_debug_image_info_table_header __efi_runtime_data +efi_m_debug_info_table_header = { + 0, + 0, + NULL +}; + +const efi_guid_t efi_debug_image_info_table_guid = + EFI_DEBUG_IMAGE_INFO_TABLE_GUID; + /** * efi_initialize_system_table() - Initialize system table * @@ -4053,6 +4063,8 @@ efi_status_t efi_initialize_system_table_pointer(void) u64 addr; u64 aligned_addr; u32 crc32_value; + efi_guid_t debug_image_info_table_guid = + efi_debug_image_info_table_guid; /* Allocate configuration table array */ ret = efi_allocate_pages(EFI_ALLOCATE_ANY_PAGES, @@ -4077,5 +4089,9 @@ efi_status_t efi_initialize_system_table_pointer(void) (const unsigned char *)systab_pointer, sizeof(struct efi_system_table_pointer)); systab_pointer->crc32 = crc32_value; + + ret = efi_install_configuration_table(&debug_image_info_table_guid, + &efi_m_debug_info_table_header); + return ret; } From patchwork Wed Apr 23 21:31:44 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Ying-Chun Liu \(PaulLiu\)" X-Patchwork-Id: 883605 Delivered-To: patch@linaro.org Received: by 2002:a5d:474d:0:b0:38f:210b:807b with SMTP id o13csp3134083wrs; Wed, 23 Apr 2025 14:32:35 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVUpSqL0L1g4SwOPwNcXp1ud2R/9Pdq8G/S3X7fGc5ukEt8HiT4KoEmdqSUW35rXXaNuN81sQ==@linaro.org X-Google-Smtp-Source: AGHT+IHjYGClK1V1D6WDSfA6Qhk1X3W/PutPyeXXm55VMxVZEWGPKWN4wKcL9bQNzpVaJJuirI45 X-Received: by 2002:a05:6000:4028:b0:39a:ca04:3e4d with SMTP id ffacd0b85a97d-3a06cf503d8mr47598f8f.7.1745443955050; Wed, 23 Apr 2025 14:32:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1745443955; cv=none; d=google.com; s=arc-20240605; b=EwguHf0sBb85Ij/qcoBdTwzsaRlk31vFQ4OtNSAJWbWdb+gCYh9vwVoNV8OFS/k9YI 8cPmjmP733zR1rGtH6bVpqNo8kfO5v6VVoa9HSeSrCJM5MZHJciHyYoRh8pid9Fen7BI Ue6jQ3zdeWWVFI+3C/KNdOpayf5DHSwo1EzVQt7ixmE3T+U03TaOEEAhYGNfl0hIJ7Jh xDI3gAA6RSE4shKxGDTYuhALglZBuT7xyG7MG4iYaxOhb6pgPpoccZWvOc7hxJZcqNWU XDhK25v+RzuZMZUCFjB5sISjZjt9D39jIxuOjKTe4A/oAVqaujW50kS9cHkC2T07CPhS XIsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=7LRpx+FoNAOUs9oPJ2fK5/pUlKszN2F1r/PYJccPvCU=; fh=yXVQQdlQRM26TTYMoA2yrv//F921MlR4o2VBZ4jl39k=; b=dfFudpBz8Ao3cQNQ2BX5IEXyudO5bYE9McBeloBw/O8Ldj24BG2fmmOFXe29HAC4ec AvimaXmfyNfkwlCJbIARTgw86Q4ptvF+b6zdTmLg6pY05c4YW3m1rWsXqSmpsh5qbsXx XlL0nlZPJMUhBnV3gJS8aNhNLQ7VePEkjvPxIX+RKgHo2gkpIBpORlfQ2rJOOe/NXlci Noo3GRBSh10q4wmxWz1GTzG5T3m2qt0pBX/FslRKgsdbsaYmQjMhNLIkYtFAymtpbiLX 4bkNGWc+Q6JFARHOYHjbfOBVPTBu+PCfqO+9yj7SQ3Uwr3Z/hspiQafRdgFprW4X1KQs A2Zg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20230601 header.b=hFJJsI1y; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dara=fail header.i=@linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id 5b1f17b1804b1-44092db72d9si19396565e9.129.2025.04.23.14.32.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Apr 2025 14:32:35 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20230601 header.b=hFJJsI1y; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dara=fail header.i=@linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 79D5E8082A; Wed, 23 Apr 2025 23:32:20 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=debian.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="hFJJsI1y"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3316D817C4; Wed, 23 Apr 2025 23:32:19 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id BC97B8059A for ; Wed, 23 Apr 2025 23:32:16 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=debian.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=grandpaul@gmail.com Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-227d6b530d8so3350675ad.3 for ; Wed, 23 Apr 2025 14:32:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1745443935; x=1746048735; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=7LRpx+FoNAOUs9oPJ2fK5/pUlKszN2F1r/PYJccPvCU=; b=hFJJsI1yCntaCqQGzOPJP+R0AFF8Tc0kB1staKJAnTfdG2yi1IWfWT5jUdYGr4wduV OKPQuez1jHvOXqJA5fn4adX1CBfYe2gdLa3hOqvyRSdway3li/AzBITv3HOtqPaAoCTO nW5EZrFhz5vqyr7sszwWqSLDHtUYtWiCbJpwWy4QTEa+ERw5vm5MohAtg1aBxIzqlDlV dXbXHvGE9IRg5RRTwIJaHjJtr5LeGnrmPo3zaYKDodzXCZqajIP/xySupgH4FFdgWl/d oJnxBz8a4aQg58Ky5ZCxegTGl8HnYrA9PwxXgH8vwekFTsvZc2VxeQDcaJp072UMC+HH cwiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745443935; x=1746048735; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=7LRpx+FoNAOUs9oPJ2fK5/pUlKszN2F1r/PYJccPvCU=; b=UWdo9BdS9t2JY9wlC3dqQP97VgqaX6PENTnLdXpsy5GBB22QVjDiD3JZoAUW0ILYGQ tfhV+VNtwd15zf/RCdJY+xIYl2Y05ZFjsvyeZbmA+pBe/GTn9N+bnbeYJRfkevc7cKSH nlW62F1LqzRZHHy76ULyT8c7P0kg86A4Ol0Yr1cqb/lynbYXJvRX7ApYZz3UQe/wYLKq yIfBL0UXIdaQQ8wFTyLW3DA4zHAVnwaAZ6K7DA9v8PzgGTioJUbEVlyH/XwqsT+UXeXL Cpd+7HVv8sKYXoO3l2iApb6Zn9hyBC+H1/duj1mV56wtoXXXDty0+jYP5h7DXdBy6p3H D/Ig== X-Gm-Message-State: AOJu0YyO/Z/vS6GT8Xm9oUhPCPvFd1IAJOQF7ZiarQ7QsJcyXMD0mGg9 FznpyAKEjdZmJVvYGVwGwFX7ubvwI7MHvzGXBCKutfLIzrAwLFgqJg2lrA== X-Gm-Gg: ASbGncu+ftbr8QjsWC9rWxK9q+aqDxhIb9T9bFqnttUMEKIizRrZDKDQGxXlFr5KXWv YVyXQYAks4SQW9MwLgadEzDgjtZ5xbEhArjksncbv4N5iH+shzVbguxUJQm3mrHrEjjz2kSS74o 81Zv/bhqvVT20JNr+n1dYkdZ2YTzdSeh067qOUtWQmX6AI4KBtPvOwIix6na5cccU7nibXLBAtN a3Z+fkka/KFKtNXOzo+5mPO9UZTclZsc6ec4LLINCkrvHPBbaW3PM5oiO5T7I6L3XB35kblEfhc kQLAkwlptriBL/O7rr6mfYYSaJjAFJQPKwKS X-Received: by 2002:a17:903:2311:b0:220:e9ac:e746 with SMTP id d9443c01a7336-22db3ded901mr756435ad.53.1745443934777; Wed, 23 Apr 2025 14:32:14 -0700 (PDT) Received: from localhost ([61.71.79.124]) by smtp.gmail.com with UTF8SMTPSA id d9443c01a7336-22c50eceb44sm109452615ad.188.2025.04.23.14.32.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Apr 2025 14:32:14 -0700 (PDT) From: "Ying-Chun Liu (PaulLiu)" To: u-boot@lists.denx.de Cc: "Ying-Chun Liu (PaulLiu)" , Heinrich Schuchardt , Ilias Apalodimas Subject: [PATCH 3/3] efi: add EFI_DEBUG_IMAGE_INFO for debug Date: Thu, 24 Apr 2025 05:31:44 +0800 Message-ID: <20250423213145.1959046-4-paulliu@debian.org> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250423213145.1959046-1-paulliu@debian.org> References: <20250423213145.1959046-1-paulliu@debian.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean From: "Ying-Chun Liu (PaulLiu)" This commit adds the functionality of generate EFI_DEBUG_IMAGE_INFO while loading the image. This feature is described in UEFI Spec 2.10. Section 18.4.3. Signed-off-by: Ying-Chun Liu (PaulLiu) Cc: Heinrich Schuchardt Cc: Ilias Apalodimas --- include/efi_api.h | 2 + include/efi_loader.h | 5 ++ lib/efi_loader/efi_boottime.c | 136 ++++++++++++++++++++++++++++++++++ 3 files changed, 143 insertions(+) diff --git a/include/efi_api.h b/include/efi_api.h index 0f4245091f1..ba87af17c1f 100644 --- a/include/efi_api.h +++ b/include/efi_api.h @@ -571,6 +571,8 @@ struct efi_loaded_image { #define EFI_DEBUG_IMAGE_INFO_UPDATE_IN_PROGRESS 0x01 #define EFI_DEBUG_IMAGE_INFO_TABLE_MODIFIED 0x02 +#define EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL 0x01 + struct efi_debug_image_info_normal { u32 image_info_type; struct efi_loaded_image *loaded_image_protocol_instance; diff --git a/include/efi_loader.h b/include/efi_loader.h index 370bc042f70..babe23a8a83 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -617,6 +617,11 @@ efi_status_t efi_root_node_register(void); efi_status_t efi_initialize_system_table(void); /* Called by bootefi to initialize debug */ efi_status_t efi_initialize_system_table_pointer(void); +/* Called by efi_load_image for register debug info */ +void efi_core_new_debug_image_info_entry(u32 image_info_type, + struct efi_loaded_image *loaded_image, + efi_handle_t image_handle); +void efi_core_remove_debug_image_info_entry(efi_handle_t image_handle); /* efi_runtime_detach() - detach unimplemented runtime functions */ void efi_runtime_detach(void); /* efi_convert_pointer() - convert pointer to virtual address */ diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index e2665459e44..bf37580c06b 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -2130,6 +2130,12 @@ efi_status_t EFIAPI efi_load_image(bool boot_policy, *image_handle = NULL; free(info); } + + if (*image_handle) { + efi_core_new_debug_image_info_entry(EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL, + info, + *image_handle); + } error: return EFI_EXIT(ret); } @@ -3359,6 +3365,7 @@ efi_status_t EFIAPI efi_unload_image(efi_handle_t image_handle) ret = EFI_INVALID_PARAMETER; goto out; } + efi_core_remove_debug_image_info_entry(image_handle); switch (efiobj->type) { case EFI_OBJECT_TYPE_STARTED_IMAGE: /* Call the unload function */ @@ -4045,6 +4052,10 @@ efi_m_debug_info_table_header = { NULL }; +static u32 efi_m_max_table_entries; + +#define EFI_DEBUG_TABLE_ENTRY_SIZE (sizeof(void *)) + const efi_guid_t efi_debug_image_info_table_guid = EFI_DEBUG_IMAGE_INFO_TABLE_GUID; @@ -4095,3 +4106,128 @@ efi_status_t efi_initialize_system_table_pointer(void) return ret; } + +/** + * Add a new efi_loaded_image structure to the efi_debug_image_info Table. + * Re-Allocates the table if it's not large enough to accomidate another + * entry. + * + * @param image_info_type type of debug image information + * @param loaded_image pointer to the loaded image protocol for the image + * being loaded + * @param image_handle image handle for the image being loaded + **/ +void efi_core_new_debug_image_info_entry(u32 image_info_type, + struct efi_loaded_image *loaded_image, + efi_handle_t image_handle) +{ + union efi_debug_image_info *table; + union efi_debug_image_info *new_table; + u32 index; + u32 table_size; + + /* Set the flag indicating that we're in the process of updating + * the table. + */ + efi_m_debug_info_table_header.update_status |= + EFI_DEBUG_IMAGE_INFO_UPDATE_IN_PROGRESS; + + table = efi_m_debug_info_table_header.efi_debug_image_info_table; + + if (efi_m_debug_info_table_header.table_size < efi_m_max_table_entries) { + /* We still have empty entries in the Table, find the first + * empty entry. + */ + index = 0; + while (table[index].normal_image) + index++; + } else { + /* table is full, re-allocate another page for a larger + * table. + */ + table_size = efi_m_max_table_entries * EFI_DEBUG_TABLE_ENTRY_SIZE; + efi_allocate_pool(EFI_RUNTIME_SERVICES_DATA, + table_size + EFI_PAGE_SIZE, + (void **)&new_table); + + if (!new_table) { + efi_m_debug_info_table_header.update_status &= + ~EFI_DEBUG_IMAGE_INFO_UPDATE_IN_PROGRESS; + return; + } + + memset(new_table, 0, table_size + EFI_PAGE_SIZE); + + /* Copy the old table into the new one. */ + memcpy(new_table, table, table_size); + /* Free the old table. */ + efi_free_pool(table); + /* Update the table header. */ + table = new_table; + efi_m_debug_info_table_header.efi_debug_image_info_table = + new_table; + + /* Enlarge the max table entries and set the first empty + * entry index to be the original max table entries. + */ + index = efi_m_max_table_entries; + efi_m_max_table_entries += + EFI_PAGE_SIZE / EFI_DEBUG_TABLE_ENTRY_SIZE; + } + + /* Allocate data for new entry. */ + efi_allocate_pool(EFI_RUNTIME_SERVICES_DATA, + sizeof(struct efi_debug_image_info_normal), + (void **)(&table[index].normal_image)); + if (table[index].normal_image) { + /* Update the entry. */ + table[index].normal_image->image_info_type = image_info_type; + table[index].normal_image->loaded_image_protocol_instance = + loaded_image; + table[index].normal_image->image_handle = image_handle; + + /* Increase the number of EFI_DEBUG_IMAGE_INFO elements and + * set the efi_m_debug_info_table_header in modified status. + */ + efi_m_debug_info_table_header.table_size++; + efi_m_debug_info_table_header.update_status |= + EFI_DEBUG_IMAGE_INFO_TABLE_MODIFIED; + } + + efi_m_debug_info_table_header.update_status &= + ~EFI_DEBUG_IMAGE_INFO_UPDATE_IN_PROGRESS; +} + +void efi_core_remove_debug_image_info_entry(efi_handle_t image_handle) +{ + union efi_debug_image_info *table; + u32 index; + + efi_m_debug_info_table_header.update_status |= + EFI_DEBUG_IMAGE_INFO_UPDATE_IN_PROGRESS; + + table = efi_m_debug_info_table_header.efi_debug_image_info_table; + + for (index = 0; index < efi_m_max_table_entries; index++) { + if (table[index].normal_image && + table[index].normal_image->image_handle == image_handle) { + /* Found a match. Free up the record, then NULL the + * pointer to indicate the slot is free. + */ + efi_free_pool(table[index].normal_image); + table[index].normal_image = NULL; + + /* Decrease the number of EFI_DEBUG_IMAGE_INFO + * elements and set the efi_m_debug_info_table_header + * in modified status. + */ + efi_m_debug_info_table_header.table_size--; + efi_m_debug_info_table_header.update_status |= + EFI_DEBUG_IMAGE_INFO_TABLE_MODIFIED; + break; + } + } + + efi_m_debug_info_table_header.update_status &= + ~EFI_DEBUG_IMAGE_INFO_UPDATE_IN_PROGRESS; +}