Skip to content

Commit

Permalink
[Cherry-Pick] Declare mock SMM Access2 Protocol. (#1177)
Browse files Browse the repository at this point in the history
Declare mock SMM Access2 Protocol for google test.

- [ ] Impacts functionality?
- [ ] Impacts security?
- [ ] Breaking change?
- [ ] Includes tests?
- [ ] Includes documentation?

Run the google test.

N/A
  • Loading branch information
ishih1 authored and apop5 committed Nov 15, 2024
1 parent 42d0738 commit 96e8877
Showing 1 changed file with 68 additions and 0 deletions.
68 changes: 68 additions & 0 deletions MdePkg/Test/Mock/Include/GoogleTest/Protocol/MockSmmAccess2.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/** @file MockSmmAccess2.h
Declare mock SMM Access2 Protocol.
Copyright (c) Microsoft Corporation.
SPDX-License-Identifier: BSD-2-Clause-Patent
**/

#ifndef MOCK_SMM_ACCESS2_H_
#define MOCK_SMM_ACCESS2_H_

#include <Library/GoogleTestLib.h>
#include <Library/FunctionMockLib.h>
extern "C" {
#include <Uefi.h>
#include <Pi/PiMultiPhase.h>
#include <Protocol/SmmAccess2.h>
}

struct MockSmmAccess2Protocol {
MOCK_INTERFACE_DECLARATION (MockSmmAccess2Protocol);

MOCK_FUNCTION_DECLARATION (
EFI_STATUS,
Open,
(IN EFI_MM_ACCESS_PROTOCOL *This)
);

MOCK_FUNCTION_DECLARATION (
EFI_STATUS,
Close,
(IN EFI_MM_ACCESS_PROTOCOL *This)
);

MOCK_FUNCTION_DECLARATION (
EFI_STATUS,
Lock,
(IN EFI_MM_ACCESS_PROTOCOL *This)
);

MOCK_FUNCTION_DECLARATION (
EFI_STATUS,
GetCapabilities,
(IN CONST EFI_MM_ACCESS_PROTOCOL *This,
IN OUT UINTN *MmramMapSize,
IN OUT EFI_MMRAM_DESCRIPTOR *MmramMap)
);
};

MOCK_INTERFACE_DEFINITION (MockSmmAccess2Protocol);
MOCK_FUNCTION_DEFINITION (MockSmmAccess2Protocol, Open, 1, EFIAPI);
MOCK_FUNCTION_DEFINITION (MockSmmAccess2Protocol, Close, 1, EFIAPI);
MOCK_FUNCTION_DEFINITION (MockSmmAccess2Protocol, Lock, 1, EFIAPI);
MOCK_FUNCTION_DEFINITION (MockSmmAccess2Protocol, GetCapabilities, 3, EFIAPI);

EFI_SMM_ACCESS2_PROTOCOL SMM_ACCESS2_PROTOCOL_INSTANCE = {
Open,
Close,
Lock,
GetCapabilities,
FALSE,
FALSE
};

extern "C" {
EFI_SMM_ACCESS2_PROTOCOL *gSmmAccess2Protocol = &SMM_ACCESS2_PROTOCOL_INSTANCE;
}

#endif

0 comments on commit 96e8877

Please sign in to comment.