-/*++\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
- Partition.c\r
-\r
-Abstract:\r
-\r
+/** @file\r
Partition driver that produces logical BlockIo devices from a physical\r
BlockIo device. The logical BlockIo devices are based on the format\r
of the raw block devices media. Currently "El Torito CD-ROM", Legacy\r
MBR, and GPT partition schemes are supported.\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
-//\r
-#include "CommonHeader.h"\r
\r
#include "Partition.h"\r
\r
};\r
\r
\r
+\r
+/**\r
+ Test to see if this driver supports ControllerHandle. Any ControllerHandle\r
+ than contains a BlockIo and DiskIo protocol can be supported.\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
PartitionDriverBindingSupported (\r
IN EFI_HANDLE ControllerHandle,\r
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
)\r
-/*++\r
-\r
- Routine Description:\r
- Test to see if this driver supports ControllerHandle. Any ControllerHandle\r
- than contains a BlockIo and DiskIo 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
- EFI_UNSUPPORTED - This driver does not support this device\r
-\r
---*/\r
{\r
EFI_STATUS Status;\r
EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;\r
return Status;\r
}\r
\r
+\r
+/**\r
+ Start this driver on ControllerHandle by opening a Block IO and Disk IO\r
+ protocol, reading Device Path, and creating a child handle with a\r
+ Disk IO and device path protocol.\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
PartitionDriverBindingStart (\r
IN EFI_HANDLE ControllerHandle,\r
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
)\r
-/*++\r
-\r
- Routine Description:\r
- Start this driver on ControllerHandle by opening a Block IO and Disk IO\r
- protocol, reading Device Path, and creating a child handle with a\r
- Disk IO and device path protocol.\r
-\r
- Arguments:\r
- This - Protocol instance pointer.\r
- ControllerHandle - Handle of device to bind driver to\r
- RemainingDevicePath - Not used\r
-\r
- Returns:\r
- EFI_SUCCESS - This driver is added to DeviceHandle\r
- EFI_ALREADY_STARTED - This driver is already running on DeviceHandle\r
- other - This driver does not support this device\r
-\r
---*/\r
{\r
EFI_STATUS Status;\r
EFI_STATUS OpenStatus;\r
return Status;\r
}\r
\r
+\r
+/**\r
+ Stop this driver on ControllerHandle. Support stoping any child handles\r
+ created by this driver.\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
PartitionDriverBindingStop (\r
IN UINTN NumberOfChildren,\r
IN EFI_HANDLE *ChildHandleBuffer\r
)\r
-/*++\r
-\r
- Routine Description:\r
- Stop this driver on ControllerHandle. Support stoping any child handles\r
- created by this driver.\r
-\r
- Arguments:\r
- This - Protocol instance pointer.\r
- ControllerHandle - Handle of device to stop driver on\r
- NumberOfChildren - Number of Children in the ChildHandleBuffer\r
- ChildHandleBuffer - List of handles for the children we need to stop.\r
-\r
- Returns:\r
- EFI_SUCCESS - This driver is removed DeviceHandle\r
- EFI_DEVICE_ERROR - This driver was not removed from this device\r
-\r
---*/\r
{\r
EFI_STATUS Status;\r
UINTN Index;\r
return EFI_SUCCESS;\r
}\r
\r
+\r
+/**\r
+ Reset the Block Device.\r
+\r
+ @param This Protocol instance pointer.\r
+ @param ExtendedVerification Driver may perform diagnostics on reset.\r
+\r
+ @retval EFI_SUCCESS The device was reset.\r
+ @retval EFI_DEVICE_ERROR The device is not functioning properly and could\r
+ not be reset.\r
+\r
+**/\r
STATIC\r
EFI_STATUS\r
EFIAPI\r
IN EFI_BLOCK_IO_PROTOCOL *This,\r
IN BOOLEAN ExtendedVerification\r
)\r
-/*++\r
-\r
- Routine Description:\r
- Reset the parent Block Device.\r
-\r
- Arguments:\r
- This - Protocol instance pointer.\r
- ExtendedVerification - Driver may perform diagnostics on reset.\r
-\r
- Returns:\r
- EFI_SUCCESS - The device was reset.\r
- EFI_DEVICE_ERROR - The device is not functioning properly and could\r
- not be reset.\r
-\r
---*/\r
{\r
PARTITION_PRIVATE_DATA *Private;\r
\r
);\r
}\r
\r
+\r
+/**\r
+ Read by using the Disk IO protocol on the parent device. Lba addresses\r
+ must be converted to byte offsets.\r
+\r
+ @param This Protocol instance pointer.\r
+ @param MediaId Id of the media, changes every time the media is replaced.\r
+ @param Lba The starting Logical Block Address to read from\r
+ @param BufferSize Size of Buffer, must be a multiple of device block size.\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_CHANGED The MediaId does not matched the current device.\r
+ @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.\r
+ @retval EFI_INVALID_PARAMETER The read request contains device addresses that are not\r
+ valid for the device.\r
+\r
+**/\r
STATIC\r
EFI_STATUS\r
EFIAPI\r
IN UINTN BufferSize,\r
OUT VOID *Buffer\r
)\r
-/*++\r
-\r
- Routine Description:\r
- Read by using the Disk IO protocol on the parent device. Lba addresses\r
- must be converted to byte offsets.\r
-\r
- Arguments:\r
- This - Protocol instance pointer.\r
- MediaId - Id of the media, changes every time the media is replaced.\r
- Lba - The starting Logical Block Address to read from\r
- BufferSize - Size of Buffer, must be a multiple of device block size.\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_CHANGED - The MediaId does not matched the current device.\r
- EFI_BAD_BUFFER_SIZE - The Buffer was not a multiple of the block size of the\r
- device.\r
- EFI_INVALID_PARAMETER - The read request contains device addresses that are not\r
- valid for the device.\r
-\r
---*/\r
{\r
PARTITION_PRIVATE_DATA *Private;\r
UINT64 Offset;\r
return Private->DiskIo->ReadDisk (Private->DiskIo, MediaId, Offset, BufferSize, Buffer);\r
}\r
\r
+/**\r
+ Write by using the Disk IO protocol on the parent device. Lba addresses\r
+ must be converted to byte offsets.\r
+\r
+ @param This Protocol instance pointer.\r
+ @param MediaId Id of the media, changes every time the media is replaced.\r
+ @param Lba The starting Logical Block Address to read from\r
+ @param BufferSize Size of Buffer, must be a multiple of device block size.\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_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.\r
+ @retval EFI_INVALID_PARAMETER The write request contains a LBA that is not\r
+ valid for the device.\r
+\r
+**/\r
STATIC\r
EFI_STATUS\r
EFIAPI\r
IN UINTN BufferSize,\r
OUT VOID *Buffer\r
)\r
-/*++\r
-\r
- Routine Description:\r
- Write by using the Disk IO protocol on the parent device. Lba addresses\r
- must be converted to byte offsets.\r
-\r
- Arguments:\r
- This - Protocol instance pointer.\r
- MediaId - Id of the media, changes every time the media is replaced.\r
- Lba - The starting Logical Block Address to read from\r
- BufferSize - Size of Buffer, must be a multiple of device block size.\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_BAD_BUFFER_SIZE - The Buffer was not a multiple of the block size of the\r
- device.\r
- EFI_INVALID_PARAMETER - The write request contains a LBA that is not\r
- valid for the device.\r
-\r
---*/\r
{\r
PARTITION_PRIVATE_DATA *Private;\r
UINT64 Offset;\r
return Private->DiskIo->WriteDisk (Private->DiskIo, MediaId, Offset, BufferSize, Buffer);\r
}\r
\r
+\r
+/**\r
+ Flush the parent Block Device.\r
+\r
+ @param This Protocol instance pointer.\r
+\r
+ @retval EFI_SUCCESS All outstanding data was written to the device\r
+ @retval EFI_DEVICE_ERROR The device reported an error while writting back the data\r
+ @retval EFI_NO_MEDIA There is no media in the device.\r
+\r
+**/\r
STATIC\r
EFI_STATUS\r
EFIAPI\r
PartitionFlushBlocks (\r
IN EFI_BLOCK_IO_PROTOCOL *This\r
)\r
-/*++\r
-\r
- Routine Description:\r
- Flush the parent Block Device.\r
-\r
- Arguments:\r
- This - Protocol instance pointer.\r
-\r
- Returns:\r
- EFI_SUCCESS - All outstanding data was written to the device\r
- EFI_DEVICE_ERROR - The device reported an error while writing back the data\r
- EFI_NO_MEDIA - There is no media in the device.\r
-\r
---*/\r
{\r
PARTITION_PRIVATE_DATA *Private;\r
\r
return Private->ParentBlockIo->FlushBlocks (Private->ParentBlockIo);\r
}\r
\r
+\r
+\r
+/**\r
+ Create a child handle for a logical block device that represents the\r
+ bytes Start to End of the Parent Block IO device.\r
+\r
+ @param[in] This Protocol instance pointer.\r
+ @param[in] This Calling context.\r
+ @param[in] ParentHandle Parent Handle for new child\r
+ @param[in] ParentDiskIo Parent DiskIo interface\r
+ @param[in] ParentBlockIo Parent BlockIo interface\r
+ @param[in] ParentDevicePath Parent Device Path\r
+ @param[in] DevicePathNode Child Device Path node\r
+ @param[in] Start Start Block\r
+ @param[in] End End Block\r
+ @param[in] BlockSize Child block size\r
+ @param[in] InstallEspGuid Flag to install EFI System Partition GUID on handle\r
+\r
+ @retval EFI_SUCCESS A child handle was added\r
+ @retval other A child handle was not added\r
+\r
+**/\r
EFI_STATUS\r
PartitionInstallChildHandle (\r
IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
IN UINT32 BlockSize,\r
IN BOOLEAN InstallEspGuid\r
)\r
-/*++\r
-\r
-Routine Description:\r
- Create a child handle for a logical block device that represents the\r
- bytes Start to End of the Parent Block IO device.\r
-\r
-Arguments:\r
- This - Calling context.\r
- ParentHandle - Parent Handle for new child\r
- ParentDiskIo - Parent DiskIo interface\r
- ParentBlockIo - Parent BlockIo interface\r
- ParentDevicePath - Parent Device Path\r
- DevicePathNode - Child Device Path node\r
- Start - Start Block\r
- End - End Block\r
- BlockSize - Child block size\r
- InstallEspGuid - Flag to install EFI System Partition GUID on handle\r
-\r
-Returns:\r
- EFI_SUCCESS - If a child handle was added\r
- EFI_OUT_OF_RESOURCES - A child handle was not added\r
-\r
---*/\r
{\r
EFI_STATUS Status;\r
PARTITION_PRIVATE_DATA *Private;\r
\r
return Status;\r
}\r
+\r
+\r
+/**\r
+ The user Entry Point for module Partition. 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
+InitializePartition (\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
+ &gPartitionDriverBinding,\r
+ ImageHandle,\r
+ &gPartitionComponentName,\r
+ NULL,\r
+ NULL\r
+ );\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+\r
+ return Status;\r
+}\r
+\r