/** @file\r
Functions to deal with Disk buffer.\r
\r
- Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved. <BR>\r
+ Copyright (c) 2005 - 2016, Intel Corporation. All rights reserved. <BR>\r
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
0\r
};\r
\r
+/**\r
+ Initialization function for HDiskImage.\r
+ \r
+ @retval EFI_SUCCESS The operation was successful.\r
+ @retval EFI_LOAD_ERROR A load error occured.\r
+**/\r
EFI_STATUS\r
HDiskImageInit (\r
VOID\r
)\r
-/*++\r
-\r
-Routine Description: \r
-\r
- Initialization function for HDiskImage\r
-\r
-Arguments: \r
-\r
- None\r
-\r
-Returns: \r
-\r
- EFI_SUCCESS\r
- EFI_LOAD_ERROR\r
-\r
---*/\r
{\r
//\r
// basically initialize the HDiskImage\r
return EFI_SUCCESS;\r
}\r
\r
+/**\r
+ Backup function for HDiskImage. Only a few fields need to be backup. \r
+ This is for making the Disk buffer refresh as few as possible.\r
+\r
+ @retval EFI_SUCCESS The operation was successful.\r
+ @retval EFI_OUT_OF_RESOURCES gST->ConOut of resources.\r
+**/\r
EFI_STATUS\r
HDiskImageBackup (\r
VOID\r
)\r
-/*++\r
-\r
-Routine Description: \r
-\r
- Backup function for HDiskImage\r
- Only a few fields need to be backup. \r
- This is for making the Disk buffer refresh \r
- as few as possible.\r
-\r
-Arguments: \r
-\r
- None\r
-\r
-Returns: \r
-\r
- EFI_SUCCESS - Success\r
- EFI_OUT_OF_RESOURCES - gST->ConOut of resources\r
-\r
---*/\r
{\r
//\r
// backup the disk name, offset and size\r
return EFI_SUCCESS;\r
}\r
\r
+/**\r
+ Cleanup function for HDiskImage.\r
+\r
+ @retval EFI_SUCCESS The operation was successful.\r
+**/\r
EFI_STATUS\r
HDiskImageCleanup (\r
VOID\r
)\r
-/*++\r
-\r
-Routine Description: \r
-\r
- Cleanup function for HDiskImage\r
-\r
-Arguments: \r
-\r
- None\r
-\r
-Returns: \r
-\r
- EFI_SUCCESS\r
-\r
---*/\r
{\r
SHELL_FREE_NON_NULL (HDiskImage.Name);\r
SHELL_FREE_NON_NULL (HDiskImageBackupVar.Name);\r
return EFI_SUCCESS;\r
}\r
\r
+/**\r
+ Set FileName field in HFileImage.\r
+\r
+ @param[in] Str File name to set.\r
+ @param[in] Offset The offset.\r
+ @param[in] Size The size.\r
+\r
+ @retval EFI_SUCCESS The operation was successful.\r
+ @retval EFI_OUT_OF_RESOURCES A memory allocation failed.\r
+**/\r
EFI_STATUS\r
EFIAPI\r
HDiskImageSetDiskNameOffsetSize (\r
IN UINTN Offset,\r
IN UINTN Size\r
)\r
-/*++\r
-\r
-Routine Description: \r
-\r
- Set FileName field in HFileImage\r
-\r
-Arguments: \r
-\r
- Str - File name to set\r
- Offset - The offset\r
- Size - The size\r
-\r
-Returns: \r
-\r
- EFI_SUCCESS\r
- EFI_OUT_OF_RESOURCES\r
-\r
---*/\r
{\r
UINTN Len;\r
UINTN Index;\r
return EFI_SUCCESS;\r
}\r
\r
+/**\r
+ Read a disk from disk into HBufferImage.\r
+\r
+ @param[in] DeviceName filename to read.\r
+ @param[in] Offset The offset.\r
+ @param[in] Size The size.\r
+ @param[in] Recover if is for recover, no information print.\r
+\r
+ @retval EFI_SUCCESS The operation was successful.\r
+ @retval EFI_OUT_OF_RESOURCES A memory allocation failed.\r
+ @retval EFI_LOAD_ERROR A load error occured.\r
+ @retval EFI_INVALID_PARAMETER A parameter was invalid. \r
+**/\r
EFI_STATUS\r
HDiskImageRead (\r
IN CONST CHAR16 *DeviceName,\r
IN UINTN Size,\r
IN BOOLEAN Recover\r
)\r
-/*++\r
-\r
-Routine Description: \r
-\r
- Read a disk from disk into HBufferImage\r
-\r
-Arguments: \r
-\r
- DeviceName - filename to read\r
- Offset - The offset\r
- Size - The size\r
- Recover - if is for recover, no information print\r
-\r
-Returns: \r
-\r
- EFI_SUCCESS\r
- EFI_LOAD_ERROR\r
- EFI_OUT_OF_RESOURCES\r
- EFI_INVALID_PARAMETER \r
- \r
---*/\r
{\r
CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
EFI_DEVICE_PATH_PROTOCOL *DupDevicePath;\r
UINTN Bytes;\r
\r
HEFI_EDITOR_LINE *Line;\r
- UINT64 ByteOffset;\r
\r
- EDIT_FILE_TYPE BufferTypeBackup;\r
-\r
- BufferTypeBackup = HBufferImage.BufferType;\r
HBufferImage.BufferType = FileTypeDiskBuffer;\r
\r
DevicePath = gEfiShellProtocol->GetDevicePathFromMap(DeviceName);\r
return EFI_OUT_OF_RESOURCES;\r
}\r
\r
- ByteOffset = MultU64x32 (Offset, BlkIo->Media->BlockSize);\r
-\r
//\r
// read from disk\r
//\r
return EFI_SUCCESS;\r
}\r
\r
+/**\r
+ Save lines in HBufferImage to disk.\r
+ NOT ALLOW TO WRITE TO ANOTHER DISK!!!!!!!!!\r
+\r
+ @param[in] DeviceName The device name.\r
+ @param[in] Offset The offset.\r
+ @param[in] Size The size.\r
+\r
+ @retval EFI_SUCCESS The operation was successful.\r
+ @retval EFI_OUT_OF_RESOURCES A memory allocation failed.\r
+ @retval EFI_LOAD_ERROR A load error occured.\r
+ @retval EFI_INVALID_PARAMETER A parameter was invalid. \r
+**/\r
EFI_STATUS\r
HDiskImageSave (\r
IN CHAR16 *DeviceName,\r
IN UINTN Offset,\r
IN UINTN Size\r
)\r
-/*++\r
-\r
-Routine Description: \r
-\r
- Save lines in HBufferImage to disk\r
- NOT ALLOW TO WRITE TO ANOTHER DISK!!!!!!!!!\r
-\r
-Arguments: \r
-\r
- DeviceName - The device name\r
- Offset - The offset\r
- Size - The size\r
-\r
-Returns: \r
-\r
- EFI_SUCCESS\r
- EFI_LOAD_ERROR\r
- EFI_OUT_OF_RESOURCES\r
- EFI_INVALID_PARAMETER\r
-\r
---*/\r
{\r
\r
CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
EFI_DEVICE_PATH_PROTOCOL *DupDevicePath;\r
+ EFI_DEVICE_PATH_PROTOCOL *DupDevicePathForFree;\r
EFI_BLOCK_IO_PROTOCOL *BlkIo;\r
EFI_STATUS Status;\r
EFI_HANDLE Handle;\r
VOID *Buffer;\r
UINTN Bytes;\r
\r
- UINT64 ByteOffset;\r
-\r
- EDIT_FILE_TYPE BufferTypeBackup;\r
-\r
//\r
// if not modified, directly return\r
//\r
return EFI_SUCCESS;\r
}\r
\r
- BufferTypeBackup = HBufferImage.BufferType;\r
HBufferImage.BufferType = FileTypeDiskBuffer;\r
\r
DevicePath = gEfiShellProtocol->GetDevicePathFromMap(DeviceName);\r
return EFI_INVALID_PARAMETER;\r
}\r
DupDevicePath = DuplicateDevicePath(DevicePath);\r
+ DupDevicePathForFree = DupDevicePath;\r
\r
//\r
// get blkio interface\r
//\r
Status = gBS->LocateDevicePath(&gEfiBlockIoProtocolGuid,&DupDevicePath,&Handle);\r
- FreePool(DupDevicePath);\r
+ FreePool(DupDevicePathForFree);\r
if (EFI_ERROR (Status)) {\r
// StatusBarSetStatusString (L"Read Disk Failed");\r
return Status;\r
return Status;\r
}\r
\r
- ByteOffset = MultU64x32 (Offset, BlkIo->Media->BlockSize);\r
-\r
//\r
// write the buffer to disk\r
//\r