Skip to content

Commit

Permalink
Add MockPciPlatformProtocol.
Browse files Browse the repository at this point in the history
  • Loading branch information
v-boscochen committed Nov 19, 2024
1 parent 038c4c4 commit 15f9d44
Showing 1 changed file with 94 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
/** @file
This file declares a mock of PCI Platform Protocol.
Copyright (c) Microsoft Corporation.
SPDX-License-Identifier: BSD-2-Clause-Patent
**/

#ifndef MOCK_PCIPLATFORMPROTOCOL_H
#define MOCK_PCIPLATFORMPROTOCOL_H

#include <Library/GoogleTestLib.h>
#include <Library/FunctionMockLib.h>

extern "C" {
#include <Uefi.h>
#include <Protocol/PciPlatform.h>
}

struct MockPciPlatformPhaseNotify {
MOCK_INTERFACE_DECLARATION (MockPciPlatformPhaseNotify);
MOCK_FUNCTION_DECLARATION (
EFI_STATUS,
MockPlatformNotify,
(IN EFI_PCI_PLATFORM_PROTOCOL *This,
IN EFI_HANDLE HostBridge,
IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PHASE Phase,
IN EFI_PCI_EXECUTION_PHASE ExecPhase
)
);
};

struct MockPciPlatformPreprocessController {
MOCK_INTERFACE_DECLARATION (MockPciPlatformPreprocessController);
MOCK_FUNCTION_DECLARATION (
EFI_STATUS,
MockPlatformPrepController,
(
IN EFI_PCI_PLATFORM_PROTOCOL *This,
IN EFI_HANDLE HostBridge,
IN EFI_HANDLE RootBridge,
IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_PCI_ADDRESS PciAddress,
IN EFI_PCI_CONTROLLER_RESOURCE_ALLOCATION_PHASE Phase,
IN EFI_PCI_EXECUTION_PHASE ExecPhase
)
);
};

struct MockPciPlatformGetPlatformPolicy {
MOCK_INTERFACE_DECLARATION (MockPciPlatformGetPlatformPolicy);
MOCK_FUNCTION_DECLARATION (
EFI_STATUS,
MockGetPlatformPolicy,
(
IN CONST EFI_PCI_PLATFORM_PROTOCOL *This,
OUT EFI_PCI_PLATFORM_POLICY *PciPolicy
)
);
};

struct MockPciPlatformGetPciRom {
MOCK_INTERFACE_DECLARATION (MockPciPlatformGetPciRom);
MOCK_FUNCTION_DECLARATION (
EFI_STATUS,
MockGetPciRom,
(
IN CONST EFI_PCI_PLATFORM_PROTOCOL *This,
IN EFI_HANDLE PciHandle,
OUT VOID **RomImage,
OUT UINTN *RomSize
)
);
};

MOCK_INTERFACE_DEFINITION (MockPciPlatformPhaseNotify);
MOCK_FUNCTION_DEFINITION (MockPciPlatformPhaseNotify, MockPlatformNotify, 4, EFIAPI);
MOCK_INTERFACE_DEFINITION (MockPciPlatformPreprocessController);
MOCK_FUNCTION_DEFINITION (MockPciPlatformPreprocessController, MockPlatformPrepController, 6, EFIAPI);
MOCK_INTERFACE_DEFINITION (MockPciPlatformGetPlatformPolicy);
MOCK_FUNCTION_DEFINITION (MockPciPlatformGetPlatformPolicy, MockGetPlatformPolicy, 2, EFIAPI);
MOCK_INTERFACE_DEFINITION (MockPciPlatformGetPciRom);
MOCK_FUNCTION_DEFINITION (MockPciPlatformGetPciRom, MockGetPciRom, 4, EFIAPI);

EFI_PCI_PLATFORM_PROTOCOL EFI_PCI_PLATFORM_PROTOCOL_MOCK = {
MockPlatformNotify, // EFI_PCI_PLATFORM_PHASE_NOTIFY
MockPlatformPrepController, // EFI_PCI_PLATFORM_PREPROCESS_CONTROLLER
MockGetPlatformPolicy, // EFI_PCI_PLATFORM_GET_PLATFORM_POLICY
MockGetPciRom, // EFI_PCI_PLATFORM_GET_PCI_ROM
};

extern "C" {
extern EFI_PCI_PLATFORM_PROTOCOL *gPciPlatformProtocol = &EFI_PCI_PLATFORM_PROTOCOL_MOCK;
}

#endif // MOCK_PCIPLATFORMPROTOCOL_H

0 comments on commit 15f9d44

Please sign in to comment.