]> git.proxmox.com Git - mirror_edk2.git/blobdiff - OldMdePkg/Include/Protocol/DeviceIo.h
Moved the MdePkg to OldMdePkg so that new code in MdePkg does not break existing...
[mirror_edk2.git] / OldMdePkg / Include / Protocol / DeviceIo.h
diff --git a/OldMdePkg/Include/Protocol/DeviceIo.h b/OldMdePkg/Include/Protocol/DeviceIo.h
new file mode 100644 (file)
index 0000000..643c810
--- /dev/null
@@ -0,0 +1,222 @@
+/** @file\r
+  Device IO protocol as defined in the EFI 1.0 specification.\r
+\r
+  Device IO is used to abstract hardware access to devices. It includes\r
+  memory mapped IO, IO, PCI Config space, and DMA.\r
+\r
+  Copyright (c) 2006, Intel Corporation                                                         \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
+  Module Name:  DeviceIo.h\r
+\r
+**/\r
+\r
+#ifndef __DEVICE_IO_H__\r
+#define __DEVICE_IO_H__\r
+\r
+#define EFI_DEVICE_IO_PROTOCOL_GUID \\r
+  { \\r
+    0xaf6ac311, 0x84c3, 0x11d2, {0x8e, 0x3c, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b } \\r
+  }\r
+\r
+typedef struct _EFI_DEVICE_IO_PROTOCOL EFI_DEVICE_IO_PROTOCOL;\r
+\r
+typedef enum {\r
+  IO_UINT8,\r
+  IO_UINT16,\r
+  IO_UINT32,\r
+  IO_UINT64,\r
+  MMIO_COPY_UINT8,\r
+  MMIO_COPY_UINT16,\r
+  MMIO_COPY_UINT32,\r
+  MMIO_COPY_UINT64\r
+} EFI_IO_WIDTH;\r
+\r
+/**                                                                 \r
+  Enables a driver to access device registers in the appropriate memory or I/O space.\r
+    \r
+  @param  This                  A pointer to the EFI_DEVICE_IO_INTERFACE instance.\r
+  @param  Width                 Signifies the width of the I/O operations.                                                                   \r
+  @param  Address               The base address of the I/O operations. \r
+  @param  Count                 The number of I/O operations to perform.\r
+  @param  Buffer                For read operations, the destination buffer to store the results. For write\r
+                                operations, the source buffer to write data from.                \r
+\r
+  @retval EFI_SUCCESS           The data was read from or written to the device.\r
+  @retval EFI_OUT_OF_RESOURCES  The request could not be completed due to a lack of resources.      \r
+  @retval EFI_INVALID_PARAMETER Width is invalid.\r
+                                   \r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_DEVICE_IO) (\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
+typedef struct {\r
+  EFI_DEVICE_IO Read;\r
+  EFI_DEVICE_IO Write;\r
+} EFI_IO_ACCESS;\r
+\r
+/**                                                                 \r
+  Provides an EFI Device Path for a PCI device with the given PCI configuration space address.\r
+    \r
+  @param  This                  A pointer to the EFI_DEVICE_IO_INTERFACE instance.\r
+  @param  PciAddress            The PCI configuration space address of the device whose Device Path\r
+                                is going to be returned.  \r
+  @param  PciDevicePath         A pointer to the pointer for the EFI Device Path for PciAddress.\r
+                                Memory for the Device Path is allocated from the pool.          \r
+\r
+  @retval EFI_SUCCESS           The PciDevicePath returns a pointer to a valid EFI Device Path.\r
+  @retval EFI_OUT_OF_RESOURCES  The request could not be completed due to a lack of resources.      \r
+  @retval EFI_UNSUPPORTED       The PciAddress does not map to a valid EFI Device Path.\r
+                                   \r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_PCI_DEVICE_PATH) (\r
+  IN EFI_DEVICE_IO_PROTOCOL           *This,\r
+  IN UINT64                           PciAddress,\r
+  IN OUT EFI_DEVICE_PATH_PROTOCOL     **PciDevicePath\r
+  );\r
+\r
+typedef enum {\r
+  EfiBusMasterRead,\r
+  EfiBusMasterWrite,\r
+  EfiBusMasterCommonBuffer\r
+} EFI_IO_OPERATION_TYPE;\r
+\r
+/**                                                                 \r
+  Provides the device-specific addresses needed to access system memory.\r
+    \r
+  @param  This                  A pointer to the EFI_DEVICE_IO_INTERFACE instance.\r
+  @param  Operation             Indicates if the bus master is going to read or write to system memory.\r
+  @param  HostAddress           The system memory address to map to the device.\r
+  @param  NumberOfBytes         On input the number of bytes to map.\r
+  @param  DeviceAddress         The resulting map address for the bus master device to use to access the\r
+                                hosts HostAddress.\r
+  @param  Mapping               A resulting value to pass to Unmap().\r
+\r
+  @retval EFI_SUCCESS           The range was mapped for the returned NumberOfBytes.\r
+  @retval EFI_OUT_OF_RESOURCES  The request could not be completed due to a lack of resources.      \r
+  @retval EFI_UNSUPPORTED       The HostAddress cannot be mapped as a common buffer.\r
+  @retval EFI_INVALID_PARAMETER The Operation or HostAddress is undefined.\r
+  @retval EFI_DEVICE_ERROR      The system hardware could not map the requested address.\r
+                                   \r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_IO_MAP) (\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
+  Completes the Map() operation and releases any corresponding resources.\r
+    \r
+  @param  This                  A pointer to the EFI_DEVICE_IO_INTERFACE instance.\r
+  @param  Mapping               A resulting value to pass to Unmap().\r
+\r
+  @retval EFI_SUCCESS           The range was mapped for the returned NumberOfBytes.\r
+  @retval EFI_DEVICE_ERROR      The system hardware could not map the requested address.\r
+                                   \r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_IO_UNMAP) (\r
+  IN EFI_DEVICE_IO_PROTOCOL           *This,\r
+  IN VOID                             *Mapping\r
+  );\r
+\r
+/**                                                                 \r
+  Allocates pages that are suitable for an EFIBusMasterCommonBuffer mapping.\r
+    \r
+  @param  This                  A pointer to the EFI_DEVICE_IO_INTERFACE instance.\r
+  @param  Type                  The type allocation to perform.\r
+  @param  MemoryType            The type of memory to allocate, EfiBootServicesData or\r
+                                EfiRuntimeServicesData.\r
+  @param  Pages                 The number of pages to allocate.\r
+  @param  HostAddress           A pointer to store the base address of the allocated range.                                \r
+\r
+  @retval EFI_SUCCESS           The requested memory pages were allocated.\r
+  @retval EFI_OUT_OF_RESOURCES  The memory pages could not be allocated.\r
+  @retval EFI_INVALID_PARAMETER The requested memory type is invalid.\r
+  @retval EFI_UNSUPPORTED       The requested HostAddress is not supported on\r
+                                this platform.                               \r
+                                   \r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_IO_ALLOCATE_BUFFER) (\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
+  Flushes any posted write data to the device.\r
+    \r
+  @param  This                  A pointer to the EFI_DEVICE_IO_INTERFACE instance.\r
+\r
+  @retval EFI_SUCCESS           The buffers were flushed.\r
+  @retval EFI_DEVICE_ERROR      The buffers were not flushed due to a hardware error.                                 \r
+  \r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_IO_FLUSH) (\r
+  IN EFI_DEVICE_IO_PROTOCOL  *This\r
+  );\r
+\r
+/**                                                                 \r
+  Frees pages that were allocated with AllocateBuffer().\r
+    \r
+  @param  This                  A pointer to the EFI_DEVICE_IO_INTERFACE instance.  \r
+  @param  Pages                 The number of pages to free.\r
+  @param  HostAddress           The base address of the range to free.\r
+\r
+  @retval EFI_SUCCESS           The requested memory pages were allocated.\r
+  @retval EFI_NOT_FOUND         The requested memory pages were not allocated with\r
+                                AllocateBuffer().  \r
+  @retval EFI_INVALID_PARAMETER HostAddress is not page aligned or Pages is invalid.\r
+  \r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_IO_FREE_BUFFER) (\r
+  IN EFI_DEVICE_IO_PROTOCOL           *This,\r
+  IN UINTN                            Pages,\r
+  IN EFI_PHYSICAL_ADDRESS             HostAddress\r
+  );\r
+\r
+struct _EFI_DEVICE_IO_PROTOCOL {\r
+  EFI_IO_ACCESS           Mem;\r
+  EFI_IO_ACCESS           Io;\r
+  EFI_IO_ACCESS           Pci;\r
+  EFI_IO_MAP              Map;\r
+  EFI_PCI_DEVICE_PATH     PciDevicePath;\r
+  EFI_IO_UNMAP            Unmap;\r
+  EFI_IO_ALLOCATE_BUFFER  AllocateBuffer;\r
+  EFI_IO_FLUSH            Flush;\r
+  EFI_IO_FREE_BUFFER      FreeBuffer;\r
+};\r
+\r
+extern EFI_GUID gEfiDeviceIoProtocolGuid;\r
+\r
+#endif\r