52c1f266b1ea0893a161b7bbaa8065bc7ed94a25
[mirror_edk2.git] / EdkModulePkg / Bus / Pci / IdeBus / Dxe / idebus.h
1 /** @file
2 Header file for IDE Bus Driver.
3
4 Copyright (c) 2006, Intel Corporation
5 All rights reserved. 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
9
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.
12
13 **/
14
15 #ifndef _IDE_BUS_H
16 #define _IDE_BUS_H
17
18
19 #include <IndustryStandard/pci22.h>
20 #include "idedata.h"
21
22 //
23 // Extra Definition to porting
24 //
25 #define EFI_MIN(a, b) (((a) < (b)) ? (a) : (b))
26
27 #define MAX_IDE_DEVICE 4
28 #define MAX_IDE_CHANNELS 2
29 #define MAX_IDE_DRIVES 2
30
31 #define INVALID_DEVICE_TYPE 0xff
32 #define ATA_DEVICE_TYPE 0x00
33 #define ATAPI_DEVICE_TYPE 0x01
34
35 typedef struct {
36 BOOLEAN HaveScannedDevice[MAX_IDE_DEVICE];
37 BOOLEAN DeviceFound[MAX_IDE_DEVICE];
38 BOOLEAN DeviceProcessed[MAX_IDE_DEVICE];
39 } IDE_BUS_DRIVER_PRIVATE_DATA;
40
41 #define IDE_BLK_IO_DEV_SIGNATURE EFI_SIGNATURE_32 ('i', 'b', 'i', 'd')
42
43 typedef struct {
44 UINT32 Signature;
45
46 EFI_HANDLE Handle;
47 EFI_BLOCK_IO_PROTOCOL BlkIo;
48 EFI_BLOCK_IO_MEDIA BlkMedia;
49 EFI_DISK_INFO_PROTOCOL DiskInfo;
50 EFI_DEVICE_PATH_PROTOCOL *DevicePath;
51 EFI_PCI_IO_PROTOCOL *PciIo;
52 IDE_BUS_DRIVER_PRIVATE_DATA *IdeBusDriverPrivateData;
53
54 //
55 // Local Data for IDE interface goes here
56 //
57 EFI_IDE_CHANNEL Channel;
58 EFI_IDE_DEVICE Device;
59 UINT16 Lun;
60 IDE_DEVICE_TYPE Type;
61
62 IDE_BASE_REGISTERS *IoPort;
63 UINT16 AtapiError;
64
65 INQUIRY_DATA *pInquiryData;
66 EFI_IDENTIFY_DATA *pIdData;
67 ATA_PIO_MODE PioMode;
68 ATA_UDMA_MODE UDma_Mode;
69 CHAR8 ModelName[41];
70 REQUEST_SENSE_DATA *SenseData;
71 UINT8 SenseDataNumber;
72 UINT8 *Cache;
73
74 //
75 // ExitBootService Event, it is used to clear pending IDE interrupt
76 //
77 EFI_EVENT ExitBootServiceEvent;
78
79 EFI_UNICODE_STRING_TABLE *ControllerNameTable;
80 } IDE_BLK_IO_DEV;
81
82 #include "ComponentName.h"
83
84 #define IDE_BLOCK_IO_DEV_FROM_THIS(a) CR (a, IDE_BLK_IO_DEV, BlkIo, IDE_BLK_IO_DEV_SIGNATURE)
85 #define IDE_BLOCK_IO_DEV_FROM_DISK_INFO_THIS(a) CR (a, IDE_BLK_IO_DEV, DiskInfo, IDE_BLK_IO_DEV_SIGNATURE)
86
87 //
88 // Global Variables
89 //
90 extern EFI_DRIVER_BINDING_PROTOCOL gIDEBusDriverBinding;
91
92 #include "ide.h"
93
94 //
95 // Prototypes
96 // Driver model protocol interface
97 //
98 /**
99 TODO: Add function description
100
101 @param ImageHandle TODO: add argument description
102 @param SystemTable TODO: add argument description
103
104 TODO: add return values
105
106 **/
107 EFI_STATUS
108 EFIAPI
109 IDEBusControllerDriverEntryPoint (
110 IN EFI_HANDLE ImageHandle,
111 IN EFI_SYSTEM_TABLE *SystemTable
112 )
113 ;
114
115 /**
116 TODO: Add function description
117
118 @param This TODO: add argument description
119 @param Controller TODO: add argument description
120 @param RemainingDevicePath TODO: add argument description
121
122 TODO: add return values
123
124 **/
125 EFI_STATUS
126 EFIAPI
127 IDEBusDriverBindingSupported (
128 IN EFI_DRIVER_BINDING_PROTOCOL *This,
129 IN EFI_HANDLE Controller,
130 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
131 )
132 ;
133
134 /**
135 TODO: Add function description
136
137 @param This TODO: add argument description
138 @param Controller TODO: add argument description
139 @param RemainingDevicePath TODO: add argument description
140
141 TODO: add return values
142
143 **/
144 EFI_STATUS
145 EFIAPI
146 IDEBusDriverBindingStart (
147 IN EFI_DRIVER_BINDING_PROTOCOL *This,
148 IN EFI_HANDLE Controller,
149 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
150 )
151 ;
152
153 /**
154 TODO: Add function description
155
156 @param This TODO: add argument description
157 @param Controller TODO: add argument description
158 @param NumberOfChildren TODO: add argument description
159 @param ChildHandleBuffer TODO: add argument description
160
161 TODO: add return values
162
163 **/
164 EFI_STATUS
165 EFIAPI
166 IDEBusDriverBindingStop (
167 IN EFI_DRIVER_BINDING_PROTOCOL *This,
168 IN EFI_HANDLE Controller,
169 IN UINTN NumberOfChildren,
170 IN EFI_HANDLE *ChildHandleBuffer
171 )
172 ;
173
174 //
175 // EFI Driver Configuration Functions
176 //
177 EFI_STATUS
178 IDEBusDriverConfigurationSetOptions (
179 IN EFI_DRIVER_CONFIGURATION_PROTOCOL *This,
180 IN EFI_HANDLE ControllerHandle,
181 IN EFI_HANDLE ChildHandle OPTIONAL,
182 IN CHAR8 *Language,
183 OUT EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED *ActionRequired
184 );
185
186 EFI_STATUS
187 IDEBusDriverConfigurationOptionsValid (
188 IN EFI_DRIVER_CONFIGURATION_PROTOCOL *This,
189 IN EFI_HANDLE ControllerHandle,
190 IN EFI_HANDLE ChildHandle OPTIONAL
191 );
192
193 EFI_STATUS
194 IDEBusDriverConfigurationForceDefaults (
195 IN EFI_DRIVER_CONFIGURATION_PROTOCOL *This,
196 IN EFI_HANDLE ControllerHandle,
197 IN EFI_HANDLE ChildHandle OPTIONAL,
198 IN UINT32 DefaultType,
199 OUT EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED *ActionRequired
200 );
201
202 //
203 // EFI Driver Diagnostics Functions
204 //
205 EFI_STATUS
206 IDEBusDriverDiagnosticsRunDiagnostics (
207 IN EFI_DRIVER_DIAGNOSTICS_PROTOCOL *This,
208 IN EFI_HANDLE ControllerHandle,
209 IN EFI_HANDLE ChildHandle OPTIONAL,
210 IN EFI_DRIVER_DIAGNOSTIC_TYPE DiagnosticType,
211 IN CHAR8 *Language,
212 OUT EFI_GUID **ErrorType,
213 OUT UINTN *BufferSize,
214 OUT CHAR16 **Buffer
215 );
216
217 //
218 // Block I/O Protocol Interface
219 //
220 /**
221 TODO: Add function description
222
223 @param This TODO: add argument description
224 @param ExtendedVerification TODO: add argument description
225
226 TODO: add return values
227
228 **/
229 EFI_STATUS
230 EFIAPI
231 IDEBlkIoReset (
232 IN EFI_BLOCK_IO_PROTOCOL *This,
233 IN BOOLEAN ExtendedVerification
234 )
235 ;
236
237 /**
238 TODO: Add function description
239
240 @param This TODO: add argument description
241 @param MediaId TODO: add argument description
242 @param LBA TODO: add argument description
243 @param BufferSize TODO: add argument description
244 @param Buffer TODO: add argument description
245
246 TODO: add return values
247
248 **/
249 EFI_STATUS
250 EFIAPI
251 IDEBlkIoReadBlocks (
252 IN EFI_BLOCK_IO_PROTOCOL *This,
253 IN UINT32 MediaId,
254 IN EFI_LBA LBA,
255 IN UINTN BufferSize,
256 OUT VOID *Buffer
257 )
258 ;
259
260 /**
261 TODO: Add function description
262
263 @param This TODO: add argument description
264 @param MediaId TODO: add argument description
265 @param LBA TODO: add argument description
266 @param BufferSize TODO: add argument description
267 @param Buffer TODO: add argument description
268
269 TODO: add return values
270
271 **/
272 EFI_STATUS
273 EFIAPI
274 IDEBlkIoWriteBlocks (
275 IN EFI_BLOCK_IO_PROTOCOL *This,
276 IN UINT32 MediaId,
277 IN EFI_LBA LBA,
278 IN UINTN BufferSize,
279 IN VOID *Buffer
280 )
281 ;
282
283 /**
284 TODO: Add function description
285
286 @param This TODO: add argument description
287
288 TODO: add return values
289
290 **/
291 EFI_STATUS
292 EFIAPI
293 IDEBlkIoFlushBlocks (
294 IN EFI_BLOCK_IO_PROTOCOL *This
295 )
296 ;
297
298 /**
299 TODO: Add function description
300
301 @param PciIo TODO: add argument description
302 @param Enable TODO: add argument description
303
304 TODO: add return values
305
306 **/
307 EFI_STATUS
308 IDERegisterDecodeEnableorDisable (
309 IN EFI_PCI_IO_PROTOCOL *PciIo,
310 IN BOOLEAN Enable
311 )
312 ;
313
314 /**
315 TODO: Add function description
316
317 @param This TODO: add argument description
318 @param InquiryData TODO: add argument description
319 @param IntquiryDataSize TODO: add argument description
320
321 TODO: add return values
322
323 **/
324 EFI_STATUS
325 EFIAPI
326 IDEDiskInfoInquiry (
327 IN EFI_DISK_INFO_PROTOCOL *This,
328 IN OUT VOID *InquiryData,
329 IN OUT UINT32 *IntquiryDataSize
330 )
331 ;
332
333 /**
334 TODO: Add function description
335
336 @param This TODO: add argument description
337 @param IdentifyData TODO: add argument description
338 @param IdentifyDataSize TODO: add argument description
339
340 TODO: add return values
341
342 **/
343 EFI_STATUS
344 EFIAPI
345 IDEDiskInfoIdentify (
346 IN EFI_DISK_INFO_PROTOCOL *This,
347 IN OUT VOID *IdentifyData,
348 IN OUT UINT32 *IdentifyDataSize
349 )
350 ;
351
352 /**
353 TODO: Add function description
354
355 @param This TODO: add argument description
356 @param SenseData TODO: add argument description
357 @param SenseDataSize TODO: add argument description
358 @param SenseDataNumber TODO: add argument description
359
360 TODO: add return values
361
362 **/
363 EFI_STATUS
364 EFIAPI
365 IDEDiskInfoSenseData (
366 IN EFI_DISK_INFO_PROTOCOL *This,
367 IN OUT VOID *SenseData,
368 IN OUT UINT32 *SenseDataSize,
369 OUT UINT8 *SenseDataNumber
370 )
371 ;
372
373 /**
374 TODO: Add function description
375
376 @param This TODO: add argument description
377 @param IdeChannel TODO: add argument description
378 @param IdeDevice TODO: add argument description
379
380 TODO: add return values
381
382 **/
383 EFI_STATUS
384 EFIAPI
385 IDEDiskInfoWhichIde (
386 IN EFI_DISK_INFO_PROTOCOL *This,
387 OUT UINT32 *IdeChannel,
388 OUT UINT32 *IdeDevice
389 )
390 ;
391
392 #endif