+++ /dev/null
-/*++\r
-\r
-Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r
-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
-Module Name:\r
-\r
- DeviceIo.h\r
- \r
-Abstract:\r
-\r
- Private Data definition for Device IO driver\r
-\r
---*/\r
-\r
-#ifndef _DEVICE_IO_H\r
-#define _DEVICE_IO_H\r
-\r
-\r
-\r
-#define DEVICE_IO_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('d', 'e', 'v', 'I')\r
-\r
-#define MAX_COMMON_BUFFER 0x00000000FFFFFFFF\r
-\r
-typedef struct {\r
- UINTN Signature;\r
- EFI_HANDLE Handle;\r
- EFI_DEVICE_IO_PROTOCOL DeviceIo;\r
- EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *PciRootBridgeIo;\r
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
- UINT16 PrimaryBus;\r
- UINT16 SubordinateBus;\r
-} DEVICE_IO_PRIVATE_DATA;\r
-\r
-#define DEVICE_IO_PRIVATE_DATA_FROM_THIS(a) CR (a, DEVICE_IO_PRIVATE_DATA, DeviceIo, DEVICE_IO_PRIVATE_DATA_SIGNATURE)\r
-\r
-EFI_STATUS\r
-DeviceIoConstructor (\r
- IN EFI_HANDLE Handle,\r
- IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *PciRootBridgeIo,\r
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r
- IN UINT16 PrimaryBus,\r
- IN UINT16 SubordinateBus\r
- )\r
-/*++\r
-\r
-Routine Description:\r
-\r
- Initialize and install a Device IO protocol on a empty device path handle.\r
-\r
-Arguments:\r
-\r
- Handle - Handle of PCI RootBridge IO instance\r
- PciRootBridgeIo - PCI RootBridge IO instance\r
- DevicePath - Device Path of PCI RootBridge IO instance\r
- PrimaryBus - Primary Bus\r
- SubordinateBus - Subordinate Bus\r
-\r
-Returns:\r
-\r
- EFI_SUCCESS - This driver is added to ControllerHandle. \r
- EFI_ALREADY_STARTED - This driver is already running on ControllerHandle. \r
- Others - This driver does not support this device.\r
-\r
---*/\r
-;\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-DeviceIoMemRead (\r
- IN EFI_DEVICE_IO_PROTOCOL *This,\r
- IN EFI_IO_WIDTH Width,\r
- IN UINT64 Address,\r
- IN UINTN Count,\r
- IN OUT VOID *Buffer\r
- )\r
-/*++\r
-\r
-Routine Description:\r
- \r
- Perform reading memory mapped I/O space of device.\r
-\r
-Arguments:\r
- \r
- This - A pointer to EFI_DEVICE_IO protocol instance. \r
- Width - Width of I/O operations.\r
- Address - The base address of I/O operations. \r
- Count - The number of I/O operations to perform. \r
- Bytes moves is Width size * Count, starting at Address. \r
- Buffer - The destination buffer to store results.\r
-\r
-Returns:\r
- \r
- EFI_SUCCESS - The data was read from the device. \r
- EFI_INVALID_PARAMETER - Width is invalid.\r
- EFI_OUT_OF_RESOURCES - The request could not be completed due to lack of resources.\r
-\r
---*/\r
-;\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-DeviceIoMemWrite (\r
- IN EFI_DEVICE_IO_PROTOCOL *This,\r
- IN EFI_IO_WIDTH Width,\r
- IN UINT64 Address,\r
- IN UINTN Count,\r
- IN OUT VOID *Buffer\r
- )\r
-/*++\r
-\r
-Routine Description:\r
- \r
- Perform writing memory mapped I/O space of device.\r
-\r
-Arguments:\r
- \r
- This - A pointer to EFI_DEVICE_IO protocol instance. \r
- Width - Width of I/O operations. \r
- Address - The base address of I/O operations. \r
- Count - The number of I/O operations to perform. \r
- Bytes moves is Width size * Count, starting at Address. \r
- Buffer - The source buffer of data to be written.\r
-\r
-Returns:\r
- \r
- EFI_SUCCESS - The data was written to the device.\r
- EFI_INVALID_PARAMETER - Width is invalid.\r
- EFI_OUT_OF_RESOURCES - The request could not be completed due to lack of resources.\r
-\r
---*/\r
-;\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-DeviceIoIoRead (\r
- IN EFI_DEVICE_IO_PROTOCOL *This,\r
- IN EFI_IO_WIDTH Width,\r
- IN UINT64 Address,\r
- IN UINTN Count,\r
- IN OUT VOID *Buffer\r
- )\r
-/*++\r
-\r
-Routine Description:\r
- \r
- Perform reading I/O space of device.\r
-\r
-Arguments:\r
- \r
- This - A pointer to EFI_DEVICE_IO protocol instance. \r
- Width - Width of I/O operations.\r
- Address - The base address of I/O operations. \r
- Count - The number of I/O operations to perform. \r
- Bytes moves is Width size * Count, starting at Address. \r
- Buffer - The destination buffer to store results.\r
-\r
-Returns:\r
- \r
- EFI_SUCCESS - The data was read from the device.\r
- EFI_INVALID_PARAMETER - Width is invalid.\r
- EFI_OUT_OF_RESOURCES - The request could not be completed due to lack of resources.\r
-\r
---*/\r
-;\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-DeviceIoIoWrite (\r
- IN EFI_DEVICE_IO_PROTOCOL *This,\r
- IN EFI_IO_WIDTH Width,\r
- IN UINT64 Address,\r
- IN UINTN Count,\r
- IN OUT VOID *Buffer\r
- )\r
-/*++\r
-\r
-Routine Description:\r
- \r
- Perform writing I/O space of device.\r
-\r
-Arguments:\r
- \r
- This - A pointer to EFI_DEVICE_IO protocol instance. \r
- Width - Width of I/O operations.\r
- Address - The base address of I/O operations.\r
- Count - The number of I/O operations to perform. \r
- Bytes moves is Width size * Count, starting at Address. \r
- Buffer - The source buffer of data to be written.\r
-\r
-Returns:\r
- \r
- EFI_SUCCESS - The data was written to the device.\r
- EFI_INVALID_PARAMETER - Width is invalid.\r
- EFI_OUT_OF_RESOURCES - The request could not be completed due to lack of resources.\r
-\r
---*/\r
-;\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-DeviceIoPciRead (\r
- IN EFI_DEVICE_IO_PROTOCOL *This,\r
- IN EFI_IO_WIDTH Width,\r
- IN UINT64 Address,\r
- IN UINTN Count,\r
- IN OUT VOID *Buffer\r
- )\r
-/*++\r
-\r
-Routine Description:\r
- \r
- Perform reading PCI configuration space of device\r
-\r
-Arguments:\r
- \r
- This - A pointer to EFI_DEVICE_IO protocol instance. \r
- Width - Width of I/O operations. \r
- Address - The base address of I/O operations. \r
- Count - The number of I/O operations to perform. \r
- Bytes moves is Width size * Count, starting at Address. \r
- Buffer - The destination buffer to store results.\r
-\r
-Returns:\r
- \r
- EFI_SUCCESS - The data was read from the device.\r
- EFI_INVALID_PARAMETER - Width is invalid.\r
- EFI_OUT_OF_RESOURCES - The request could not be completed due to lack of resources.\r
-\r
---*/\r
-;\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-DeviceIoPciWrite (\r
- IN EFI_DEVICE_IO_PROTOCOL *This,\r
- IN EFI_IO_WIDTH Width,\r
- IN UINT64 Address,\r
- IN UINTN Count,\r
- IN OUT VOID *Buffer\r
- )\r
-/*++\r
-\r
-Routine Description:\r
- \r
- Perform writing PCI configuration space of device.\r
-\r
-Arguments:\r
- \r
- This - A pointer to EFI_DEVICE_IO protocol instance. \r
- Width - Width of I/O operations. \r
- Address - The base address of I/O operations. \r
- Count - The number of I/O operations to perform. \r
- Bytes moves is Width size * Count, starting at Address. \r
- Buffer - The source buffer of data to be written.\r
-\r
-Returns:\r
- \r
- EFI_SUCCESS - The data was written to the device.\r
- EFI_INVALID_PARAMETER - Width is invalid.\r
- EFI_OUT_OF_RESOURCES - The request could not be completed due to lack of resources.\r
-\r
---*/\r
-;\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-DeviceIoPciDevicePath (\r
- IN EFI_DEVICE_IO_PROTOCOL *This,\r
- IN UINT64 Address,\r
- IN OUT EFI_DEVICE_PATH_PROTOCOL **PciDevicePath\r
- )\r
-/*++\r
-\r
-Routine Description:\r
- \r
- Append a PCI device path node to another device path.\r
-\r
-Arguments:\r
- \r
- This - A pointer to EFI_DEVICE_IO_PROTOCOL. \r
- Address - PCI bus,device, function.\r
- PciDevicePath - PCI device path.\r
-\r
-Returns:\r
- \r
- Pointer to the appended PCI device path.\r
-\r
---*/\r
-;\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-DeviceIoMap (\r
- IN EFI_DEVICE_IO_PROTOCOL *This,\r
- IN EFI_IO_OPERATION_TYPE Operation,\r
- IN EFI_PHYSICAL_ADDRESS *HostAddress,\r
- IN OUT UINTN *NumberOfBytes,\r
- OUT EFI_PHYSICAL_ADDRESS *DeviceAddress,\r
- OUT VOID **Mapping\r
- )\r
-/*++\r
-\r
-Routine Description:\r
- \r
- Provides the device-specific addresses needed to access system memory.\r
-\r
-Arguments:\r
- \r
- This - A pointer to the EFI_DEVICE_IO_INTERFACE instance. \r
- Operation - Indicates if the bus master is going to read or write to system memory. \r
- HostAddress - The system memory address to map to the device.\r
- NumberOfBytes - On input the number of bytes to map. On output the number of bytes\r
- that were mapped.\r
- DeviceAddress - The resulting map address for the bus master device to use to access the\r
- hosts HostAddress.\r
- Mapping - A resulting value to pass to Unmap().\r
-\r
-Returns:\r
- \r
- EFI_SUCCESS - The range was mapped for the returned NumberOfBytes. \r
- EFI_INVALID_PARAMETER - The Operation or HostAddress is undefined. \r
- EFI_UNSUPPORTED - The HostAddress cannot be mapped as a common buffer.\r
- EFI_DEVICE_ERROR - The system hardware could not map the requested address. \r
- EFI_OUT_OF_RESOURCES - The request could not be completed due to a lack of resources.\r
-\r
---*/\r
-;\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-DeviceIoUnmap (\r
- IN EFI_DEVICE_IO_PROTOCOL *This,\r
- IN VOID *Mapping\r
- )\r
-/*++\r
-\r
-Routine Description:\r
- \r
- Completes the Map() operation and releases any corresponding resources.\r
-\r
-Arguments:\r
- \r
- This - A pointer to the EFI_DEVICE_IO_INTERFACE instance.\r
- Mapping - The mapping value returned from Map().\r
-\r
-Returns:\r
- \r
- EFI_SUCCESS - The range was unmapped.\r
- EFI_DEVICE_ERROR - The data was not committed to the target system memory.\r
-\r
---*/\r
-;\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-DeviceIoAllocateBuffer (\r
- IN EFI_DEVICE_IO_PROTOCOL *This,\r
- IN EFI_ALLOCATE_TYPE Type,\r
- IN EFI_MEMORY_TYPE MemoryType,\r
- IN UINTN Pages,\r
- IN OUT EFI_PHYSICAL_ADDRESS *HostAddress\r
- )\r
-/*++\r
-\r
-Routine Description:\r
- \r
- Allocates pages that are suitable for an EFIBusMasterCommonBuffer mapping.\r
-\r
-Arguments:\r
- \r
- This - A pointer to the EFI_DEVICE_IO_INTERFACE instance.\r
- Type - The type allocation to perform.\r
- MemoryType - The type of memory to allocate, EfiBootServicesData or\r
- EfiRuntimeServicesData.\r
- Pages - The number of pages to allocate.\r
- HostAddress - A pointer to store the base address of the allocated range.\r
-\r
-Returns:\r
- \r
- EFI_SUCCESS - The requested memory pages were allocated.\r
- EFI_OUT_OF_RESOURCES - The memory pages could not be allocated.\r
- EFI_INVALID_PARAMETER - The requested memory type is invalid.\r
- EFI_UNSUPPORTED - The requested PhysicalAddress is not supported on\r
- this platform.\r
-\r
---*/\r
-;\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-DeviceIoFlush (\r
- IN EFI_DEVICE_IO_PROTOCOL *This\r
- )\r
-/*++\r
-\r
-Routine Description:\r
- \r
- Flushes any posted write data to the device.\r
-\r
-Arguments:\r
- \r
- This - A pointer to the EFI_DEVICE_IO_INTERFACE instance.\r
-\r
-Returns:\r
- \r
- EFI_SUCCESS - The buffers were flushed.\r
- EFI_DEVICE_ERROR - The buffers were not flushed due to a hardware error.\r
-\r
---*/\r
-;\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-DeviceIoFreeBuffer (\r
- IN EFI_DEVICE_IO_PROTOCOL *This,\r
- IN UINTN Pages,\r
- IN EFI_PHYSICAL_ADDRESS HostAddress\r
- )\r
-/*++\r
-\r
-Routine Description:\r
- \r
- Frees pages that were allocated with AllocateBuffer().\r
-\r
-Arguments:\r
- \r
- This - A pointer to the EFI_DEVICE_IO_INTERFACE instance.\r
- Pages - The number of pages to free.\r
- HostAddress - The base address of the range to free.\r
-\r
-Returns:\r
- \r
- EFI_SUCCESS - The requested memory pages were freed.\r
- EFI_NOT_FOUND - The requested memory pages were not allocated with\r
- AllocateBuffer(). \r
- EFI_INVALID_PARAMETER - HostAddress is not page aligned or Pages is invalid.\r
-\r
---*/\r
-;\r
-\r
-#endif\r
-\r