-/*++\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:\r
-\r
- DiskIo.c\r
-\r
-Abstract:\r
-\r
+/** @file\r
DiskIo driver that layers it's self on every Block IO protocol in the system.\r
DiskIo converts a block oriented device to a byte oriented device.\r
\r
ReadDisk may have to do reads that are not aligned on sector boundaries.\r
There are three cases:\r
-\r
UnderRun - The first byte is not on a sector boundary or the read request is\r
less than a sector in length.\r
-\r
Aligned - A read of N contiguous sectors.\r
-\r
OverRun - The last byte is not on a sector boundary.\r
\r
---*/\r
+ Copyright (c) 2006 - 2007, 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
+**/\r
\r
//\r
// Include common header file for this module.\r
NULL\r
};\r
\r
+\r
+/**\r
+ Test to see if this driver supports ControllerHandle. \r
+\r
+ @param This Protocol instance pointer.\r
+ @param ControllerHandle Handle of device to test\r
+ @param RemainingDevicePath Optional parameter use to pick a specific child\r
+ device to start.\r
+\r
+ @retval EFI_SUCCESS This driver supports this device\r
+ @retval EFI_ALREADY_STARTED This driver is already running on this device\r
+ @retval other This driver does not support this device\r
+\r
+**/\r
EFI_STATUS\r
EFIAPI\r
DiskIoDriverBindingSupported (\r
IN EFI_HANDLE ControllerHandle,\r
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL\r
)\r
-/*++\r
-\r
- Routine Description:\r
- Test to see if this driver supports ControllerHandle. Any ControllerHandle\r
- than contains a BlockIo protocol can be supported.\r
-\r
- Arguments:\r
- This - Protocol instance pointer.\r
- ControllerHandle - Handle of device to test.\r
- RemainingDevicePath - Not used.\r
-\r
- Returns:\r
- EFI_SUCCESS - This driver supports this device.\r
- EFI_ALREADY_STARTED - This driver is already running on this device.\r
- other - This driver does not support this device.\r
-\r
---*/\r
{\r
EFI_STATUS Status;\r
EFI_BLOCK_IO_PROTOCOL *BlockIo;\r
if (EFI_ERROR (Status)) {\r
return Status;\r
}\r
+\r
//\r
// Close the I/O Abstraction(s) used to perform the supported test.\r
//\r
return EFI_SUCCESS;\r
}\r
\r
+\r
+/**\r
+ Start this driver on ControllerHandle by opening a Block IO protocol and\r
+ installing a Disk IO protocol on ControllerHandle.\r
+\r
+ @param This Protocol instance pointer.\r
+ @param ControllerHandle Handle of device to bind driver to\r
+ @param RemainingDevicePath Optional parameter use to pick a specific child\r
+ device to start.\r
+\r
+ @retval EFI_SUCCESS This driver is added to ControllerHandle\r
+ @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle\r
+ @retval other This driver does not support this device\r
+\r
+**/\r
EFI_STATUS\r
EFIAPI\r
DiskIoDriverBindingStart (\r
IN EFI_HANDLE ControllerHandle,\r
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL\r
)\r
-/*++\r
-\r
- Routine Description:\r
- Start this driver on ControllerHandle by opening a Block IO protocol and\r
- installing a Disk IO protocol on ControllerHandle.\r
-\r
- Arguments:\r
- This - Protocol instance pointer.\r
- ControllerHandle - Handle of device to bind driver to.\r
- RemainingDevicePath - Not used, always produce all possible children.\r
-\r
- Returns:\r
- EFI_SUCCESS - This driver is added to ControllerHandle.\r
- EFI_ALREADY_STARTED - This driver is already running on ControllerHandle.\r
- other - This driver does not support this device.\r
-\r
---*/\r
{\r
EFI_STATUS Status;\r
DISK_IO_PRIVATE_DATA *Private;\r
if (EFI_ERROR (Status)) {\r
return Status;\r
}\r
+ \r
//\r
// Initialize the Disk IO device instance.\r
//\r
Status = EFI_OUT_OF_RESOURCES;\r
goto ErrorExit;\r
}\r
+ \r
//\r
// Install protocol interfaces for the Disk IO device.\r
//\r
return Status;\r
}\r
\r
+\r
+/**\r
+ Stop this driver on ControllerHandle by removing Disk IO protocol and closing\r
+ the Block IO protocol on ControllerHandle.\r
+\r
+ @param This Protocol instance pointer.\r
+ @param ControllerHandle Handle of device to stop driver on\r
+ @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of\r
+ children is zero stop the entire bus driver.\r
+ @param ChildHandleBuffer List of Child Handles to Stop.\r
+\r
+ @retval EFI_SUCCESS This driver is removed ControllerHandle\r
+ @retval other This driver was not removed from this device\r
+\r
+**/\r
EFI_STATUS\r
EFIAPI\r
DiskIoDriverBindingStop (\r
IN UINTN NumberOfChildren,\r
IN EFI_HANDLE *ChildHandleBuffer\r
)\r
-/*++\r
-\r
- Routine Description:\r
- Stop this driver on ControllerHandle by removing Disk IO protocol and closing\r
- the Block IO protocol on ControllerHandle.\r
-\r
- Arguments:\r
- This - Protocol instance pointer.\r
- ControllerHandle - Handle of device to stop driver on.\r
- NumberOfChildren - Not used.\r
- ChildHandleBuffer - Not used.\r
-\r
- Returns:\r
- EFI_SUCCESS - This driver is removed ControllerHandle.\r
- other - This driver was not removed from this device.\r
- EFI_UNSUPPORTED\r
-\r
---*/\r
{\r
EFI_STATUS Status;\r
EFI_DISK_IO_PROTOCOL *DiskIo;\r
return Status;\r
}\r
\r
+\r
+\r
+/**\r
+ Read BufferSize bytes from Offset into Buffer.\r
+ Reads may support reads that are not aligned on\r
+ sector boundaries. There are three cases:\r
+ UnderRun - The first byte is not on a sector boundary or the read request is\r
+ less than a sector in length.\r
+ Aligned - A read of N contiguous sectors.\r
+ OverRun - The last byte is not on a sector boundary.\r
+\r
+ @param This Protocol instance pointer.\r
+ @param MediaId Id of the media, changes every time the media is replaced.\r
+ @param Offset The starting byte offset to read from\r
+ @param BufferSize Size of Buffer\r
+ @param Buffer Buffer containing read data\r
+\r
+ @retval EFI_SUCCESS The data was read correctly from the device.\r
+ @retval EFI_DEVICE_ERROR The device reported an error while performing the read.\r
+ @retval EFI_NO_MEDIA There is no media in the device.\r
+ @retval EFI_MEDIA_CHNAGED The MediaId does not matched the current device.\r
+ @retval EFI_INVALID_PARAMETER The read request contains device addresses that are not\r
+ valid for the device.\r
+\r
+**/\r
EFI_STATUS\r
EFIAPI\r
DiskIoReadDisk (\r
IN UINTN BufferSize,\r
OUT VOID *Buffer\r
)\r
-/*++\r
-\r
- Routine Description:\r
- Read BufferSize bytes from Offset into Buffer.\r
-\r
- Reads may support reads that are not aligned on\r
- sector boundaries. There are three cases:\r
-\r
- UnderRun - The first byte is not on a sector boundary or the read request is\r
- less than a sector in length.\r
-\r
- Aligned - A read of N contiguous sectors.\r
-\r
- OverRun - The last byte is not on a sector boundary.\r
-\r
-\r
- Arguments:\r
- This - Protocol instance pointer.\r
- MediaId - Id of the media, changes every time the media is replaced.\r
- Offset - The starting byte offset to read from.\r
- BufferSize - Size of Buffer.\r
- Buffer - Buffer containing read data.\r
-\r
- Returns:\r
- EFI_SUCCESS - The data was read correctly from the device.\r
- EFI_DEVICE_ERROR - The device reported an error while performing the read.\r
- EFI_NO_MEDIA - There is no media in the device.\r
- EFI_MEDIA_CHNAGED - The MediaId does not matched the current device.\r
- EFI_INVALID_PARAMETER - The read request contains device addresses that are not\r
- valid for the device.\r
- EFI_OUT_OF_RESOURCES\r
-\r
---*/\r
{\r
EFI_STATUS Status;\r
DISK_IO_PRIVATE_DATA *Private;\r
return Status;\r
}\r
\r
+\r
+/**\r
+ Read BufferSize bytes from Offset into Buffer.\r
+ Writes may require a read modify write to support writes that are not\r
+ aligned on sector boundaries. There are three cases:\r
+ UnderRun - The first byte is not on a sector boundary or the write request\r
+ is less than a sector in length. Read modify write is required.\r
+ Aligned - A write of N contiguous sectors.\r
+ OverRun - The last byte is not on a sector boundary. Read modified write\r
+ required.\r
+\r
+ @param This Protocol instance pointer.\r
+ @param MediaId Id of the media, changes every time the media is replaced.\r
+ @param Offset The starting byte offset to read from\r
+ @param BufferSize Size of Buffer\r
+ @param Buffer Buffer containing read data\r
+\r
+ @retval EFI_SUCCESS The data was written correctly to the device.\r
+ @retval EFI_WRITE_PROTECTED The device can not be written to.\r
+ @retval EFI_DEVICE_ERROR The device reported an error while performing the write.\r
+ @retval EFI_NO_MEDIA There is no media in the device.\r
+ @retval EFI_MEDIA_CHNAGED The MediaId does not matched the current device.\r
+ @retval EFI_INVALID_PARAMETER The write request contains device addresses that are not\r
+ valid for the device.\r
+\r
+**/\r
EFI_STATUS\r
EFIAPI\r
DiskIoWriteDisk (\r
IN UINTN BufferSize,\r
IN VOID *Buffer\r
)\r
-/*++\r
-\r
- Routine Description:\r
- Read BufferSize bytes from Offset into Buffer.\r
-\r
- Writes may require a read modify write to support writes that are not\r
- aligned on sector boundaries. There are three cases:\r
-\r
- UnderRun - The first byte is not on a sector boundary or the write request\r
- is less than a sector in length. Read modify write is required.\r
-\r
- Aligned - A write of N contiguous sectors.\r
-\r
- OverRun - The last byte is not on a sector boundary. Read modified write\r
- required.\r
-\r
- Arguments:\r
- This - Protocol instance pointer.\r
- MediaId - Id of the media, changes every time the media is replaced.\r
- Offset - The starting byte offset to read from.\r
- BufferSize - Size of Buffer.\r
- Buffer - Buffer containing read data.\r
-\r
- Returns:\r
- EFI_SUCCESS - The data was written correctly to the device.\r
- EFI_WRITE_PROTECTED - The device can not be written to.\r
- EFI_DEVICE_ERROR - The device reported an error while performing the write.\r
- EFI_NO_MEDIA - There is no media in the device.\r
- EFI_MEDIA_CHNAGED - The MediaId does not matched the current device.\r
- EFI_INVALID_PARAMETER - The write request contains device addresses that are not\r
- valid for the device.\r
- EFI_OUT_OF_RESOURCES\r
-\r
---*/\r
{\r
EFI_STATUS Status;\r
DISK_IO_PRIVATE_DATA *Private;\r
\r
return Status;\r
}\r
+\r
+\r
+/**\r
+ The user Entry Point for module DiskIo. The user code starts with this function.\r
+\r
+ @param[in] ImageHandle The firmware allocated handle for the EFI image. \r
+ @param[in] SystemTable A pointer to the EFI System Table.\r
+ \r
+ @retval EFI_SUCCESS The entry point is executed successfully.\r
+ @retval other Some error occurs when executing this entry point.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+InitializeDiskIo (\r
+ IN EFI_HANDLE ImageHandle,\r
+ IN EFI_SYSTEM_TABLE *SystemTable\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+\r
+ //\r
+ // Install driver model protocol(s).\r
+ //\r
+ Status = EfiLibInstallAllDriverProtocols (\r
+ ImageHandle,\r
+ SystemTable,\r
+ &gDiskIoDriverBinding,\r
+ ImageHandle,\r
+ &gDiskIoComponentName,\r
+ NULL,\r
+ NULL\r
+ );\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+\r
+ return Status;\r
+}\r
+\r