2007-06-19 12:12:02 +02:00
|
|
|
/** @file
|
2007-11-22 07:00:39 +01:00
|
|
|
Device IO protocol as defined in the EFI 1.10 specification.
|
2007-06-19 12:12:02 +02:00
|
|
|
|
|
|
|
Device IO is used to abstract hardware access to devices. It includes
|
|
|
|
memory mapped IO, IO, PCI Config space, and DMA.
|
|
|
|
|
2009-06-04 11:22:50 +02:00
|
|
|
Copyright (c) 2006 - 2009, Intel Corporation
|
2007-06-19 12:12:02 +02:00
|
|
|
All rights reserved. This program and the accompanying materials
|
|
|
|
are licensed and made available under the terms and conditions of the BSD License
|
|
|
|
which accompanies this distribution. The full text of the license may be found at
|
|
|
|
http://opensource.org/licenses/bsd-license.php
|
|
|
|
|
|
|
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|
|
|
|
|
|
|
**/
|
|
|
|
|
|
|
|
#ifndef __DEVICE_IO_H__
|
|
|
|
#define __DEVICE_IO_H__
|
|
|
|
|
|
|
|
#define EFI_DEVICE_IO_PROTOCOL_GUID \
|
|
|
|
{ \
|
|
|
|
0xaf6ac311, 0x84c3, 0x11d2, {0x8e, 0x3c, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b } \
|
|
|
|
}
|
|
|
|
|
|
|
|
typedef struct _EFI_DEVICE_IO_PROTOCOL EFI_DEVICE_IO_PROTOCOL;
|
|
|
|
|
2008-08-14 06:29:48 +02:00
|
|
|
///
|
|
|
|
/// Protocol GUID name defined in EFI1.1.
|
|
|
|
///
|
2007-06-21 09:16:27 +02:00
|
|
|
#define DEVICE_IO_PROTOCOL EFI_DEVICE_IO_PROTOCOL_GUID
|
|
|
|
|
2008-08-14 06:29:48 +02:00
|
|
|
///
|
|
|
|
/// Protocol defined in EFI1.1.
|
|
|
|
///
|
2007-06-21 09:16:27 +02:00
|
|
|
typedef EFI_DEVICE_IO_PROTOCOL EFI_DEVICE_IO_INTERFACE;
|
|
|
|
|
2008-12-08 15:48:27 +01:00
|
|
|
///
|
|
|
|
/// Device IO Access Width
|
|
|
|
///
|
2007-06-19 12:12:02 +02:00
|
|
|
typedef enum {
|
2008-11-21 04:18:22 +01:00
|
|
|
IO_UINT8 = 0,
|
|
|
|
IO_UINT16 = 1,
|
|
|
|
IO_UINT32 = 2,
|
|
|
|
IO_UINT64 = 3,
|
2008-11-21 16:50:41 +01:00
|
|
|
//
|
2008-11-23 05:06:56 +01:00
|
|
|
// Below enumerations are added in "Extensible Firmware Interface Specification,
|
|
|
|
// Version 1.10, Specification Update, Version 001".
|
2008-11-21 16:50:41 +01:00
|
|
|
//
|
2008-11-21 04:18:22 +01:00
|
|
|
MMIO_COPY_UINT8 = 4,
|
|
|
|
MMIO_COPY_UINT16 = 5,
|
|
|
|
MMIO_COPY_UINT32 = 6,
|
|
|
|
MMIO_COPY_UINT64 = 7
|
2007-06-19 12:12:02 +02:00
|
|
|
} EFI_IO_WIDTH;
|
|
|
|
|
|
|
|
/**
|
|
|
|
Enables a driver to access device registers in the appropriate memory or I/O space.
|
|
|
|
|
|
|
|
@param This A pointer to the EFI_DEVICE_IO_INTERFACE instance.
|
|
|
|
@param Width Signifies the width of the I/O operations.
|
|
|
|
@param Address The base address of the I/O operations.
|
|
|
|
@param Count The number of I/O operations to perform.
|
|
|
|
@param Buffer For read operations, the destination buffer to store the results. For write
|
2008-11-21 04:00:06 +01:00
|
|
|
operations, the source buffer to write data from. If
|
2008-11-21 04:18:22 +01:00
|
|
|
Width is MMIO_COPY_UINT8, MMIO_COPY_UINT16,
|
|
|
|
MMIO_COPY_UINT32, or MMIO_COPY_UINT64, then
|
|
|
|
Buffer is interpreted as a base address of an I/O operation such as Address.
|
2007-06-19 12:12:02 +02:00
|
|
|
|
|
|
|
@retval EFI_SUCCESS The data was read from or written to the device.
|
|
|
|
@retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
|
|
|
|
@retval EFI_INVALID_PARAMETER Width is invalid.
|
|
|
|
|
|
|
|
**/
|
|
|
|
typedef
|
|
|
|
EFI_STATUS
|
2008-06-24 09:14:18 +02:00
|
|
|
(EFIAPI *EFI_DEVICE_IO)(
|
2007-06-19 12:12:02 +02:00
|
|
|
IN EFI_DEVICE_IO_PROTOCOL *This,
|
|
|
|
IN EFI_IO_WIDTH Width,
|
|
|
|
IN UINT64 Address,
|
|
|
|
IN UINTN Count,
|
|
|
|
IN OUT VOID *Buffer
|
|
|
|
);
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
EFI_DEVICE_IO Read;
|
|
|
|
EFI_DEVICE_IO Write;
|
|
|
|
} EFI_IO_ACCESS;
|
|
|
|
|
|
|
|
/**
|
|
|
|
Provides an EFI Device Path for a PCI device with the given PCI configuration space address.
|
|
|
|
|
|
|
|
@param This A pointer to the EFI_DEVICE_IO_INTERFACE instance.
|
|
|
|
@param PciAddress The PCI configuration space address of the device whose Device Path
|
|
|
|
is going to be returned.
|
|
|
|
@param PciDevicePath A pointer to the pointer for the EFI Device Path for PciAddress.
|
|
|
|
Memory for the Device Path is allocated from the pool.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS The PciDevicePath returns a pointer to a valid EFI Device Path.
|
|
|
|
@retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
|
|
|
|
@retval EFI_UNSUPPORTED The PciAddress does not map to a valid EFI Device Path.
|
|
|
|
|
|
|
|
**/
|
|
|
|
typedef
|
|
|
|
EFI_STATUS
|
2008-06-24 09:14:18 +02:00
|
|
|
(EFIAPI *EFI_PCI_DEVICE_PATH)(
|
2007-06-19 12:12:02 +02:00
|
|
|
IN EFI_DEVICE_IO_PROTOCOL *This,
|
|
|
|
IN UINT64 PciAddress,
|
|
|
|
IN OUT EFI_DEVICE_PATH_PROTOCOL **PciDevicePath
|
|
|
|
);
|
|
|
|
|
|
|
|
typedef enum {
|
2008-11-19 15:24:27 +01:00
|
|
|
///
|
|
|
|
/// A read operation from system memory by a bus master.
|
|
|
|
///
|
2007-06-19 12:12:02 +02:00
|
|
|
EfiBusMasterRead,
|
2008-11-19 15:24:27 +01:00
|
|
|
|
|
|
|
///
|
|
|
|
/// A write operation to system memory by a bus master.
|
|
|
|
///
|
2007-06-19 12:12:02 +02:00
|
|
|
EfiBusMasterWrite,
|
2008-11-19 15:24:27 +01:00
|
|
|
|
|
|
|
///
|
|
|
|
/// Provides both read and write access to system memory
|
|
|
|
/// by both the processor and a bus master. The buffer is
|
2008-12-01 15:06:25 +01:00
|
|
|
/// coherent from both the processor's and the bus master's
|
2008-11-19 15:24:27 +01:00
|
|
|
/// point of view.
|
|
|
|
///
|
2007-06-19 12:12:02 +02:00
|
|
|
EfiBusMasterCommonBuffer
|
|
|
|
} EFI_IO_OPERATION_TYPE;
|
|
|
|
|
|
|
|
/**
|
|
|
|
Provides the device-specific addresses needed to access system memory.
|
|
|
|
|
|
|
|
@param This A pointer to the EFI_DEVICE_IO_INTERFACE instance.
|
|
|
|
@param Operation Indicates if the bus master is going to read or write to system memory.
|
|
|
|
@param HostAddress The system memory address to map to the device.
|
2009-06-04 07:49:29 +02:00
|
|
|
@param NumberOfBytes On input, the number of bytes to map.
|
2009-06-04 11:22:50 +02:00
|
|
|
On output the number of bytes that were mapped.
|
2007-06-19 12:12:02 +02:00
|
|
|
@param DeviceAddress The resulting map address for the bus master device to use to access the
|
|
|
|
hosts HostAddress.
|
|
|
|
@param Mapping A resulting value to pass to Unmap().
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS The range was mapped for the returned NumberOfBytes.
|
|
|
|
@retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
|
|
|
|
@retval EFI_UNSUPPORTED The HostAddress cannot be mapped as a common buffer.
|
|
|
|
@retval EFI_INVALID_PARAMETER The Operation or HostAddress is undefined.
|
|
|
|
@retval EFI_DEVICE_ERROR The system hardware could not map the requested address.
|
|
|
|
|
|
|
|
**/
|
|
|
|
typedef
|
|
|
|
EFI_STATUS
|
2008-06-24 09:14:18 +02:00
|
|
|
(EFIAPI *EFI_IO_MAP)(
|
2007-06-19 12:12:02 +02:00
|
|
|
IN EFI_DEVICE_IO_PROTOCOL *This,
|
|
|
|
IN EFI_IO_OPERATION_TYPE Operation,
|
|
|
|
IN EFI_PHYSICAL_ADDRESS *HostAddress,
|
|
|
|
IN OUT UINTN *NumberOfBytes,
|
|
|
|
OUT EFI_PHYSICAL_ADDRESS *DeviceAddress,
|
|
|
|
OUT VOID **Mapping
|
|
|
|
);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Completes the Map() operation and releases any corresponding resources.
|
|
|
|
|
|
|
|
@param This A pointer to the EFI_DEVICE_IO_INTERFACE instance.
|
|
|
|
@param Mapping A resulting value to pass to Unmap().
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS The range was mapped for the returned NumberOfBytes.
|
|
|
|
@retval EFI_DEVICE_ERROR The system hardware could not map the requested address.
|
|
|
|
|
|
|
|
**/
|
|
|
|
typedef
|
|
|
|
EFI_STATUS
|
2008-06-24 09:14:18 +02:00
|
|
|
(EFIAPI *EFI_IO_UNMAP)(
|
2007-06-19 12:12:02 +02:00
|
|
|
IN EFI_DEVICE_IO_PROTOCOL *This,
|
|
|
|
IN VOID *Mapping
|
|
|
|
);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Allocates pages that are suitable for an EFIBusMasterCommonBuffer mapping.
|
|
|
|
|
|
|
|
@param This A pointer to the EFI_DEVICE_IO_INTERFACE instance.
|
|
|
|
@param Type The type allocation to perform.
|
|
|
|
@param MemoryType The type of memory to allocate, EfiBootServicesData or
|
|
|
|
EfiRuntimeServicesData.
|
|
|
|
@param Pages The number of pages to allocate.
|
|
|
|
@param HostAddress A pointer to store the base address of the allocated range.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS The requested memory pages were allocated.
|
|
|
|
@retval EFI_OUT_OF_RESOURCES The memory pages could not be allocated.
|
|
|
|
@retval EFI_INVALID_PARAMETER The requested memory type is invalid.
|
|
|
|
@retval EFI_UNSUPPORTED The requested HostAddress is not supported on
|
|
|
|
this platform.
|
|
|
|
|
|
|
|
**/
|
|
|
|
typedef
|
|
|
|
EFI_STATUS
|
2008-06-24 09:14:18 +02:00
|
|
|
(EFIAPI *EFI_IO_ALLOCATE_BUFFER)(
|
2007-06-19 12:12:02 +02:00
|
|
|
IN EFI_DEVICE_IO_PROTOCOL *This,
|
|
|
|
IN EFI_ALLOCATE_TYPE Type,
|
|
|
|
IN EFI_MEMORY_TYPE MemoryType,
|
|
|
|
IN UINTN Pages,
|
|
|
|
IN OUT EFI_PHYSICAL_ADDRESS *HostAddress
|
|
|
|
);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Flushes any posted write data to the device.
|
|
|
|
|
|
|
|
@param This A pointer to the EFI_DEVICE_IO_INTERFACE instance.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS The buffers were flushed.
|
|
|
|
@retval EFI_DEVICE_ERROR The buffers were not flushed due to a hardware error.
|
|
|
|
|
|
|
|
**/
|
|
|
|
typedef
|
|
|
|
EFI_STATUS
|
2008-06-24 09:14:18 +02:00
|
|
|
(EFIAPI *EFI_IO_FLUSH)(
|
2007-06-19 12:12:02 +02:00
|
|
|
IN EFI_DEVICE_IO_PROTOCOL *This
|
|
|
|
);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Frees pages that were allocated with AllocateBuffer().
|
|
|
|
|
|
|
|
@param This A pointer to the EFI_DEVICE_IO_INTERFACE instance.
|
|
|
|
@param Pages The number of pages to free.
|
|
|
|
@param HostAddress The base address of the range to free.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS The requested memory pages were allocated.
|
|
|
|
@retval EFI_NOT_FOUND The requested memory pages were not allocated with
|
|
|
|
AllocateBuffer().
|
|
|
|
@retval EFI_INVALID_PARAMETER HostAddress is not page aligned or Pages is invalid.
|
|
|
|
|
|
|
|
**/
|
|
|
|
typedef
|
|
|
|
EFI_STATUS
|
2008-06-24 09:14:18 +02:00
|
|
|
(EFIAPI *EFI_IO_FREE_BUFFER)(
|
2007-06-19 12:12:02 +02:00
|
|
|
IN EFI_DEVICE_IO_PROTOCOL *This,
|
|
|
|
IN UINTN Pages,
|
|
|
|
IN EFI_PHYSICAL_ADDRESS HostAddress
|
|
|
|
);
|
|
|
|
|
2008-10-13 04:54:29 +02:00
|
|
|
///
|
|
|
|
/// This protocol provides the basic Memory, I/O, and PCI interfaces that
|
|
|
|
/// are used to abstract accesses to devices.
|
|
|
|
///
|
2007-06-19 12:12:02 +02:00
|
|
|
struct _EFI_DEVICE_IO_PROTOCOL {
|
2008-10-09 20:09:49 +02:00
|
|
|
///
|
|
|
|
/// Allows reads and writes to memory mapped I/O space.
|
|
|
|
///
|
2007-06-19 12:12:02 +02:00
|
|
|
EFI_IO_ACCESS Mem;
|
2008-10-09 20:09:49 +02:00
|
|
|
///
|
|
|
|
/// Allows reads and writes to I/O space.
|
|
|
|
///
|
2007-06-19 12:12:02 +02:00
|
|
|
EFI_IO_ACCESS Io;
|
2008-10-09 20:09:49 +02:00
|
|
|
///
|
|
|
|
/// Allows reads and writes to PCI configuration space.
|
|
|
|
///
|
2007-06-19 12:12:02 +02:00
|
|
|
EFI_IO_ACCESS Pci;
|
|
|
|
EFI_IO_MAP Map;
|
|
|
|
EFI_PCI_DEVICE_PATH PciDevicePath;
|
|
|
|
EFI_IO_UNMAP Unmap;
|
|
|
|
EFI_IO_ALLOCATE_BUFFER AllocateBuffer;
|
|
|
|
EFI_IO_FLUSH Flush;
|
|
|
|
EFI_IO_FREE_BUFFER FreeBuffer;
|
|
|
|
};
|
|
|
|
|
|
|
|
extern EFI_GUID gEfiDeviceIoProtocolGuid;
|
|
|
|
|
|
|
|
#endif
|