3 Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #ifndef _PCI_ROOT_BRIDGE_H_
16 #define _PCI_ROOT_BRIDGE_H_
22 #include <Library/BaseLib.h>
23 #include <Library/BaseMemoryLib.h>
24 #include <Library/DebugLib.h>
25 #include <Library/DxeServicesTableLib.h>
26 #include <Library/IoLib.h>
27 #include <Library/MemoryAllocationLib.h>
28 #include <Library/PciLib.h>
29 #include <Library/UefiLib.h>
30 #include <Library/UefiBootServicesTableLib.h>
31 #include <Library/OmapDmaLib.h>
33 #include <Protocol/EmbeddedExternalDevice.h>
34 #include <Protocol/DevicePath.h>
35 #include <Protocol/PciIo.h>
36 #include <Protocol/PciRootBridgeIo.h>
37 #include <Protocol/PciHostBridgeResourceAllocation.h>
39 #include <IndustryStandard/Pci22.h>
40 #include <IndustryStandard/Acpi.h>
42 #include <Omap3530/Omap3530.h>
46 #define EFI_RESOURCE_NONEXISTENT 0xFFFFFFFFFFFFFFFFULL
47 #define EFI_RESOURCE_LESS 0xFFFFFFFFFFFFFFFEULL
48 #define EFI_RESOURCE_SATISFIED 0x0000000000000000ULL
52 ACPI_HID_DEVICE_PATH AcpiDevicePath
;
53 EFI_DEVICE_PATH_PROTOCOL EndDevicePath
;
54 } EFI_PCI_ROOT_BRIDGE_DEVICE_PATH
;
57 #define ACPI_CONFIG_IO 0
58 #define ACPI_CONFIG_MMIO 1
59 #define ACPI_CONFIG_BUS 2
62 EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR Desc
[3];
63 EFI_ACPI_END_TAG_DESCRIPTOR EndDesc
;
67 #define PCI_ROOT_BRIDGE_SIGNATURE SIGNATURE_32 ('P', 'c', 'i', 'F')
72 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL Io
;
73 EFI_PCI_ROOT_BRIDGE_DEVICE_PATH DevicePath
;
85 ACPI_CONFIG_INFO
*Config
;
90 #define INSTANCE_FROM_PCI_ROOT_BRIDGE_IO_THIS(a) CR (a, PCI_ROOT_BRIDGE, Io, PCI_ROOT_BRIDGE_SIGNATURE)
96 UINT16
volatile *ui16
;
97 UINT32
volatile *ui32
;
98 UINT64
volatile *ui64
;
106 PciRootBridgeIoPollMem (
107 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*This
,
108 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width
,
118 PciRootBridgeIoPollIo (
119 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*This
,
120 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width
,
130 PciRootBridgeIoMemRead (
131 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*This
,
132 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width
,
140 PciRootBridgeIoMemWrite (
141 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*This
,
142 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width
,
150 PciRootBridgeIoIoRead (
151 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*This
,
152 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width
,
153 IN UINT64 UserAddress
,
155 IN OUT VOID
*UserBuffer
160 PciRootBridgeIoIoWrite (
161 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*This
,
162 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width
,
163 IN UINT64 UserAddress
,
165 IN OUT VOID
*UserBuffer
170 PciRootBridgeIoCopyMem (
171 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*This
,
172 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width
,
173 IN UINT64 DestAddress
,
174 IN UINT64 SrcAddress
,
180 PciRootBridgeIoPciRead (
181 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*This
,
182 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width
,
190 PciRootBridgeIoPciWrite (
191 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*This
,
192 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width
,
201 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*This
,
202 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_OPERATION Operation
,
203 IN VOID
*HostAddress
,
204 IN OUT UINTN
*NumberOfBytes
,
205 OUT EFI_PHYSICAL_ADDRESS
*DeviceAddress
,
211 PciRootBridgeIoUnmap (
212 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*This
,
218 PciRootBridgeIoAllocateBuffer (
219 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*This
,
220 IN EFI_ALLOCATE_TYPE Type
,
221 IN EFI_MEMORY_TYPE MemoryType
,
223 OUT VOID
**HostAddress
,
229 PciRootBridgeIoFreeBuffer (
230 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*This
,
232 OUT VOID
*HostAddress
237 PciRootBridgeIoFlush (
238 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*This
243 PciRootBridgeIoGetAttributes (
244 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*This
,
245 OUT UINT64
*Supported
,
246 OUT UINT64
*Attributes
251 PciRootBridgeIoSetAttributes (
252 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*This
,
253 IN UINT64 Attributes
,
254 IN OUT UINT64
*ResourceBase
,
255 IN OUT UINT64
*ResourceLength
260 PciRootBridgeIoConfiguration (
261 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL
*This
,
266 // Private Function Prototypes
270 PciRootBridgeIoMemRW (
271 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width
,
273 IN BOOLEAN InStrideFlag
,
275 IN BOOLEAN OutStrideFlag
,
280 PciIoMemAddressValid (
281 IN EFI_PCI_IO_PROTOCOL
*This
,
286 EmulatePciIoForEhci (