]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Omap35xxPkg/PciEmulation/PciEmulation.h
Moving OMAP 3530 code out of BeagleBoard package into its own package
[mirror_edk2.git] / Omap35xxPkg / PciEmulation / PciEmulation.h
diff --git a/Omap35xxPkg/PciEmulation/PciEmulation.h b/Omap35xxPkg/PciEmulation/PciEmulation.h
new file mode 100644 (file)
index 0000000..c19cd8c
--- /dev/null
@@ -0,0 +1,305 @@
+/** @file\r
+\r
+  Copyright (c) 2008-2009 Apple Inc. All rights reserved.<BR>\r
+\r
+  All rights reserved. This program and the accompanying materials\r
+  are licensed and made available under the terms and conditions of the BSD License\r
+  which accompanies this distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#ifndef _PCI_ROOT_BRIDGE_H_\r
+#define _PCI_ROOT_BRIDGE_H_\r
+\r
+#include <PiDxe.h>\r
+\r
+#include <TPS65950.h>\r
+\r
+#include <Library/BaseLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/DxeServicesTableLib.h>\r
+#include <Library/IoLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+#include <Library/PciLib.h>\r
+#include <Library/UefiLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/UncachedMemoryAllocationLib.h>\r
+\r
+#include <Protocol/EmbeddedExternalDevice.h>\r
+#include <Protocol/Cpu.h>\r
+#include <Protocol/DevicePath.h>\r
+#include <Protocol/PciIo.h>\r
+#include <Protocol/PciRootBridgeIo.h>\r
+#include <Protocol/PciHostBridgeResourceAllocation.h>\r
+\r
+#include <IndustryStandard/Pci22.h>\r
+#include <IndustryStandard/Acpi.h>\r
+\r
+extern EFI_CPU_ARCH_PROTOCOL  *gCpu;\r
+\r
+#define EFI_RESOURCE_NONEXISTENT  0xFFFFFFFFFFFFFFFFULL\r
+#define EFI_RESOURCE_LESS         0xFFFFFFFFFFFFFFFEULL\r
+#define EFI_RESOURCE_SATISFIED    0x0000000000000000ULL\r
+\r
+\r
+typedef struct {\r
+  ACPI_HID_DEVICE_PATH      AcpiDevicePath;\r
+  EFI_DEVICE_PATH_PROTOCOL  EndDevicePath;\r
+} EFI_PCI_ROOT_BRIDGE_DEVICE_PATH;\r
+\r
+\r
+#define ACPI_CONFIG_IO    0\r
+#define ACPI_CONFIG_MMIO  1\r
+#define ACPI_CONFIG_BUS   2\r
+\r
+typedef struct {\r
+  EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR Desc[3];\r
+  EFI_ACPI_END_TAG_DESCRIPTOR       EndDesc;\r
+} ACPI_CONFIG_INFO;\r
+\r
+\r
+#define PCI_ROOT_BRIDGE_SIGNATURE SIGNATURE_32 ('P', 'c', 'i', 'F')\r
+\r
+typedef struct {\r
+  UINT32                                            Signature;\r
+  EFI_HANDLE                                        Handle;\r
+  EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL                   Io;\r
+  EFI_PCI_ROOT_BRIDGE_DEVICE_PATH                   DevicePath;\r
+  \r
+  UINT8   StartBus;\r
+  UINT8   EndBus;\r
+  UINT16  Type;\r
+  UINT32  MemoryStart;\r
+  UINT32  MemorySize;\r
+  UINTN   IoOffset;\r
+  UINT32  IoStart;\r
+  UINT32  IoSize;\r
+  UINT64  PciAttributes;  \r
+\r
+  ACPI_CONFIG_INFO  *Config;\r
+\r
+} PCI_ROOT_BRIDGE;\r
+\r
+\r
+#define INSTANCE_FROM_PCI_ROOT_BRIDGE_IO_THIS(a) CR (a, PCI_ROOT_BRIDGE, Io, PCI_ROOT_BRIDGE_SIGNATURE)\r
+\r
+\r
+typedef union {\r
+  UINT8   volatile  *buf;\r
+  UINT8   volatile  *ui8;\r
+  UINT16  volatile  *ui16;\r
+  UINT32  volatile  *ui32;\r
+  UINT64  volatile  *ui64;\r
+  UINTN   volatile  ui;\r
+} PTR;\r
+\r
+\r
+typedef struct {\r
+  EFI_PHYSICAL_ADDRESS                      HostAddress;\r
+  EFI_PHYSICAL_ADDRESS                      DeviceAddress;\r
+  UINTN                                     NumberOfBytes;\r
+  EFI_PCI_IO_PROTOCOL_OPERATION             Operation;\r
+  \r
+} MAP_INFO_INSTANCE;\r
+\r
+\r
+typedef struct {\r
+  EFI_PHYSICAL_ADDRESS                        HostAddress;\r
+  EFI_PHYSICAL_ADDRESS                        DeviceAddress;\r
+  UINTN                                       NumberOfBytes;\r
+  EFI_PCI_IO_PROTOCOL_OPERATION               Operation;\r
+} PCI_DMA_MAP;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+PciRootBridgeIoPollMem ( \r
+  IN  EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL        *This,\r
+  IN  EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH  Width,\r
+  IN  UINT64                                 Address,\r
+  IN  UINT64                                 Mask,\r
+  IN  UINT64                                 Value,\r
+  IN  UINT64                                 Delay,\r
+  OUT UINT64                                 *Result\r
+  );\r
+  \r
+EFI_STATUS\r
+EFIAPI\r
+PciRootBridgeIoPollIo ( \r
+  IN  EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL        *This,\r
+  IN  EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH  Width,\r
+  IN  UINT64                                 Address,\r
+  IN  UINT64                                 Mask,\r
+  IN  UINT64                                 Value,\r
+  IN  UINT64                                 Delay,\r
+  OUT UINT64                                 *Result\r
+  );\r
+  \r
+EFI_STATUS\r
+EFIAPI\r
+PciRootBridgeIoMemRead (\r
+  IN     EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL        *This,\r
+  IN     EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH  Width,\r
+  IN     UINT64                                 Address,\r
+  IN     UINTN                                  Count,\r
+  IN OUT VOID                                   *Buffer\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+PciRootBridgeIoMemWrite (\r
+  IN     EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL        *This,\r
+  IN     EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH  Width,\r
+  IN     UINT64                                 Address,\r
+  IN     UINTN                                  Count,\r
+  IN OUT VOID                                   *Buffer\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+PciRootBridgeIoIoRead (\r
+  IN     EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL        *This,\r
+  IN     EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH  Width,\r
+  IN     UINT64                                 UserAddress,\r
+  IN     UINTN                                  Count,\r
+  IN OUT VOID                                   *UserBuffer\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+PciRootBridgeIoIoWrite (\r
+  IN     EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL        *This,\r
+  IN     EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH  Width,\r
+  IN     UINT64                                 UserAddress,\r
+  IN     UINTN                                  Count,\r
+  IN OUT VOID                                   *UserBuffer\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+PciRootBridgeIoCopyMem (\r
+  IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL        *This,\r
+  IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH  Width,\r
+  IN UINT64                                 DestAddress,\r
+  IN UINT64                                 SrcAddress,\r
+  IN UINTN                                  Count\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+PciRootBridgeIoPciRead (\r
+  IN     EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL        *This,\r
+  IN     EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH  Width,\r
+  IN     UINT64                                 Address,\r
+  IN     UINTN                                  Count,\r
+  IN OUT VOID                                   *Buffer\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+PciRootBridgeIoPciWrite (\r
+  IN     EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL        *This,\r
+  IN     EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH  Width,\r
+  IN     UINT64                                 Address,\r
+  IN     UINTN                                  Count,\r
+  IN OUT VOID                                   *Buffer\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+PciRootBridgeIoMap (\r
+  IN     EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL            *This,\r
+  IN     EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_OPERATION  Operation,\r
+  IN     VOID                                       *HostAddress,\r
+  IN OUT UINTN                                      *NumberOfBytes,\r
+  OUT    EFI_PHYSICAL_ADDRESS                       *DeviceAddress,\r
+  OUT    VOID                                       **Mapping\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+PciRootBridgeIoUnmap (\r
+  IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL  *This,\r
+  IN VOID                             *Mapping\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+PciRootBridgeIoAllocateBuffer (\r
+  IN  EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL  *This,\r
+  IN  EFI_ALLOCATE_TYPE                Type,\r
+  IN  EFI_MEMORY_TYPE                  MemoryType,\r
+  IN  UINTN                            Pages,\r
+  OUT VOID                             **HostAddress,\r
+  IN  UINT64                           Attributes\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+PciRootBridgeIoFreeBuffer (\r
+  IN  EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL  *This,\r
+  IN  UINTN                            Pages,\r
+  OUT VOID                             *HostAddress\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+PciRootBridgeIoFlush (\r
+  IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL  *This\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+PciRootBridgeIoGetAttributes (\r
+  IN  EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL  *This,\r
+  OUT UINT64                           *Supported,\r
+  OUT UINT64                           *Attributes\r
+  );\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+PciRootBridgeIoSetAttributes (\r
+  IN     EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL  *This,\r
+  IN     UINT64                           Attributes,\r
+  IN OUT UINT64                           *ResourceBase,\r
+  IN OUT UINT64                           *ResourceLength \r
+  ); \r
+\r
+EFI_STATUS\r
+EFIAPI\r
+PciRootBridgeIoConfiguration (\r
+  IN  EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL  *This,\r
+  OUT VOID                             **Resources\r
+  );\r
+\r
+//\r
+// Private Function Prototypes\r
+//\r
+EFI_STATUS\r
+EFIAPI\r
+PciRootBridgeIoMemRW (\r
+  IN  EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH  Width,\r
+  IN  UINTN                                  Count,\r
+  IN  BOOLEAN                                InStrideFlag,\r
+  IN  PTR                                    In,\r
+  IN  BOOLEAN                                OutStrideFlag,\r
+  OUT PTR                                    Out\r
+  );\r
+\r
+BOOLEAN\r
+PciIoMemAddressValid (\r
+  IN EFI_PCI_IO_PROTOCOL  *This,\r
+  IN UINT64               Address\r
+  );\r
+\r
+EFI_STATUS\r
+EmulatePciIoForEhci (\r
+  INTN    MvPciIfMaxIf\r
+  );\r
+\r
+#endif\r
+\r