]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Include/Protocol/DeviceIo.h
Update the Guid Value of Ext SCSI Pass Thru Protocol
[mirror_edk2.git] / MdePkg / Include / Protocol / DeviceIo.h
CommitLineData
878ddf1f 1/** @file\r
2 Device IO protocol as defined in the EFI 1.0 specification.\r
3\r
4 Device IO is used to abstract hardware access to devices. It includes\r
5 memory mapped IO, IO, PCI Config space, and DMA.\r
6\r
7 Copyright (c) 2006, Intel Corporation \r
8 All rights reserved. This program and the accompanying materials \r
9 are licensed and made available under the terms and conditions of the BSD License \r
10 which accompanies this distribution. The full text of the license may be found at \r
11 http://opensource.org/licenses/bsd-license.php \r
12\r
13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
14 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
15\r
16 Module Name: DeviceIo.h\r
17\r
18**/\r
19\r
20#ifndef __DEVICE_IO_H__\r
21#define __DEVICE_IO_H__\r
22\r
23#define EFI_DEVICE_IO_PROTOCOL_GUID \\r
24 { \\r
25 0xaf6ac311, 0x84c3, 0x11d2, {0x8e, 0x3c, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b } \\r
26 }\r
27\r
28typedef struct _EFI_DEVICE_IO_PROTOCOL EFI_DEVICE_IO_PROTOCOL;\r
29\r
30typedef enum {\r
31 IO_UINT8,\r
32 IO_UINT16,\r
33 IO_UINT32,\r
34 IO_UINT64,\r
35 MMIO_COPY_UINT8,\r
36 MMIO_COPY_UINT16,\r
37 MMIO_COPY_UINT32,\r
38 MMIO_COPY_UINT64\r
39} EFI_IO_WIDTH;\r
40\r
41/** \r
42 Enables a driver to access device registers in the appropriate memory or I/O space.\r
43 \r
44 @param This A pointer to the EFI_DEVICE_IO_INTERFACE instance.\r
45 @param Width Signifies the width of the I/O operations. \r
46 @param Address The base address of the I/O operations. \r
47 @param Count The number of I/O operations to perform.\r
48 @param Buffer For read operations, the destination buffer to store the results. For write\r
49 operations, the source buffer to write data from. \r
0647c9ad 50\r
878ddf1f 51 @retval EFI_SUCCESS The data was read from or written to the device.\r
52 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources. \r
53 @retval EFI_INVALID_PARAMETER Width is invalid.\r
54 \r
55**/\r
56typedef\r
57EFI_STATUS\r
58(EFIAPI *EFI_DEVICE_IO) (\r
59 IN EFI_DEVICE_IO_PROTOCOL *This,\r
60 IN EFI_IO_WIDTH Width,\r
61 IN UINT64 Address,\r
62 IN UINTN Count,\r
63 IN OUT VOID *Buffer\r
64 );\r
65\r
66typedef struct {\r
67 EFI_DEVICE_IO Read;\r
68 EFI_DEVICE_IO Write;\r
69} EFI_IO_ACCESS;\r
70\r
71/** \r
72 Provides an EFI Device Path for a PCI device with the given PCI configuration space address.\r
73 \r
74 @param This A pointer to the EFI_DEVICE_IO_INTERFACE instance.\r
75 @param PciAddress The PCI configuration space address of the device whose Device Path\r
76 is going to be returned. \r
77 @param PciDevicePath A pointer to the pointer for the EFI Device Path for PciAddress.\r
78 Memory for the Device Path is allocated from the pool. \r
0647c9ad 79\r
878ddf1f 80 @retval EFI_SUCCESS The PciDevicePath returns a pointer to a valid EFI Device Path.\r
81 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources. \r
82 @retval EFI_UNSUPPORTED The PciAddress does not map to a valid EFI Device Path.\r
83 \r
84**/\r
85typedef\r
86EFI_STATUS\r
87(EFIAPI *EFI_PCI_DEVICE_PATH) (\r
88 IN EFI_DEVICE_IO_PROTOCOL *This,\r
89 IN UINT64 PciAddress,\r
90 IN OUT EFI_DEVICE_PATH_PROTOCOL **PciDevicePath\r
91 );\r
92\r
93typedef enum {\r
94 EfiBusMasterRead,\r
95 EfiBusMasterWrite,\r
96 EfiBusMasterCommonBuffer\r
97} EFI_IO_OPERATION_TYPE;\r
98\r
99/** \r
100 Provides the device-specific addresses needed to access system memory.\r
101 \r
102 @param This A pointer to the EFI_DEVICE_IO_INTERFACE instance.\r
103 @param Operation Indicates if the bus master is going to read or write to system memory.\r
104 @param HostAddress The system memory address to map to the device.\r
105 @param NumberOfBytes On input the number of bytes to map.\r
106 @param DeviceAddress The resulting map address for the bus master device to use to access the\r
107 hosts HostAddress.\r
108 @param Mapping A resulting value to pass to Unmap().\r
0647c9ad 109\r
878ddf1f 110 @retval EFI_SUCCESS The range was mapped for the returned NumberOfBytes.\r
111 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources. \r
112 @retval EFI_UNSUPPORTED The HostAddress cannot be mapped as a common buffer.\r
113 @retval EFI_INVALID_PARAMETER The Operation or HostAddress is undefined.\r
114 @retval EFI_DEVICE_ERROR The system hardware could not map the requested address.\r
115 \r
116**/\r
117typedef\r
118EFI_STATUS\r
119(EFIAPI *EFI_IO_MAP) (\r
120 IN EFI_DEVICE_IO_PROTOCOL *This,\r
121 IN EFI_IO_OPERATION_TYPE Operation,\r
122 IN EFI_PHYSICAL_ADDRESS *HostAddress,\r
123 IN OUT UINTN *NumberOfBytes,\r
124 OUT EFI_PHYSICAL_ADDRESS *DeviceAddress,\r
125 OUT VOID **Mapping\r
126 );\r
127\r
128/** \r
129 Completes the Map() operation and releases any corresponding resources.\r
130 \r
131 @param This A pointer to the EFI_DEVICE_IO_INTERFACE instance.\r
132 @param Mapping A resulting value to pass to Unmap().\r
0647c9ad 133\r
878ddf1f 134 @retval EFI_SUCCESS The range was mapped for the returned NumberOfBytes.\r
135 @retval EFI_DEVICE_ERROR The system hardware could not map the requested address.\r
136 \r
137**/\r
138typedef\r
139EFI_STATUS\r
140(EFIAPI *EFI_IO_UNMAP) (\r
141 IN EFI_DEVICE_IO_PROTOCOL *This,\r
142 IN VOID *Mapping\r
143 );\r
144\r
145/** \r
146 Allocates pages that are suitable for an EFIBusMasterCommonBuffer mapping.\r
147 \r
148 @param This A pointer to the EFI_DEVICE_IO_INTERFACE instance.\r
149 @param Type The type allocation to perform.\r
150 @param MemoryType The type of memory to allocate, EfiBootServicesData or\r
151 EfiRuntimeServicesData.\r
152 @param Pages The number of pages to allocate.\r
153 @param HostAddress A pointer to store the base address of the allocated range. \r
0647c9ad 154\r
878ddf1f 155 @retval EFI_SUCCESS The requested memory pages were allocated.\r
156 @retval EFI_OUT_OF_RESOURCES The memory pages could not be allocated.\r
157 @retval EFI_INVALID_PARAMETER The requested memory type is invalid.\r
158 @retval EFI_UNSUPPORTED The requested HostAddress is not supported on\r
159 this platform. \r
160 \r
161**/\r
162typedef\r
163EFI_STATUS\r
164(EFIAPI *EFI_IO_ALLOCATE_BUFFER) (\r
165 IN EFI_DEVICE_IO_PROTOCOL *This,\r
166 IN EFI_ALLOCATE_TYPE Type,\r
167 IN EFI_MEMORY_TYPE MemoryType,\r
168 IN UINTN Pages,\r
169 IN OUT EFI_PHYSICAL_ADDRESS *HostAddress\r
170 );\r
171\r
172/** \r
173 Flushes any posted write data to the device.\r
174 \r
175 @param This A pointer to the EFI_DEVICE_IO_INTERFACE instance.\r
0647c9ad 176\r
878ddf1f 177 @retval EFI_SUCCESS The buffers were flushed.\r
178 @retval EFI_DEVICE_ERROR The buffers were not flushed due to a hardware error. \r
179 \r
180**/\r
181typedef\r
182EFI_STATUS\r
183(EFIAPI *EFI_IO_FLUSH) (\r
184 IN EFI_DEVICE_IO_PROTOCOL *This\r
185 );\r
186\r
187/** \r
188 Frees pages that were allocated with AllocateBuffer().\r
189 \r
190 @param This A pointer to the EFI_DEVICE_IO_INTERFACE instance. \r
191 @param Pages The number of pages to free.\r
192 @param HostAddress The base address of the range to free.\r
0647c9ad 193\r
878ddf1f 194 @retval EFI_SUCCESS The requested memory pages were allocated.\r
195 @retval EFI_NOT_FOUND The requested memory pages were not allocated with\r
196 AllocateBuffer(). \r
197 @retval EFI_INVALID_PARAMETER HostAddress is not page aligned or Pages is invalid.\r
198 \r
199**/\r
200typedef\r
201EFI_STATUS\r
202(EFIAPI *EFI_IO_FREE_BUFFER) (\r
203 IN EFI_DEVICE_IO_PROTOCOL *This,\r
204 IN UINTN Pages,\r
205 IN EFI_PHYSICAL_ADDRESS HostAddress\r
206 );\r
207\r
208struct _EFI_DEVICE_IO_PROTOCOL {\r
209 EFI_IO_ACCESS Mem;\r
210 EFI_IO_ACCESS Io;\r
211 EFI_IO_ACCESS Pci;\r
212 EFI_IO_MAP Map;\r
213 EFI_PCI_DEVICE_PATH PciDevicePath;\r
214 EFI_IO_UNMAP Unmap;\r
215 EFI_IO_ALLOCATE_BUFFER AllocateBuffer;\r
216 EFI_IO_FLUSH Flush;\r
217 EFI_IO_FREE_BUFFER FreeBuffer;\r
218};\r
219\r
220extern EFI_GUID gEfiDeviceIoProtocolGuid;\r
221\r
222#endif\r