mirror of https://github.com/acidanthera/audk.git
Added CWD to EfiFileLib. Fix some X64 warnings.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9942 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
3ba736f39c
commit
85e385f42b
|
@ -1057,7 +1057,7 @@ DisassembleInstruction (
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (Thumb) {
|
if (Thumb) {
|
||||||
DisassembleThumbInstruction ((UINT16 **)OpCodePtr, Buf, Size, &ItBlock, Extended);
|
DisassembleThumbInstruction ((UINT16 **)OpCodePtr, Buf, Size, ItBlock, Extended);
|
||||||
} else {
|
} else {
|
||||||
DisassembleArmInstruction ((UINT32 **)OpCodePtr, Buf, Size, Extended);
|
DisassembleArmInstruction ((UINT32 **)OpCodePtr, Buf, Size, Extended);
|
||||||
}
|
}
|
||||||
|
|
|
@ -282,13 +282,13 @@ EblExitCmd (
|
||||||
IN CHAR8 **Argv
|
IN CHAR8 **Argv
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
UINTN MemoryMapSize;
|
UINTN MemoryMapSize;
|
||||||
EFI_MEMORY_DESCRIPTOR *MemoryMap;
|
EFI_MEMORY_DESCRIPTOR *MemoryMap;
|
||||||
UINTN MapKey;
|
UINTN MapKey;
|
||||||
UINTN DescriptorSize;
|
UINTN DescriptorSize;
|
||||||
UINTN DescriptorVersion;
|
UINT32 DescriptorVersion;
|
||||||
UINTN Pages;
|
UINTN Pages;
|
||||||
|
|
||||||
if (Argc > 1) {
|
if (Argc > 1) {
|
||||||
if (AsciiStriCmp (Argv[1], "efi") != 0) {
|
if (AsciiStriCmp (Argv[1], "efi") != 0) {
|
||||||
|
@ -298,42 +298,42 @@ EblExitCmd (
|
||||||
return EFI_ABORTED;
|
return EFI_ABORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
MemoryMap = NULL;
|
MemoryMap = NULL;
|
||||||
MemoryMapSize = 0;
|
MemoryMapSize = 0;
|
||||||
do {
|
do {
|
||||||
Status = gBS->GetMemoryMap (
|
Status = gBS->GetMemoryMap (
|
||||||
&MemoryMapSize,
|
&MemoryMapSize,
|
||||||
MemoryMap,
|
MemoryMap,
|
||||||
&MapKey,
|
&MapKey,
|
||||||
&DescriptorSize,
|
&DescriptorSize,
|
||||||
&DescriptorVersion
|
&DescriptorVersion
|
||||||
);
|
);
|
||||||
if (Status == EFI_BUFFER_TOO_SMALL) {
|
if (Status == EFI_BUFFER_TOO_SMALL) {
|
||||||
|
|
||||||
Pages = EFI_SIZE_TO_PAGES (MemoryMapSize) + 1;
|
Pages = EFI_SIZE_TO_PAGES (MemoryMapSize) + 1;
|
||||||
MemoryMap = AllocatePages (Pages);
|
MemoryMap = AllocatePages (Pages);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Get System MemoryMap
|
// Get System MemoryMap
|
||||||
//
|
//
|
||||||
Status = gBS->GetMemoryMap (
|
Status = gBS->GetMemoryMap (
|
||||||
&MemoryMapSize,
|
&MemoryMapSize,
|
||||||
MemoryMap,
|
MemoryMap,
|
||||||
&MapKey,
|
&MapKey,
|
||||||
&DescriptorSize,
|
&DescriptorSize,
|
||||||
&DescriptorVersion
|
&DescriptorVersion
|
||||||
);
|
);
|
||||||
// Don't do anything between the GetMemoryMap() and ExitBootServices()
|
// Don't do anything between the GetMemoryMap() and ExitBootServices()
|
||||||
if (!EFI_ERROR (Status)) {
|
if (!EFI_ERROR (Status)) {
|
||||||
Status = gBS->ExitBootServices (gImageHandle, MapKey);
|
Status = gBS->ExitBootServices (gImageHandle, MapKey);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
FreePages (MemoryMap, Pages);
|
FreePages (MemoryMap, Pages);
|
||||||
MemoryMap = NULL;
|
MemoryMap = NULL;
|
||||||
MemoryMapSize = 0;
|
MemoryMapSize = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while (EFI_ERROR (Status));
|
} while (EFI_ERROR (Status));
|
||||||
|
|
||||||
//
|
//
|
||||||
// At this point it is very dangerous to do things EFI as most of EFI is now gone.
|
// At this point it is very dangerous to do things EFI as most of EFI is now gone.
|
||||||
|
|
|
@ -311,5 +311,38 @@ UINTN
|
||||||
EfiGetDeviceCounts (
|
EfiGetDeviceCounts (
|
||||||
IN EFI_OPEN_FILE_TYPE Type
|
IN EFI_OPEN_FILE_TYPE Type
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Set the Curent Working Directory (CWD). If a call is made to EfiOpen () and
|
||||||
|
the path does not contain a device name, The CWD is prepended to the path.
|
||||||
|
|
||||||
|
@param Cwd Current Working Directory to set
|
||||||
|
|
||||||
|
|
||||||
|
@return EFI_SUCCESS CWD is set
|
||||||
|
@return EFI_INVALID_PARAMETER Cwd is not a valid device:path
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
EfiSetCwd (
|
||||||
|
IN CHAR8 *Cwd
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Set the Curent Working Directory (CWD). If a call is made to EfiOpen () and
|
||||||
|
the path does not contain a device name, The CWD is prepended to the path.
|
||||||
|
|
||||||
|
@param Cwd Current Working Directory
|
||||||
|
|
||||||
|
|
||||||
|
@return NULL No CWD set
|
||||||
|
@return 'other' malloc'ed buffer contains CWD.
|
||||||
|
|
||||||
|
**/
|
||||||
|
CHAR8 *
|
||||||
|
EfiGettCwd (
|
||||||
|
VOID
|
||||||
|
);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -55,6 +55,9 @@
|
||||||
#include <Library/EblNetworkLib.h>
|
#include <Library/EblNetworkLib.h>
|
||||||
|
|
||||||
|
|
||||||
|
CHAR8 *gCwd = NULL;
|
||||||
|
|
||||||
|
|
||||||
#define EFI_OPEN_FILE_GUARD_HEADER 0x4B4D4641
|
#define EFI_OPEN_FILE_GUARD_HEADER 0x4B4D4641
|
||||||
#define EFI_OPEN_FILE_GUARD_FOOTER 0x444D5A56
|
#define EFI_OPEN_FILE_GUARD_FOOTER 0x444D5A56
|
||||||
|
|
||||||
|
@ -635,6 +638,7 @@ EfiOpen (
|
||||||
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
|
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
|
||||||
UINTN Size;
|
UINTN Size;
|
||||||
EFI_IP_ADDRESS Ip;
|
EFI_IP_ADDRESS Ip;
|
||||||
|
CHAR8 *CwdPlusPathName;
|
||||||
|
|
||||||
EblUpdateDeviceLists ();
|
EblUpdateDeviceLists ();
|
||||||
|
|
||||||
|
@ -656,8 +660,22 @@ EfiOpen (
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FileStart == 0) {
|
if (FileStart == 0) {
|
||||||
|
if (gCwd == NULL) {
|
||||||
|
// No CWD
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
// We could add a current working diretory concept
|
// We could add a current working diretory concept
|
||||||
return NULL;
|
CwdPlusPathName = AllocatePool (AsciiStrSize (gCwd) + AsciiStrSize (PathName));
|
||||||
|
if (CwdPlusPathName == NULL) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
AsciiStrCpy (CwdPlusPathName, gCwd);
|
||||||
|
AsciiStrCat (CwdPlusPathName, PathName);
|
||||||
|
File = EfiOpen (CwdPlusPathName, OpenMode, SectionType);
|
||||||
|
FreePool (CwdPlusPathName);
|
||||||
|
return File;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -1481,3 +1499,66 @@ EfiWrite (
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Set the Curent Working Directory (CWD). If a call is made to EfiOpen () and
|
||||||
|
the path does not contain a device name, The CWD is prepended to the path.
|
||||||
|
|
||||||
|
@param Cwd Current Working Directory to set
|
||||||
|
|
||||||
|
|
||||||
|
@return EFI_SUCCESS CWD is set
|
||||||
|
@return EFI_INVALID_PARAMETER Cwd is not a valid device:path
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
EfiSetCwd (
|
||||||
|
IN CHAR8 *Cwd
|
||||||
|
)
|
||||||
|
{
|
||||||
|
EFI_OPEN_FILE *File;
|
||||||
|
|
||||||
|
File = EfiOpen (Cwd, EFI_FILE_MODE_READ, 0);
|
||||||
|
if (File == NULL) {
|
||||||
|
return EFI_INVALID_PARAMETER;
|
||||||
|
}
|
||||||
|
|
||||||
|
EfiClose (File);
|
||||||
|
|
||||||
|
if (gCwd != NULL) {
|
||||||
|
FreePool (gCwd);
|
||||||
|
}
|
||||||
|
|
||||||
|
gCwd = AllocatePool (AsciiStrSize (Cwd));
|
||||||
|
if (gCwd == NULL) {
|
||||||
|
return EFI_INVALID_PARAMETER;
|
||||||
|
}
|
||||||
|
AsciiStrCpy (gCwd, Cwd);
|
||||||
|
return EFI_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Set the Curent Working Directory (CWD). If a call is made to EfiOpen () and
|
||||||
|
the path does not contain a device name, The CWD is prepended to the path.
|
||||||
|
The CWD buffer is only valid until a new call is made to EfiSetCwd(). After
|
||||||
|
a call to EfiSetCwd() it is not legal to use the pointer returned by
|
||||||
|
this funciton.
|
||||||
|
|
||||||
|
@param Cwd Current Working Directory
|
||||||
|
|
||||||
|
|
||||||
|
@return NULL No CWD set
|
||||||
|
@return 'other' Returns buffer that contains CWD.
|
||||||
|
|
||||||
|
**/
|
||||||
|
CHAR8 *
|
||||||
|
EfiGettCwd (
|
||||||
|
VOID
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return gCwd;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue