Integrate patch from Andrew Fish to make it run on OS X.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9194 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
qhuang8
2009-08-25 07:29:13 +00:00
parent 7f22d35110
commit ccd55824e7
44 changed files with 1038 additions and 359 deletions

View File

@ -1,6 +1,6 @@
/*++ /*++
Copyright (c) 2006, Intel Corporation Copyright (c) 2006 - 2009, Intel Corporation
All rights reserved. This program and the accompanying materials All rights reserved. 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
@ -58,12 +58,15 @@ CPU_ARCH_PROTOCOL_PRIVATE mCpuTemplate = {
4 4
}, },
{ {
CpuMemoryServiceRead, {
CpuMemoryServiceWrite, CpuMemoryServiceRead,
CpuIoServiceRead, CpuMemoryServiceWrite
CpuIoServiceWrite },
{
CpuIoServiceRead,
CpuIoServiceWrite
}
}, },
0,
TRUE TRUE
}; };
@ -430,7 +433,7 @@ Returns:
// //
// Locate DataHub protocol. // Locate DataHub protocol.
// //
Status = gBS->LocateProtocol (&gEfiDataHubProtocolGuid, NULL, &DataHub); Status = gBS->LocateProtocol (&gEfiDataHubProtocolGuid, NULL, (VOID **)&DataHub);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return; return;
} }

View File

@ -42,7 +42,7 @@
IntelFrameworkPkg/IntelFrameworkPkg.dec IntelFrameworkPkg/IntelFrameworkPkg.dec
IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec
UnixPkg/UnixPkg.dec UnixPkg/UnixPkg.dec
MdePkg/MdePkg.dec MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec MdeModulePkg/MdeModulePkg.dec
@ -70,4 +70,4 @@
[Depex] [Depex]
gEfiDataHubProtocolGuid gEfiDataHubProtocolGuid

View File

@ -1,6 +1,6 @@
/*++ /*++
Copyright (c) 2006 - 2008, Intel Corporation Copyright (c) 2006 - 2009, Intel Corporation
All rights reserved. This program and the accompanying materials All rights reserved. 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
@ -33,8 +33,8 @@ Revision History
#include <Library/HobLib.h> #include <Library/HobLib.h>
#include <Library/BaseMemoryLib.h> #include <Library/BaseMemoryLib.h>
#include <Library/MemoryAllocationLib.h> #include <Library/MemoryAllocationLib.h>
#include <Library/UefiBootServicesTableLib.h> #include <Library/UefiBootServicesTableLib.h>
#include <Library/DevicePathLib.h> #include <Library/DevicePathLib.h>
#include "FwBlockService.h" #include "FwBlockService.h"
@ -210,7 +210,7 @@ Returns:
--*/ --*/
{ {
EFI_FW_VOL_INSTANCE *FwhInstance; EFI_FW_VOL_INSTANCE *FwhInstance = NULL;
EFI_STATUS Status; EFI_STATUS Status;
// //
@ -250,7 +250,7 @@ Returns:
--*/ --*/
{ {
EFI_FW_VOL_INSTANCE *FwhInstance; EFI_FW_VOL_INSTANCE *FwhInstance = NULL;
EFI_STATUS Status; EFI_STATUS Status;
// //
@ -303,7 +303,7 @@ Returns:
UINTN Offset; UINTN Offset;
EFI_LBA StartLba; EFI_LBA StartLba;
EFI_LBA NextLba; EFI_LBA NextLba;
EFI_FW_VOL_INSTANCE *FwhInstance; EFI_FW_VOL_INSTANCE *FwhInstance = NULL;
EFI_FV_BLOCK_MAP_ENTRY *BlockMap; EFI_FV_BLOCK_MAP_ENTRY *BlockMap;
EFI_STATUS Status; EFI_STATUS Status;
@ -626,7 +626,7 @@ Returns:
--*/ --*/
{ {
EFI_FW_VOL_INSTANCE *FwhInstance; EFI_FW_VOL_INSTANCE *FwhInstance = NULL;
EFI_FVB_ATTRIBUTES_2 OldAttributes; EFI_FVB_ATTRIBUTES_2 OldAttributes;
EFI_FVB_ATTRIBUTES_2 *AttribPtr; EFI_FVB_ATTRIBUTES_2 *AttribPtr;
UINT32 Capabilities; UINT32 Capabilities;
@ -733,7 +733,7 @@ Returns:
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
FvbProtocolGetPhysicalAddress ( FvbProtocolGetPhysicalAddress (
IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
OUT EFI_PHYSICAL_ADDRESS *Address OUT EFI_PHYSICAL_ADDRESS *Address
) )
/*++ /*++
@ -764,7 +764,7 @@ Returns:
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
FvbProtocolGetBlockSize ( FvbProtocolGetBlockSize (
IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
IN EFI_LBA Lba, IN EFI_LBA Lba,
OUT UINTN *BlockSize, OUT UINTN *BlockSize,
OUT UINTN *NumOfBlocks OUT UINTN *NumOfBlocks
@ -808,7 +808,7 @@ Returns:
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
FvbProtocolGetAttributes ( FvbProtocolGetAttributes (
IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
OUT EFI_FVB_ATTRIBUTES_2 *Attributes OUT EFI_FVB_ATTRIBUTES_2 *Attributes
) )
/*++ /*++
@ -835,7 +835,7 @@ Returns:
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
FvbProtocolSetAttributes ( FvbProtocolSetAttributes (
IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
IN OUT EFI_FVB_ATTRIBUTES_2 *Attributes IN OUT EFI_FVB_ATTRIBUTES_2 *Attributes
) )
/*++ /*++
@ -862,7 +862,7 @@ Returns:
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
FvbProtocolEraseBlocks ( FvbProtocolEraseBlocks (
IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
... ...
) )
/*++ /*++
@ -891,7 +891,7 @@ Returns:
--*/ --*/
{ {
EFI_FW_VOL_BLOCK_DEVICE *FvbDevice; EFI_FW_VOL_BLOCK_DEVICE *FvbDevice;
EFI_FW_VOL_INSTANCE *FwhInstance; EFI_FW_VOL_INSTANCE *FwhInstance = NULL;
UINTN NumOfBlocks; UINTN NumOfBlocks;
VA_LIST args; VA_LIST args;
EFI_LBA StartingLba; EFI_LBA StartingLba;
@ -960,7 +960,7 @@ Returns:
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
FvbProtocolWrite ( FvbProtocolWrite (
IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
IN EFI_LBA Lba, IN EFI_LBA Lba,
IN UINTN Offset, IN UINTN Offset,
IN OUT UINTN *NumBytes, IN OUT UINTN *NumBytes,
@ -1008,7 +1008,7 @@ Returns:
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
FvbProtocolRead ( FvbProtocolRead (
IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
IN EFI_LBA Lba, IN EFI_LBA Lba,
IN UINTN Offset, IN UINTN Offset,
IN OUT UINTN *NumBytes, IN OUT UINTN *NumBytes,
@ -1124,7 +1124,7 @@ Returns:
--*/ --*/
{ {
EFI_STATUS Status; EFI_STATUS Status;
EFI_FW_VOL_INSTANCE *FwhInstance; EFI_FW_VOL_INSTANCE *FwhInstance = NULL;
EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader; EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader;
EFI_DXE_SERVICES *DxeServices; EFI_DXE_SERVICES *DxeServices;
EFI_GCD_MEMORY_SPACE_DESCRIPTOR Descriptor; EFI_GCD_MEMORY_SPACE_DESCRIPTOR Descriptor;

View File

@ -34,8 +34,8 @@ Abstract:
#include <Library/BaseMemoryLib.h> #include <Library/BaseMemoryLib.h>
#include <Library/MemoryAllocationLib.h> #include <Library/MemoryAllocationLib.h>
#include <Library/UefiBootServicesTableLib.h> #include <Library/UefiBootServicesTableLib.h>
#include <Library/PcdLib.h> #include <Library/PcdLib.h>
#include <Library/DevicePathLib.h> #include <Library/DevicePathLib.h>
#include <Guid/FirmwareFileSystem2.h> #include <Guid/FirmwareFileSystem2.h>
#include <Guid/SystemNvDataGuid.h> #include <Guid/SystemNvDataGuid.h>

View File

@ -1,6 +1,6 @@
/*++ /*++
Copyright (c) 2006, Intel Corporation Copyright (c) 2006 - 2009, Intel Corporation
All rights reserved. This program and the accompanying materials All rights reserved. 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
@ -161,7 +161,7 @@ FvbGetLbaAddress (
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
FvbProtocolGetAttributes ( FvbProtocolGetAttributes (
IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
OUT EFI_FVB_ATTRIBUTES_2 *Attributes OUT EFI_FVB_ATTRIBUTES_2 *Attributes
) )
; ;
@ -169,7 +169,7 @@ FvbProtocolGetAttributes (
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
FvbProtocolSetAttributes ( FvbProtocolSetAttributes (
IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
IN OUT EFI_FVB_ATTRIBUTES_2 *Attributes IN OUT EFI_FVB_ATTRIBUTES_2 *Attributes
) )
; ;
@ -177,7 +177,7 @@ FvbProtocolSetAttributes (
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
FvbProtocolGetPhysicalAddress ( FvbProtocolGetPhysicalAddress (
IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
OUT EFI_PHYSICAL_ADDRESS *Address OUT EFI_PHYSICAL_ADDRESS *Address
) )
; ;
@ -185,7 +185,7 @@ FvbProtocolGetPhysicalAddress (
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
FvbProtocolGetBlockSize ( FvbProtocolGetBlockSize (
IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
IN EFI_LBA Lba, IN EFI_LBA Lba,
OUT UINTN *BlockSize, OUT UINTN *BlockSize,
OUT UINTN *NumOfBlocks OUT UINTN *NumOfBlocks
@ -195,7 +195,7 @@ FvbProtocolGetBlockSize (
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
FvbProtocolRead ( FvbProtocolRead (
IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
IN EFI_LBA Lba, IN EFI_LBA Lba,
IN UINTN Offset, IN UINTN Offset,
IN OUT UINTN *NumBytes, IN OUT UINTN *NumBytes,
@ -206,7 +206,7 @@ FvbProtocolRead (
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
FvbProtocolWrite ( FvbProtocolWrite (
IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
IN EFI_LBA Lba, IN EFI_LBA Lba,
IN UINTN Offset, IN UINTN Offset,
IN OUT UINTN *NumBytes, IN OUT UINTN *NumBytes,
@ -217,7 +217,7 @@ FvbProtocolWrite (
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
FvbProtocolEraseBlocks ( FvbProtocolEraseBlocks (
IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This, IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
... ...
) )
; ;

View File

@ -53,7 +53,7 @@
DxeServicesTableLib DxeServicesTableLib
BaseLib BaseLib
UefiDriverEntryPoint UefiDriverEntryPoint
UefiLib UefiLib
DevicePathLib DevicePathLib

View File

@ -1,6 +1,7 @@
/*++ /*++
Copyright (c) 2006, Intel Corporation Copyright (c) 2006 - 2009, Intel Corporation
Portions copyright (c) 2008-2009 Apple Inc.
All rights reserved. This program and the accompanying materials All rights reserved. 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
@ -19,14 +20,21 @@ Abstract:
#ifndef __UNIX_INCLUDE_H__ #ifndef __UNIX_INCLUDE_H__
#define __UNIX_INCLUDE_H__ #define __UNIX_INCLUDE_H__
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/vfs.h>
#include <sys/poll.h> #ifdef __APPLE__
#include <dirent.h> #include <sys/param.h>
#include <errno.h> #include <sys/mount.h>
#include <fcntl.h> #else
#include <time.h> #include <sys/vfs.h>
#include <utime.h> #endif
#include <unistd.h>
#include <sys/poll.h>
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
#include <time.h>
#include <utime.h>
#include <unistd.h>
#endif #endif

View File

@ -26,7 +26,7 @@ Unix Autoscan PPI
#define PEI_UNIX_AUTOSCAN_PPI_GUID \ #define PEI_UNIX_AUTOSCAN_PPI_GUID \
{ \ { \
0xf2ed3d14, 0x8985, 0x11db, {0xb0, 0x57, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \ 0xf2ed3d14, 0x8985, 0x11db, {0xb0, 0x57, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \
} }
typedef typedef

View File

@ -26,7 +26,7 @@ Abstract:
#define UNIX_FWH_PPI_GUID \ #define UNIX_FWH_PPI_GUID \
{ \ { \
0xf2f0dc30, 0x8985, 0x11db, {0xa1, 0x5b, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \ 0xf2f0dc30, 0x8985, 0x11db, {0xa1, 0x5b, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \
} }
typedef typedef

View File

@ -28,7 +28,7 @@ Abstract:
#define UNIX_PEI_LOAD_FILE_GUID \ #define UNIX_PEI_LOAD_FILE_GUID \
{ \ { \
0xf2f48768, 0x8985, 0x11db, {0xb8, 0xda, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \ 0xf2f48768, 0x8985, 0x11db, {0xb8, 0xda, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \
} }
typedef typedef

View File

@ -26,7 +26,7 @@ Abstract:
#define PEI_UNIX_THUNK_PPI_GUID \ #define PEI_UNIX_THUNK_PPI_GUID \
{ \ { \
0xf2f830f2, 0x8985, 0x11db, {0x80, 0x6b, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \ 0xf2f830f2, 0x8985, 0x11db, {0x80, 0x6b, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \
} }
typedef typedef

View File

@ -22,7 +22,7 @@ Abstract:
#define EFI_UNIX_IO_PROTOCOL_GUID \ #define EFI_UNIX_IO_PROTOCOL_GUID \
{ \ { \
0xf2e23f54, 0x8985, 0x11db, {0xac, 0x79, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \ 0xf2e23f54, 0x8985, 0x11db, {0xac, 0x79, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \
} }
typedef struct { typedef struct {
@ -44,7 +44,7 @@ extern EFI_GUID gEfiUnixIoProtocolGuid;
// //
#define EFI_UNIX_VIRTUAL_DISKS_GUID \ #define EFI_UNIX_VIRTUAL_DISKS_GUID \
{ \ { \
0xf2ba331a, 0x8985, 0x11db, {0xa4, 0x06, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \ 0xf2ba331a, 0x8985, 0x11db, {0xa4, 0x06, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \
} }
extern EFI_GUID gEfiUnixVirtualDisksGuid; extern EFI_GUID gEfiUnixVirtualDisksGuid;
@ -54,7 +54,7 @@ extern EFI_GUID gEfiUnixVirtualDisksGuid;
// //
#define EFI_UNIX_PHYSICAL_DISKS_GUID \ #define EFI_UNIX_PHYSICAL_DISKS_GUID \
{ \ { \
0xf2bdcc96, 0x8985, 0x11db, {0x87, 0x19, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \ 0xf2bdcc96, 0x8985, 0x11db, {0x87, 0x19, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \
} }
extern EFI_GUID gEfiUnixPhysicalDisksGuid; extern EFI_GUID gEfiUnixPhysicalDisksGuid;
@ -64,7 +64,7 @@ extern EFI_GUID gEfiUnixPhysicalDisksGuid;
// //
#define EFI_UNIX_FILE_SYSTEM_GUID \ #define EFI_UNIX_FILE_SYSTEM_GUID \
{ \ { \
0xf2c16b9e, 0x8985, 0x11db, {0x92, 0xc8, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \ 0xf2c16b9e, 0x8985, 0x11db, {0x92, 0xc8, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \
} }
extern EFI_GUID gEfiUnixFileSystemGuid; extern EFI_GUID gEfiUnixFileSystemGuid;
@ -84,7 +84,7 @@ extern EFI_GUID gEfiUnixSerialPortGuid;
// //
#define EFI_UNIX_UGA_GUID \ #define EFI_UNIX_UGA_GUID \
{ \ { \
0xf2c8b80e, 0x8985, 0x11db, {0x93, 0xf1, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \ 0xf2c8b80e, 0x8985, 0x11db, {0x93, 0xf1, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \
} }
extern EFI_GUID gEfiUnixUgaGuid; extern EFI_GUID gEfiUnixUgaGuid;
@ -94,7 +94,7 @@ extern EFI_GUID gEfiUnixUgaGuid;
// //
#define EFI_UNIX_GOP_GUID \ #define EFI_UNIX_GOP_GUID \
{ \ { \
0xbace07c2, 0x8987, 0x11db, {0xa5, 0x9a, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \ 0xbace07c2, 0x8987, 0x11db, {0xa5, 0x9a, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \
} }
extern EFI_GUID gEfiUnixGopGuid; extern EFI_GUID gEfiUnixGopGuid;
@ -104,7 +104,7 @@ extern EFI_GUID gEfiUnixGopGuid;
// //
#define EFI_UNIX_CONSOLE_GUID \ #define EFI_UNIX_CONSOLE_GUID \
{ \ { \
0xf2cc5d06, 0x8985, 0x11db, {0xbb, 0x19, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \ 0xf2cc5d06, 0x8985, 0x11db, {0xbb, 0x19, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \
} }
extern EFI_GUID gEfiUnixConsoleGuid; extern EFI_GUID gEfiUnixConsoleGuid;
@ -114,7 +114,7 @@ extern EFI_GUID gEfiUnixConsoleGuid;
// //
#define EFI_UNIX_MEMORY_GUID \ #define EFI_UNIX_MEMORY_GUID \
{ \ { \
0xf2d006cc, 0x8985, 0x11db, {0xa4, 0x72, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \ 0xf2d006cc, 0x8985, 0x11db, {0xa4, 0x72, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \
} }
extern EFI_GUID gEfiUnixMemoryGuid; extern EFI_GUID gEfiUnixMemoryGuid;
@ -124,7 +124,7 @@ extern EFI_GUID gEfiUnixMemoryGuid;
// //
#define EFI_UNIX_CPU_MODEL_GUID \ #define EFI_UNIX_CPU_MODEL_GUID \
{ \ { \
0xf2d3b330, 0x8985, 0x11db, {0x8a, 0xa3, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \ 0xf2d3b330, 0x8985, 0x11db, {0x8a, 0xa3, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \
} }
extern EFI_GUID gEfiUnixCPUModelGuid; extern EFI_GUID gEfiUnixCPUModelGuid;
@ -134,7 +134,7 @@ extern EFI_GUID gEfiUnixCPUModelGuid;
// //
#define EFI_UNIX_CPU_SPEED_GUID \ #define EFI_UNIX_CPU_SPEED_GUID \
{ \ { \
0xf2d74e5a, 0x8985, 0x11db, {0x97, 0x05, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \ 0xf2d74e5a, 0x8985, 0x11db, {0x97, 0x05, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \
} }
extern EFI_GUID gEfiUnixCPUSpeedGuid; extern EFI_GUID gEfiUnixCPUSpeedGuid;

View File

@ -1,6 +1,7 @@
/*++ /*++
Copyright (c) 2004, Intel Corporation Copyright (c) 2004 - 2009, Intel Corporation
Portions copyright (c) 2008-2009 Apple Inc.<BR>
All rights reserved. This program and the accompanying materials All rights reserved. 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
@ -31,7 +32,13 @@ Abstract:
#include <sys/termios.h> #include <sys/termios.h>
#include <stdio.h> #include <stdio.h>
#include <sys/time.h> #include <sys/time.h>
#if __CYGWIN__
#include <sys/dirent.h>
#else
#include <sys/dir.h> #include <sys/dir.h>
#endif
#include <unistd.h> #include <unistd.h>
#include <poll.h> #include <poll.h>
#include <sys/types.h> #include <sys/types.h>
@ -42,12 +49,24 @@ Abstract:
#include <errno.h> #include <errno.h>
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <termio.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#ifdef __APPLE__
#include <sys/param.h>
#include <sys/mount.h>
#define _XOPEN_SOURCE
#else
#include <termio.h>
#include <sys/vfs.h> #include <sys/vfs.h>
#endif
#include <utime.h> #include <utime.h>
#include <dlfcn.h> #include <dlfcn.h>
#include <Base.h>
#include <Library/PeCoffLib.h>
#define EFI_UNIX_THUNK_PROTOCOL_GUID \ #define EFI_UNIX_THUNK_PROTOCOL_GUID \
{ \ { \
0xf2e98868, 0x8985, 0x11db, {0x9a, 0x59, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \ 0xf2e98868, 0x8985, 0x11db, {0x9a, 0x59, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \
@ -167,7 +186,11 @@ void
typedef typedef
int int
#if __CYGWIN__
(*UnixIoCtl) (int fd, int __request, ...);
#else
(*UnixIoCtl) (int fd, unsigned long int __request, ...); (*UnixIoCtl) (int fd, unsigned long int __request, ...);
#endif
typedef typedef
int int
@ -204,8 +227,29 @@ VOID *
// //
// Work functions to enable source level debug in the emulator
// //
//
typedef
RETURN_STATUS
(EFIAPI *UnixPeCoffGetEntryPoint) (
IN VOID *Pe32Data,
IN OUT VOID **EntryPoint
);
typedef
VOID
(EFIAPI *UnixPeCoffRelocateImageExtraAction) (
IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
);
typedef
VOID
(EFIAPI *UnixPeCoffLoaderUnloadImageExtraAction) (
IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
);
#define EFI_UNIX_THUNK_PROTOCOL_SIGNATURE SIGNATURE_32 ('L', 'N', 'X', 'T') #define EFI_UNIX_THUNK_PROTOCOL_SIGNATURE SIGNATURE_32 ('L', 'N', 'X', 'T')
@ -254,6 +298,11 @@ typedef struct _EFI_UNIX_THUNK_PROTOCOL {
UnixDlopen Dlopen; UnixDlopen Dlopen;
UnixDlerror Dlerror; UnixDlerror Dlerror;
UnixDlsym Dlsym; UnixDlsym Dlsym;
UnixPeCoffGetEntryPoint PeCoffGetEntryPoint;
UnixPeCoffRelocateImageExtraAction PeCoffRelocateImageExtraAction;
UnixPeCoffLoaderUnloadImageExtraAction PeCoffUnloadImageExtraAction;
} EFI_UNIX_THUNK_PROTOCOL; } EFI_UNIX_THUNK_PROTOCOL;
extern EFI_GUID gEfiUnixThunkProtocolGuid; extern EFI_GUID gEfiUnixThunkProtocolGuid;

View File

@ -29,7 +29,7 @@ Abstract:
// UnixIo.h depends on UnixThunk.h // UnixIo.h depends on UnixThunk.h
// //
#include <Common/UnixInclude.h> #include <Common/UnixInclude.h>
#include <Protocol/UnixThunk.h> #include <Protocol/UnixThunk.h>
#include <Protocol/UnixIo.h> #include <Protocol/UnixIo.h>

View File

@ -1,6 +1,7 @@
/**@file /**@file
Copyright (c) 2006 - 2009, Intel Corporation Copyright (c) 2006 - 2009, Intel Corporation
Portions copyright (c) 2008-2009 Apple Inc. All rights reserved.
All rights reserved. This program and the accompanying materials All rights reserved. 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
@ -22,12 +23,10 @@ Abstract:
**/ **/
#include <FrameworkDxe.h> #include <PiDxe.h>
#include <Guid/StatusCodeDataTypeId.h>
#include <UnixDxe.h> #include <UnixDxe.h>
#include <Library/PeCoffLib.h> #include <Library/PeCoffLib.h>
#include <Library/BaseLib.h> #include <Library/BaseLib.h>
#include <Library/DebugLib.h> #include <Library/DebugLib.h>
#include <Library/HobLib.h> #include <Library/HobLib.h>
@ -35,9 +34,12 @@ Abstract:
#include <Library/PeCoffExtraActionLib.h> #include <Library/PeCoffExtraActionLib.h>
// //
// Cache of UnixThunk protocol // Cache of UnixThunk protocol
// //
EFI_UNIX_THUNK_PROTOCOL *mUnix;
EFI_UNIX_THUNK_PROTOCOL *mUnix = NULL;
/** /**
@ -82,35 +84,10 @@ PeCoffLoaderRelocateImageExtraAction (
IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
) )
{ {
VOID * Handle; mUnix->PeCoffRelocateImageExtraAction (ImageContext);
VOID * Entry;
ASSERT (ImageContext != NULL);
Handle = NULL;
Entry = NULL;
DEBUG ((EFI_D_ERROR, "Loading %a 0x%08lx - entry point 0x%08lx\n",
ImageContext->PdbPointer,
(UINTN)ImageContext->ImageAddress,
(UINTN)ImageContext->EntryPoint));
Handle = mUnix->Dlopen(ImageContext->PdbPointer, RTLD_NOW);
if (Handle) {
Entry = mUnix->Dlsym(Handle, "_ModuleEntryPoint");
} else {
DEBUG ((EFI_D_ERROR, "%a\n", mUnix->Dlerror()));
}
if (Entry != NULL) {
ImageContext->EntryPoint = Entry;
DEBUG ((EFI_D_ERROR, "Change %a Entrypoint to :0x%08lx\n", ImageContext->PdbPointer, Entry));
} }
return;
}
/** /**
Performs additional actions just before a PE/COFF image is unloaded. Any resources Performs additional actions just before a PE/COFF image is unloaded. Any resources
@ -128,5 +105,5 @@ PeCoffLoaderUnloadImageExtraAction (
IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
) )
{ {
ASSERT (ImageContext != NULL); mUnix->PeCoffUnloadImageExtraAction (ImageContext);
} }

View File

@ -2,7 +2,7 @@
# PeCoff extra action libary for DXE phase that run Unix emulator. # PeCoff extra action libary for DXE phase that run Unix emulator.
# #
# Lib to provide memory journal status code reporting Routines # Lib to provide memory journal status code reporting Routines
# Copyright (c) 2007, Intel Corporation # Copyright (c) 2007 - 2009, Intel Corporation
# All rights reserved. This program and the accompanying materials # All rights reserved. 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
@ -39,8 +39,6 @@
[Packages] [Packages]
UnixPkg/UnixPkg.dec UnixPkg/UnixPkg.dec
MdePkg/MdePkg.dec MdePkg/MdePkg.dec
IntelFrameworkPkg/IntelFrameworkPkg.dec
IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec
[LibraryClasses] [LibraryClasses]
DebugLib DebugLib

View File

@ -1,6 +1,7 @@
/*++ /*++
Copyright (c) 2006 - 2008, Intel Corporation Copyright (c) 2006 - 2009, Intel Corporation
Portions copyright (c) 2008-2009 Apple Inc. All rights reserved.
All rights reserved. This program and the accompanying materials All rights reserved. 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
@ -54,38 +55,24 @@ Returns:
--*/ --*/
{ {
PEI_UNIX_THUNK_PPI *UnixThunkPpi;
EFI_STATUS Status; EFI_STATUS Status;
EFI_PEI_PPI_DESCRIPTOR *PpiDescriptor; EFI_UNIX_THUNK_PROTOCOL *Unix;
UNIX_PEI_LOAD_FILE_PPI *PeiUnixService;
EFI_PHYSICAL_ADDRESS ImageAddress;
UINT64 ImageSize;
EFI_PHYSICAL_ADDRESS ImageEntryPoint;
ASSERT (Pe32Data != NULL);
ASSERT (EntryPoint != NULL);
//
// Locate Unix ThunkPpi for retrieving standard output handle
//
Status = PeiServicesLocatePpi ( Status = PeiServicesLocatePpi (
&gUnixPeiLoadFilePpiGuid, &gPeiUnixThunkPpiGuid,
0, 0,
&PpiDescriptor, NULL,
(void **)&PeiUnixService (VOID **) &UnixThunkPpi
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
Status = PeiUnixService->PeiLoadFileService ( Unix = (EFI_UNIX_THUNK_PROTOCOL *)UnixThunkPpi->UnixThunk ();
Pe32Data,
&ImageAddress,
&ImageSize,
&ImageEntryPoint
);
if (EFI_ERROR (Status)) { return Unix->PeCoffGetEntryPoint (Pe32Data, EntryPoint);
return Status;
}
*EntryPoint = (VOID*)(UINTN)ImageEntryPoint;
return Status;
} }
/** /**
@ -255,6 +242,8 @@ PeCoffLoaderGetPdbPointer (
return (VOID *) ((CHAR8 *)CodeViewEntryPointer + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY)); return (VOID *) ((CHAR8 *)CodeViewEntryPointer + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY));
case CODEVIEW_SIGNATURE_RSDS: case CODEVIEW_SIGNATURE_RSDS:
return (VOID *) ((CHAR8 *)CodeViewEntryPointer + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_RSDS_ENTRY)); return (VOID *) ((CHAR8 *)CodeViewEntryPointer + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_RSDS_ENTRY));
case CODEVIEW_SIGNATURE_MTOC:
return (VOID *) ((CHAR8 *)CodeViewEntryPointer + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_MTOC_ENTRY));
default: default:
break; break;
} }

View File

@ -1,6 +1,7 @@
/**@file /**@file
Copyright (c) 2006 - 2009, Intel Corporation Copyright (c) 2006 - 2009, Intel Corporation
Portions copyright (c) 2008-2009 Apple Inc. All rights reserved.
All rights reserved. This program and the accompanying materials All rights reserved. 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
@ -36,7 +37,7 @@ Abstract:
EFI_UNIX_THUNK_PROTOCOL *mUnix = NULL; EFI_UNIX_THUNK_PROTOCOL *mUnix = NULL;
/** /**
The function caches the pointer of the WinNT thunk functions The function caches the pointer of the Unix thunk functions
It will ASSERT() if Unix thunk ppi is not installed. It will ASSERT() if Unix thunk ppi is not installed.
@retval EFI_SUCCESS WinNT thunk protocol is found and cached. @retval EFI_SUCCESS WinNT thunk protocol is found and cached.
@ -83,39 +84,13 @@ PeCoffLoaderRelocateImageExtraAction (
IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
) )
{ {
VOID * Handle;
VOID * Entry;
ASSERT (ImageContext != NULL);
Handle = NULL;
Entry = NULL;
if (mUnix == NULL) { if (mUnix == NULL) {
UnixPeCoffGetUnixThunkStucture (); UnixPeCoffGetUnixThunkStucture ();
} }
DEBUG ((EFI_D_ERROR, "Loading %a 0x%08lx - entry point 0x%08lx\n", mUnix->PeCoffRelocateImageExtraAction (ImageContext);
ImageContext->PdbPointer,
(UINTN)ImageContext->ImageAddress,
(UINTN)ImageContext->EntryPoint));
Handle = mUnix->Dlopen (ImageContext->PdbPointer, RTLD_NOW);
if (Handle) {
Entry = mUnix->Dlsym(Handle, "_ModuleEntryPoint");
} else {
DEBUG ((EFI_D_ERROR, "%a\n", mUnix->Dlerror()));
}
if (Entry != NULL) {
ImageContext->EntryPoint = Entry;
DEBUG ((EFI_D_ERROR, "Change %a Entrypoint to :0x%08lx\n", ImageContext->PdbPointer, Entry));
} }
return;
}
/** /**
Performs additional actions just before a PE/COFF image is unloaded. Any resources Performs additional actions just before a PE/COFF image is unloaded. Any resources
that were allocated by PeCoffLoaderRelocateImageExtraAction() must be freed. that were allocated by PeCoffLoaderRelocateImageExtraAction() must be freed.
@ -132,5 +107,8 @@ PeCoffLoaderUnloadImageExtraAction (
IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
) )
{ {
ASSERT (ImageContext != NULL); if (mUnix == NULL) {
UnixPeCoffGetUnixThunkStucture ();
}
mUnix->PeCoffUnloadImageExtraAction (ImageContext);
} }

View File

@ -2,7 +2,7 @@
# PeCoff extra action libary for Pei phase that run UNIX emulator. # PeCoff extra action libary for Pei phase that run UNIX emulator.
# #
# Lib to provide memory journal status code reporting Routines # Lib to provide memory journal status code reporting Routines
# Copyright (c) 2007, Intel Corporation # Copyright (c) 2007 - 2009, Intel Corporation
# All rights reserved. This program and the accompanying materials # All rights reserved. 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
@ -37,8 +37,6 @@
[Packages] [Packages]
MdePkg/MdePkg.dec MdePkg/MdePkg.dec
UnixPkg/UnixPkg.dec UnixPkg/UnixPkg.dec
IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec
IntelFrameworkPkg/IntelFrameworkPkg.dec
[LibraryClasses] [LibraryClasses]
BaseLib BaseLib

View File

@ -50,7 +50,7 @@
BaseMemoryLib BaseMemoryLib
DebugLib DebugLib
PcdLib PcdLib
GenericBdsLib GenericBdsLib
DevicePathLib DevicePathLib

View File

@ -1,6 +1,6 @@
/*++ /*++
Copyright (c) 2006, Intel Corporation Copyright (c) 2006 - 2009, Intel Corporation
All rights reserved. This program and the accompanying materials All rights reserved. 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
@ -32,22 +32,22 @@ UINT16 gPlatformBootTimeOutDefault = 10;
// //
UNIX_PLATFORM_UGA_DEVICE_PATH gUgaDevicePath0 = UNIX_PLATFORM_UGA_DEVICE_PATH gUgaDevicePath0 =
{ {
{ {
HARDWARE_DEVICE_PATH, HARDWARE_DEVICE_PATH,
HW_VENDOR_DP, HW_VENDOR_DP,
{ {
(UINT8) (sizeof (VENDOR_DEVICE_PATH)), (UINT8) (sizeof (VENDOR_DEVICE_PATH)),
(UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8), (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8)
}, },
EFI_UNIX_THUNK_PROTOCOL_GUID EFI_UNIX_THUNK_PROTOCOL_GUID
}, },
{ {
HARDWARE_DEVICE_PATH, HARDWARE_DEVICE_PATH,
HW_VENDOR_DP, HW_VENDOR_DP,
{ {
(UINT8) (sizeof (UNIX_VENDOR_DEVICE_PATH_NODE)), (UINT8) (sizeof (UNIX_VENDOR_DEVICE_PATH_NODE)),
(UINT8) ((sizeof (UNIX_VENDOR_DEVICE_PATH_NODE)) >> 8), (UINT8) ((sizeof (UNIX_VENDOR_DEVICE_PATH_NODE)) >> 8)
}, },
EFI_UNIX_UGA_GUID, EFI_UNIX_UGA_GUID,
0 0
}, },
@ -58,19 +58,19 @@ UNIX_PLATFORM_UGA_DEVICE_PATH gUgaDevicePath1 = {
{ {
HARDWARE_DEVICE_PATH, HARDWARE_DEVICE_PATH,
HW_VENDOR_DP, HW_VENDOR_DP,
{ {
(UINT8) (sizeof (VENDOR_DEVICE_PATH)), (UINT8) (sizeof (VENDOR_DEVICE_PATH)),
(UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8), (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8)
}, },
EFI_UNIX_THUNK_PROTOCOL_GUID EFI_UNIX_THUNK_PROTOCOL_GUID
}, },
{ {
HARDWARE_DEVICE_PATH, HARDWARE_DEVICE_PATH,
HW_VENDOR_DP, HW_VENDOR_DP,
{ {
(UINT8) (sizeof (UNIX_VENDOR_DEVICE_PATH_NODE)), (UINT8) (sizeof (UNIX_VENDOR_DEVICE_PATH_NODE)),
(UINT8) ((sizeof (UNIX_VENDOR_DEVICE_PATH_NODE)) >> 8), (UINT8) ((sizeof (UNIX_VENDOR_DEVICE_PATH_NODE)) >> 8)
}, },
EFI_UNIX_UGA_GUID, EFI_UNIX_UGA_GUID,
1 1
}, },
@ -80,20 +80,20 @@ UNIX_PLATFORM_UGA_DEVICE_PATH gUgaDevicePath1 = {
UNIX_CONSOLE_DEVICE_PATH gUnixConsoleDevicePath = { UNIX_CONSOLE_DEVICE_PATH gUnixConsoleDevicePath = {
{ {
HARDWARE_DEVICE_PATH, HARDWARE_DEVICE_PATH,
HW_VENDOR_DP, HW_VENDOR_DP,
{ {
(UINT8) (sizeof (VENDOR_DEVICE_PATH)), (UINT8) (sizeof (VENDOR_DEVICE_PATH)),
(UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8), (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8)
}, },
EFI_UNIX_THUNK_PROTOCOL_GUID EFI_UNIX_THUNK_PROTOCOL_GUID
}, },
{ {
HARDWARE_DEVICE_PATH, HARDWARE_DEVICE_PATH,
HW_VENDOR_DP, HW_VENDOR_DP,
{ {
(UINT8) (sizeof (UNIX_VENDOR_DEVICE_PATH_NODE)), (UINT8) (sizeof (UNIX_VENDOR_DEVICE_PATH_NODE)),
(UINT8) ((sizeof (UNIX_VENDOR_DEVICE_PATH_NODE)) >> 8), (UINT8) ((sizeof (UNIX_VENDOR_DEVICE_PATH_NODE)) >> 8)
}, },
EFI_UNIX_CONSOLE_GUID, EFI_UNIX_CONSOLE_GUID,
0 0
}, },

View File

@ -64,7 +64,7 @@
[Packages] [Packages]
MdePkg/MdePkg.dec MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec MdeModulePkg/MdeModulePkg.dec
IntelFrameworkPkg/IntelFrameworkPkg.dec IntelFrameworkPkg/IntelFrameworkPkg.dec
IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec

View File

@ -89,7 +89,7 @@ Returns:
} }
gUnix->GetLocalTime (Time); gUnix->GetLocalTime (Time);
if (Capabilities != NULL) { if (Capabilities != NULL) {
Capabilities->Resolution = 1; Capabilities->Resolution = 1;

View File

@ -1,6 +1,6 @@
/*++ /*++
Copyright (c) 2004 - 2008, Intel Corporation Copyright (c) 2004 - 2009, Intel Corporation
All rights reserved. This program and the accompanying materials All rights reserved. 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
@ -113,9 +113,30 @@ Returns:
--*/ --*/
{ {
EFI_STATUS Status;
UINTN HandleCount;
EFI_HANDLE *HandleBuffer;
UINTN Index;
// //
// BUGBUG Need to kill all console windows later // Disconnect all
// //
Status = gBS->LocateHandleBuffer (
AllHandles,
NULL,
NULL,
&HandleCount,
&HandleBuffer
);
if (!EFI_ERROR (Status)) {
for (Index = 0; Index < HandleCount; Index++) {
Status = gBS->DisconnectController (HandleBuffer[Index], NULL, NULL);
}
gBS->FreePool (HandleBuffer);
}
// //
// Discard ResetType, always return 0 as exit code // Discard ResetType, always return 0 as exit code
// //
@ -124,6 +145,7 @@ Returns:
// //
// Should never go here // Should never go here
// //
while (1) ASSERT (FALSE);
;
return;
} }

95
UnixPkg/Sec/Ia32/Stack.S Normal file
View File

@ -0,0 +1,95 @@
#------------------------------------------------------------------------------
#
# Copyright (c) 2008 - 2009, Intel Corporation
# Portions copyright (c) 2008-2009 Apple Inc.
# All rights reserved. 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
# http://opensource.org/licenses/bsd-license.php
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
# Module Name:
#
# Stack.asm
#
# Abstract:
#
# Switch the stack from temporary memory to permenent memory.
#
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
# VOID
# EFIAPI
# SecSwitchStack (
# UINT32 TemporaryMemoryBase,
# UINT32 PermenentMemoryBase
# );
#------------------------------------------------------------------------------
#include <ProcessorBind.h>
ASM_GLOBAL ASM_PFX(SecSwitchStack)
ASM_PFX(SecSwitchStack):
#
# Save three register: eax, ebx, ecx
#
push %eax
push %ebx
push %ecx
push %edx
#
# !!CAUTION!! this function address's is pushed into stack after
# migration of whole temporary memory, so need save it to permenent
# memory at first!
#
movl 20(%esp), %ebx # Save the first parameter
movl 24(%esp), %ecx # Save the second parameter
#
# Save this function's return address into permenent memory at first.
# Then, Fixup the esp point to permenent memory
#
movl %esp, %eax
subl %ebx, %eax
addl %ecx, %eax
movl (%esp), %edx # copy pushed register's value to permenent memory
movl %edx, (%eax)
movl 4(%esp), %edx
movl %edx, 4(%eax)
movl 8(%esp), %edx
movl %edx, 8(%eax)
movl 12(%esp), %edx
movl %edx, 12(%eax)
movl 16(%esp), %edx
movl %edx, 16(%eax)
movl %eax, %esp # From now, esp is pointed to permenent memory
#
# Fixup the ebp point to permenent memory
#
#ifndef __APPLE__
movl %ebp, %eax
subl %ebx, %eax
addl %ecx, %eax
movl %eax, %ebp # From now, ebp is pointed to permenent memory
#
# Fixup callee's ebp point for PeiDispatch
#
movl (%ebp), %eax
subl %ebx, %eax
addl %ecx, %eax
movl %eax, (%ebp) # From now, Temporary's PPI caller's stack is in permenent memory
#endif
pop %edx
pop %ecx
pop %ebx
pop %eax
ret

View File

@ -1,6 +1,7 @@
/*++ /*++
Copyright (c) 2006 - 2007 Intel Corporation. Copyright (c) 2006 - 2009 Intel Corporation.
Portions copyright (c) 2008-2009 Apple Inc.
All rights reserved. This program and the accompanying materials All rights reserved. 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
@ -14,7 +15,7 @@ Module Name:
SecMain.c SecMain.c
Abstract: Abstract:
WinNt emulator of SEC phase. It's really a Posix application, but this is Unix emulator of SEC phase. It's really a Posix application, but this is
Ok since all the other modules for NT32 are NOT Posix applications. Ok since all the other modules for NT32 are NOT Posix applications.
This program processes host environment variables and figures out This program processes host environment variables and figures out
@ -35,21 +36,29 @@ Abstract:
#include "SecMain.h" #include "SecMain.h"
#include <sys/mman.h> #include <sys/mman.h>
#include <Ppi/UnixPeiLoadFile.h> #include <Ppi/UnixPeiLoadFile.h>
#include <Framework/StatusCode.h>
#include <Ppi/TemporaryRamSupport.h> #include <Ppi/TemporaryRamSupport.h>
#include <dlfcn.h> #include <dlfcn.h>
#ifdef __APPLE__
#define MAP_ANONYMOUS MAP_ANON
char *gGdbWorkingFileName = NULL;
#endif
// //
// Globals // Globals
// //
UNIX_PEI_LOAD_FILE_PPI mSecNtLoadFilePpi = { SecWinNtPeiLoadFile }; UNIX_PEI_LOAD_FILE_PPI mSecUnixLoadFilePpi = { SecUnixPeiLoadFile };
PEI_UNIX_AUTOSCAN_PPI mSecNtAutoScanPpi = { SecWinNtPeiAutoScan }; PEI_UNIX_AUTOSCAN_PPI mSecUnixAutoScanPpi = { SecUnixPeiAutoScan };
PEI_UNIX_THUNK_PPI mSecWinNtThunkPpi = { SecWinNtWinNtThunkAddress }; PEI_UNIX_THUNK_PPI mSecUnixThunkPpi = { SecUnixUnixThunkAddress };
EFI_PEI_PROGRESS_CODE_PPI mSecStatusCodePpi = { SecPeiReportStatusCode }; EFI_PEI_PROGRESS_CODE_PPI mSecStatusCodePpi = { SecPeiReportStatusCode };
UNIX_FWH_PPI mSecFwhInformationPpi = { SecWinNtFdAddress }; UNIX_FWH_PPI mSecFwhInformationPpi = { SecUnixFdAddress };
TEMPORARY_RAM_SUPPORT_PPI mSecTemporaryRamSupportPpi = {SecTemporaryRamSupport}; TEMPORARY_RAM_SUPPORT_PPI mSecTemporaryRamSupportPpi = {SecTemporaryRamSupport};
@ -57,17 +66,17 @@ EFI_PEI_PPI_DESCRIPTOR gPrivateDispatchTable[] = {
{ {
EFI_PEI_PPI_DESCRIPTOR_PPI, EFI_PEI_PPI_DESCRIPTOR_PPI,
&gUnixPeiLoadFilePpiGuid, &gUnixPeiLoadFilePpiGuid,
&mSecNtLoadFilePpi &mSecUnixLoadFilePpi
}, },
{ {
EFI_PEI_PPI_DESCRIPTOR_PPI, EFI_PEI_PPI_DESCRIPTOR_PPI,
&gPeiUnixAutoScanPpiGuid, &gPeiUnixAutoScanPpiGuid,
&mSecNtAutoScanPpi &mSecUnixAutoScanPpi
}, },
{ {
EFI_PEI_PPI_DESCRIPTOR_PPI, EFI_PEI_PPI_DESCRIPTOR_PPI,
&gPeiUnixThunkPpiGuid, &gPeiUnixThunkPpiGuid,
&mSecWinNtThunkPpi &mSecUnixThunkPpi
}, },
{ {
EFI_PEI_PPI_DESCRIPTOR_PPI, EFI_PEI_PPI_DESCRIPTOR_PPI,
@ -107,6 +116,12 @@ UNIX_FD_INFO *gFdInfo;
UINTN gSystemMemoryCount = 0; UINTN gSystemMemoryCount = 0;
UNIX_SYSTEM_MEMORY *gSystemMemory; UNIX_SYSTEM_MEMORY *gSystemMemory;
UINTN mImageContextModHandleArraySize = 0;
IMAGE_CONTEXT_TO_MOD_HANDLE *mImageContextModHandleArray = NULL;
VOID VOID
EFIAPI EFIAPI
SecSwitchStack ( SecSwitchStack (
@ -134,17 +149,16 @@ SecNt32PeCoffRelocateImage (
); );
INTN int
EFIAPI
main ( main (
IN INTN Argc, IN int Argc,
IN CHAR8 **Argv, IN char **Argv,
IN CHAR8 **Envp IN char **Envp
) )
/*++ /*++
Routine Description: Routine Description:
Main entry point to SEC for WinNt. This is a unix program Main entry point to SEC for Unix. This is a unix program
Arguments: Arguments:
Argc - Number of command line arguments Argc - Number of command line arguments
@ -179,6 +193,19 @@ Returns:
printf ("\nEDK SEC Main UNIX Emulation Environment from www.TianoCore.org\n"); printf ("\nEDK SEC Main UNIX Emulation Environment from www.TianoCore.org\n");
#ifdef __APPLE__
//
// We can't use dlopen on OS X, so we need a scheme to get symboles into gdb
// We need to create a temp file that contains gdb commands so we can load
// symbols when we load every PE/COFF image.
//
Index = strlen (*Argv);
gGdbWorkingFileName = malloc (Index + strlen(".gdb"));
strcpy (gGdbWorkingFileName, *Argv);
strcat (gGdbWorkingFileName, ".gdb");
#endif
// //
// Allocate space for gSystemMemory Array // Allocate space for gSystemMemory Array
// //
@ -200,12 +227,12 @@ Returns:
// //
// Setup Boot Mode. If BootModeStr == "" then BootMode = 0 (BOOT_WITH_FULL_CONFIGURATION) // Setup Boot Mode. If BootModeStr == "" then BootMode = 0 (BOOT_WITH_FULL_CONFIGURATION)
// //
printf (" BootMode 0x%02x\n", FixedPcdGet32 (PcdUnixBootMode)); printf (" BootMode 0x%02x\n", (unsigned int)FixedPcdGet32 (PcdUnixBootMode));
// //
// Open up a 128K file to emulate temp memory for PEI. // Open up a 128K file to emulate temp memory for PEI.
// on a real platform this would be SRAM, or using the cache as RAM. // on a real platform this would be SRAM, or using the cache as RAM.
// Set InitialStackMemory to zero so WinNtOpenFile 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,
@ -218,11 +245,11 @@ 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",
(UINTN)(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) InitialStackMemory + (UINT64) InitialStackMemorySize); StackPointer < (UINTN*)(UINTN)((UINTN) InitialStackMemory + (UINT64) InitialStackMemorySize);
StackPointer ++) { StackPointer ++) {
*StackPointer = 0x5AA55AA5; *StackPointer = 0x5AA55AA5;
} }
@ -255,7 +282,7 @@ Returns:
&gFdInfo[Index].Size &gFdInfo[Index].Size
); );
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
printf ("ERROR : Can not open Firmware Device File %s (%x). Exiting.\n", FileName, Status); printf ("ERROR : Can not open Firmware Device File %s (%x). Exiting.\n", FileName, (unsigned int)Status);
exit (1); exit (1);
} }
@ -354,7 +381,7 @@ MapFile (
/*++ /*++
Routine Description: Routine Description:
Opens and memory maps a file using WinNt services. If BaseAddress is non zero Opens and memory maps a file using Unix services. If BaseAddress is non zero
the process will try and allocate the memory starting at BaseAddress. the process will try and allocate the memory starting at BaseAddress.
Arguments: Arguments:
@ -415,12 +442,12 @@ Returns:
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
SecPeiReportStatusCode ( SecPeiReportStatusCode (
IN EFI_PEI_SERVICES **PeiServices, IN CONST EFI_PEI_SERVICES **PeiServices,
IN EFI_STATUS_CODE_TYPE CodeType, IN EFI_STATUS_CODE_TYPE CodeType,
IN EFI_STATUS_CODE_VALUE Value, IN EFI_STATUS_CODE_VALUE Value,
IN UINT32 Instance, IN UINT32 Instance,
IN EFI_GUID * CallerId, IN CONST EFI_GUID *CallerId,
IN EFI_STATUS_CODE_DATA * Data OPTIONAL IN CONST EFI_STATUS_CODE_DATA *Data OPTIONAL
) )
/*++ /*++
@ -460,7 +487,7 @@ Returns:
// //
// Processes ASSERT () // Processes ASSERT ()
// //
printf ("ASSERT %s(%d): %s\n", Filename, LineNumber, Description); printf ("ASSERT %s(%d): %s\n", Filename, (int)LineNumber, Description);
} else if (ReportStatusCodeExtractDebugInfo (Data, &ErrorLevel, &Marker, &Format)) { } else if (ReportStatusCodeExtractDebugInfo (Data, &ErrorLevel, &Marker, &Format)) {
// //
@ -605,7 +632,7 @@ Returns:
// //
// Load the PEI Core from a Firmware Volume // Load the PEI Core from a Firmware Volume
// //
Status = SecWinNtPeiLoadFile ( Status = SecUnixPeiLoadFile (
PeiCorePe32File, PeiCorePe32File,
&PeiImageAddress, &PeiImageAddress,
&PeiCoreSize, &PeiCoreSize,
@ -633,7 +660,7 @@ Returns:
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
SecWinNtPeiAutoScan ( SecUnixPeiAutoScan (
IN UINTN Index, IN UINTN Index,
OUT EFI_PHYSICAL_ADDRESS *MemoryBase, OUT EFI_PHYSICAL_ADDRESS *MemoryBase,
OUT UINT64 *MemorySize OUT UINT64 *MemorySize
@ -646,7 +673,7 @@ Routine Description:
It uses gSystemMemory[] and gSystemMemoryCount that were created by It uses gSystemMemory[] and gSystemMemoryCount that were created by
parsing the host environment variable EFI_MEMORY_SIZE. parsing the host environment variable EFI_MEMORY_SIZE.
The size comes from the varaible and the address comes from the call to The size comes from the varaible and the address comes from the call to
WinNtOpenFile. UnixOpenFile.
Arguments: Arguments:
Index - Which memory region to use Index - Which memory region to use
@ -680,19 +707,18 @@ Returns:
VOID * VOID *
EFIAPI EFIAPI
SecWinNtWinNtThunkAddress ( SecUnixUnixThunkAddress (
VOID VOID
) )
/*++ /*++
Routine Description: Routine Description:
Since the SEC is the only Unix program in stack it must export Since the SEC is the only Unix program in stack it must export
an interface to do Win API calls. That's what the WinNtThunk address an interface to do POSIX calls. gUnix is initailized in UnixThunk.c.
is for. gWinNt is initailized in WinNtThunk.c.
Arguments: Arguments:
InterfaceSize - sizeof (EFI_WIN_NT_THUNK_PROTOCOL); InterfaceSize - sizeof (EFI_WIN_NT_THUNK_PROTOCOL);
InterfaceBase - Address of the gWinNt global InterfaceBase - Address of the gUnix global
Returns: Returns:
EFI_SUCCESS - Data returned EFI_SUCCESS - Data returned
@ -704,12 +730,11 @@ Returns:
EFI_STATUS EFI_STATUS
EFIAPI SecUnixPeiLoadFile (
SecWinNtPeiLoadFile (
IN VOID *Pe32Data, IN VOID *Pe32Data,
IN EFI_PHYSICAL_ADDRESS *ImageAddress, OUT EFI_PHYSICAL_ADDRESS *ImageAddress,
IN UINT64 *ImageSize, OUT UINT64 *ImageSize,
IN EFI_PHYSICAL_ADDRESS *EntryPoint OUT EFI_PHYSICAL_ADDRESS *EntryPoint
) )
/*++ /*++
@ -759,10 +784,7 @@ Returns:
return Status; return Status;
} }
Status = SecNt32PeCoffRelocateImage(&ImageContext); SecPeCoffRelocateImageExtraAction (&ImageContext);
if (EFI_ERROR (Status)) {
return Status;
}
// //
// BugBug: Flush Instruction Cache Here when CPU Lib is ready // BugBug: Flush Instruction Cache Here when CPU Lib is ready
@ -775,9 +797,30 @@ Returns:
return EFI_SUCCESS; return EFI_SUCCESS;
} }
RETURN_STATUS
EFIAPI
SecPeCoffGetEntryPoint (
IN VOID *Pe32Data,
IN OUT VOID **EntryPoint
)
{
EFI_STATUS Status;
EFI_PHYSICAL_ADDRESS ImageAddress;
UINT64 ImageSize;
EFI_PHYSICAL_ADDRESS PhysEntryPoint;
Status = SecUnixPeiLoadFile (Pe32Data, &ImageAddress, &ImageSize, &PhysEntryPoint);
*EntryPoint = (VOID *)(UINTN)PhysEntryPoint;
return Status;
}
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
SecWinNtFdAddress ( SecUnixFdAddress (
IN UINTN Index, IN UINTN Index,
IN OUT EFI_PHYSICAL_ADDRESS *FdBase, IN OUT EFI_PHYSICAL_ADDRESS *FdBase,
IN OUT UINT64 *FdSize IN OUT UINT64 *FdSize
@ -882,6 +925,131 @@ Returns:
} }
EFI_STATUS
AddHandle (
IN PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext,
IN VOID *ModHandle
)
/*++
Routine Description:
Store the ModHandle in an array indexed by the Pdb File name.
The ModHandle is needed to unload the image.
Arguments:
ImageContext - Input data returned from PE Laoder Library. Used to find the
.PDB file name of the PE Image.
ModHandle - Returned from LoadLibraryEx() and stored for call to
FreeLibrary().
Returns:
EFI_SUCCESS - ModHandle was stored.
--*/
{
UINTN Index;
IMAGE_CONTEXT_TO_MOD_HANDLE *Array;
UINTN PreviousSize;
Array = mImageContextModHandleArray;
for (Index = 0; Index < mImageContextModHandleArraySize; Index++, Array++) {
if (Array->ImageContext == NULL) {
//
// Make a copy of the stirng and store the ModHandle
//
Array->ImageContext = ImageContext;
Array->ModHandle = ModHandle;
return EFI_SUCCESS;
}
}
//
// No free space in mImageContextModHandleArray so grow it by
// IMAGE_CONTEXT_TO_MOD_HANDLE entires. realloc will
// copy the old values to the new locaiton. But it does
// not zero the new memory area.
//
PreviousSize = mImageContextModHandleArraySize * sizeof (IMAGE_CONTEXT_TO_MOD_HANDLE);
mImageContextModHandleArraySize += MAX_IMAGE_CONTEXT_TO_MOD_HANDLE_ARRAY_SIZE;
mImageContextModHandleArray = realloc (mImageContextModHandleArray, mImageContextModHandleArraySize * sizeof (IMAGE_CONTEXT_TO_MOD_HANDLE));
if (mImageContextModHandleArray == NULL) {
ASSERT (FALSE);
return EFI_OUT_OF_RESOURCES;
}
memset (mImageContextModHandleArray + PreviousSize, 0, MAX_IMAGE_CONTEXT_TO_MOD_HANDLE_ARRAY_SIZE * sizeof (IMAGE_CONTEXT_TO_MOD_HANDLE));
return AddHandle (ImageContext, ModHandle);
}
VOID *
RemoveHandle (
IN PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
)
/*++
Routine Description:
Return the ModHandle and delete the entry in the array.
Arguments:
ImageContext - Input data returned from PE Laoder Library. Used to find the
.PDB file name of the PE Image.
Returns:
ModHandle - ModHandle assoicated with ImageContext is returned
NULL - No ModHandle associated with ImageContext
--*/
{
UINTN Index;
IMAGE_CONTEXT_TO_MOD_HANDLE *Array;
if (ImageContext->PdbPointer == NULL) {
//
// If no PDB pointer there is no ModHandle so return NULL
//
return NULL;
}
Array = mImageContextModHandleArray;
for (Index = 0; Index < mImageContextModHandleArraySize; Index++, Array++) {
if ((Array->ImageContext == ImageContext)) {
//
// If you find a match return it and delete the entry
//
Array->ImageContext = NULL;
return Array->ModHandle;
}
}
return NULL;
}
//
// 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....
//
// Put .gdbinit in the CWD where you do gdb SecMain.dll for source level debug
//
// cat .gdbinit
// b SecGdbScriptBreak
// command
// silent
// source SecMain.dll.gdb
// c
// end
//
VOID
SecGdbScriptBreak (
VOID
)
{
}
VOID VOID
SecUnixLoaderBreak ( SecUnixLoaderBreak (
@ -890,19 +1058,128 @@ SecUnixLoaderBreak (
{ {
} }
EFI_STATUS BOOLEAN
IsPdbFile (
IN CHAR8 *PdbFileName
)
{
UINTN Len;
if (PdbFileName == NULL) {
return FALSE;
}
Len = strlen (PdbFileName);
if ((Len < 5)|| (PdbFileName[Len - 4] != '.')) {
return FALSE;
}
if ((PdbFileName[Len - 3] == 'P' || PdbFileName[Len - 3] == 'p') &&
(PdbFileName[Len - 2] == 'D' || PdbFileName[Len - 2] == 'd') &&
(PdbFileName[Len - 1] == 'B' || PdbFileName[Len - 1] == 'b')) {
return TRUE;
}
return FALSE;
}
#define MAX_SPRINT_BUFFER_SIZE 0x200
void
PrintLoadAddress (
IN PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
)
{
fprintf (stderr,
"0x%08lx Loading %s with entry point 0x%08lx\n",
(unsigned long)ImageContext->ImageAddress + ImageContext->SizeOfHeaders,
ImageContext->PdbPointer,
(unsigned long)ImageContext->EntryPoint
);
// Keep output synced up
fflush (stderr);
}
VOID
EFIAPI EFIAPI
SecNt32PeCoffRelocateImage ( SecPeCoffRelocateImageExtraAction (
IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
) )
{ {
void * Handle;
void * Entry;
EFI_STATUS Status; EFI_STATUS Status;
Handle = NULL;
Entry = NULL;
Status = PeCoffLoaderRelocateImage (ImageContext); Status = PeCoffLoaderRelocateImage (ImageContext);
if (EFI_ERROR (Status)) {
PrintLoadAddress (ImageContext);
return;
}
#ifdef __APPLE__
PrintLoadAddress (ImageContext);
//
// In mach-o (OS X executable) dlopen() can only load files in the MH_DYLIB of MH_BUNDLE format.
// To convert to PE/COFF we need to construct a mach-o with the MH_PRELOAD format. We create
// .dSYM files for the PE/COFF images that can be used by gdb for source level debugging.
//
FILE *GdbTempFile;
//
// 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.
//
if (ImageContext->PdbPointer != NULL && !IsPdbFile (ImageContext->PdbPointer)) {
//
// Now we have a database of the images that are currently loaded
//
//
// '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
// 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.
//
// 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
// data base of info ready to roll.
//
// We could use qXfer:libraries:read, but OS X GDB does not currently support it.
// <library-list>
// <library name="/lib/libc.so.6"> // ImageContext->PdbPointer
// <segment address="0x10000000"/> // ImageContext->ImageAddress + ImageContext->SizeOfHeaders
// </library>
// </library-list>
//
//
// Write the file we need for the gdb script
//
GdbTempFile = fopen (gGdbWorkingFileName, "w");
if (GdbTempFile != NULL) {
fprintf (GdbTempFile, "add-symbol-file %s 0x%x\n", ImageContext->PdbPointer, (UINTN)(ImageContext->ImageAddress + ImageContext->SizeOfHeaders));
fclose (GdbTempFile);
//
// 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....
//
SecGdbScriptBreak ();
}
AddHandle (ImageContext, ImageContext->PdbPointer);
}
#else
void *Handle = NULL;
void *Entry = NULL;
fprintf (stderr, fprintf (stderr,
"Loading %s 0x%08lx - entry point 0x%08lx\n", "Loading %s 0x%08lx - entry point 0x%08lx\n",
ImageContext->PdbPointer, ImageContext->PdbPointer,
@ -918,23 +1195,63 @@ SecNt32PeCoffRelocateImage (
} }
if (Entry != NULL) { if (Entry != NULL) {
ImageContext->EntryPoint = Entry; ImageContext->EntryPoint = (UINTN)Entry;
printf("Change %s Entrypoint to :0x%08lx\n", ImageContext->PdbPointer, Entry); printf("Change %s Entrypoint to :0x%08lx\n", ImageContext->PdbPointer, (unsigned long)Entry);
} }
SecUnixLoaderBreak (); SecUnixLoaderBreak ();
return Status; #endif
return;
} }
EFI_STATUS VOID
EFIAPI EFIAPI
SecNt32PeCoffUnloadimage ( SecPeCoffLoaderUnloadImageExtraAction (
IN PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext IN PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
) )
{ {
return EFI_SUCCESS; VOID *Handle;
Handle = RemoveHandle (ImageContext);
#ifdef __APPLE__
FILE *GdbTempFile;
if (Handle != NULL) {
//
// Need to skip .PDB files created from VC++
//
if (!IsPdbFile (ImageContext->PdbPointer)) {
//
// Write the file we need for the gdb script
//
GdbTempFile = fopen (gGdbWorkingFileName, "w");
if (GdbTempFile != NULL) {
fprintf (GdbTempFile, "remove-symbol-file %s\n", ImageContext->PdbPointer);
fclose (GdbTempFile);
//
// 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....
//
SecGdbScriptBreak ();
}
}
}
#else
//
// Don't want to confuse gdb with symbols for something that got unloaded
//
if (Handle != NULL) {
dlclose (Handle);
}
#endif
return;
} }
VOID VOID

View File

@ -1,6 +1,7 @@
/*++ /*++
Copyright (c) 2006 - 2008, Intel Corporation Copyright (c) 2006 - 2009, Intel Corporation
Portions copyright (c) 2008-2009 Apple Inc.
All rights reserved. This program and the accompanying materials All rights reserved. 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
@ -28,6 +29,7 @@ Abstract:
#include <Library/PrintLib.h> #include <Library/PrintLib.h>
#include <Library/PcdLib.h> #include <Library/PcdLib.h>
#include <Library/DebugLib.h> #include <Library/DebugLib.h>
#include <Library/ReportStatusCodeLib.h>
#define STACK_SIZE 0x20000 #define STACK_SIZE 0x20000
@ -42,10 +44,17 @@ typedef struct {
} UNIX_SYSTEM_MEMORY; } UNIX_SYSTEM_MEMORY;
#define MAX_IMAGE_CONTEXT_TO_MOD_HANDLE_ARRAY_SIZE 0x100
typedef struct {
PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext;
VOID *ModHandle;
} IMAGE_CONTEXT_TO_MOD_HANDLE;
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
SecWinNtPeiLoadFile ( SecUnixPeiLoadFile (
VOID *Pe32Data, // TODO: add IN/OUT modifier to Pe32Data VOID *Pe32Data, // TODO: add IN/OUT modifier to Pe32Data
EFI_PHYSICAL_ADDRESS *ImageAddress, // TODO: add IN/OUT modifier to ImageAddress EFI_PHYSICAL_ADDRESS *ImageAddress, // TODO: add IN/OUT modifier to ImageAddress
UINT64 *ImageSize, // TODO: add IN/OUT modifier to ImageSize UINT64 *ImageSize, // TODO: add IN/OUT modifier to ImageSize
@ -73,7 +82,7 @@ Returns:
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
SecWinNtPeiAutoScan ( SecUnixPeiAutoScan (
IN UINTN Index, IN UINTN Index,
OUT EFI_PHYSICAL_ADDRESS *MemoryBase, OUT EFI_PHYSICAL_ADDRESS *MemoryBase,
OUT UINT64 *MemorySize OUT UINT64 *MemorySize
@ -99,7 +108,7 @@ Returns:
VOID * VOID *
EFIAPI EFIAPI
SecWinNtWinNtThunkAddress ( SecUnixUnixThunkAddress (
VOID VOID
) )
/*++ /*++
@ -122,7 +131,7 @@ Returns:
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
SecWinNtWinNtFwhAddress ( SecUnixUnixFwhAddress (
IN OUT UINT64 *FwhSize, IN OUT UINT64 *FwhSize,
IN OUT EFI_PHYSICAL_ADDRESS *FwhBase IN OUT EFI_PHYSICAL_ADDRESS *FwhBase
) )
@ -147,12 +156,12 @@ Returns:
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
SecPeiReportStatusCode ( SecPeiReportStatusCode (
IN EFI_PEI_SERVICES **PeiServices, IN CONST EFI_PEI_SERVICES **PeiServices,
IN EFI_STATUS_CODE_TYPE CodeType, IN EFI_STATUS_CODE_TYPE CodeType,
IN EFI_STATUS_CODE_VALUE Value, IN EFI_STATUS_CODE_VALUE Value,
IN UINT32 Instance, IN UINT32 Instance,
IN EFI_GUID * CallerId, IN CONST EFI_GUID *CallerId,
IN EFI_STATUS_CODE_DATA * Data OPTIONAL IN CONST EFI_STATUS_CODE_DATA *Data OPTIONAL
) )
/*++ /*++
@ -176,12 +185,11 @@ Returns:
--*/ --*/
; ;
INTN int
EFIAPI
main ( main (
IN INTN Argc, IN int Argc,
IN CHAR8 **Argv, IN char **Argv,
IN CHAR8 **Envp IN char **Envp
) )
/*++ /*++
@ -331,7 +339,7 @@ Returns:
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
SecWinNtPeCoffLoaderLoadAsDll ( SecUnixPeCoffLoaderLoadAsDll (
IN CHAR8 *PdbFileName, IN CHAR8 *PdbFileName,
IN VOID **ImageEntryPoint, IN VOID **ImageEntryPoint,
OUT VOID **ModHandle OUT VOID **ModHandle
@ -357,7 +365,7 @@ Returns:
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
SecWinNtPeCoffLoaderFreeLibrary ( SecUnixPeCoffLoaderFreeLibrary (
OUT VOID *ModHandle OUT VOID *ModHandle
) )
/*++ /*++
@ -379,7 +387,7 @@ Returns:
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
SecWinNtFdAddress ( SecUnixFdAddress (
IN UINTN Index, IN UINTN Index,
IN OUT EFI_PHYSICAL_ADDRESS *FdBase, IN OUT EFI_PHYSICAL_ADDRESS *FdBase,
IN OUT UINT64 *FdSize IN OUT UINT64 *FdSize
@ -509,4 +517,25 @@ SecTemporaryRamSupport (
IN UINTN CopySize IN UINTN CopySize
); );
RETURN_STATUS
EFIAPI
SecPeCoffGetEntryPoint (
IN VOID *Pe32Data,
IN OUT VOID **EntryPoint
);
VOID
EFIAPI
SecPeCoffRelocateImageExtraAction (
IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
);
VOID
EFIAPI
SecPeCoffLoaderUnloadImageExtraAction (
IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
);
extern EFI_UNIX_THUNK_PROTOCOL *gUnix; extern EFI_UNIX_THUNK_PROTOCOL *gUnix;

View File

@ -2,7 +2,8 @@
# Entry Point of Unix Emulator # Entry Point of Unix Emulator
# #
# Main executable file of Unix Emulator that loads PEI core after initialization finished. # Main executable file of Unix Emulator that loads PEI core after initialization finished.
# Copyright (c) 2008, Intel Corporation # Copyright (c) 2008 - 2009, Intel Corporation
# Portions copyright (c) 2008-2009 Apple Inc.
# #
# All rights reserved. This program and the accompanying materials # All rights reserved. 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
@ -35,7 +36,10 @@
UnixThunk.c UnixThunk.c
FwVol.c FwVol.c
SecMain.c SecMain.c
Stack.S
[Sources.Ia32]
Ia32/Gasket.S
Ia32/Stack.S
[Packages] [Packages]
MdePkg/MdePkg.dec MdePkg/MdePkg.dec
@ -74,3 +78,10 @@
GCC:*_*_IA32_CC_FLAGS == -m32 -g -fshort-wchar -fno-strict-aliasing -Wall -malign-double -idirafter/usr/include -c -include $(DEST_DIR_DEBUG)/AutoGen.h -DSTRING_ARRAY_NAME=$(BASE_NAME)Strings GCC:*_*_IA32_CC_FLAGS == -m32 -g -fshort-wchar -fno-strict-aliasing -Wall -malign-double -idirafter/usr/include -c -include $(DEST_DIR_DEBUG)/AutoGen.h -DSTRING_ARRAY_NAME=$(BASE_NAME)Strings
GCC:*_*_IA32_PP_FLAGS == -m32 -E -x assembler-with-cpp -include $(DEST_DIR_DEBUG)/AutoGen.h GCC:*_*_IA32_PP_FLAGS == -m32 -E -x assembler-with-cpp -include $(DEST_DIR_DEBUG)/AutoGen.h
GCC:*_*_IA32_ASM_FLAGS == -c -x assembler -imacros $(DEST_DIR_DEBUG)/AutoGen.h GCC:*_*_IA32_ASM_FLAGS == -c -x assembler -imacros $(DEST_DIR_DEBUG)/AutoGen.h
#
# Need to do this link via gcc and not ld as the pathing to libraries changes from OS version to OS version
#
XCODE:*_*_IA32_DLINK_PATH == gcc
XCODE:*_*_IA32_DLINK_FLAGS == -arch i386 -L/usr/X11R6/lib -lXext -lX11 -lIOKit -framework Carbon
XCODE:*_*_IA32_ASM_FLAGS == -arch i386 -g

View File

@ -1,6 +1,19 @@
/*++
Copyright (c) 2004 - 2009, Intel Corporation
Portions copyright (c) 2008-2009 Apple Inc. All rights reserved.
All rights reserved. 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
http://opensource.org/licenses/bsd-license.php
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 <sys/ipc.h> #include <sys/ipc.h>
#include <sys/shm.h> #include <sys/shm.h>
#include <sys/dir.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@ -123,8 +136,15 @@ TryCreateShmImage(UGA_IO_PRIVATE *drv)
XDestroyImage(drv->image); XDestroyImage(drv->image);
return 0; return 0;
} }
#ifndef __APPLE__
//
// This closes shared memory in real time on OS X. Only closes after folks quit using
// it on Linux.
//
/* Can this fail ? */ /* Can this fail ? */
shmctl (drv->xshm_info.shmid, IPC_RMID, NULL); shmctl (drv->xshm_info.shmid, IPC_RMID, NULL);
#endif
drv->xshm_info.shmaddr = (char*)drv->image_data; drv->xshm_info.shmaddr = (char*)drv->image_data;
drv->image->data = (char*)drv->image_data; drv->image->data = (char*)drv->image_data;
@ -157,6 +177,12 @@ UgaClose (EFI_UNIX_UGA_IO_PROTOCOL *UgaIo)
} }
XDestroyWindow(drv->display, drv->win); XDestroyWindow(drv->display, drv->win);
XCloseDisplay(drv->display); XCloseDisplay(drv->display);
#ifdef __APPLE__
// Free up the shared memory
shmctl (drv->xshm_info.shmid, IPC_RMID, NULL);
#endif
free(drv); free(drv);
return EFI_SUCCESS; return EFI_SUCCESS;
} }
@ -534,16 +560,45 @@ UgaCreate (EFI_UNIX_UGA_IO_PROTOCOL **Uga, CONST CHAR16 *Title)
char *display_name = NULL; char *display_name = NULL;
int title_len; int title_len;
drv = (UGA_IO_PRIVATE *) drv = (UGA_IO_PRIVATE *)calloc (1, sizeof (UGA_IO_PRIVATE));
calloc (1, sizeof (UGA_IO_PRIVATE));
if (drv == NULL) if (drv == NULL)
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
#ifdef __APPLE__
//
//
//
EFI_STATUS EFIAPI GasketUgaClose (EFI_UNIX_UGA_IO_PROTOCOL *UgaIo);
EFI_STATUS EFIAPI GasketUgaSize (EFI_UNIX_UGA_IO_PROTOCOL *UgaIo, UINT32 Width, UINT32 Height);
EFI_STATUS EFIAPI GasketUgaCheckKey (EFI_UNIX_UGA_IO_PROTOCOL *UgaIo);
EFI_STATUS EFIAPI GasketUgaGetKey (EFI_UNIX_UGA_IO_PROTOCOL *UgaIo, EFI_INPUT_KEY *key);
EFI_STATUS EFIAPI GasketUgaBlt (
EFI_UNIX_UGA_IO_PROTOCOL *UgaIo,
IN EFI_UGA_PIXEL *BltBuffer OPTIONAL,
IN EFI_UGA_BLT_OPERATION BltOperation,
IN UINTN SourceX,
IN UINTN SourceY,
IN UINTN DestinationX,
IN UINTN DestinationY,
IN UINTN Width,
IN UINTN Height,
IN UINTN Delta OPTIONAL
);
drv->UgaIo.UgaClose = GasketUgaClose;
drv->UgaIo.UgaSize = GasketUgaSize;
drv->UgaIo.UgaCheckKey = GasketUgaCheckKey;
drv->UgaIo.UgaGetKey = GasketUgaGetKey;
drv->UgaIo.UgaBlt = GasketUgaBlt;
#else
drv->UgaIo.UgaClose = UgaClose; drv->UgaIo.UgaClose = UgaClose;
drv->UgaIo.UgaSize = UgaSize; drv->UgaIo.UgaSize = UgaSize;
drv->UgaIo.UgaCheckKey = UgaCheckKey; drv->UgaIo.UgaCheckKey = UgaCheckKey;
drv->UgaIo.UgaGetKey = UgaGetKey; drv->UgaIo.UgaGetKey = UgaGetKey;
drv->UgaIo.UgaBlt = UgaBlt; drv->UgaIo.UgaBlt = UgaBlt;
#endif
drv->key_count = 0; drv->key_count = 0;
drv->key_rd = 0; drv->key_rd = 0;

View File

@ -1,6 +1,7 @@
/*++ /*++
Copyright (c) 2004 - 2006, Intel Corporation Copyright (c) 2004 - 2009, Intel Corporation
Portions copyright (c) 2008-2009 Apple Inc. All rights reserved.
All rights reserved. This program and the accompanying materials All rights reserved. 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
@ -149,11 +150,136 @@ GetErrno(void)
return errno; return errno;
} }
#if __APPLE__
void GasketmsSleep (unsigned long Milliseconds);
void Gasketexit (int status);
void GasketSetTimer (UINT64 PeriodMs, VOID (*CallBack)(UINT64 DeltaMs));
void GasketGetLocalTime (EFI_TIME *Time);
struct tm *Gasketgmtime (const time_t *clock);
long GasketGetTimeZone (void);
int GasketGetDayLight (void);
int Gasketpoll (struct pollfd *pfd, int nfds, int timeout);
int Gasketread (int fd, void *buf, int count);
int Gasketwrite (int fd, const void *buf, int count);
char *Gasketgetenv (const char *name);
int Gasketopen (const char *name, int flags, int mode);
off_t Gasketlseek (int fd, off_t off, int whence);
int Gasketftruncate (int fd, long int len);
int Gasketclose (int fd);
int Gasketmkdir (const char *pathname, mode_t mode);
int Gasketrmdir (const char *pathname);
int Gasketunlink (const char *pathname);
int GasketGetErrno (void);
DIR *Gasketopendir (const char *pathname);
void *Gasketrewinddir (DIR *dir);
struct dirent *Gasketreaddir (DIR *dir);
int Gasketclosedir (DIR *dir);
int Gasketstat (const char *path, struct stat *buf);
int Gasketstatfs (const char *path, struct statfs *buf);
int Gasketrename (const char *oldpath, const char *newpath);
time_t Gasketmktime (struct tm *tm);
int Gasketfsync (int fd);
int Gasketchmod (const char *path, mode_t mode);
int Gasketutime (const char *filename, const struct utimbuf *buf);
int Gaskettcflush (int fildes, int queue_selector);
EFI_STATUS GasketUgaCreate(struct _EFI_UNIX_UGA_IO_PROTOCOL **UgaIo, CONST CHAR16 *Title);
void Gasketperror (__const char *__s);
//
// ... is always an int or pointer to device specific data structure
//
int Gasketioctl (int fd, unsigned long int __request, ...);
int Gasketfcntl (int __fd, int __cmd, ...);
int Gasketcfsetispeed (struct termios *__termios_p, speed_t __speed);
int Gasketcfsetospeed (struct termios *__termios_p, speed_t __speed);
int Gaskettcgetattr (int __fd, struct termios *__termios_p);
int Gaskettcsetattr (int __fd, int __optional_actions, __const struct termios *__termios_p);
int Gasketsigaction (int sig, const struct sigaction *act, struct sigaction *oact);
int Gasketsetcontext (const ucontext_t *ucp);
int Gasketgetcontext (ucontext_t *ucp);
int Gasketsigemptyset (sigset_t *set);
int Gasketsigaltstack (const stack_t *ss, stack_t *oss);
RETURN_STATUS
GasketUnixPeCoffGetEntryPoint (
IN VOID *Pe32Data,
IN OUT VOID **EntryPoint
);
VOID
GasketUnixPeCoffRelocateImageExtraAction (
IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
);
VOID
GasketPeCoffLoaderUnloadImageExtraAction (
IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
);
#endif
extern EFI_STATUS extern EFI_STATUS
UgaCreate(struct _EFI_UNIX_UGA_IO_PROTOCOL **UgaIo, CONST CHAR16 *Title); 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__
//
// 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.
// 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
//
GasketmsSleep, /* Sleep */
Gasketexit, /* Exit */
GasketSetTimer,
GasketGetLocalTime,
Gasketgmtime,
GasketGetTimeZone,
GasketGetDayLight,
(UnixPoll)Gasketpoll,
(UnixRead)Gasketread,
(UnixWrite)Gasketwrite,
Gasketgetenv,
(UnixOpen)Gasketopen,
(UnixSeek)Gasketlseek,
(UnixFtruncate)Gasketftruncate,
Gasketclose,
Gasketmkdir,
Gasketrmdir,
Gasketunlink,
GasketGetErrno,
Gasketopendir,
(UnixRewindDir)Gasketrewinddir,
Gasketreaddir,
Gasketclosedir,
Gasketstat,
Gasketstatfs,
Gasketrename,
Gasketmktime,
Gasketfsync,
Gasketchmod,
Gasketutime,
Gaskettcflush,
GasketUgaCreate,
Gasketperror,
Gasketioctl,
Gasketfcntl,
Gasketcfsetispeed,
Gasketcfsetospeed,
Gaskettcgetattr,
Gaskettcsetattr,
dlopen, // Update me with a gasket
dlerror, // Update me with a gasket
dlsym, // Update me with a gasket
SecPeCoffGetEntryPoint, // Update me with a gasket
SecPeCoffRelocateImageExtraAction, // Update me with a gasket
SecPeCoffLoaderUnloadImageExtraAction // Update me with a gasket
#else
msSleep, /* Sleep */ msSleep, /* Sleep */
exit, /* Exit */ exit, /* Exit */
SetTimer, SetTimer,
@ -166,8 +292,8 @@ EFI_UNIX_THUNK_PROTOCOL mUnixThunkTable = {
(UnixWrite)write, (UnixWrite)write,
getenv, getenv,
(UnixOpen)open, (UnixOpen)open,
lseek, (UnixSeek)lseek,
ftruncate, (UnixFtruncate)ftruncate,
close, close,
mkdir, mkdir,
rmdir, rmdir,
@ -195,7 +321,11 @@ EFI_UNIX_THUNK_PROTOCOL mUnixThunkTable = {
tcsetattr, tcsetattr,
dlopen, dlopen,
dlerror, dlerror,
dlsym dlsym,
SecPeCoffGetEntryPoint,
SecPeCoffRelocateImageExtraAction,
SecPeCoffLoaderUnloadImageExtraAction
#endif
}; };

View File

@ -62,7 +62,7 @@ UINT64 mTimerPeriodMs;
VOID VOID
TimerCallback (UINT64 DeltaMs) TimerCallback (UINT64 DeltaMs)
/*++ /*++
Routine Description: Routine Description:
@ -84,12 +84,12 @@ Returns:
--*/ --*/
{ {
EFI_TPL OriginalTPL; EFI_TPL OriginalTPL;
EFI_TIMER_NOTIFY CallbackFunction; EFI_TIMER_NOTIFY CallbackFunction;
OriginalTPL = gBS->RaiseTPL (TPL_HIGH_LEVEL); OriginalTPL = gBS->RaiseTPL (TPL_HIGH_LEVEL);
if (OriginalTPL < TPL_HIGH_LEVEL) { if (OriginalTPL < TPL_HIGH_LEVEL) {
CallbackFunction = mTimerNotifyFunction; CallbackFunction = mTimerNotifyFunction;
// //
@ -99,7 +99,7 @@ Returns:
if (CallbackFunction != NULL) { if (CallbackFunction != NULL) {
CallbackFunction ((UINT64) (DeltaMs * 10000)); CallbackFunction ((UINT64) (DeltaMs * 10000));
} }
} }
gBS->RestoreTPL (OriginalTPL); gBS->RestoreTPL (OriginalTPL);
@ -164,13 +164,13 @@ Returns:
return EFI_ALREADY_STARTED; return EFI_ALREADY_STARTED;
} }
if (NotifyFunction == NULL) { if (NotifyFunction == NULL) {
/* Disable timer. */ /* Disable timer. */
gUnix->SetTimer (0, TimerCallback); gUnix->SetTimer (0, TimerCallback);
} else if (mTimerNotifyFunction == NULL) { } else if (mTimerNotifyFunction == NULL) {
/* Enable Timer. */ /* Enable Timer. */
gUnix->SetTimer (mTimerPeriodMs, TimerCallback); gUnix->SetTimer (mTimerPeriodMs, TimerCallback);
} }
mTimerNotifyFunction = NotifyFunction; mTimerNotifyFunction = NotifyFunction;
return EFI_SUCCESS; return EFI_SUCCESS;
@ -224,13 +224,13 @@ Returns:
// If TimerPeriod is 0, then the timer thread should be canceled // If TimerPeriod is 0, then the timer thread should be canceled
// If the TimerPeriod is valid, then create and/or adjust the period of the timer thread // If the TimerPeriod is valid, then create and/or adjust the period of the timer thread
// //
if (TimerPeriod == 0 if (TimerPeriod == 0
|| ((TimerPeriod > TIMER_MINIMUM_VALUE) || ((TimerPeriod > TIMER_MINIMUM_VALUE)
&& (TimerPeriod < TIMER_MAXIMUM_VALUE))) { && (TimerPeriod < TIMER_MAXIMUM_VALUE))) {
mTimerPeriodMs = DivU64x32 (TimerPeriod + 5000, 10000); mTimerPeriodMs = DivU64x32 (TimerPeriod + 5000, 10000);
gUnix->SetTimer (mTimerPeriodMs, TimerCallback); gUnix->SetTimer (mTimerPeriodMs, TimerCallback);
} }
return EFI_SUCCESS; return EFI_SUCCESS;
} }
@ -369,6 +369,6 @@ Returns:
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
return Status; return Status;
} }
return EFI_SUCCESS; return EFI_SUCCESS;
} }

View File

@ -148,7 +148,7 @@ UnixBlockIoDriverDiagnosticsRunDiagnostics (
if (DiagnosticType != EfiDriverDiagnosticTypeStandard) { if (DiagnosticType != EfiDriverDiagnosticTypeStandard) {
*ErrorType = &gEfiBlockIoProtocolGuid; *ErrorType = &gEfiBlockIoProtocolGuid;
*BufferSize = 0x60; *BufferSize = 0x60;
gBS->AllocatePool (EfiBootServicesData, (UINTN) (*BufferSize), gBS->AllocatePool (EfiBootServicesData, (UINTN) (*BufferSize),
(void *)Buffer); (void *)Buffer);
CopyMem (*Buffer, L"Unix Block I/O Driver Diagnostics Failed\n", *BufferSize); CopyMem (*Buffer, L"Unix Block I/O Driver Diagnostics Failed\n", *BufferSize);
return EFI_DEVICE_ERROR; return EFI_DEVICE_ERROR;

View File

@ -1,6 +1,6 @@
/*++ /*++
Copyright (c) 2004 - 2007, Intel Corporation Copyright (c) 2004 - 2009, Intel Corporation
All rights reserved. This program and the accompanying materials All rights reserved. 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
@ -1276,6 +1276,7 @@ This function extends the capability of SetFilePointer to accept 64 bit paramete
EFI_STATUS Status; EFI_STATUS Status;
off_t res; off_t res;
Status = EFI_SUCCESS;
res = Private->UnixThunk->Lseek(Private->fd, DistanceToMove, MoveMethod); res = Private->UnixThunk->Lseek(Private->fd, DistanceToMove, MoveMethod);
if (res == -1) { if (res == -1) {
Status = EFI_INVALID_PARAMETER; Status = EFI_INVALID_PARAMETER;

View File

@ -56,7 +56,7 @@ typedef struct {
UINTN ReadMode; UINTN ReadMode;
UINTN Mode; UINTN Mode;
int fd; int fd;
UINT64 LastBlock; UINT64 LastBlock;
UINTN BlockSize; UINTN BlockSize;

View File

@ -94,7 +94,7 @@ typedef struct {
UINTN RowsY; UINTN RowsY;
} UNIX_SIMPLE_TEXT_OUT_MODE; } UNIX_SIMPLE_TEXT_OUT_MODE;
#if 0 #if 0
// //
// Simple Text Out protocol member functions // Simple Text Out protocol member functions
// //
@ -319,7 +319,7 @@ Returns:
--*/ --*/
; ;
#endif #endif
// //
// Simple Text Out constructor and destructor. // Simple Text Out constructor and destructor.
// //
@ -365,7 +365,7 @@ Returns:
--*/ --*/
; ;
#if 0 #if 0
// //
// Simple Text In protocol member functions. // Simple Text In protocol member functions.
// //
@ -441,7 +441,7 @@ Returns:
--*/ --*/
; ;
#endif #endif
// //
// Simple Text In constructor // Simple Text In constructor
// //

View File

@ -27,7 +27,7 @@ Abstract:
--*/ --*/
#include "Console.h" #include "Console.h"
#include <sys/poll.h> #include <sys/poll.h>
// //
// Private worker functions // Private worker functions
@ -68,7 +68,7 @@ Returns:
EFI_STATUS EFI_STATUS
UnixConvertInputRecordToEfiKey ( UnixConvertInputRecordToEfiKey (
IN char c, IN char c,
OUT EFI_INPUT_KEY *Key OUT EFI_INPUT_KEY *Key
) )
/*++ /*++
@ -92,8 +92,8 @@ Returns:
--*/ --*/
{ {
Key->ScanCode = 0; Key->ScanCode = 0;
if (c == '\n') if (c == '\n')
c = '\r'; c = '\r';
Key->UnicodeChar = c; Key->UnicodeChar = c;
return EFI_SUCCESS; return EFI_SUCCESS;
} }
@ -124,7 +124,7 @@ Returns:
{ {
EFI_STATUS Status; EFI_STATUS Status;
UNIX_SIMPLE_TEXT_PRIVATE_DATA *Private; UNIX_SIMPLE_TEXT_PRIVATE_DATA *Private;
char c; char c;
Private = UNIX_SIMPLE_TEXT_IN_PRIVATE_DATA_FROM_THIS (This); Private = UNIX_SIMPLE_TEXT_IN_PRIVATE_DATA_FROM_THIS (This);
@ -133,7 +133,7 @@ Returns:
return Status; return Status;
} }
if (Private->UnixThunk->Read (0, &c, 1) != 1) if (Private->UnixThunk->Read (0, &c, 1) != 1)
return EFI_NOT_READY; return EFI_NOT_READY;
Status = UnixConvertInputRecordToEfiKey (c, Key); Status = UnixConvertInputRecordToEfiKey (c, Key);
@ -193,11 +193,11 @@ Returns:
--*/ --*/
{ {
struct pollfd pfd; struct pollfd pfd;
pfd.fd = 0; pfd.fd = 0;
pfd.events = POLLIN; pfd.events = POLLIN;
if (Private->UnixThunk->Poll (&pfd, 1, 0) <= 0) { if (Private->UnixThunk->Poll (&pfd, 1, 0) <= 0) {
return EFI_NOT_READY; return EFI_NOT_READY;
} }
return EFI_SUCCESS; return EFI_SUCCESS;

View File

@ -26,13 +26,13 @@ Abstract:
// Private worker functions. // Private worker functions.
// //
#if 0 #if 0
VOID VOID
UnixSimpleTextOutScrollScreen ( UnixSimpleTextOutScrollScreen (
IN OUT UNIX_SIMPLE_TEXT_PRIVATE_DATA *Console IN OUT UNIX_SIMPLE_TEXT_PRIVATE_DATA *Console
); );
#endif #endif
VOID VOID
UnixSimpleTextOutPutChar ( UnixSimpleTextOutPutChar (
IN OUT UNIX_SIMPLE_TEXT_PRIVATE_DATA *Console, IN OUT UNIX_SIMPLE_TEXT_PRIVATE_DATA *Console,
@ -51,7 +51,7 @@ UnixSimpleTextOutSetMode (
IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This, IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
IN UINTN ModeNumber IN UINTN ModeNumber
); );
// //
// Modeule Global for Simple Text Out Mode. // Modeule Global for Simple Text Out Mode.
// //
@ -60,12 +60,12 @@ UnixSimpleTextOutSetMode (
UNIX_SIMPLE_TEXT_OUT_MODE mUnixSimpleTextOutSupportedModes[] = { UNIX_SIMPLE_TEXT_OUT_MODE mUnixSimpleTextOutSupportedModes[] = {
{ 80, 25 }, { 80, 25 },
#if 0 #if 0
{ 80, 50 }, { 80, 50 },
{ 80, 43 }, { 80, 43 },
{ 100, 100 }, { 100, 100 },
{ 100, 999 } { 100, 999 }
#endif #endif
}; };
EFI_STATUS EFI_STATUS
@ -131,7 +131,7 @@ Returns:
for (Str = String; *Str != '\0'; Str++) { for (Str = String; *Str != '\0'; Str++) {
switch (*Str) { switch (*Str) {
#if 0 #if 0
case '\n': case '\n':
if (Private->Position.Y == (Private->MaxScreenSize.Y - 1)) { if (Private->Position.Y == (Private->MaxScreenSize.Y - 1)) {
UnixSimpleTextOutScrollScreen (Private); UnixSimpleTextOutScrollScreen (Private);
@ -155,7 +155,7 @@ Returns:
} }
break; break;
#endif #endif
default: default:
UnixSimpleTextOutPutChar (Private, *Str); UnixSimpleTextOutPutChar (Private, *Str);
} }
@ -186,11 +186,11 @@ Returns:
--*/ --*/
{ {
char c = Char; char c = Char;
Console->UnixThunk->Write (1, &c, 1); Console->UnixThunk->Write (1, &c, 1);
} }
#if 0 #if 0
VOID VOID
UnixSimpleTextOutScrollScreen ( UnixSimpleTextOutScrollScreen (
IN OUT UNIX_SIMPLE_TEXT_PRIVATE_DATA *Console IN OUT UNIX_SIMPLE_TEXT_PRIVATE_DATA *Console
@ -212,8 +212,8 @@ Returns:
--*/ --*/
{ {
} }
#endif #endif
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
@ -358,9 +358,9 @@ Returns:
Private = UNIX_SIMPLE_TEXT_OUT_PRIVATE_DATA_FROM_THIS (This); Private = UNIX_SIMPLE_TEXT_OUT_PRIVATE_DATA_FROM_THIS (This);
#if 0 #if 0
Private->Attribute = (WORD) Attribute; Private->Attribute = (WORD) Attribute;
#endif #endif
This->Mode->Attribute = (INT32) Attribute; This->Mode->Attribute = (INT32) Attribute;
return EFI_SUCCESS; return EFI_SUCCESS;
@ -393,10 +393,10 @@ Returns:
Private = UNIX_SIMPLE_TEXT_OUT_PRIVATE_DATA_FROM_THIS (This); Private = UNIX_SIMPLE_TEXT_OUT_PRIVATE_DATA_FROM_THIS (This);
This->SetCursorPosition (This, 0, 0); This->SetCursorPosition (This, 0, 0);
Private->UnixThunk->Write (1, "\e[2J", 4); Private->UnixThunk->Write (1, "\e[2J", 4);
#if 0
#if 0
Private->UnixThunk->FillConsoleOutputCharacter ( Private->UnixThunk->FillConsoleOutputCharacter (
Private->NtOutHandle, Private->NtOutHandle,
' ', ' ',
@ -411,7 +411,7 @@ Returns:
Private->Possition, Private->Possition,
&ConsoleWindow &ConsoleWindow
); );
#endif #endif
return EFI_SUCCESS; return EFI_SUCCESS;
} }
@ -441,36 +441,36 @@ Returns:
--*/ --*/
{ {
char buf[12]; char buf[12];
UNIX_SIMPLE_TEXT_PRIVATE_DATA *Private; UNIX_SIMPLE_TEXT_PRIVATE_DATA *Private;
Private = UNIX_SIMPLE_TEXT_OUT_PRIVATE_DATA_FROM_THIS (This); Private = UNIX_SIMPLE_TEXT_OUT_PRIVATE_DATA_FROM_THIS (This);
#if 0 #if 0
Private->Position.X = (WORD) Column; Private->Position.X = (WORD) Column;
#endif #endif
This->Mode->CursorColumn = (INT32) Column; This->Mode->CursorColumn = (INT32) Column;
#if 0 #if 0
Private->Position.Y = (WORD) Row; Private->Position.Y = (WORD) Row;
#endif #endif
This->Mode->CursorRow = (INT32) Row; This->Mode->CursorRow = (INT32) Row;
#if 0 #if 0
Private->UnixThunk->SetConsoleCursorPosition (Private->NtOutHandle, Private->Possition); Private->UnixThunk->SetConsoleCursorPosition (Private->NtOutHandle, Private->Possition);
#endif #endif
buf[0] = '\e';
buf[1] = '[';
buf[2] = '0' + ((Row / 100) % 10);
buf[3] = '0' + ((Row / 10) % 10);
buf[4] = '0' + ((Row / 1) % 10);
buf[5] = ';';
buf[6] = '0' + ((Column / 100) % 10);
buf[7] = '0' + ((Column / 10) % 10);
buf[8] = '0' + ((Column / 1) % 10);
buf[9] = 'H';
Private->UnixThunk->Write (1, buf, 10);
buf[0] = '\e';
buf[1] = '[';
buf[2] = '0' + ((Row / 100) % 10);
buf[3] = '0' + ((Row / 10) % 10);
buf[4] = '0' + ((Row / 1) % 10);
buf[5] = ';';
buf[6] = '0' + ((Column / 100) % 10);
buf[7] = '0' + ((Column / 10) % 10);
buf[8] = '0' + ((Column / 1) % 10);
buf[9] = 'H';
Private->UnixThunk->Write (1, buf, 10);
return EFI_SUCCESS; return EFI_SUCCESS;
} }
@ -498,19 +498,19 @@ Returns:
--*/ --*/
{ {
UNIX_SIMPLE_TEXT_PRIVATE_DATA *Private; UNIX_SIMPLE_TEXT_PRIVATE_DATA *Private;
#if 0 #if 0
CONSOLE_CURSOR_INFO Info; CONSOLE_CURSOR_INFO Info;
#endif #endif
Private = UNIX_SIMPLE_TEXT_OUT_PRIVATE_DATA_FROM_THIS (This); Private = UNIX_SIMPLE_TEXT_OUT_PRIVATE_DATA_FROM_THIS (This);
Private->CursorEnable = Enable; Private->CursorEnable = Enable;
This->Mode->CursorVisible = Enable; This->Mode->CursorVisible = Enable;
#if 0 #if 0
Private->UnixThunk->GetConsoleCursorInfo (Private->NtOutHandle, &Info); Private->UnixThunk->GetConsoleCursorInfo (Private->NtOutHandle, &Info);
Info.bVisible = Enable; Info.bVisible = Enable;
Private->UnixThunk->SetConsoleCursorInfo (Private->NtOutHandle, &Info); Private->UnixThunk->SetConsoleCursorInfo (Private->NtOutHandle, &Info);
#endif #endif
return EFI_SUCCESS; return EFI_SUCCESS;
} }
@ -539,13 +539,13 @@ Returns:
CHAR16 *WindowName; CHAR16 *WindowName;
//WindowName = Private->UnixIo->EnvString; //WindowName = Private->UnixIo->EnvString;
#if 0 #if 0
Private->Attribute = FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_INTENSITY; Private->Attribute = FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_INTENSITY;
if (*WindowName == '?') { if (*WindowName == '?') {
Private->Attribute = BACKGROUND_RED | FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_GREEN; Private->Attribute = BACKGROUND_RED | FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_GREEN;
WindowName = L"EFI Emulator Error Console"; WindowName = L"EFI Emulator Error Console";
} }
#endif #endif
WindowName = L"EFI Emulator Error Console"; WindowName = L"EFI Emulator Error Console";
AddUnicodeString ( AddUnicodeString (
@ -576,7 +576,7 @@ Returns:
SimpleTextOut->Mode->MaxMode = MAX_SIMPLE_TEXT_OUT_MODE; SimpleTextOut->Mode->MaxMode = MAX_SIMPLE_TEXT_OUT_MODE;
SimpleTextOut->Mode->Attribute = 0; //FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_INTENSITY; SimpleTextOut->Mode->Attribute = 0; //FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_INTENSITY;
#if 0 #if 0
// //
// Open the window an initialize it! // Open the window an initialize it!
// //
@ -588,7 +588,7 @@ Returns:
NULL NULL
); );
Private->UnixThunk->SetConsoleTitle (WindowName); Private->UnixThunk->SetConsoleTitle (WindowName);
#endif #endif
return SimpleTextOut->SetMode (SimpleTextOut, 0); return SimpleTextOut->SetMode (SimpleTextOut, 0);
} }
@ -613,8 +613,8 @@ Returns:
--*/ --*/
{ {
#if 0 #if 0
Console->UnixThunk->CloseHandle (Console->NtOutHandle); Console->UnixThunk->CloseHandle (Console->NtOutHandle);
#endif #endif
return EFI_SUCCESS; return EFI_SUCCESS;
} }

View File

@ -62,6 +62,6 @@
gEfiSimpleTextInProtocolGuid # PROTOCOL BY_START gEfiSimpleTextInProtocolGuid # PROTOCOL BY_START
gEfiSimpleTextOutProtocolGuid # PROTOCOL BY_START gEfiSimpleTextOutProtocolGuid # PROTOCOL BY_START
gEfiUnixIoProtocolGuid # PROTOCOL TO_START gEfiUnixIoProtocolGuid # PROTOCOL TO_START
[Guids] [Guids]
gEfiUnixConsoleGuid gEfiUnixConsoleGuid

View File

@ -1,6 +1,6 @@
/*++ /*++
Copyright (c) 2006 - 2007, Intel Corporation Copyright (c) 2006 - 2009, Intel Corporation
All rights reserved. This program and the accompanying materials All rights reserved. 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
@ -46,7 +46,6 @@ Abstract:
--*/ --*/
#include "UnixSerialIo.h" #include "UnixSerialIo.h"
#include <termio.h>
EFI_DRIVER_BINDING_PROTOCOL gUnixSerialIoDriverBinding = { EFI_DRIVER_BINDING_PROTOCOL gUnixSerialIoDriverBinding = {
UnixSerialIoDriverBindingSupported, UnixSerialIoDriverBindingSupported,
@ -454,7 +453,7 @@ Returns:
UnixHandle = UnixIo->UnixThunk->Open (AsciiDevName, O_RDWR | O_NOCTTY, 0); UnixHandle = UnixIo->UnixThunk->Open (AsciiDevName, O_RDWR | O_NOCTTY, 0);
if (UnixHandle == -1) { if (UnixHandle == -1) {
DEBUG ((EFI_D_INFO, "Faile to open serial device, %s!\r\n", UnixIo->EnvString )); DEBUG ((EFI_D_INFO, "Failed to open serial device, %s!\r\n", UnixIo->EnvString ));
UnixIo->UnixThunk->Perror (AsciiDevName); UnixIo->UnixThunk->Perror (AsciiDevName);
Status = EFI_DEVICE_ERROR; Status = EFI_DEVICE_ERROR;
goto Error; goto Error;
@ -1125,6 +1124,7 @@ Returns:
return EFI_DEVICE_ERROR; return EFI_DEVICE_ERROR;
} }
Bits = 0;
if ((Status & TIOCM_CTS) == TIOCM_CTS) { if ((Status & TIOCM_CTS) == TIOCM_CTS) {
Bits |= EFI_SERIAL_CLEAR_TO_SEND; Bits |= EFI_SERIAL_CLEAR_TO_SEND;
} }
@ -1206,6 +1206,7 @@ Returns:
--*/ --*/
{ {
UNIX_SERIAL_IO_PRIVATE_DATA *Private; UNIX_SERIAL_IO_PRIVATE_DATA *Private;
EFI_STATUS Status;
UINT8 *ByteBuffer; UINT8 *ByteBuffer;
UINT32 TotalBytesWritten; UINT32 TotalBytesWritten;
UINT32 BytesToGo; UINT32 BytesToGo;
@ -1219,6 +1220,7 @@ Returns:
Private = UNIX_SERIAL_IO_PRIVATE_DATA_FROM_THIS (This); Private = UNIX_SERIAL_IO_PRIVATE_DATA_FROM_THIS (This);
ByteBuffer = (UINT8 *) Buffer; ByteBuffer = (UINT8 *) Buffer;
Status = EFI_SUCCESS;
TotalBytesWritten = 0; TotalBytesWritten = 0;
if (Private->SoftwareLoopbackEnable || Private->HardwareLoopbackEnable) { if (Private->SoftwareLoopbackEnable || Private->HardwareLoopbackEnable) {
@ -1250,6 +1252,10 @@ Returns:
&ByteBuffer[TotalBytesWritten], &ByteBuffer[TotalBytesWritten],
BytesToGo BytesToGo
); );
if (BytesWritten == -1) {
Status = EFI_DEVICE_ERROR;
break;
}
if (Private->HardwareFlowControl) { if (Private->HardwareFlowControl) {
// //
@ -1269,7 +1275,7 @@ Returns:
gBS->RestoreTPL (Tpl); gBS->RestoreTPL (Tpl);
return EFI_SUCCESS; return Status;
} }
EFI_STATUS EFI_STATUS

View File

@ -1,6 +1,7 @@
/*++ /*++
Copyright (c) 2006 - 2008, Intel Corporation Copyright (c) 2006 - 2009, Intel Corporation
Portions copyright (c) 2008-2009 Apple Inc.
All rights reserved. This program and the accompanying materials All rights reserved. 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
@ -23,8 +24,13 @@ Abstract:
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <stdio.h> #include <stdio.h>
#ifdef __APPLE__
#else
#include <stdlib.h> #include <stdlib.h>
#include <termio.h> #include <termio.h>
#endif
#include <fcntl.h> #include <fcntl.h>
#include <errno.h> #include <errno.h>

View File

@ -1,6 +1,6 @@
/*++ /*++
Copyright (c) 2006 - 2007, Intel Corporation Copyright (c) 2006 - 2009, Intel Corporation
All rights reserved. This program and the accompanying materials All rights reserved. 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
@ -566,6 +566,8 @@ Done:
gBS->FreePool (PrivateFile); gBS->FreePool (PrivateFile);
} }
*Root = NULL;
} }
gBS->RestoreTPL (OldTpl); gBS->RestoreTPL (OldTpl);
@ -1262,7 +1264,12 @@ Returns:
CHAR8 *FullFileName; CHAR8 *FullFileName;
EFI_TPL OldTpl; EFI_TPL OldTpl;
if (This == NULL || BufferSize == NULL || Buffer == NULL) { if (This == NULL || BufferSize == NULL) {
return EFI_INVALID_PARAMETER;
}
if ((*BufferSize != 0) && (Buffer == NULL)) {
// Buffer can be NULL if *BufferSize is zero
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }

View File

@ -68,13 +68,13 @@ typedef struct {
EFI_UNIX_THUNK_PROTOCOL *UnixThunk; EFI_UNIX_THUNK_PROTOCOL *UnixThunk;
EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *SimpleFileSystem; EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *SimpleFileSystem;
EFI_FILE EfiFile; EFI_FILE EfiFile;
INTN fd; INTN fd;
DIR *Dir; DIR *Dir;
BOOLEAN IsRootDirectory; BOOLEAN IsRootDirectory;
BOOLEAN IsDirectoryPath; BOOLEAN IsDirectoryPath;
BOOLEAN IsOpenedByRead; BOOLEAN IsOpenedByRead;
char *FileName; char *FileName;
struct dirent *Dirent; struct dirent *Dirent;
} UNIX_EFI_FILE_PRIVATE; } UNIX_EFI_FILE_PRIVATE;
#define UNIX_EFI_FILE_PRIVATE_DATA_FROM_THIS(a) \ #define UNIX_EFI_FILE_PRIVATE_DATA_FROM_THIS(a) \

View File

@ -35,7 +35,7 @@ Abstract:
#include <Library/UefiDriverEntryPoint.h> #include <Library/UefiDriverEntryPoint.h>
#include <Library/UnixLib.h> #include <Library/UnixLib.h>
#include <Library/MemoryAllocationLib.h> #include <Library/MemoryAllocationLib.h>
#include <Library/UefiBootServicesTableLib.h> #include <Library/UefiBootServicesTableLib.h>
#include <Library/DevicePathLib.h> #include <Library/DevicePathLib.h>
// //

View File

@ -47,8 +47,8 @@
UnixLib UnixLib
UefiDriverEntryPoint UefiDriverEntryPoint
UefiLib UefiLib
DebugLib DebugLib
DevicePathLib DevicePathLib