From a72fe3433300d9ee0ec2680547cdb94ed4872292 Mon Sep 17 00:00:00 2001 From: "YiTa Wu (AMI US Holdings Inc)" Date: Mon, 2 Dec 2024 21:57:01 +0800 Subject: [PATCH 1/2] Mock Functions for MmReportStatusCodeHandler --- .../Protocol/MockMmReportStatusCodeHandler.h | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 MdePkg/Test/Mock/Include/GoogleTest/Protocol/MockMmReportStatusCodeHandler.h diff --git a/MdePkg/Test/Mock/Include/GoogleTest/Protocol/MockMmReportStatusCodeHandler.h b/MdePkg/Test/Mock/Include/GoogleTest/Protocol/MockMmReportStatusCodeHandler.h new file mode 100644 index 0000000000..3eeec12a77 --- /dev/null +++ b/MdePkg/Test/Mock/Include/GoogleTest/Protocol/MockMmReportStatusCodeHandler.h @@ -0,0 +1,50 @@ +/** @file MockMmReportStatusCodeHandler.h + This file declares a mock of Standalone MM Report Status Code Handler Protocol. + + Copyright (c) Microsoft Corporation. + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#ifndef MOCK_MM_REPORT_STATUS_CODE_HANDLER_PROTOCOL_H +#define MOCK_MM_REPORT_STATUS_CODE_HANDLER_PROTOCOL_H + +#include +#include + +extern "C" { + #include + #include + #include +} + +struct MockReportStatusCodeHandler { + MOCK_INTERFACE_DECLARATION (MockReportStatusCodeHandler); + + MOCK_FUNCTION_DECLARATION ( + EFI_STATUS, + Register, + ( + IN EFI_MM_RSC_HANDLER_CALLBACK Callback) + ); + + MOCK_FUNCTION_DECLARATION ( + EFI_STATUS, + Unregister, + (IN EFI_MM_RSC_HANDLER_CALLBACK Callback) + ); +}; + +MOCK_INTERFACE_DEFINITION (MockReportStatusCodeHandler); +MOCK_FUNCTION_DEFINITION (MockReportStatusCodeHandler, Register, 1, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockReportStatusCodeHandler, Unregister, 1, EFIAPI); + +EFI_MM_RSC_HANDLER_PROTOCOL MmRscHandlerProtocol = { + Register, + Unregister +}; + +extern "C" { + EFI_MM_RSC_HANDLER_PROTOCOL *MmRscHandlerProtocolServices = &MmRscHandlerProtocol; +} + +#endif From 3921296bbe962c800080b9c3bf2e7cd498561ade Mon Sep 17 00:00:00 2001 From: "YiTa Wu (AMI US Holdings Inc)" Date: Wed, 4 Dec 2024 14:47:49 +0800 Subject: [PATCH 2/2] Match Edk2 design --- .../Protocol/MockMmReportStatusCodeHandler.h | 23 ++++++++----------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/MdePkg/Test/Mock/Include/GoogleTest/Protocol/MockMmReportStatusCodeHandler.h b/MdePkg/Test/Mock/Include/GoogleTest/Protocol/MockMmReportStatusCodeHandler.h index 3eeec12a77..45d4dc5e03 100644 --- a/MdePkg/Test/Mock/Include/GoogleTest/Protocol/MockMmReportStatusCodeHandler.h +++ b/MdePkg/Test/Mock/Include/GoogleTest/Protocol/MockMmReportStatusCodeHandler.h @@ -17,8 +17,8 @@ extern "C" { #include } -struct MockReportStatusCodeHandler { - MOCK_INTERFACE_DECLARATION (MockReportStatusCodeHandler); +struct MockEfiMmRscHandlerProtocol { + MOCK_INTERFACE_DECLARATION (MockEfiMmRscHandlerProtocol); MOCK_FUNCTION_DECLARATION ( EFI_STATUS, @@ -34,17 +34,14 @@ struct MockReportStatusCodeHandler { ); }; -MOCK_INTERFACE_DEFINITION (MockReportStatusCodeHandler); -MOCK_FUNCTION_DEFINITION (MockReportStatusCodeHandler, Register, 1, EFIAPI); -MOCK_FUNCTION_DEFINITION (MockReportStatusCodeHandler, Unregister, 1, EFIAPI); +MOCK_INTERFACE_DEFINITION (MockEfiMmRscHandlerProtocol); +MOCK_FUNCTION_DEFINITION (MockEfiMmRscHandlerProtocol, Register, 1, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockEfiMmRscHandlerProtocol, Unregister, 1, EFIAPI); -EFI_MM_RSC_HANDLER_PROTOCOL MmRscHandlerProtocol = { - Register, - Unregister -}; - -extern "C" { - EFI_MM_RSC_HANDLER_PROTOCOL *MmRscHandlerProtocolServices = &MmRscHandlerProtocol; -} +#define MOCK_EFI_MM_RSC_HANDLER_PROTOCOL_INSTANCE(NAME) \ + EFI_MM_RSC_HANDLER_PROTOCOL NAME##_INSTANCE = { \ + Register, \ + Unregister }; \ + EFI_MM_RSC_HANDLER_PROTOCOL *NAME = &NAME##_INSTANCE; #endif