From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM01-SN1-obe.outbound.protection.outlook.com (mail-sn1nam01on061e.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe40::61e]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id E860821939234 for ; Wed, 12 Apr 2017 11:56:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=f1kVY4ON6rp6hr5FmlB88xWYpDdJn1V53NE9Vt+QblM=; b=algi436aSaSJUFKq7TdWWHVB20+vcODLBe8Tm5rWYy1Fqrjvth2pRaV9tBxHbTTav/qmZ93JSbjBzFqGF5GJethTiRi0fzvn+oo/DPcrdTiQL2I5ozenWYb/3McU6QuRxKZz0OLa0D5xz7Tb14f06RsKQTeQxL7lnC7WdB+F3rQ= Authentication-Results: ml01.01.org; dkim=none (message not signed) header.d=none;ml01.01.org; dmarc=none action=none header.from=amd.com; Received: from leduran-Precision-WorkStation-T5400.amd.com (165.204.77.1) by DM5PR12MB1242.namprd12.prod.outlook.com (10.168.237.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1019.17; Wed, 12 Apr 2017 18:56:52 +0000 From: Leo Duran To: CC: Leo Duran , Feng Tian , Star Zeng , Laszlo Ersek , Brijesh Singh Date: Wed, 12 Apr 2017 13:56:40 -0500 Message-ID: <1492023400-16132-2-git-send-email-leo.duran@amd.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1492023400-16132-1-git-send-email-leo.duran@amd.com> References: <1492023400-16132-1-git-send-email-leo.duran@amd.com> MIME-Version: 1.0 X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: MWHPR22CA0050.namprd22.prod.outlook.com (10.171.142.12) To DM5PR12MB1242.namprd12.prod.outlook.com (10.168.237.21) X-MS-Office365-Filtering-Correlation-Id: 6e68121d-e399-490f-280f-08d481d5af1f X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(48565401081)(201703131423075)(201703031133081); SRVR:DM5PR12MB1242; X-Microsoft-Exchange-Diagnostics: 1; DM5PR12MB1242; 3:Y+oCF81FX60s2MAlpefFlwIz3wh59fefjPUhc5Dd9oDHlrZRGHG9vFLuRlbbhCaRNLQcw8LF7vZCbbUNAm5mjv0Zrnm8Vqi31lmLVHgc5ZMXwz6hK5bxAHwXhXzJT8dNr515AyYmR8tkn8x359dTZKvrrCIPcFhYL2ROtgbDb20dluB/tiNhsC5AE0Fnz7G/RMO8WeA2BdCFFzu21ZTqWJKK2E3Bf1FoQLE8kzmP4ZHMwo0KQDxpl0HJAnI7hrFwC1AM+Ww00mjRs+TVnRVIK2wUE/vTDWd1g0eHOaN8CcBqFp1XhuwMj2IQFfOTW+Hj0+yrWb8vUBvM1pl85NW6T9DaZfLPm8dNtdvy8VYGNt4=; 25:MLRMOB1zrOal6HIoXcv56vhf8SV2rKzyo0UGcw+Pgz/kIqn3DNfXN+S3PqxCXlXkw3NDvqZ5m6y+Z1hhtN0+hzEGI1swJTLSmM60trvcmIarE77/MlkCxbToMAcxke40tGD9nFc1IH/tPuvgxS5wgJWaBYwgr2Vhv2Uf2fZHeeMYEcowPRDqoQBsvwJ7gsCMYSUmKDX2CmlC4nPZ+zXwTnZOyDfxUnlUAdsCTqIvus3UE+Q/aN3GanHZtwaPn0wiGSagiI5o8fm2v0va8PdNg9o6vgE9LjzBz2CUH4Jq1J7P29XsFpCff4oWVGL/B3MEqGqIcbgxwHpIE3Zfy4fRV82/FyaHkYBhqURpYlJlgcFlGjG0P+4iA00iJU6cCo6BId62dBSK4iA6hZ9TjLl4ZU5HCbVYkpMaVxmf35dmpKaPYdIeK2VE2eGBajxCKTn16SboLbf08nqt1SHKleYHJA== X-Microsoft-Exchange-Diagnostics: 1; DM5PR12MB1242; 31:yK5tsjPITU2LXirJhLgIKirkCFqH3XdBzF77g0Y2ai1LTfY94/oKUl6rTRmUHilI2REivA4/065vDtTZ0e61TheRiPQkh2QgxoqhXFDvubtwd4Ynd/wVJiAQdUAzbu0AkWhPKCAsF3V5ZpGdLlIsKRh5mFL7lOpQmQOo2cIvxoFKwn2iz3HYR3g4kAobg8mfh9Syv0TEIPrGFCjF8Fnd/MrMAzX/pYH2cIZnp4z7kzU=; 20:njJNoqH6VpRCqPIydr3Ddl7C6flj+dNQrsRSU3aMFOFIwryJW+deXXOHuHztLBF5zeXPSXRdUmZQOCzCUPBiVkG4WWoQc53l0U3CKjapacmvEtgWqcWf8hiYSMznZfB+kdPwiCTkeSKy7lxvT9U3MpmXvMLKCb/YXHgV+jHgoAb45SOP03GXXoeulMl6xDlt3wIE8LL5/ltm3agsoCXiir+/sPb1zZfvaenCd4B/9dC/vXgQ/0Ho5DuiKfmtPic1Cm8bXMdX+izolemD/hHGMkoFn+tfYL4jRc1yOiPbf5QOYbCL+xABrS/RDDuEv6Hf+D4qciKK4S0+zq9/kuPFOmLL+aeIj4F1yRIlOo+jyTvMcJHmkWVveRKZwccenAvyJmUb4XkxD/xYzFcmn0+R6Hml4GjSmFnweUC5Y6c7MZwjF7JvsYS9UJh0OrbUrWsecR9Oo0fXGPNIIWsSthiHG7pga+Kffqa6JvU07KRcb0GzaJXgmUNnnKUiElF44aqj X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110)(228905959029699); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040450)(601004)(2401047)(8121501046)(5005006)(93006095)(93001095)(10201501046)(3002001)(6055026)(6041248)(201703131423075)(201702281528075)(201703061421075)(20161123564025)(20161123562025)(20161123560025)(20161123555025)(6072148); SRVR:DM5PR12MB1242; BCL:0; PCL:0; RULEID:; SRVR:DM5PR12MB1242; X-Microsoft-Exchange-Diagnostics: 1; DM5PR12MB1242; 4:l1+uS8l35TJzIUCVXoyPg733TNb/YQJQp0BozLL6sw9kqFyNgRm1DXdxcjNoyofagicwx+Dph8gRvmDNPEGeRUR8DWB4Yqt997S5h37jwgO2NR3ITGRLDacyn4Bda7+a6GzCBDmq6NmOFg2IvElkQTdUDaBhXGhwEVG9vUxODX+SJYdE1nKyfjsJErYiIiSp9MPeWMtyR+jErRoM+sTQ20oWo1rRYN0PO7W8luHWPSZfq2U+Sj7jGY9hphb4MP02r2ut6FprhmDWQmBP8j8dHYyV2OoL+exZs9gDQbs7kchV8dSj7Kfaifq4xlQ8UC54WxGqbXvW3Vyd7NKXJMTAe9jzarNkgLTG42Hw4kYfL4b2BlRVy0os5F9wu5zNsxYahfA2cO5bdWWDeVzvmjDfivQOLsi79wkAwj8rna64pWTYOc3VBc+cL3wxlkU9V4HpGsCz5vOTPWPvrGe/tjPSXXxbO+a0Bauc3/W4pGfhLb2WqKsqDTwww77zH/FAr/uRSiJRyd1OKCdtePsc3VFDUShzKWuzFVQqKKBgHx4Noymxn9svuG9QLu00n6A2VSZT+kRW7wzsAYtLoRxG5peQ8fHTSgIadlZlTHxTGbBtGWnDbZn/VdjykPGwIVm7PQddspC6aTP5RPcg1CfdC6oU6onkSsC/IgFb1qSRrqOZAF7LPRqAAVzsYfdZiYuRts0Ip2K5G8daT3Ok2wfDE+nfIEgbGPJU25XT392SI37OJCpmJmK0Enz1N5edXNPNwVRQESJBEbzW3Bj5Sj6KWtQk/4DVjT7NFCNOQlVmv/VF4O11NK1MT+cwPoyv1mL20m0c X-Forefront-PRVS: 027578BB13 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(39860400002)(39400400002)(39850400002)(39840400002)(39450400003)(39410400002)(33646002)(6916009)(575784001)(5660300001)(50466002)(966004)(305945005)(50226002)(2950100002)(189998001)(48376002)(86362001)(2351001)(76176999)(53936002)(6306002)(53376002)(38730400002)(110136004)(6116002)(53416004)(81166006)(36756003)(42186005)(8676002)(50986999)(3846002)(5003940100001)(47776003)(6486002)(66066001)(2906002)(6666003)(25786009)(54906002)(4326008)(16799955002)(15188155005)(19627235001); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR12MB1242; H:leduran-Precision-WorkStation-T5400.amd.com; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM5PR12MB1242; 23:bb3Zz9P9uXALRepDe6eo8tvdr6qCCZYG47YJm6R58?= =?us-ascii?Q?x8sbQ9PdsI7zRn84Bxa/WJ9cB436xob9WgatSStQIRM6M/o6ttYsCrtLNcpY?= =?us-ascii?Q?iJu7U0BAflMfKKfMd+pxM9d70EYHIsgjzRinRRcgbqdq4/Vgjf4HM0MMFoMl?= =?us-ascii?Q?ljgNdrQPly4ysICmHfNHxTpnmV9BJDI4LTMGr43bU9Tl88vYNAQs2nVnxnKw?= =?us-ascii?Q?Minzzyc5ImuIYuXArGCoyWJ9A95aSDfFNJtLiQPapuRM+F2IdfQ7M98e/yvi?= =?us-ascii?Q?aGT8DAu9Ozbw+B+1KL2vKwHqu0VPe4yLBq2E3AhKwkfd2qoglBeBYBk1w+g0?= =?us-ascii?Q?TVQqu8wLtTkM1qZjRsgf0SmbmfHY+QBITuZ6ysR/dBtAfgFUnLaFq7nknJlm?= =?us-ascii?Q?0iwvJADxC1gKUyV3BXLgC2D5fH3ge/kp6mNSkP/EnS3tTbqWyicFrFCOO2Tu?= =?us-ascii?Q?3FY7ivD3Gsqn2mfMWd0Rt6YIfYuKre34qUA604n7cZ9xen9fHG8ZsnD8qi4U?= =?us-ascii?Q?ZlSPic4Jl38zmqluwaQjA5i2L1ueQkcvAczBhm8NfiIek89F34l+H/bCcGPg?= =?us-ascii?Q?F4596JeSV3n4iLMGmtAG8E6/BAiFBmF6C9nB/flojmDS1D6SzGZhu5hq3ZUY?= =?us-ascii?Q?1xSuQBblnIRrnd1F9Nx3s3fJkD0x9iGujyd7SQ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ECewi8cO7w X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Apr 2017 18:56:52.4988 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB1242 Subject: [PATCH] MdeModulePkg: Add EFI_GCD_MEMORY_SPACE_NOTIFY_PROTOCOL X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Apr 2017 18:56:54 -0000 Content-Type: text/plain GCD consumes the protocol to issue a Notify() on Add/Remove operations. The intended use-case is to allow OvmfPkg take actions on behalf of an SEV-enabled guest. The new protocol is simply added to the list of optional protocols handled by DxeMain, and as such leverages the existing DxeProtocolNotify framework. Cc: Feng Tian Cc: Star Zeng Cc: Laszlo Ersek Cc: Brijesh Singh Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Leo Duran --- MdeModulePkg/Core/Dxe/DxeMain.h | 10 +++- MdeModulePkg/Core/Dxe/DxeMain.inf | 4 ++ MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c | 7 +++ MdeModulePkg/Core/Dxe/DxeMain/DxeProtocolNotify.c | 9 ++- MdeModulePkg/Core/Dxe/Gcd/Gcd.c | 8 +++ .../Include/Protocol/GcdMemorySpaceNotify.h | 65 ++++++++++++++++++++++ MdeModulePkg/MdeModulePkg.dec | 3 + 7 files changed, 100 insertions(+), 6 deletions(-) create mode 100644 MdeModulePkg/Include/Protocol/GcdMemorySpaceNotify.h diff --git a/MdeModulePkg/Core/Dxe/DxeMain.h b/MdeModulePkg/Core/Dxe/DxeMain.h index 1a0babb..8a037ff 100644 --- a/MdeModulePkg/Core/Dxe/DxeMain.h +++ b/MdeModulePkg/Core/Dxe/DxeMain.h @@ -3,6 +3,8 @@ internal structure and functions used by DxeCore module. Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
+Copyright (c) 2017, AMD Incorporated. All rights reserved.
+ This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -17,7 +19,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #define _DXE_MAIN_H_ - #include #include @@ -53,6 +54,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include #include #include +#include + #include #include #include @@ -296,12 +299,13 @@ extern EFI_RUNTIME_ARCH_PROTOCOL gRuntimeTemplate; extern EFI_LOAD_FIXED_ADDRESS_CONFIGURATION_TABLE gLoadModuleAtFixAddressConfigurationTable; extern BOOLEAN gLoadFixedAddressCodeMemoryReady; + +extern EFI_GCD_MEMORY_SPACE_NOTIFY_PROTOCOL *gGcdMemorySpaceNotify; + // // Service Initialization Functions // - - /** Called to initialize the pool. diff --git a/MdeModulePkg/Core/Dxe/DxeMain.inf b/MdeModulePkg/Core/Dxe/DxeMain.inf index 30d5984..888a16f 100644 --- a/MdeModulePkg/Core/Dxe/DxeMain.inf +++ b/MdeModulePkg/Core/Dxe/DxeMain.inf @@ -4,6 +4,8 @@ # It provides an implementation of DXE Core that is compliant with DXE CIS. # # Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
+# Copyright (c) 2017, AMD Incorporated. All rights reserved.
+# # This program and the accompanying materials # are licensed and made available under the terms and conditions of the BSD License # which accompanies this distribution. The full text of the license may be found at @@ -162,6 +164,8 @@ gEfiSmmBase2ProtocolGuid ## SOMETIMES_CONSUMES gEfiBlockIoProtocolGuid ## SOMETIMES_CONSUMES + gEfiGcdMemorySpaceNotifyProtocolGuid ## CONSUMES + # Arch Protocols gEfiBdsArchProtocolGuid ## CONSUMES gEfiCpuArchProtocolGuid ## CONSUMES diff --git a/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c b/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c index 91e94a7..46b68da 100644 --- a/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c +++ b/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c @@ -2,6 +2,8 @@ DXE Core Main Entry Point Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
+Copyright (c) 2017, AMD Incorporated. All rights reserved.
+ This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -42,6 +44,11 @@ EFI_GUID *gDxeCoreFileName; EFI_LOADED_IMAGE_PROTOCOL *gDxeCoreLoadedImage; // +// DXE Core global for GCD notification protocol +// +EFI_GCD_MEMORY_SPACE_NOTIFY_PROTOCOL *gGcdMemorySpaceNotify = NULL; + +// // DXE Core Module Variables // EFI_BOOT_SERVICES mBootServices = { diff --git a/MdeModulePkg/Core/Dxe/DxeMain/DxeProtocolNotify.c b/MdeModulePkg/Core/Dxe/DxeMain/DxeProtocolNotify.c index ea7c610..2314e34 100644 --- a/MdeModulePkg/Core/Dxe/DxeMain/DxeProtocolNotify.c +++ b/MdeModulePkg/Core/Dxe/DxeMain/DxeProtocolNotify.c @@ -4,6 +4,8 @@ events that represent the Architectural Protocols. Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.
+Copyright (c) 2017, AMD Incorporated. All rights reserved.
+ This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -45,9 +47,10 @@ EFI_CORE_PROTOCOL_NOTIFY_ENTRY mArchProtocols[] = { // Optional protocols that the DXE Core will use if they are present // EFI_CORE_PROTOCOL_NOTIFY_ENTRY mOptionalProtocols[] = { - { &gEfiSecurity2ArchProtocolGuid, (VOID **)&gSecurity2, NULL, NULL, FALSE }, - { &gEfiSmmBase2ProtocolGuid, (VOID **)&gSmmBase2, NULL, NULL, FALSE }, - { NULL, (VOID **)NULL, NULL, NULL, FALSE } + { &gEfiSecurity2ArchProtocolGuid, (VOID **)&gSecurity2, NULL, NULL, FALSE }, + { &gEfiSmmBase2ProtocolGuid, (VOID **)&gSmmBase2, NULL, NULL, FALSE }, + { &gEfiGcdMemorySpaceNotifyProtocolGuid, (VOID **)&gGcdMemorySpaceNotify, NULL, NULL, FALSE }, + { NULL, (VOID **)NULL, NULL, NULL, FALSE } }; // diff --git a/MdeModulePkg/Core/Dxe/Gcd/Gcd.c b/MdeModulePkg/Core/Dxe/Gcd/Gcd.c index a06f8bb..223fcd8 100644 --- a/MdeModulePkg/Core/Dxe/Gcd/Gcd.c +++ b/MdeModulePkg/Core/Dxe/Gcd/Gcd.c @@ -4,6 +4,8 @@ are accessible to the CPU that is executing the DXE core. Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
+Copyright (c) 2017, AMD Incorporated. All rights reserved.
+ This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -896,6 +898,9 @@ CoreConvertSpace ( } else { Entry->Capabilities = Capabilities | EFI_MEMORY_RUNTIME; } + if (gGcdMemorySpaceNotify) { + gGcdMemorySpaceNotify->MemorySpaceAddNotify (GcdMemoryType, BaseAddress, Length, Entry->Capabilities); + } break; case GCD_ADD_IO_OPERATION: Entry->GcdIoType = GcdIoType; @@ -914,6 +919,9 @@ CoreConvertSpace ( case GCD_REMOVE_MEMORY_OPERATION: Entry->GcdMemoryType = EfiGcdMemoryTypeNonExistent; Entry->Capabilities = 0; + if (gGcdMemorySpaceNotify) { + gGcdMemorySpaceNotify->MemorySpaceRemoveNotify (BaseAddress, Length); + } break; case GCD_REMOVE_IO_OPERATION: Entry->GcdIoType = EfiGcdIoTypeNonExistent; diff --git a/MdeModulePkg/Include/Protocol/GcdMemorySpaceNotify.h b/MdeModulePkg/Include/Protocol/GcdMemorySpaceNotify.h new file mode 100644 index 0000000..9174957 --- /dev/null +++ b/MdeModulePkg/Include/Protocol/GcdMemorySpaceNotify.h @@ -0,0 +1,65 @@ +/** @file + This file declares the GcdMemorySpaceNotify Protocol. + + This Protocol is consumed by GCD to issue notications during ADD/REMOVE operations. + + Copyright (c) 2017, AMD Inc. All rights reserved.
+ + This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#ifndef __EFI_GCD_MEMORY_SPACE_NOTIFY_H__ +#define __EFI_GCD_MEMORY_SPACE_NOTIFY_H__ + +#define EFI_GCD_MEMORY_SPACE_NOTIFY_GUID \ + { \ + 0xc842db69, 0x610e, 0x401a, {0x90, 0xd0, 0x88, 0x41, 0xf1, 0xdc, 0x53, 0x79 } \ + } + +/** + Notify on: Add a segment of memory to GCD map. + + @param GcdMemoryType Memory type of the segment. + @param BaseAddress Base address of the segment. + @param Length Length of the segment. + @param Capabilities Alterable attributes of the segment. + +**/ +typedef +VOID +(EFIAPI *GCD_ADD_MEMORY_NOTIFY) ( + IN EFI_GCD_MEMORY_TYPE GcdMemoryType, + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length, + IN UINT64 Capabilities +); + +/** + Notify on: Remove a segment of memory to GCD map. + + @param BaseAddress Base address of the segment. + @param Length Length of the segment. + +**/ +typedef +VOID +(EFIAPI *GCD_REMOVE_MEMORY_NOTIFY) ( + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length +); + +typedef struct { + GCD_ADD_MEMORY_NOTIFY MemorySpaceAddNotify; + GCD_REMOVE_MEMORY_NOTIFY MemorySpaceRemoveNotify; +} EFI_GCD_MEMORY_SPACE_NOTIFY_PROTOCOL; + +extern EFI_GUID gEfiGcdMemorySpaceNotifyProtocolGuid; + +#endif diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec index ca09cbc..95f9311 100644 --- a/MdeModulePkg/MdeModulePkg.dec +++ b/MdeModulePkg/MdeModulePkg.dec @@ -546,6 +546,9 @@ ## Include/Protocol/NonDiscoverableDevice.h gEdkiiNonDiscoverableDeviceProtocolGuid = { 0x0d51905b, 0xb77e, 0x452a, {0xa2, 0xc0, 0xec, 0xa0, 0xcc, 0x8d, 0x51, 0x4a } } + ## Include/Protocol/GcdMemorySpaceNotify.h + gEfiGcdMemorySpaceNotifyProtocolGuid = { 0xc842db69, 0x610e, 0x401a, {0x90, 0xd0, 0x88, 0x41, 0xf1, 0xdc, 0x53, 0x79 } } + # # [Error.gEfiMdeModulePkgTokenSpaceGuid] # 0x80000001 | Invalid value provided. -- 2.7.4