/** @file
Functions to deal with Disk buffer.
Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved. <BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include "HexEditor.h"
extern EFI_HANDLE HImageHandleBackup;
extern HEFI_EDITOR_BUFFER_IMAGE HBufferImage;
extern BOOLEAN HBufferImageNeedRefresh;
extern BOOLEAN HBufferImageMouseNeedRefresh;
extern HEFI_EDITOR_GLOBAL_EDITOR HMainEditor;
//
// for basic initialization of HDiskImage
//
NULL,
0,
0,
0
};
/**
Initialization function for HDiskImage.
@retval EFI_SUCCESS The operation was successful.
@retval EFI_LOAD_ERROR A load error occured.
**/
)
{
//
// basically initialize the HDiskImage
//
return EFI_SUCCESS;
}
/**
Backup function for HDiskImage. Only a few fields need to be backup.
This is for making the Disk buffer refresh as few as possible.
@retval EFI_SUCCESS The operation was successful.
@retval EFI_OUT_OF_RESOURCES gST->ConOut of resources.
**/
)
{
//
// backup the disk name, offset and size
//
//
return EFI_OUT_OF_RESOURCES;
}
return EFI_SUCCESS;
}
/**
Cleanup function for HDiskImage.
@retval EFI_SUCCESS The operation was successful.
**/
)
{
return EFI_SUCCESS;
}
/**
Set FileName field in HFileImage.
@param[in] Str File name to set.
@param[in] Offset The offset.
@param[in] Size The size.
@retval EFI_SUCCESS The operation was successful.
@retval EFI_OUT_OF_RESOURCES A memory allocation failed.
**/
)
{
//
// free the old file name
//
return EFI_OUT_OF_RESOURCES;
}
}
return EFI_SUCCESS;
}
/**
Read a disk from disk into HBufferImage.
@param[in] DeviceName filename to read.
@param[in] Offset The offset.
@param[in] Size The size.
@param[in] Recover if is for recover, no information print.
@retval EFI_SUCCESS The operation was successful.
@retval EFI_OUT_OF_RESOURCES A memory allocation failed.
@retval EFI_LOAD_ERROR A load error occured.
@retval EFI_INVALID_PARAMETER A parameter was invalid.
**/
)
{
if (DevicePath == NULL) {
StatusBarSetStatusString (L"Cannot Find Device");
return EFI_INVALID_PARAMETER;
}
//
// get blkio interface
//
StatusBarSetStatusString (L"Read Disk Failed");
return Status;
}
Status = gBS->OpenProtocol(Handle, &gEfiBlockIoProtocolGuid, (VOID**)&BlkIo, gImageHandle, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL);
StatusBarSetStatusString (L"Read Disk Failed");
return Status;
}
//
// if Offset exceeds LastBlock,
// return error
//
StatusBarSetStatusString (L"Invalid Offset + Size");
return EFI_LOAD_ERROR;
}
StatusBarSetStatusString (L"Read Disk Failed");
return EFI_OUT_OF_RESOURCES;
}
//
// read from disk
//
);
StatusBarSetStatusString (L"Read Disk Failed");
return EFI_LOAD_ERROR;
}
HBufferImageFree ();
//
// convert buffer to line list
//
StatusBarSetStatusString (L"Read Disk Failed");
return Status;
}
StatusBarSetStatusString (L"Read Disk Failed");
return EFI_OUT_OF_RESOURCES;
}
//
// initialize some variables
//
if (!Recover) {
StatusBarSetStatusString (L"Read Disk Failed");
return EFI_OUT_OF_RESOURCES;
}
HMainEditor.SelectStart = 0;
HMainEditor.SelectEnd = 0;
}
//
// has line
//
Link,
);
} else {
//
// create a dummy line
//
Line = HBufferImageCreateLine ();
StatusBarSetStatusString (L"Read Disk Failed");
return EFI_OUT_OF_RESOURCES;
}
}
return EFI_SUCCESS;
}
/**
Save lines in HBufferImage to disk.
NOT ALLOW TO WRITE TO ANOTHER DISK!!!!!!!!!
@param[in] DeviceName The device name.
@param[in] Offset The offset.
@param[in] Size The size.
@retval EFI_SUCCESS The operation was successful.
@retval EFI_OUT_OF_RESOURCES A memory allocation failed.
@retval EFI_LOAD_ERROR A load error occured.
@retval EFI_INVALID_PARAMETER A parameter was invalid.
**/
)
{
//
// if not modified, directly return
//
return EFI_SUCCESS;
}
if (DevicePath == NULL) {
// StatusBarSetStatusString (L"Cannot Find Device");
return EFI_INVALID_PARAMETER;
}
//
// get blkio interface
//
// StatusBarSetStatusString (L"Read Disk Failed");
return Status;
}
Status = gBS->OpenProtocol(Handle, &gEfiBlockIoProtocolGuid, (VOID**)&BlkIo, gImageHandle, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL);
// StatusBarSetStatusString (L"Read Disk Failed");
return Status;
}
return EFI_OUT_OF_RESOURCES;
}
//
// concatenate the line list to a buffer
//
return Status;
}
//
// write the buffer to disk
//
);
return EFI_LOAD_ERROR;
}
//
// now not modified
//
return EFI_SUCCESS;
}