mirror of
https://github.com/acidanthera/audk.git
synced 2025-07-31 01:24:12 +02:00
UnixPkg: Enable gasket functions for all X64 toolchains
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10924 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
124f761f02
commit
3ff2e32407
@ -48,7 +48,7 @@ char *gGdbWorkingFileName = NULL;
|
|||||||
//
|
//
|
||||||
// Globals
|
// Globals
|
||||||
//
|
//
|
||||||
#ifdef __APPLE__
|
#if defined(__APPLE__) || defined(MDE_CPU_X64)
|
||||||
UNIX_PEI_LOAD_FILE_PPI mSecUnixLoadFilePpi = { GasketSecUnixPeiLoadFile };
|
UNIX_PEI_LOAD_FILE_PPI mSecUnixLoadFilePpi = { GasketSecUnixPeiLoadFile };
|
||||||
PEI_UNIX_AUTOSCAN_PPI mSecUnixAutoScanPpi = { GasketSecUnixPeiAutoScan };
|
PEI_UNIX_AUTOSCAN_PPI mSecUnixAutoScanPpi = { GasketSecUnixPeiAutoScan };
|
||||||
PEI_UNIX_THUNK_PPI mSecUnixThunkPpi = { GasketSecUnixUnixThunkAddress };
|
PEI_UNIX_THUNK_PPI mSecUnixThunkPpi = { GasketSecUnixUnixThunkAddress };
|
||||||
@ -143,7 +143,7 @@ MapFile (
|
|||||||
IN OUT EFI_PHYSICAL_ADDRESS *BaseAddress,
|
IN OUT EFI_PHYSICAL_ADDRESS *BaseAddress,
|
||||||
OUT UINT64 *Length
|
OUT UINT64 *Length
|
||||||
);
|
);
|
||||||
|
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
EFIAPI
|
EFIAPI
|
||||||
SecNt32PeCoffRelocateImage (
|
SecNt32PeCoffRelocateImage (
|
||||||
@ -237,7 +237,7 @@ Returns:
|
|||||||
// Set InitialStackMemory to zero so UnixOpenFile will allocate a new mapping
|
// Set InitialStackMemory to zero so UnixOpenFile will allocate a new mapping
|
||||||
//
|
//
|
||||||
InitialStackMemorySize = STACK_SIZE;
|
InitialStackMemorySize = STACK_SIZE;
|
||||||
InitialStackMemory = (UINTN)MapMemory(0,
|
InitialStackMemory = (UINTN)MapMemory(0,
|
||||||
(UINT32) InitialStackMemorySize,
|
(UINT32) InitialStackMemorySize,
|
||||||
PROT_READ | PROT_WRITE | PROT_EXEC,
|
PROT_READ | PROT_WRITE | PROT_EXEC,
|
||||||
MAP_ANONYMOUS | MAP_PRIVATE);
|
MAP_ANONYMOUS | MAP_PRIVATE);
|
||||||
@ -249,7 +249,7 @@ Returns:
|
|||||||
printf (" SEC passing in %u KB of temp RAM at 0x%08lx to PEI\n",
|
printf (" SEC passing in %u KB of temp RAM at 0x%08lx to PEI\n",
|
||||||
(unsigned int)(InitialStackMemorySize / 1024),
|
(unsigned int)(InitialStackMemorySize / 1024),
|
||||||
(unsigned long)InitialStackMemory);
|
(unsigned long)InitialStackMemory);
|
||||||
|
|
||||||
for (StackPointer = (UINTN*) (UINTN) InitialStackMemory;
|
for (StackPointer = (UINTN*) (UINTN) InitialStackMemory;
|
||||||
StackPointer < (UINTN*)(UINTN)((UINTN) InitialStackMemory + (UINT64) InitialStackMemorySize);
|
StackPointer < (UINTN*)(UINTN)((UINTN) InitialStackMemory + (UINT64) InitialStackMemorySize);
|
||||||
StackPointer ++) {
|
StackPointer ++) {
|
||||||
@ -422,12 +422,12 @@ Returns:
|
|||||||
{
|
{
|
||||||
close (fd);
|
close (fd);
|
||||||
return EFI_DEVICE_ERROR;
|
return EFI_DEVICE_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
res = MapMemory(fd, FileSize, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE);
|
res = MapMemory(fd, FileSize, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE);
|
||||||
|
|
||||||
close (fd);
|
close (fd);
|
||||||
|
|
||||||
if (res == MAP_FAILED)
|
if (res == MAP_FAILED)
|
||||||
@ -493,7 +493,7 @@ Returns:
|
|||||||
|
|
||||||
} else if (ReportStatusCodeExtractDebugInfo (Data, &ErrorLevel, &Marker, &Format)) {
|
} else if (ReportStatusCodeExtractDebugInfo (Data, &ErrorLevel, &Marker, &Format)) {
|
||||||
//
|
//
|
||||||
// Process DEBUG () macro
|
// Process DEBUG () macro
|
||||||
//
|
//
|
||||||
AsciiBSPrint (PrintBuffer, BYTES_PER_RECORD, Format, Marker);
|
AsciiBSPrint (PrintBuffer, BYTES_PER_RECORD, Format, Marker);
|
||||||
printf ("%s", PrintBuffer);
|
printf ("%s", PrintBuffer);
|
||||||
@ -560,17 +560,17 @@ Returns:
|
|||||||
// | |
|
// | |
|
||||||
// | Stack |
|
// | Stack |
|
||||||
// |-----------| <---- TemporaryRamBase
|
// |-----------| <---- TemporaryRamBase
|
||||||
//
|
//
|
||||||
TopOfStack = (VOID *)(LargestRegion + PeiStackSize);
|
TopOfStack = (VOID *)(LargestRegion + PeiStackSize);
|
||||||
TopOfMemory = LargestRegion + PeiStackSize;
|
TopOfMemory = LargestRegion + PeiStackSize;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Reservet space for storing PeiCore's parament in stack.
|
// Reservet space for storing PeiCore's parament in stack.
|
||||||
//
|
//
|
||||||
TopOfStack = (VOID *)((UINTN)TopOfStack - sizeof (EFI_SEC_PEI_HAND_OFF) - CPU_STACK_ALIGNMENT);
|
TopOfStack = (VOID *)((UINTN)TopOfStack - sizeof (EFI_SEC_PEI_HAND_OFF) - CPU_STACK_ALIGNMENT);
|
||||||
TopOfStack = ALIGN_POINTER (TopOfStack, CPU_STACK_ALIGNMENT);
|
TopOfStack = ALIGN_POINTER (TopOfStack, CPU_STACK_ALIGNMENT);
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Bind this information into the SEC hand-off state
|
// Bind this information into the SEC hand-off state
|
||||||
//
|
//
|
||||||
@ -578,7 +578,7 @@ Returns:
|
|||||||
SecCoreData->DataSize = sizeof(EFI_SEC_PEI_HAND_OFF);
|
SecCoreData->DataSize = sizeof(EFI_SEC_PEI_HAND_OFF);
|
||||||
SecCoreData->BootFirmwareVolumeBase = (VOID*)BootFirmwareVolumeBase;
|
SecCoreData->BootFirmwareVolumeBase = (VOID*)BootFirmwareVolumeBase;
|
||||||
SecCoreData->BootFirmwareVolumeSize = PcdGet32 (PcdUnixFirmwareFdSize);
|
SecCoreData->BootFirmwareVolumeSize = PcdGet32 (PcdUnixFirmwareFdSize);
|
||||||
SecCoreData->TemporaryRamBase = (VOID*)(UINTN)LargestRegion;
|
SecCoreData->TemporaryRamBase = (VOID*)(UINTN)LargestRegion;
|
||||||
SecCoreData->TemporaryRamSize = STACK_SIZE;
|
SecCoreData->TemporaryRamSize = STACK_SIZE;
|
||||||
SecCoreData->StackBase = SecCoreData->TemporaryRamBase;
|
SecCoreData->StackBase = SecCoreData->TemporaryRamBase;
|
||||||
SecCoreData->StackSize = PeiStackSize;
|
SecCoreData->StackSize = PeiStackSize;
|
||||||
@ -597,21 +597,21 @@ Returns:
|
|||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
DispatchTableSize = sizeof (gPrivateDispatchTable);
|
DispatchTableSize = sizeof (gPrivateDispatchTable);
|
||||||
DispatchTableSize += OverrideDispatchTableExtraSize ();
|
DispatchTableSize += OverrideDispatchTableExtraSize ();
|
||||||
|
|
||||||
DispatchTable = malloc (DispatchTableSize);
|
DispatchTable = malloc (DispatchTableSize);
|
||||||
if (DispatchTable == NULL) {
|
if (DispatchTable == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Allow an override for extra PPIs to be passed up to PEI
|
// Allow an override for extra PPIs to be passed up to PEI
|
||||||
// This is an easy way to enable OS specific customizations
|
// This is an easy way to enable OS specific customizations
|
||||||
//
|
//
|
||||||
OverrideDispatchTable (&gPrivateDispatchTable[0], sizeof (gPrivateDispatchTable), DispatchTable, DispatchTableSize);
|
OverrideDispatchTable (&gPrivateDispatchTable[0], sizeof (gPrivateDispatchTable), DispatchTable, DispatchTableSize);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Transfer control to the PEI Core
|
// Transfer control to the PEI Core
|
||||||
//
|
//
|
||||||
@ -735,13 +735,13 @@ Returns:
|
|||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Allocate space in UNIX (not emulator) memory. Extra space is for alignment
|
// Allocate space in UNIX (not emulator) memory. Extra space is for alignment
|
||||||
//
|
//
|
||||||
ImageContext.ImageAddress = (EFI_PHYSICAL_ADDRESS) (UINTN) MapMemory (
|
ImageContext.ImageAddress = (EFI_PHYSICAL_ADDRESS) (UINTN) MapMemory (
|
||||||
0,
|
0,
|
||||||
(UINT32) (ImageContext.ImageSize + (ImageContext.SectionAlignment * 2)),
|
(UINT32) (ImageContext.ImageSize + (ImageContext.SectionAlignment * 2)),
|
||||||
PROT_READ | PROT_WRITE | PROT_EXEC,
|
PROT_READ | PROT_WRITE | PROT_EXEC,
|
||||||
MAP_ANONYMOUS | MAP_PRIVATE
|
MAP_ANONYMOUS | MAP_PRIVATE
|
||||||
@ -749,7 +749,7 @@ Returns:
|
|||||||
if (ImageContext.ImageAddress == 0) {
|
if (ImageContext.ImageAddress == 0) {
|
||||||
return EFI_OUT_OF_RESOURCES;
|
return EFI_OUT_OF_RESOURCES;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Align buffer on section boundry
|
// Align buffer on section boundry
|
||||||
//
|
//
|
||||||
@ -761,12 +761,12 @@ Returns:
|
|||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = PeCoffLoaderRelocateImage (&ImageContext);
|
Status = PeCoffLoaderRelocateImage (&ImageContext);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SecPeCoffRelocateImageExtraAction (&ImageContext);
|
SecPeCoffRelocateImageExtraAction (&ImageContext);
|
||||||
|
|
||||||
@ -842,7 +842,7 @@ Returns:
|
|||||||
|
|
||||||
if (Index == 0) {
|
if (Index == 0) {
|
||||||
//
|
//
|
||||||
// FD 0 has XIP code and well known PCD values
|
// FD 0 has XIP code and well known PCD values
|
||||||
// If the memory buffer could not be allocated at the FD build address
|
// If the memory buffer could not be allocated at the FD build address
|
||||||
// the Fixup is the difference.
|
// the Fixup is the difference.
|
||||||
//
|
//
|
||||||
@ -930,16 +930,16 @@ AddHandle (
|
|||||||
|
|
||||||
Routine Description:
|
Routine Description:
|
||||||
Store the ModHandle in an array indexed by the Pdb File name.
|
Store the ModHandle in an array indexed by the Pdb File name.
|
||||||
The ModHandle is needed to unload the image.
|
The ModHandle is needed to unload the image.
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
ImageContext - Input data returned from PE Laoder Library. Used to find the
|
ImageContext - Input data returned from PE Laoder Library. Used to find the
|
||||||
.PDB file name of the PE Image.
|
.PDB file name of the PE Image.
|
||||||
ModHandle - Returned from LoadLibraryEx() and stored for call to
|
ModHandle - Returned from LoadLibraryEx() and stored for call to
|
||||||
FreeLibrary().
|
FreeLibrary().
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
EFI_SUCCESS - ModHandle was stored.
|
EFI_SUCCESS - ModHandle was stored.
|
||||||
|
|
||||||
--*/
|
--*/
|
||||||
{
|
{
|
||||||
@ -959,9 +959,9 @@ Returns:
|
|||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// No free space in mImageContextModHandleArray so grow it by
|
// No free space in mImageContextModHandleArray so grow it by
|
||||||
// IMAGE_CONTEXT_TO_MOD_HANDLE entires. realloc will
|
// IMAGE_CONTEXT_TO_MOD_HANDLE entires. realloc will
|
||||||
// copy the old values to the new locaiton. But it does
|
// copy the old values to the new locaiton. But it does
|
||||||
// not zero the new memory area.
|
// not zero the new memory area.
|
||||||
@ -974,9 +974,9 @@ Returns:
|
|||||||
ASSERT (FALSE);
|
ASSERT (FALSE);
|
||||||
return EFI_OUT_OF_RESOURCES;
|
return EFI_OUT_OF_RESOURCES;
|
||||||
}
|
}
|
||||||
|
|
||||||
memset (mImageContextModHandleArray + PreviousSize, 0, MAX_IMAGE_CONTEXT_TO_MOD_HANDLE_ARRAY_SIZE * sizeof (IMAGE_CONTEXT_TO_MOD_HANDLE));
|
memset (mImageContextModHandleArray + PreviousSize, 0, MAX_IMAGE_CONTEXT_TO_MOD_HANDLE_ARRAY_SIZE * sizeof (IMAGE_CONTEXT_TO_MOD_HANDLE));
|
||||||
|
|
||||||
return AddHandle (ImageContext, ModHandle);
|
return AddHandle (ImageContext, ModHandle);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -991,7 +991,7 @@ Routine Description:
|
|||||||
Return the ModHandle and delete the entry in the array.
|
Return the ModHandle and delete the entry in the array.
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
ImageContext - Input data returned from PE Laoder Library. Used to find the
|
ImageContext - Input data returned from PE Laoder Library. Used to find the
|
||||||
.PDB file name of the PE Image.
|
.PDB file name of the PE Image.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
@ -1027,7 +1027,7 @@ Returns:
|
|||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Target for gdb breakpoint in a script that uses gGdbWorkingFileName to source a
|
// Target for gdb breakpoint in a script that uses gGdbWorkingFileName to source a
|
||||||
// add-symbol-file command. Hey what can you say scripting in gdb is not that great....
|
// add-symbol-file command. Hey what can you say scripting in gdb is not that great....
|
||||||
//
|
//
|
||||||
// Put .gdbinit in the CWD where you do gdb SecMain.dll for source level debug
|
// Put .gdbinit in the CWD where you do gdb SecMain.dll for source level debug
|
||||||
@ -1069,13 +1069,13 @@ IsPdbFile (
|
|||||||
if ((Len < 5)|| (PdbFileName[Len - 4] != '.')) {
|
if ((Len < 5)|| (PdbFileName[Len - 4] != '.')) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((PdbFileName[Len - 3] == 'P' || PdbFileName[Len - 3] == 'p') &&
|
if ((PdbFileName[Len - 3] == 'P' || PdbFileName[Len - 3] == 'p') &&
|
||||||
(PdbFileName[Len - 2] == 'D' || PdbFileName[Len - 2] == 'd') &&
|
(PdbFileName[Len - 2] == 'D' || PdbFileName[Len - 2] == 'd') &&
|
||||||
(PdbFileName[Len - 1] == 'B' || PdbFileName[Len - 1] == 'b')) {
|
(PdbFileName[Len - 1] == 'B' || PdbFileName[Len - 1] == 'b')) {
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1090,14 +1090,14 @@ PrintLoadAddress (
|
|||||||
if (ImageContext->PdbPointer == NULL) {
|
if (ImageContext->PdbPointer == NULL) {
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
"0x%08lx Loading NO DEBUG with entry point 0x%08lx\n",
|
"0x%08lx Loading NO DEBUG with entry point 0x%08lx\n",
|
||||||
(unsigned long)(ImageContext->ImageAddress),
|
(unsigned long)(ImageContext->ImageAddress),
|
||||||
(unsigned long)ImageContext->EntryPoint
|
(unsigned long)ImageContext->EntryPoint
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
"0x%08lx Loading %s with entry point 0x%08lx\n",
|
"0x%08lx Loading %s with entry point 0x%08lx\n",
|
||||||
(unsigned long)(ImageContext->ImageAddress + ImageContext->SizeOfHeaders),
|
(unsigned long)(ImageContext->ImageAddress + ImageContext->SizeOfHeaders),
|
||||||
ImageContext->PdbPointer,
|
ImageContext->PdbPointer,
|
||||||
(unsigned long)ImageContext->EntryPoint
|
(unsigned long)ImageContext->EntryPoint
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -1112,7 +1112,7 @@ SecPeCoffRelocateImageExtraAction (
|
|||||||
IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
|
IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
PrintLoadAddress (ImageContext);
|
PrintLoadAddress (ImageContext);
|
||||||
|
|
||||||
@ -1122,7 +1122,7 @@ SecPeCoffRelocateImageExtraAction (
|
|||||||
// .dSYM files for the PE/COFF images that can be used by gdb for source level debugging.
|
// .dSYM files for the PE/COFF images that can be used by gdb for source level debugging.
|
||||||
//
|
//
|
||||||
FILE *GdbTempFile;
|
FILE *GdbTempFile;
|
||||||
|
|
||||||
//
|
//
|
||||||
// In the Mach-O to PE/COFF conversion the size of the PE/COFF headers is not accounted for.
|
// In the Mach-O to PE/COFF conversion the size of the PE/COFF headers is not accounted for.
|
||||||
// Thus we need to skip over the PE/COFF header when giving load addresses for our symbol table.
|
// Thus we need to skip over the PE/COFF header when giving load addresses for our symbol table.
|
||||||
@ -1131,27 +1131,27 @@ SecPeCoffRelocateImageExtraAction (
|
|||||||
//
|
//
|
||||||
// Now we have a database of the images that are currently loaded
|
// Now we have a database of the images that are currently loaded
|
||||||
//
|
//
|
||||||
|
|
||||||
//
|
//
|
||||||
// 'symbol-file' will clear out currnet symbol mappings in gdb.
|
// 'symbol-file' will clear out currnet symbol mappings in gdb.
|
||||||
// you can do a 'add-symbol-file filename address' for every image we loaded to get source
|
// you can do a 'add-symbol-file filename address' for every image we loaded to get source
|
||||||
// level debug in gdb. Note Sec, being a true application will work differently.
|
// level debug in gdb. Note Sec, being a true application will work differently.
|
||||||
|
//
|
||||||
|
// We add the PE/COFF header size into the image as the mach-O does not have a header in
|
||||||
|
// loaded into system memory.
|
||||||
//
|
//
|
||||||
// We add the PE/COFF header size into the image as the mach-O does not have a header in
|
|
||||||
// loaded into system memory.
|
|
||||||
//
|
|
||||||
// This gives us a data base of gdb commands and after something is unloaded that entry will be
|
// This gives us a data base of gdb commands and after something is unloaded that entry will be
|
||||||
// removed. We don't yet have the scheme of how to comunicate with gdb, but we have the
|
// removed. We don't yet have the scheme of how to comunicate with gdb, but we have the
|
||||||
// data base of info ready to roll.
|
// data base of info ready to roll.
|
||||||
//
|
//
|
||||||
// We could use qXfer:libraries:read, but OS X GDB does not currently support it.
|
// We could use qXfer:libraries:read, but OS X GDB does not currently support it.
|
||||||
// <library-list>
|
// <library-list>
|
||||||
// <library name="/lib/libc.so.6"> // ImageContext->PdbPointer
|
// <library name="/lib/libc.so.6"> // ImageContext->PdbPointer
|
||||||
// <segment address="0x10000000"/> // ImageContext->ImageAddress + ImageContext->SizeOfHeaders
|
// <segment address="0x10000000"/> // ImageContext->ImageAddress + ImageContext->SizeOfHeaders
|
||||||
// </library>
|
// </library>
|
||||||
// </library-list>
|
// </library-list>
|
||||||
//
|
//
|
||||||
|
|
||||||
//
|
//
|
||||||
// Write the file we need for the gdb script
|
// Write the file we need for the gdb script
|
||||||
//
|
//
|
||||||
@ -1159,37 +1159,45 @@ SecPeCoffRelocateImageExtraAction (
|
|||||||
if (GdbTempFile != NULL) {
|
if (GdbTempFile != NULL) {
|
||||||
fprintf (GdbTempFile, "add-symbol-file %s 0x%08lx\n", ImageContext->PdbPointer, (long unsigned int)(ImageContext->ImageAddress + ImageContext->SizeOfHeaders));
|
fprintf (GdbTempFile, "add-symbol-file %s 0x%08lx\n", ImageContext->PdbPointer, (long unsigned int)(ImageContext->ImageAddress + ImageContext->SizeOfHeaders));
|
||||||
fclose (GdbTempFile);
|
fclose (GdbTempFile);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Target for gdb breakpoint in a script that uses gGdbWorkingFileName to set a breakpoint.
|
// Target for gdb breakpoint in a script that uses gGdbWorkingFileName to set a breakpoint.
|
||||||
// Hey what can you say scripting in gdb is not that great....
|
// Hey what can you say scripting in gdb is not that great....
|
||||||
//
|
//
|
||||||
SecGdbScriptBreak ();
|
SecGdbScriptBreak ();
|
||||||
}
|
}
|
||||||
|
|
||||||
AddHandle (ImageContext, ImageContext->PdbPointer);
|
AddHandle (ImageContext, ImageContext->PdbPointer);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
void *Handle = NULL;
|
void *Handle = NULL;
|
||||||
void *Entry = NULL;
|
void *Entry = NULL;
|
||||||
|
|
||||||
fprintf (stderr,
|
if (ImageContext->PdbPointer == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!IsPdbFile (ImageContext->PdbPointer)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf (stderr,
|
||||||
"Loading %s 0x%08lx - entry point 0x%08lx\n",
|
"Loading %s 0x%08lx - entry point 0x%08lx\n",
|
||||||
ImageContext->PdbPointer,
|
ImageContext->PdbPointer,
|
||||||
(unsigned long)ImageContext->ImageAddress,
|
(unsigned long)ImageContext->ImageAddress,
|
||||||
(unsigned long)ImageContext->EntryPoint);
|
(unsigned long)ImageContext->EntryPoint);
|
||||||
|
|
||||||
Handle = dlopen (ImageContext->PdbPointer, RTLD_NOW);
|
Handle = dlopen (ImageContext->PdbPointer, RTLD_NOW);
|
||||||
|
|
||||||
if (Handle) {
|
if (Handle) {
|
||||||
Entry = dlsym (Handle, "_ModuleEntryPoint");
|
Entry = dlsym (Handle, "_ModuleEntryPoint");
|
||||||
} else {
|
} else {
|
||||||
printf("%s\n", dlerror());
|
printf("%s\n", dlerror());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Entry != NULL) {
|
if (Entry != NULL) {
|
||||||
ImageContext->EntryPoint = (UINTN)Entry;
|
ImageContext->EntryPoint = (UINTN)Entry;
|
||||||
printf("Change %s Entrypoint to :0x%08lx\n", ImageContext->PdbPointer, (unsigned long)Entry);
|
printf("Change %s Entrypoint to :0x%08lx\n", ImageContext->PdbPointer, (unsigned long)Entry);
|
||||||
@ -1215,12 +1223,12 @@ SecPeCoffLoaderUnloadImageExtraAction (
|
|||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
FILE *GdbTempFile;
|
FILE *GdbTempFile;
|
||||||
|
|
||||||
if (Handle != NULL) {
|
if (Handle != NULL) {
|
||||||
//
|
//
|
||||||
// Need to skip .PDB files created from VC++
|
// Need to skip .PDB files created from VC++
|
||||||
//
|
//
|
||||||
if (!IsPdbFile (ImageContext->PdbPointer)) {
|
if (!IsPdbFile (ImageContext->PdbPointer)) {
|
||||||
//
|
//
|
||||||
// Write the file we need for the gdb script
|
// Write the file we need for the gdb script
|
||||||
//
|
//
|
||||||
@ -1228,16 +1236,16 @@ SecPeCoffLoaderUnloadImageExtraAction (
|
|||||||
if (GdbTempFile != NULL) {
|
if (GdbTempFile != NULL) {
|
||||||
fprintf (GdbTempFile, "remove-symbol-file %s\n", ImageContext->PdbPointer);
|
fprintf (GdbTempFile, "remove-symbol-file %s\n", ImageContext->PdbPointer);
|
||||||
fclose (GdbTempFile);
|
fclose (GdbTempFile);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Target for gdb breakpoint in a script that uses gGdbWorkingFileName to set a breakpoint.
|
// Target for gdb breakpoint in a script that uses gGdbWorkingFileName to set a breakpoint.
|
||||||
// Hey what can you say scripting in gdb is not that great....
|
// Hey what can you say scripting in gdb is not that great....
|
||||||
//
|
//
|
||||||
SecGdbScriptBreak ();
|
SecGdbScriptBreak ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
//
|
//
|
||||||
// Don't want to confuse gdb with symbols for something that got unloaded
|
// Don't want to confuse gdb with symbols for something that got unloaded
|
||||||
@ -1268,32 +1276,32 @@ SecTemporaryRamSupport (
|
|||||||
{
|
{
|
||||||
//
|
//
|
||||||
// Migrate the whole temporary memory to permenent memory.
|
// Migrate the whole temporary memory to permenent memory.
|
||||||
//
|
//
|
||||||
CopyMem (
|
CopyMem (
|
||||||
(VOID*)(UINTN)PermanentMemoryBase,
|
(VOID*)(UINTN)PermanentMemoryBase,
|
||||||
(VOID*)(UINTN)TemporaryMemoryBase,
|
(VOID*)(UINTN)TemporaryMemoryBase,
|
||||||
CopySize
|
CopySize
|
||||||
);
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
// SecSwitchStack function must be invoked after the memory migration
|
// SecSwitchStack function must be invoked after the memory migration
|
||||||
// immediatly, also we need fixup the stack change caused by new call into
|
// immediatly, also we need fixup the stack change caused by new call into
|
||||||
// permenent memory.
|
// permenent memory.
|
||||||
//
|
//
|
||||||
SecSwitchStack (
|
SecSwitchStack (
|
||||||
(UINT32) TemporaryMemoryBase,
|
(UINT32) TemporaryMemoryBase,
|
||||||
(UINT32) PermanentMemoryBase
|
(UINT32) PermanentMemoryBase
|
||||||
);
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
// We need *not* fix the return address because currently,
|
// We need *not* fix the return address because currently,
|
||||||
// The PeiCore is excuted in flash.
|
// The PeiCore is excuted in flash.
|
||||||
//
|
//
|
||||||
|
|
||||||
//
|
//
|
||||||
// Simulate to invalid temporary memory, terminate temporary memory
|
// Simulate to invalid temporary memory, terminate temporary memory
|
||||||
//
|
//
|
||||||
//ZeroMem ((VOID*)(UINTN)TemporaryMemoryBase, CopySize);
|
//ZeroMem ((VOID*)(UINTN)TemporaryMemoryBase, CopySize);
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -2,13 +2,13 @@
|
|||||||
|
|
||||||
Copyright (c) 2004 - 2009, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2004 - 2009, Intel Corporation. All rights reserved.<BR>
|
||||||
Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
|
Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
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
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
http://opensource.org/licenses/bsd-license.php
|
http://opensource.org/licenses/bsd-license.php
|
||||||
|
|
||||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
|
|
||||||
Module Name:
|
Module Name:
|
||||||
|
|
||||||
@ -16,7 +16,7 @@ Module Name:
|
|||||||
|
|
||||||
Abstract:
|
Abstract:
|
||||||
|
|
||||||
Since the SEC is the only program in our emulation we
|
Since the SEC is the only program in our emulation we
|
||||||
must use a Tiano mechanism to export APIs to other modules.
|
must use a Tiano mechanism to export APIs to other modules.
|
||||||
This is the role of the EFI_UNIX_THUNK_PROTOCOL.
|
This is the role of the EFI_UNIX_THUNK_PROTOCOL.
|
||||||
|
|
||||||
@ -25,7 +25,7 @@ Abstract:
|
|||||||
are not added. It looks like adding a element to end and not initializing
|
are not added. It looks like adding a element to end and not initializing
|
||||||
it may cause the table to be initaliized with the members at the end being
|
it may cause the table to be initaliized with the members at the end being
|
||||||
set to zero. This is bad as jumping to zero will crash.
|
set to zero. This is bad as jumping to zero will crash.
|
||||||
|
|
||||||
|
|
||||||
gUnix is a a public exported global that contains the initialized
|
gUnix is a a public exported global that contains the initialized
|
||||||
data.
|
data.
|
||||||
@ -36,7 +36,7 @@ Abstract:
|
|||||||
#include "Uefi.h"
|
#include "Uefi.h"
|
||||||
#include "Library/UnixLib.h"
|
#include "Library/UnixLib.h"
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#if defined(__APPLE__) || defined(MDE_CPU_X64)
|
||||||
#include "Gasket.h"
|
#include "Gasket.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -52,12 +52,12 @@ settimer_handler (int sig)
|
|||||||
|
|
||||||
gettimeofday (&timeval, NULL);
|
gettimeofday (&timeval, NULL);
|
||||||
delta = ((UINT64)timeval.tv_sec * 1000) + (timeval.tv_usec / 1000)
|
delta = ((UINT64)timeval.tv_sec * 1000) + (timeval.tv_usec / 1000)
|
||||||
- ((UINT64)settimer_timeval.tv_sec * 1000)
|
- ((UINT64)settimer_timeval.tv_sec * 1000)
|
||||||
- (settimer_timeval.tv_usec / 1000);
|
- (settimer_timeval.tv_usec / 1000);
|
||||||
settimer_timeval = timeval;
|
settimer_timeval = timeval;
|
||||||
|
|
||||||
if (settimer_callback) {
|
if (settimer_callback) {
|
||||||
#ifdef __APPLE__
|
#if defined(__APPLE__) || defined(MDE_CPU_X64)
|
||||||
ReverseGasketUint64 (settimer_callback, delta);
|
ReverseGasketUint64 (settimer_callback, delta);
|
||||||
#else
|
#else
|
||||||
(*settimer_callback)(delta);
|
(*settimer_callback)(delta);
|
||||||
@ -90,7 +90,7 @@ SetTimer (UINT64 PeriodMs, VOID (*CallBack)(UINT64 DeltaMs))
|
|||||||
timerval.it_value.tv_usec = remainder * 1000;
|
timerval.it_value.tv_usec = remainder * 1000;
|
||||||
timerval.it_value.tv_sec = DivU64x32(PeriodMs, 1000);
|
timerval.it_value.tv_sec = DivU64x32(PeriodMs, 1000);
|
||||||
timerval.it_interval = timerval.it_value;
|
timerval.it_interval = timerval.it_value;
|
||||||
|
|
||||||
if (setitimer (ITIMER_REAL, &timerval, NULL) != 0) {
|
if (setitimer (ITIMER_REAL, &timerval, NULL) != 0) {
|
||||||
printf ("SetTimer: setitimer error %s\n", strerror (errno));
|
printf ("SetTimer: setitimer error %s\n", strerror (errno));
|
||||||
}
|
}
|
||||||
@ -110,8 +110,8 @@ msSleep (unsigned long Milliseconds)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
rq = rm;
|
rq = rm;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -171,10 +171,10 @@ UgaCreate(struct _EFI_UNIX_UGA_IO_PROTOCOL **UgaIo, CONST CHAR16 *Title);
|
|||||||
|
|
||||||
EFI_UNIX_THUNK_PROTOCOL mUnixThunkTable = {
|
EFI_UNIX_THUNK_PROTOCOL mUnixThunkTable = {
|
||||||
EFI_UNIX_THUNK_PROTOCOL_SIGNATURE,
|
EFI_UNIX_THUNK_PROTOCOL_SIGNATURE,
|
||||||
#ifdef __APPLE__
|
#if defined(__APPLE__) || defined(MDE_CPU_X64)
|
||||||
//
|
//
|
||||||
// Mac OS X requires the stack to be 16-byte aligned for IA-32. So on an OS X build
|
// Mac OS X requires the stack to be 16-byte aligned for IA-32. So on an OS X build
|
||||||
// we add an assembly wrapper that makes sure the stack ges aligned.
|
// we add an assembly wrapper that makes sure the stack ges aligned.
|
||||||
// This has the nice benfit of being able to run EFI ABI code, like the EFI shell
|
// This has the nice benfit of being able to run EFI ABI code, like the EFI shell
|
||||||
// that is checked in to source control in the OS X version of the emulator
|
// that is checked in to source control in the OS X version of the emulator
|
||||||
//
|
//
|
||||||
@ -217,9 +217,9 @@ EFI_UNIX_THUNK_PROTOCOL mUnixThunkTable = {
|
|||||||
Gasketcfsetospeed,
|
Gasketcfsetospeed,
|
||||||
Gaskettcgetattr,
|
Gaskettcgetattr,
|
||||||
Gaskettcsetattr,
|
Gaskettcsetattr,
|
||||||
GasketUnixPeCoffGetEntryPoint,
|
GasketUnixPeCoffGetEntryPoint,
|
||||||
GasketUnixPeCoffRelocateImageExtraAction,
|
GasketUnixPeCoffRelocateImageExtraAction,
|
||||||
GasketUnixPeCoffUnloadImageExtraAction
|
GasketUnixPeCoffUnloadImageExtraAction
|
||||||
|
|
||||||
#else
|
#else
|
||||||
msSleep, /* Sleep */
|
msSleep, /* Sleep */
|
||||||
|
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user