diff --git a/MdePkg/Test/Mock/Include/GoogleTest/Protocol/MockPciRootBridgeIoProtocol.h b/MdePkg/Test/Mock/Include/GoogleTest/Protocol/MockPciRootBridgeIoProtocol.h index 800c540cba..fade525cc4 100644 --- a/MdePkg/Test/Mock/Include/GoogleTest/Protocol/MockPciRootBridgeIoProtocol.h +++ b/MdePkg/Test/Mock/Include/GoogleTest/Protocol/MockPciRootBridgeIoProtocol.h @@ -11,7 +11,8 @@ #include #include -extern "C" { +extern "C" +{ #include #include } @@ -19,52 +20,245 @@ extern "C" { // // Declarations to handle usage of the Pci Root Bridge Io Protocol by creating mock // +struct MockPciRootBridgeIoPollIoMem { + MOCK_INTERFACE_DECLARATION (MockPciRootBridgeIoPollIoMem); + MOCK_FUNCTION_DECLARATION ( + EFI_STATUS, + MockPciRootBridgePollMem, + (IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL * This, + IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width, + IN UINT64 Address, + IN UINT64 Mask, + IN UINT64 Value, + IN UINT64 Delay, + OUT UINT64 *Result) + ); + MOCK_FUNCTION_DECLARATION ( + EFI_STATUS, + MockPciRootBridgePollIo, + (IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL * This, + IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width, + IN UINT64 Address, + IN UINT64 Mask, + IN UINT64 Value, + IN UINT64 Delay, + OUT UINT64 *Result) + ); +}; + struct MockPciRootBridgeIoConfigAccess { MOCK_INTERFACE_DECLARATION (MockPciRootBridgeIoConfigAccess); + MOCK_FUNCTION_DECLARATION ( + EFI_STATUS, + MockPciRootBridgeMemRead, + (IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL * This, + IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width, + IN UINT64 Address, + IN UINTN Count, + IN OUT VOID *Buffer) + ); + MOCK_FUNCTION_DECLARATION ( + EFI_STATUS, + MockPciRootBridgeMemWrite, + (IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL * This, + IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width, + IN UINT64 Address, + IN UINTN Count, + IN OUT VOID *Buffer) + ); MOCK_FUNCTION_DECLARATION ( EFI_STATUS, MockPciRootBridgeIoRead, - (IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This, - IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width, - IN UINT64 Address, - IN UINTN Count, - IN OUT VOID *Buffer) + (IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL * This, + IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width, + IN UINT64 Address, + IN UINTN Count, + IN OUT VOID *Buffer) ); MOCK_FUNCTION_DECLARATION ( EFI_STATUS, MockPciRootBridgeIoWrite, + (IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL * This, + IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width, + IN UINT64 Address, + IN UINTN Count, + IN OUT VOID *Buffer) + ); + + MOCK_FUNCTION_DECLARATION ( + EFI_STATUS, + MockPciRootBridgePciRead, + (IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL * This, + IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width, + IN UINT64 Address, + IN UINTN Count, + IN OUT VOID *Buffer) + ); + MOCK_FUNCTION_DECLARATION ( + EFI_STATUS, + MockPciRootBridgePciWrite, + (IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL * This, + IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width, + IN UINT64 Address, + IN UINTN Count, + IN OUT VOID *Buffer) + ); +}; + +struct MockPciRootBridgeIoCopyMem { + MOCK_INTERFACE_DECLARATION (MockPciRootBridgeIoCopyMem); + MOCK_FUNCTION_DECLARATION ( + EFI_STATUS, + MockPciRootBridgeCopyMem, + (IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL * This, + IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width, + IN UINT64 DestAddress, + IN UINT64 SrcAddress, + IN UINTN Count) + ); +}; + +struct MockPciRootBridgeIoMap { + MOCK_INTERFACE_DECLARATION (MockPciRootBridgeIoMap); + MOCK_FUNCTION_DECLARATION ( + EFI_STATUS, + MockPciRootBridgeMap, + (IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL * This, + IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_OPERATION Operation, + IN VOID *HostAddress, + IN OUT UINTN *NumberOfBytes, + OUT EFI_PHYSICAL_ADDRESS *DeviceAddress, + OUT VOID **Mapping) + ); +}; + +struct MockPciRootBridgeIoUnMap { + MOCK_INTERFACE_DECLARATION (MockPciRootBridgeIoUnMap); + MOCK_FUNCTION_DECLARATION ( + EFI_STATUS, + MockPciRootBridgeUnMap, + (IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This, + IN VOID *Mapping) + ); +}; + +struct MockPciRootBridgeIoAllocateBuffer { + MOCK_INTERFACE_DECLARATION (MockPciRootBridgeIoAllocateBuffer); + MOCK_FUNCTION_DECLARATION ( + EFI_STATUS, + MockPciRootBridgeAllocateBuffer, + (IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This, + IN EFI_ALLOCATE_TYPE Type, + IN EFI_MEMORY_TYPE MemoryType, + IN UINTN Pages, + IN OUT VOID **HostAddress, + IN UINT64 Attributes) + ); +}; + +struct MockPciRootBridgeIoFreeBuffer { + MOCK_INTERFACE_DECLARATION (MockPciRootBridgeIoFreeBuffer); + MOCK_FUNCTION_DECLARATION ( + EFI_STATUS, + MockPciRootBridgeFreeBuffer, + (IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This, + IN UINTN Pages, + IN VOID *HostAddress) + ); +}; + +struct MockPciRootBridgeIoFlush { + MOCK_INTERFACE_DECLARATION (MockPciRootBridgeIoFlush); + MOCK_FUNCTION_DECLARATION ( + EFI_STATUS, + MockPciRootBridgeFlush, + (IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This) + ); +}; + +struct MockPciRootBridgeIoGetAttributes { + MOCK_INTERFACE_DECLARATION (MockPciRootBridgeIoGetAttributes); + MOCK_FUNCTION_DECLARATION ( + EFI_STATUS, + MockPciRootBridgeGetAttributes, + (IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This, + OUT UINT64 *Supports, + OUT UINT64 *Attributes) + ); +}; + +struct MockPciRootBridgeIoSetAttributes { + MOCK_INTERFACE_DECLARATION (MockPciRootBridgeIoSetAttributes); + MOCK_FUNCTION_DECLARATION ( + EFI_STATUS, + MockPciRootBridgeSetAttributes, (IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This, - IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width, - IN UINT64 Address, - IN UINTN Count, - IN OUT VOID *Buffer) + IN UINT64 Attributes, + IN OUT UINT64 *ResourceBase, + IN OUT UINT64 *ResourceLength) + ); +}; + +struct MockPciRootBridgeIoConfiguration { + MOCK_INTERFACE_DECLARATION (MockPciRootBridgeIoConfiguration); + MOCK_FUNCTION_DECLARATION ( + EFI_STATUS, + MockPciRootBridgeConfiguration, + (IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This, + OUT VOID **Resources) ); }; +MOCK_INTERFACE_DEFINITION (MockPciRootBridgeIoPollIoMem); +MOCK_FUNCTION_DEFINITION (MockPciRootBridgeIoPollIoMem, MockPciRootBridgePollMem, 7, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockPciRootBridgeIoPollIoMem, MockPciRootBridgePollIo, 7, EFIAPI); MOCK_INTERFACE_DEFINITION (MockPciRootBridgeIoConfigAccess); +MOCK_FUNCTION_DEFINITION (MockPciRootBridgeIoConfigAccess, MockPciRootBridgeMemRead, 5, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockPciRootBridgeIoConfigAccess, MockPciRootBridgeMemWrite, 5, EFIAPI); MOCK_FUNCTION_DEFINITION (MockPciRootBridgeIoConfigAccess, MockPciRootBridgeIoRead, 5, EFIAPI); MOCK_FUNCTION_DEFINITION (MockPciRootBridgeIoConfigAccess, MockPciRootBridgeIoWrite, 5, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockPciRootBridgeIoConfigAccess, MockPciRootBridgePciRead, 5, EFIAPI); +MOCK_FUNCTION_DEFINITION (MockPciRootBridgeIoConfigAccess, MockPciRootBridgePciWrite, 5, EFIAPI); +MOCK_INTERFACE_DEFINITION (MockPciRootBridgeIoCopyMem); +MOCK_FUNCTION_DEFINITION (MockPciRootBridgeIoCopyMem, MockPciRootBridgeCopyMem, 5, EFIAPI); +MOCK_INTERFACE_DEFINITION (MockPciRootBridgeIoMap); +MOCK_FUNCTION_DEFINITION (MockPciRootBridgeIoMap, MockPciRootBridgeMap, 6, EFIAPI); +MOCK_INTERFACE_DEFINITION (MockPciRootBridgeIoUnMap); +MOCK_FUNCTION_DEFINITION (MockPciRootBridgeIoUnMap, MockPciRootBridgeUnMap, 2, EFIAPI); +MOCK_INTERFACE_DEFINITION (MockPciRootBridgeIoAllocateBuffer); +MOCK_FUNCTION_DEFINITION (MockPciRootBridgeIoAllocateBuffer, MockPciRootBridgeAllocateBuffer, 6, EFIAPI); +MOCK_INTERFACE_DEFINITION (MockPciRootBridgeIoFreeBuffer); +MOCK_FUNCTION_DEFINITION (MockPciRootBridgeIoFreeBuffer, MockPciRootBridgeFreeBuffer, 3, EFIAPI); +MOCK_INTERFACE_DEFINITION (MockPciRootBridgeIoFlush); +MOCK_FUNCTION_DEFINITION (MockPciRootBridgeIoFlush, MockPciRootBridgeFlush, 1, EFIAPI); +MOCK_INTERFACE_DEFINITION (MockPciRootBridgeIoGetAttributes); +MOCK_FUNCTION_DEFINITION (MockPciRootBridgeIoGetAttributes, MockPciRootBridgeGetAttributes, 3, EFIAPI); +MOCK_INTERFACE_DEFINITION (MockPciRootBridgeIoSetAttributes); +MOCK_FUNCTION_DEFINITION (MockPciRootBridgeIoSetAttributes, MockPciRootBridgeSetAttributes, 4, EFIAPI); +MOCK_INTERFACE_DEFINITION (MockPciRootBridgeIoConfiguration); +MOCK_FUNCTION_DEFINITION (MockPciRootBridgeIoConfiguration, MockPciRootBridgeConfiguration, 2, EFIAPI); EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL PCI_ROOT_BRIDGE_IO_PROTOCOL_MOCK = { - NULL, // EFI_HANDLE ParentHandle; - NULL, // EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_POLL_IO_MEM PollMem; - NULL, // EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_POLL_IO_MEM PollIo; - { NULL, NULL }, // EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_ACCESS Mem; - { NULL, NULL }, // EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_ACCESS Io; - { MockPciRootBridgeIoRead, MockPciRootBridgeIoWrite }, // EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_ACCESS Pci; - NULL, // EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_COPY_MEM CopyMem; - NULL, // EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_MAP Map; - NULL, // EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_UNMAP Unmap; - NULL, // EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_ALLOCATE_BUFFER AllocateBuffer; - NULL, // EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_FREE_BUFFER FreeBuffer; - NULL, // EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_FLUSH Flush; - NULL, // EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_GET_ATTRIBUTES GetAttributes; - NULL, // EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_SET_ATTRIBUTES SetAttributes; - NULL, // EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_CONFIGURATION Configuration; + NULL, // EFI_HANDLE ParentHandle; + MockPciRootBridgePollMem, // EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_POLL_IO_MEM PollMem; + MockPciRootBridgePollIo, // EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_POLL_IO_MEM PollIo; + { MockPciRootBridgeMemRead, MockPciRootBridgeMemWrite }, // EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_ACCESS Mem; + { MockPciRootBridgeIoRead, MockPciRootBridgeIoWrite }, // EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_ACCESS Io; + { MockPciRootBridgePciRead, MockPciRootBridgePciWrite }, // EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_ACCESS Pci; + MockPciRootBridgeCopyMem, // EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_COPY_MEM CopyMem; + MockPciRootBridgeMap, // EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_MAP Map; + MockPciRootBridgeUnMap, // EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_UNMAP Unmap; + MockPciRootBridgeAllocateBuffer, // EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_ALLOCATE_BUFFER AllocateBuffer; + MockPciRootBridgeFreeBuffer, // EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_FREE_BUFFER FreeBuffer; + MockPciRootBridgeFlush, // EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_FLUSH Flush; + MockPciRootBridgeGetAttributes, // EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_GET_ATTRIBUTES GetAttributes; + MockPciRootBridgeSetAttributes, // EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_SET_ATTRIBUTES SetAttributes; + MockPciRootBridgeConfiguration, // EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_CONFIGURATION Configuration; }; -extern "C" { +extern "C" +{ extern EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *gPciRootBridgeIoProtocol = &PCI_ROOT_BRIDGE_IO_PROTOCOL_MOCK; }