VirtualBox

source: vbox/trunk/src/VBox/Devices/EFI/Firmware2/VBoxPkg/VBoxIdeBusDxe/IdeBus.h@ 33114

Last change on this file since 33114 was 33027, checked in by vboxsync, 14 years ago

EFI: legal notes.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 23.4 KB
Line 
1/* $Id: IdeBus.h 33027 2010-10-11 06:17:12Z vboxsync $ */
2/** @file
3 * IdeBus.h
4 */
5
6/*
7 * Copyright (C) 2009-2010 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18/** @file
19 Header file for IDE Bus Driver.
20
21 Copyright (c) 2006 - 2007 Intel Corporation. <BR>
22 All rights reserved. This program and the accompanying materials
23 are licensed and made available under the terms and conditions of the BSD License
24 which accompanies this distribution. The full text of the license may be found at
25 http://opensource.org/licenses/bsd-license.php
26
27 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
28 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
29
30**/
31
32#ifndef _IDE_BUS_H_
33#define _IDE_BUS_H_
34
35
36
37#include <FrameworkDxe.h>
38
39#include <Protocol/IdeControllerInit.h>
40#include <Protocol/BlockIo.h>
41#include <Protocol/PciIo.h>
42#include <Protocol/DiskInfo.h>
43#include <Protocol/DevicePath.h>
44
45#include <Library/DebugLib.h>
46#include <Library/UefiDriverEntryPoint.h>
47#include <Library/BaseLib.h>
48#include <Library/UefiLib.h>
49#include <Library/BaseMemoryLib.h>
50#include <Library/ReportStatusCodeLib.h>
51#include <Library/MemoryAllocationLib.h>
52#include <Library/PerformanceLib.h>
53#include <Library/UefiBootServicesTableLib.h>
54#include <Library/UefiRuntimeServicesTableLib.h>
55#include <Library/DevicePathLib.h>
56
57#include <Guid/EventGroup.h>
58
59#include <IndustryStandard/Pci.h>
60#include "IdeData.h"
61
62//
63// Global Variables
64//
65extern EFI_DRIVER_BINDING_PROTOCOL gIDEBusDriverBinding;
66extern EFI_DRIVER_DIAGNOSTICS_PROTOCOL gIDEBusDriverDiagnostics;
67extern EFI_DRIVER_DIAGNOSTICS2_PROTOCOL gIDEBusDriverDiagnostics2;
68
69//
70// Extra Definition to porting
71//
72#define MAX_IDE_DEVICE 4
73#define MAX_IDE_CHANNELS 2
74#define MAX_IDE_DRIVES 2
75
76#define INVALID_DEVICE_TYPE 0xff
77#define ATA_DEVICE_TYPE 0x00
78#define ATAPI_DEVICE_TYPE 0x01
79
80typedef struct {
81 BOOLEAN HaveScannedDevice[MAX_IDE_DEVICE];
82 BOOLEAN DeviceFound[MAX_IDE_DEVICE];
83 BOOLEAN DeviceProcessed[MAX_IDE_DEVICE];
84} IDE_BUS_DRIVER_PRIVATE_DATA;
85
86#define IDE_BLK_IO_DEV_SIGNATURE SIGNATURE_32 ('i', 'b', 'i', 'd')
87
88typedef struct {
89 UINT32 Signature;
90
91 EFI_HANDLE Handle;
92 EFI_BLOCK_IO_PROTOCOL BlkIo;
93 EFI_BLOCK_IO_MEDIA BlkMedia;
94 EFI_DISK_INFO_PROTOCOL DiskInfo;
95 EFI_DEVICE_PATH_PROTOCOL *DevicePath;
96 EFI_PCI_IO_PROTOCOL *PciIo;
97 IDE_BUS_DRIVER_PRIVATE_DATA *IdeBusDriverPrivateData;
98
99 //
100 // Local Data for IDE interface goes here
101 //
102 EFI_IDE_CHANNEL Channel;
103 EFI_IDE_DEVICE Device;
104 UINT16 Lun;
105 IDE_DEVICE_TYPE Type;
106
107 IDE_BASE_REGISTERS *IoPort;
108 UINT16 AtapiError;
109
110 ATAPI_INQUIRY_DATA *InquiryData;
111 EFI_IDENTIFY_DATA *IdData;
112 ATA_PIO_MODE PioMode;
113 EFI_ATA_MODE UdmaMode;
114 CHAR8 ModelName[41];
115 ATAPI_REQUEST_SENSE_DATA *SenseData;
116 UINT8 SenseDataNumber;
117 UINT8 *Cache;
118
119 //
120 // ExitBootService Event, it is used to clear pending IDE interrupt
121 //
122 EFI_EVENT ExitBootServiceEvent;
123
124 EFI_UNICODE_STRING_TABLE *ControllerNameTable;
125} IDE_BLK_IO_DEV;
126
127#include "ComponentName.h"
128
129#define IDE_BLOCK_IO_DEV_FROM_THIS(a) CR (a, IDE_BLK_IO_DEV, BlkIo, IDE_BLK_IO_DEV_SIGNATURE)
130#define IDE_BLOCK_IO_DEV_FROM_DISK_INFO_THIS(a) CR (a, IDE_BLK_IO_DEV, DiskInfo, IDE_BLK_IO_DEV_SIGNATURE)
131
132#include "Ide.h"
133
134
135/**
136 Supported function of Driver Binding protocol for this driver.
137
138 @param This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
139 @param ControllerHandle The handle of the controller to test.
140 @param RemainingDevicePath A pointer to the remaining portion of a device path.
141
142 @retval EFI_SUCCESS Driver loaded.
143 @retval other Driver not loaded.
144
145**/
146EFI_STATUS
147EFIAPI
148IDEBusDriverBindingSupported (
149 IN EFI_DRIVER_BINDING_PROTOCOL *This,
150 IN EFI_HANDLE Controller,
151 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
152 );
153
154/**
155 Start function of Driver binding protocol which start this driver on Controller
156 by detecting all disks and installing BlockIo protocol on them.
157
158 @param This Protocol instance pointer.
159 @param Controller Handle of device to bind driver to.
160 @param RemainingDevicePath produce all possible children.
161
162 @retval EFI_SUCCESS This driver is added to ControllerHandle.
163 @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle.
164 @retval other This driver does not support this device.
165
166**/
167EFI_STATUS
168EFIAPI
169IDEBusDriverBindingStart (
170 IN EFI_DRIVER_BINDING_PROTOCOL *This,
171 IN EFI_HANDLE Controller,
172 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
173 );
174
175/**
176 Stop function of Driver Binding Protocol which is to stop the driver on Controller Handle and all
177 child handle attached to the controller handle if there are.
178
179 @param This Protocol instance pointer.
180 @param Controller Handle of device to stop driver on
181 @param NumberOfChildren Not used
182 @param ChildHandleBuffer Not used
183
184 @retval EFI_SUCCESS This driver is removed DeviceHandle
185 @retval other This driver was not removed from this device
186
187**/
188EFI_STATUS
189EFIAPI
190IDEBusDriverBindingStop (
191 IN EFI_DRIVER_BINDING_PROTOCOL *This,
192 IN EFI_HANDLE Controller,
193 IN UINTN NumberOfChildren,
194 IN EFI_HANDLE *ChildHandleBuffer
195 );
196
197//
198// EFI Driver Configuration Functions
199//
200/**
201 Allows the user to set controller specific options for a controller that a
202 driver is currently managing.
203
204 @param This A pointer to the EFI_DRIVER_CONFIGURATION_ PROTOCOL instance.
205 @param ControllerHandle The handle of the controller to set options on.
206 @param ChildHandle The handle of the child controller to set options on.
207 This is an optional parameter that may be NULL.
208 It will be NULL for device drivers, and for a bus drivers
209 that wish to set options for the bus controller.
210 It will not be NULL for a bus driver that wishes to set
211 options for one of its child controllers.
212 @param Language A pointer to a three character ISO 639-2 language identifier.
213 This is the language of the user interface that should be presented
214 to the user, and it must match one of the languages specified in
215 SupportedLanguages. The number of languages supported by a driver is up to
216 the driver writer.
217 @param ActionRequired A pointer to the action that the calling agent is required
218 to perform when this function returns.
219
220
221 @retval EFI_SUCCESS The driver specified by This successfully set the configuration
222 options for the controller specified by ControllerHandle..
223 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
224 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid EFI_HANDLE.
225 @retval EFI_INVALID_PARAMETER ActionRequired is NULL.
226 @retval EFI_UNSUPPORTED The driver specified by This does not support setting configuration options for
227 the controller specified by ControllerHandle and ChildHandle.
228 @retval EFI_UNSUPPORTED The driver specified by This does not support the language specified by Language.
229 @retval EFI_DEVICE_ERROR A device error occurred while attempt to set the configuration options for the
230 controller specified by ControllerHandle and ChildHandle.
231 @retval EFI_OUT_RESOURCES There are not enough resources available to set the configuration options for the
232 controller specified by ControllerHandle and ChildHandle
233**/
234EFI_STATUS
235EFIAPI
236IDEBusDriverConfigurationSetOptions (
237 IN EFI_DRIVER_CONFIGURATION_PROTOCOL *This,
238 IN EFI_HANDLE ControllerHandle,
239 IN EFI_HANDLE ChildHandle OPTIONAL,
240 IN CHAR8 *Language,
241 OUT EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED *ActionRequired
242 );
243
244/**
245 Tests to see if a controller's current configuration options are valid.
246
247 @param This A pointer to the EFI_DRIVER_CONFIGURATION_PROTOCOL instance.
248 @param ControllerHandle The handle of the controller to test if it's current configuration options
249 are valid.
250 @param ChildHandle The handle of the child controller to test if it's current configuration
251 options are valid. This is an optional parameter that may be NULL. It will
252 be NULL for device drivers. It will also be NULL for a bus drivers that
253 wish to test the configuration options for the bus controller. It will
254 not be NULL for a bus driver that wishes to test configuration options for
255 one of its child controllers.
256 @retval EFI_SUCCESS The controller specified by ControllerHandle and ChildHandle that is being
257 managed by the driver specified by This has a valid set of configuration
258 options.
259 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
260 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid EFI_HANDLE.
261 @retval EFI_UNSUPPORTED The driver specified by This is not currently managing the controller
262 specified by ControllerHandle and ChildHandle.
263 @retval EFI_DEVICE_ERROR The controller specified by ControllerHandle and ChildHandle that is being
264 managed by the driver specified by This has an invalid set of configuration
265 options.
266**/
267EFI_STATUS
268EFIAPI
269IDEBusDriverConfigurationOptionsValid (
270 IN EFI_DRIVER_CONFIGURATION_PROTOCOL *This,
271 IN EFI_HANDLE ControllerHandle,
272 IN EFI_HANDLE ChildHandle OPTIONAL
273 );
274
275/**
276 Forces a driver to set the default configuration options for a controller.
277
278 @param This A pointer to the EFI_DRIVER_CONFIGURATION_ PROTOCOL instance.
279 @param ControllerHandle The handle of the controller to force default configuration options on.
280 @param ChildHandle The handle of the child controller to force default configuration
281 options on This is an optional parameter that may be NULL. It
282 will be NULL for device drivers. It will also be NULL for a bus
283 drivers that wish to force default configuration options for the bus
284 controller. It will not be NULL for a bus driver that wishes to force
285 default configuration options for one of its child controllers.
286 @param DefaultType The type of default configuration options to force on the controller
287 specified by ControllerHandle and ChildHandle.
288 @param ActionRequired A pointer to the action that the calling agent is required to perform
289 when this function returns.
290
291 @retval EFI_SUCCESS The driver specified by This successfully forced the
292 default configuration options on the controller specified by
293 ControllerHandle and ChildHandle.
294 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
295 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid EFI_HANDLE.
296 @retval EFI_INVALID_PARAMETER ActionRequired is NULL.
297 @retval EFI_UNSUPPORTED The driver specified by This does not support forcing the default
298 configuration options on the controller specified by ControllerHandle
299 and ChildHandle.
300 @retval EFI_UNSUPPORTED The driver specified by This does not support the configuration type
301 specified by DefaultType.
302 @retval EFI_DEVICE_ERROR A device error occurred while attempt to force the default configuration
303 options on the controller specified by ControllerHandle and ChildHandle.
304 @retval EFI_OUT_RESOURCES There are not enough resources available to force the default configuration
305 options on the controller specified by ControllerHandle and ChildHandle.
306**/
307EFI_STATUS
308EFIAPI
309IDEBusDriverConfigurationForceDefaults (
310 IN EFI_DRIVER_CONFIGURATION_PROTOCOL *This,
311 IN EFI_HANDLE ControllerHandle,
312 IN EFI_HANDLE ChildHandle OPTIONAL,
313 IN UINT32 DefaultType,
314 OUT EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED *ActionRequired
315 );
316
317//
318// EFI Driver Diagnostics Functions
319//
320/**
321 Runs diagnostics on a controller.
322
323 @param This A pointer to the EFI_DRIVER_DIAGNOSTICS_PROTOCOLinstance.
324 @param ControllerHandle The handle of the controller to run diagnostics on.
325 @param ChildHandle The handle of the child controller to run diagnostics on
326 This is an optional parameter that may be NULL. It will
327 be NULL for device drivers. It will also be NULL for a
328 bus drivers that wish to run diagnostics on the bus controller.
329 It will not be NULL for a bus driver that wishes to run
330 diagnostics on one of its child controllers.
331 @param DiagnosticType Indicates type of diagnostics to perform on the controller
332 specified by ControllerHandle and ChildHandle.
333 @param Language A pointer to a three character ISO 639-2 language identifier.
334 This is the language in which the optional error message should
335 be returned in Buffer, and it must match one of the languages
336 specified in SupportedLanguages. The number of languages supported by
337 a driver is up to the driver writer.
338 @param ErrorType A GUID that defines the format of the data returned in Buffer.
339 @param BufferSize The size, in bytes, of the data returned in Buffer.
340 @param Buffer A buffer that contains a Null-terminated Unicode string
341 plus some additional data whose format is defined by ErrorType.
342 Buffer is allocated by this function with AllocatePool(), and
343 it is the caller's responsibility to free it with a call to FreePool().
344
345 @retval EFI_SUCCESS The controller specified by ControllerHandle and ChildHandle passed
346 the diagnostic.
347 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
348 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid EFI_HANDLE.
349 @retval EFI_INVALID_PARAMETER Language is NULL.
350 @retval EFI_INVALID_PARAMETER ErrorType is NULL.
351 @retval EFI_INVALID_PARAMETER BufferType is NULL.
352 @retval EFI_INVALID_PARAMETER Buffer is NULL.
353 @retval EFI_UNSUPPORTED The driver specified by This does not support running
354 diagnostics for the controller specified by ControllerHandle
355 and ChildHandle.
356 @retval EFI_UNSUPPORTED The driver specified by This does not support the
357 type of diagnostic specified by DiagnosticType.
358 @retval EFI_UNSUPPORTED The driver specified by This does not support the language
359 specified by Language.
360 @retval EFI_OUT_OF_RESOURCES There are not enough resources available to complete the
361 diagnostics.
362 @retval EFI_OUT_OF_RESOURCES There are not enough resources available to return the
363 status information in ErrorType, BufferSize,and Buffer.
364 @retval EFI_DEVICE_ERROR The controller specified by ControllerHandle and ChildHandle
365 did not pass the diagnostic.
366**/
367EFI_STATUS
368EFIAPI
369IDEBusDriverDiagnosticsRunDiagnostics (
370 IN EFI_DRIVER_DIAGNOSTICS_PROTOCOL *This,
371 IN EFI_HANDLE ControllerHandle,
372 IN EFI_HANDLE ChildHandle OPTIONAL,
373 IN EFI_DRIVER_DIAGNOSTIC_TYPE DiagnosticType,
374 IN CHAR8 *Language,
375 OUT EFI_GUID **ErrorType,
376 OUT UINTN *BufferSize,
377 OUT CHAR16 **Buffer
378 );
379
380/**
381 issue ATA or ATAPI command to reset a block IO device.
382 @param This Block IO protocol instance pointer.
383 @param ExtendedVerification If FALSE,for ATAPI device, driver will only invoke ATAPI reset method
384 If TRUE, for ATAPI device, driver need invoke ATA reset method after
385 invoke ATAPI reset method
386
387 @retval EFI_DEVICE_ERROR When the device is neighther ATA device or ATAPI device.
388 @retval EFI_SUCCESS The device reset successfully
389
390**/
391EFI_STATUS
392EFIAPI
393IDEBlkIoReset (
394 IN EFI_BLOCK_IO_PROTOCOL *This,
395 IN BOOLEAN ExtendedVerification
396 );
397
398/**
399 Read data from a block IO device.
400
401 @param This Block IO protocol instance pointer.
402 @param MediaId The media ID of the device
403 @param Lba Starting LBA address to read data
404 @param BufferSize The size of data to be read
405 @param Buffer Caller supplied buffer to save data
406
407 @retval EFI_DEVICE_ERROR unknown device type
408 @retval EFI_SUCCESS read the data successfully.
409
410**/
411EFI_STATUS
412EFIAPI
413IDEBlkIoReadBlocks (
414 IN EFI_BLOCK_IO_PROTOCOL *This,
415 IN UINT32 MediaId,
416 IN EFI_LBA Lba,
417 IN UINTN BufferSize,
418 OUT VOID *Buffer
419 );
420
421/**
422 Write data to block io device
423
424 @param This Protocol instance pointer.
425 @param MediaId The media ID of the device
426 @param Lba Starting LBA address to write data
427 @param BufferSize The size of data to be written
428 @param Buffer Caller supplied buffer to save data
429
430 @retval EFI_DEVICE_ERROR unknown device type
431 @retval other write data status
432
433**/
434EFI_STATUS
435EFIAPI
436IDEBlkIoWriteBlocks (
437 IN EFI_BLOCK_IO_PROTOCOL *This,
438 IN UINT32 MediaId,
439 IN EFI_LBA Lba,
440 IN UINTN BufferSize,
441 IN VOID *Buffer
442 );
443
444/**
445 Flushes all modified data to a physical block devices
446
447 @param This Indicates a pointer to the calling context which to sepcify a
448 sepcific block device
449
450 @retval EFI_SUCCESS Always return success.
451**/
452EFI_STATUS
453EFIAPI
454IDEBlkIoFlushBlocks (
455 IN EFI_BLOCK_IO_PROTOCOL *This
456 );
457/**
458 This function is used by the IDE bus driver to get inquiry data.
459 Data format of Identify data is defined by the Interface GUID.
460
461 @param This Pointer to the EFI_DISK_INFO_PROTOCOL instance.
462 @param InquiryData Pointer to a buffer for the inquiry data.
463 @param InquiryDataSize Pointer to the value for the inquiry data size.
464
465 @retval EFI_SUCCESS The command was accepted without any errors.
466 @retval EFI_NOT_FOUND Device does not support this data class
467 @retval EFI_DEVICE_ERROR Error reading InquiryData from device
468 @retval EFI_BUFFER_TOO_SMALL IntquiryDataSize not big enough
469
470**/
471EFI_STATUS
472EFIAPI
473IDEDiskInfoInquiry (
474 IN EFI_DISK_INFO_PROTOCOL *This,
475 IN OUT VOID *InquiryData,
476 IN OUT UINT32 *InquiryDataSize
477 );
478
479/**
480 This function is used by the IDE bus driver to get identify data.
481 Data format of Identify data is defined by the Interface GUID.
482
483 @param This Pointer to the EFI_DISK_INFO_PROTOCOL instance.
484 @param IdentifyData Pointer to a buffer for the identify data.
485 @param IdentifyDataSize Pointer to the value for the identify data size.
486
487 @retval EFI_SUCCESS The command was accepted without any errors.
488 @retval EFI_NOT_FOUND Device does not support this data class
489 @retval EFI_DEVICE_ERROR Error reading IdentifyData from device
490 @retval EFI_BUFFER_TOO_SMALL IdentifyDataSize not big enough
491
492**/
493EFI_STATUS
494EFIAPI
495IDEDiskInfoIdentify (
496 IN EFI_DISK_INFO_PROTOCOL *This,
497 IN OUT VOID *IdentifyData,
498 IN OUT UINT32 *IdentifyDataSize
499 );
500
501/**
502 This function is used by the IDE bus driver to get sense data.
503 Data format of Sense data is defined by the Interface GUID.
504
505 @param This Pointer to the EFI_DISK_INFO_PROTOCOL instance.
506 @param SenseData Pointer to the SenseData.
507 @param SenseDataSize Size of SenseData in bytes.
508 @param SenseDataNumber Pointer to the value for the identify data size.
509
510 @retval EFI_SUCCESS The command was accepted without any errors.
511 @retval EFI_NOT_FOUND Device does not support this data class
512 @retval EFI_DEVICE_ERROR Error reading InquiryData from device
513 @retval EFI_BUFFER_TOO_SMALL SenseDataSize not big enough
514
515**/
516EFI_STATUS
517EFIAPI
518IDEDiskInfoSenseData (
519 IN EFI_DISK_INFO_PROTOCOL *This,
520 IN OUT VOID *SenseData,
521 IN OUT UINT32 *SenseDataSize,
522 OUT UINT8 *SenseDataNumber
523 );
524
525/**
526 This function is used by the IDE bus driver to get controller information.
527
528 @param This Pointer to the EFI_DISK_INFO_PROTOCOL instance.
529 @param IdeChannel Pointer to the Ide Channel number. Primary or secondary.
530 @param IdeDevice Pointer to the Ide Device number. Master or slave.
531
532 @retval EFI_SUCCESS IdeChannel and IdeDevice are valid
533 @retval EFI_UNSUPPORTED This is not an IDE device
534
535**/
536EFI_STATUS
537EFIAPI
538IDEDiskInfoWhichIde (
539 IN EFI_DISK_INFO_PROTOCOL *This,
540 OUT UINT32 *IdeChannel,
541 OUT UINT32 *IdeDevice
542 );
543/**
544 The is an event(generally the event is exitBootService event) call back function.
545 Clear pending IDE interrupt before OS loader/kernel take control of the IDE device.
546
547 @param Event Pointer to this event
548 @param Context Event hanlder private data
549
550**/
551VOID
552EFIAPI
553ClearInterrupt (
554 IN EFI_EVENT Event,
555 IN VOID *Context
556 );
557#endif
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette