]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Integrate patch from Andrew Fish to make it run on OS X.
authorqhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 25 Aug 2009 07:29:13 +0000 (07:29 +0000)
committerqhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 25 Aug 2009 07:29:13 +0000 (07:29 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9194 6f19259b-4bc3-4df7-8a09-765794883524

44 files changed:
UnixPkg/CpuRuntimeDxe/Cpu.c
UnixPkg/CpuRuntimeDxe/Cpu.inf
UnixPkg/FvbServicesRuntimeDxe/FWBlockService.c
UnixPkg/FvbServicesRuntimeDxe/FvbInfo.c
UnixPkg/FvbServicesRuntimeDxe/FwBlockService.h
UnixPkg/FvbServicesRuntimeDxe/UnixFwh.inf
UnixPkg/Include/Common/UnixInclude.h
UnixPkg/Include/Ppi/UnixAutoScan.h
UnixPkg/Include/Ppi/UnixFwh.h
UnixPkg/Include/Ppi/UnixPeiLoadFile.h
UnixPkg/Include/Ppi/UnixThunk.h
UnixPkg/Include/Protocol/UnixIo.h
UnixPkg/Include/Protocol/UnixThunk.h
UnixPkg/Include/UnixDxe.h
UnixPkg/Library/DxeUnixPeCoffExtraActionLib/DxeUnixPeCoffExtraActionLib.c
UnixPkg/Library/DxeUnixPeCoffExtraActionLib/DxeUnixPeCoffExtraActionLib.inf
UnixPkg/Library/EdkUnixPeiPeCoffGetEntryPointLib/PeCoffGetEntryPoint.c
UnixPkg/Library/PeiUnixPeCoffExtraActionLib/PeiUnixPeCoffExtraActionLib.c
UnixPkg/Library/PeiUnixPeCoffExtraActionLib/PeiUnixPeCoffExtraActionLib.inf
UnixPkg/Library/UnixBdsLib/PlatformBds.inf
UnixPkg/Library/UnixBdsLib/PlatformData.c
UnixPkg/MiscSubClassPlatformDxe/MiscSubClassDriver.inf
UnixPkg/RealTimeClockRuntimeDxe/RealTimeClock.c
UnixPkg/ResetRuntimeDxe/Reset.c
UnixPkg/Sec/Ia32/Stack.S [new file with mode: 0644]
UnixPkg/Sec/SecMain.c
UnixPkg/Sec/SecMain.h
UnixPkg/Sec/SecMain.inf
UnixPkg/Sec/UgaX11.c
UnixPkg/Sec/UnixThunk.c
UnixPkg/TimerDxe/Timer.c
UnixPkg/UnixBlockIoDxe/DriverDiagnostics.c
UnixPkg/UnixBlockIoDxe/UnixBlockIo.c
UnixPkg/UnixBlockIoDxe/UnixBlockIo.h
UnixPkg/UnixConsoleDxe/Console.h
UnixPkg/UnixConsoleDxe/ConsoleIn.c
UnixPkg/UnixConsoleDxe/ConsoleOut.c
UnixPkg/UnixConsoleDxe/UnixConsole.inf
UnixPkg/UnixSerialIoDxe/UnixSerialIo.c
UnixPkg/UnixSerialIoDxe/UnixSerialIo.h
UnixPkg/UnixSimpleFileSystemDxe/UnixSimpleFileSystem.c
UnixPkg/UnixSimpleFileSystemDxe/UnixSimpleFileSystem.h
UnixPkg/UnixThunkDxe/UnixThunk.c
UnixPkg/UnixThunkDxe/UnixThunk.inf

index dc25d4d8124f10b0f40d0673fbc53af066105c32..a151aafc07534beea34926d1df81df1f81fe578b 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
 /*++\r
 \r
-Copyright (c) 2006, Intel Corporation\r
+Copyright (c) 2006 - 2009, Intel Corporation\r
 All rights reserved. This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
 All rights reserved. This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -58,12 +58,15 @@ CPU_ARCH_PROTOCOL_PRIVATE mCpuTemplate = {
     4\r
   },\r
   {\r
     4\r
   },\r
   {\r
-    CpuMemoryServiceRead,\r
-    CpuMemoryServiceWrite,\r
-    CpuIoServiceRead,\r
-    CpuIoServiceWrite\r
+    {\r
+      CpuMemoryServiceRead,\r
+      CpuMemoryServiceWrite\r
+    },\r
+    {\r
+      CpuIoServiceRead,\r
+      CpuIoServiceWrite\r
+    }\r
   },\r
   },\r
-  0,\r
   TRUE\r
 };\r
 \r
   TRUE\r
 };\r
 \r
@@ -430,7 +433,7 @@ Returns:
   //\r
   // Locate DataHub protocol.\r
   //\r
   //\r
   // Locate DataHub protocol.\r
   //\r
-  Status = gBS->LocateProtocol (&gEfiDataHubProtocolGuid, NULL, &DataHub);\r
+  Status = gBS->LocateProtocol (&gEfiDataHubProtocolGuid, NULL, (VOID **)&DataHub);\r
   if (EFI_ERROR (Status)) {\r
     return;\r
   }\r
   if (EFI_ERROR (Status)) {\r
     return;\r
   }\r
index edab145b61535b51ad8311df8dedebe9cb5704a0..a0f66b671350b5ac5071a7fefb69dfa5abe42c16 100644 (file)
@@ -42,7 +42,7 @@
   IntelFrameworkPkg/IntelFrameworkPkg.dec\r
   IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec\r
   UnixPkg/UnixPkg.dec\r
   IntelFrameworkPkg/IntelFrameworkPkg.dec\r
   IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec\r
   UnixPkg/UnixPkg.dec\r
-  MdePkg/MdePkg.dec
+  MdePkg/MdePkg.dec\r
   MdeModulePkg/MdeModulePkg.dec\r
 \r
 \r
   MdeModulePkg/MdeModulePkg.dec\r
 \r
 \r
@@ -70,4 +70,4 @@
 \r
 \r
 [Depex]\r
 \r
 \r
 [Depex]\r
-  gEfiDataHubProtocolGuid
+  gEfiDataHubProtocolGuid\r
index 132442b6b9981c012b6e47fa09cba1421c257c55..30723c5d729d40ca240e14ea903f8da45d616cfd 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
 /*++\r
 \r
-Copyright (c) 2006 - 2008, Intel Corporation                                                         \r
+Copyright (c) 2006 - 2009, Intel Corporation                                                         \r
 All rights reserved. This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
 All rights reserved. This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
@@ -33,8 +33,8 @@ Revision History
 #include <Library/HobLib.h>\r
 #include <Library/BaseMemoryLib.h>\r
 #include <Library/MemoryAllocationLib.h>\r
 #include <Library/HobLib.h>\r
 #include <Library/BaseMemoryLib.h>\r
 #include <Library/MemoryAllocationLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/DevicePathLib.h>
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/DevicePathLib.h>\r
 \r
 #include "FwBlockService.h"\r
 \r
 \r
 #include "FwBlockService.h"\r
 \r
@@ -210,7 +210,7 @@ Returns:
 \r
 --*/\r
 {\r
 \r
 --*/\r
 {\r
-  EFI_FW_VOL_INSTANCE *FwhInstance;\r
+  EFI_FW_VOL_INSTANCE *FwhInstance = NULL;\r
   EFI_STATUS          Status;\r
 \r
   //\r
   EFI_STATUS          Status;\r
 \r
   //\r
@@ -250,7 +250,7 @@ Returns:
 \r
 --*/\r
 {\r
 \r
 --*/\r
 {\r
-  EFI_FW_VOL_INSTANCE *FwhInstance;\r
+  EFI_FW_VOL_INSTANCE *FwhInstance = NULL;\r
   EFI_STATUS          Status;\r
 \r
   //\r
   EFI_STATUS          Status;\r
 \r
   //\r
@@ -303,7 +303,7 @@ Returns:
   UINTN                   Offset;\r
   EFI_LBA                 StartLba;\r
   EFI_LBA                 NextLba;\r
   UINTN                   Offset;\r
   EFI_LBA                 StartLba;\r
   EFI_LBA                 NextLba;\r
-  EFI_FW_VOL_INSTANCE     *FwhInstance;\r
+  EFI_FW_VOL_INSTANCE     *FwhInstance = NULL;\r
   EFI_FV_BLOCK_MAP_ENTRY  *BlockMap;\r
   EFI_STATUS              Status;\r
 \r
   EFI_FV_BLOCK_MAP_ENTRY  *BlockMap;\r
   EFI_STATUS              Status;\r
 \r
@@ -626,7 +626,7 @@ Returns:
 \r
 --*/\r
 {\r
 \r
 --*/\r
 {\r
-  EFI_FW_VOL_INSTANCE *FwhInstance;\r
+  EFI_FW_VOL_INSTANCE   *FwhInstance = NULL;\r
   EFI_FVB_ATTRIBUTES_2  OldAttributes;\r
   EFI_FVB_ATTRIBUTES_2  *AttribPtr;\r
   UINT32              Capabilities;\r
   EFI_FVB_ATTRIBUTES_2  OldAttributes;\r
   EFI_FVB_ATTRIBUTES_2  *AttribPtr;\r
   UINT32              Capabilities;\r
@@ -733,7 +733,7 @@ Returns:
 EFI_STATUS\r
 EFIAPI\r
 FvbProtocolGetPhysicalAddress (\r
 EFI_STATUS\r
 EFIAPI\r
 FvbProtocolGetPhysicalAddress (\r
-  IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL           *This,\r
+  IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL     *This,\r
   OUT EFI_PHYSICAL_ADDRESS                        *Address\r
   )\r
 /*++\r
   OUT EFI_PHYSICAL_ADDRESS                        *Address\r
   )\r
 /*++\r
@@ -764,7 +764,7 @@ Returns:
 EFI_STATUS\r
 EFIAPI\r
 FvbProtocolGetBlockSize (\r
 EFI_STATUS\r
 EFIAPI\r
 FvbProtocolGetBlockSize (\r
-  IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL           *This,\r
+  IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL     *This,\r
   IN  EFI_LBA                                     Lba,\r
   OUT UINTN                                       *BlockSize,\r
   OUT UINTN                                       *NumOfBlocks\r
   IN  EFI_LBA                                     Lba,\r
   OUT UINTN                                       *BlockSize,\r
   OUT UINTN                                       *NumOfBlocks\r
@@ -808,7 +808,7 @@ Returns:
 EFI_STATUS\r
 EFIAPI\r
 FvbProtocolGetAttributes (\r
 EFI_STATUS\r
 EFIAPI\r
 FvbProtocolGetAttributes (\r
-  IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL           *This,\r
+  IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL     *This,\r
   OUT EFI_FVB_ATTRIBUTES_2                          *Attributes\r
   )\r
 /*++\r
   OUT EFI_FVB_ATTRIBUTES_2                          *Attributes\r
   )\r
 /*++\r
@@ -835,7 +835,7 @@ Returns:
 EFI_STATUS\r
 EFIAPI\r
 FvbProtocolSetAttributes (\r
 EFI_STATUS\r
 EFIAPI\r
 FvbProtocolSetAttributes (\r
-  IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL           *This,\r
+  IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL     *This,\r
   IN OUT EFI_FVB_ATTRIBUTES_2                       *Attributes\r
   )\r
 /*++\r
   IN OUT EFI_FVB_ATTRIBUTES_2                       *Attributes\r
   )\r
 /*++\r
@@ -862,7 +862,7 @@ Returns:
 EFI_STATUS\r
 EFIAPI\r
 FvbProtocolEraseBlocks (\r
 EFI_STATUS\r
 EFIAPI\r
 FvbProtocolEraseBlocks (\r
-  IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL    *This,\r
+  IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL    *This,\r
   ...  \r
   )\r
 /*++\r
   ...  \r
   )\r
 /*++\r
@@ -891,7 +891,7 @@ Returns:
 --*/\r
 {\r
   EFI_FW_VOL_BLOCK_DEVICE *FvbDevice;\r
 --*/\r
 {\r
   EFI_FW_VOL_BLOCK_DEVICE *FvbDevice;\r
-  EFI_FW_VOL_INSTANCE     *FwhInstance;\r
+  EFI_FW_VOL_INSTANCE     *FwhInstance = NULL;\r
   UINTN                   NumOfBlocks;\r
   VA_LIST                 args;\r
   EFI_LBA                 StartingLba;\r
   UINTN                   NumOfBlocks;\r
   VA_LIST                 args;\r
   EFI_LBA                 StartingLba;\r
@@ -960,7 +960,7 @@ Returns:
 EFI_STATUS\r
 EFIAPI\r
 FvbProtocolWrite (\r
 EFI_STATUS\r
 EFIAPI\r
 FvbProtocolWrite (\r
-  IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL           *This,\r
+  IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL     *This,\r
   IN EFI_LBA                                      Lba,\r
   IN UINTN                                        Offset,\r
   IN OUT UINTN                                    *NumBytes,\r
   IN EFI_LBA                                      Lba,\r
   IN UINTN                                        Offset,\r
   IN OUT UINTN                                    *NumBytes,\r
@@ -1008,7 +1008,7 @@ Returns:
 EFI_STATUS\r
 EFIAPI\r
 FvbProtocolRead (\r
 EFI_STATUS\r
 EFIAPI\r
 FvbProtocolRead (\r
-  IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL           *This,\r
+  IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL     *This,\r
   IN EFI_LBA                                      Lba,\r
   IN UINTN                                        Offset,\r
   IN OUT UINTN                                    *NumBytes,\r
   IN EFI_LBA                                      Lba,\r
   IN UINTN                                        Offset,\r
   IN OUT UINTN                                    *NumBytes,\r
@@ -1124,7 +1124,7 @@ Returns:
 --*/\r
 {\r
   EFI_STATUS                          Status;\r
 --*/\r
 {\r
   EFI_STATUS                          Status;\r
-  EFI_FW_VOL_INSTANCE                 *FwhInstance;\r
+  EFI_FW_VOL_INSTANCE                 *FwhInstance = NULL;\r
   EFI_FIRMWARE_VOLUME_HEADER          *FwVolHeader;\r
   EFI_DXE_SERVICES                    *DxeServices;\r
   EFI_GCD_MEMORY_SPACE_DESCRIPTOR     Descriptor;\r
   EFI_FIRMWARE_VOLUME_HEADER          *FwVolHeader;\r
   EFI_DXE_SERVICES                    *DxeServices;\r
   EFI_GCD_MEMORY_SPACE_DESCRIPTOR     Descriptor;\r
index 0e7580cb3634f74374ff74ccebfb14e85aad9ef9..b8399edf992bf8e321cb11585d1fd2a22c508886 100644 (file)
@@ -34,8 +34,8 @@ Abstract:
 #include <Library/BaseMemoryLib.h>\r
 #include <Library/MemoryAllocationLib.h>\r
 #include <Library/UefiBootServicesTableLib.h>\r
 #include <Library/BaseMemoryLib.h>\r
 #include <Library/MemoryAllocationLib.h>\r
 #include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/PcdLib.h>
-#include <Library/DevicePathLib.h>
+#include <Library/PcdLib.h>\r
+#include <Library/DevicePathLib.h>\r
 \r
 #include <Guid/FirmwareFileSystem2.h>\r
 #include <Guid/SystemNvDataGuid.h>\r
 \r
 #include <Guid/FirmwareFileSystem2.h>\r
 #include <Guid/SystemNvDataGuid.h>\r
index 5ed8107745598589d6c18dd096aca0700c853d54..b87192dfde6ec5bc1908526e1bf2dcc20a7d89d3 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
 /*++\r
 \r
-Copyright (c) 2006, Intel Corporation                                                         \r
+Copyright (c) 2006 - 2009, Intel Corporation                                                         \r
 All rights reserved. This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
 All rights reserved. This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
@@ -161,7 +161,7 @@ FvbGetLbaAddress (
 EFI_STATUS\r
 EFIAPI\r
 FvbProtocolGetAttributes (\r
 EFI_STATUS\r
 EFIAPI\r
 FvbProtocolGetAttributes (\r
-  IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL           *This,\r
+  IN  CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL           *This,\r
   OUT EFI_FVB_ATTRIBUTES_2                          *Attributes\r
   )\r
 ;\r
   OUT EFI_FVB_ATTRIBUTES_2                          *Attributes\r
   )\r
 ;\r
@@ -169,7 +169,7 @@ FvbProtocolGetAttributes (
 EFI_STATUS\r
 EFIAPI\r
 FvbProtocolSetAttributes (\r
 EFI_STATUS\r
 EFIAPI\r
 FvbProtocolSetAttributes (\r
-  IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL           *This,\r
+  IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL           *This,\r
   IN OUT EFI_FVB_ATTRIBUTES_2                       *Attributes\r
   )\r
 ;\r
   IN OUT EFI_FVB_ATTRIBUTES_2                       *Attributes\r
   )\r
 ;\r
@@ -177,7 +177,7 @@ FvbProtocolSetAttributes (
 EFI_STATUS\r
 EFIAPI\r
 FvbProtocolGetPhysicalAddress (\r
 EFI_STATUS\r
 EFIAPI\r
 FvbProtocolGetPhysicalAddress (\r
-  IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL           *This,\r
+  IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL           *This,\r
   OUT EFI_PHYSICAL_ADDRESS                        *Address\r
   )\r
 ;\r
   OUT EFI_PHYSICAL_ADDRESS                        *Address\r
   )\r
 ;\r
@@ -185,7 +185,7 @@ FvbProtocolGetPhysicalAddress (
 EFI_STATUS\r
 EFIAPI\r
 FvbProtocolGetBlockSize (\r
 EFI_STATUS\r
 EFIAPI\r
 FvbProtocolGetBlockSize (\r
-  IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL           *This,\r
+  IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL     *This,\r
   IN  EFI_LBA                                     Lba,\r
   OUT UINTN                                       *BlockSize,\r
   OUT UINTN                                       *NumOfBlocks\r
   IN  EFI_LBA                                     Lba,\r
   OUT UINTN                                       *BlockSize,\r
   OUT UINTN                                       *NumOfBlocks\r
@@ -195,7 +195,7 @@ FvbProtocolGetBlockSize (
 EFI_STATUS\r
 EFIAPI\r
 FvbProtocolRead (\r
 EFI_STATUS\r
 EFIAPI\r
 FvbProtocolRead (\r
-  IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL           *This,\r
+  IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL     *This,\r
   IN EFI_LBA                                      Lba,\r
   IN UINTN                                        Offset,\r
   IN OUT UINTN                                    *NumBytes,\r
   IN EFI_LBA                                      Lba,\r
   IN UINTN                                        Offset,\r
   IN OUT UINTN                                    *NumBytes,\r
@@ -206,7 +206,7 @@ FvbProtocolRead (
 EFI_STATUS\r
 EFIAPI\r
 FvbProtocolWrite (\r
 EFI_STATUS\r
 EFIAPI\r
 FvbProtocolWrite (\r
-  IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL           *This,\r
+  IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL     *This,\r
   IN EFI_LBA                                      Lba,\r
   IN UINTN                                        Offset,\r
   IN OUT UINTN                                    *NumBytes,\r
   IN EFI_LBA                                      Lba,\r
   IN UINTN                                        Offset,\r
   IN OUT UINTN                                    *NumBytes,\r
@@ -217,7 +217,7 @@ FvbProtocolWrite (
 EFI_STATUS\r
 EFIAPI\r
 FvbProtocolEraseBlocks (\r
 EFI_STATUS\r
 EFIAPI\r
 FvbProtocolEraseBlocks (\r
-  IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL    *This,\r
+  IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL    *This,\r
   ...\r
   )\r
 ;\r
   ...\r
   )\r
 ;\r
index 05fc4270912137471d8c024820a5a8cc3a3576ce..0f3817f02885e3463c19eb24a3d35210ab9491d9 100644 (file)
@@ -53,7 +53,7 @@
   DxeServicesTableLib\r
   BaseLib\r
   UefiDriverEntryPoint\r
   DxeServicesTableLib\r
   BaseLib\r
   UefiDriverEntryPoint\r
-  UefiLib
+  UefiLib\r
   DevicePathLib\r
 \r
 \r
   DevicePathLib\r
 \r
 \r
index 922964672ca259c722f831893fd32e7b48153ce3..487386f9cb78b58d3e82ecd670d38d0e3f0dbdab 100644 (file)
@@ -1,6 +1,7 @@
 /*++\r
 \r
 /*++\r
 \r
-Copyright (c) 2006, Intel Corporation\r
+Copyright (c) 2006 - 2009, Intel Corporation\r
+Portions copyright (c) 2008-2009 Apple Inc.\r
 All rights reserved. This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
 All rights reserved. This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -19,14 +20,21 @@ Abstract:
 \r
 #ifndef __UNIX_INCLUDE_H__\r
 #define __UNIX_INCLUDE_H__\r
 \r
 #ifndef __UNIX_INCLUDE_H__\r
 #define __UNIX_INCLUDE_H__\r
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/vfs.h>
-#include <sys/poll.h>
-#include <dirent.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <time.h>
-#include <utime.h>
-#include <unistd.h>
+#include <sys/types.h>\r
+#include <sys/stat.h>\r
+\r
+#ifdef __APPLE__\r
+#include <sys/param.h>\r
+#include <sys/mount.h>\r
+#else\r
+#include <sys/vfs.h>\r
+#endif \r
+\r
+#include <sys/poll.h>\r
+#include <dirent.h>\r
+#include <errno.h>\r
+#include <fcntl.h>\r
+#include <time.h>\r
+#include <utime.h>\r
+#include <unistd.h>\r
 #endif\r
 #endif\r
index 0c04d8202e616845f81a7e3c66b21ffe2f517c44..9660796effb122127466b8fca452cc5ca52596ca 100644 (file)
@@ -26,7 +26,7 @@ Unix Autoscan PPI
 \r
 #define PEI_UNIX_AUTOSCAN_PPI_GUID \\r
   { \\r
 \r
 #define PEI_UNIX_AUTOSCAN_PPI_GUID \\r
   { \\r
-    0xf2ed3d14, 0x8985, 0x11db, {0xb0, 0x57, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \
+    0xf2ed3d14, 0x8985, 0x11db, {0xb0, 0x57, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \\r
   }\r
 \r
 typedef\r
   }\r
 \r
 typedef\r
index a9885a57bf5663b14e26515b466c2b825d56097d..1deed11454c76f470bb58ddc7dcc1db3d56341a5 100644 (file)
@@ -26,7 +26,7 @@ Abstract:
 \r
 #define UNIX_FWH_PPI_GUID \\r
   { \\r
 \r
 #define UNIX_FWH_PPI_GUID \\r
   { \\r
-    0xf2f0dc30, 0x8985, 0x11db, {0xa1, 0x5b, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \
+    0xf2f0dc30, 0x8985, 0x11db, {0xa1, 0x5b, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \\r
   }\r
 \r
 typedef\r
   }\r
 \r
 typedef\r
index b91c630b5a33f8261de6a65305c3efd05c35332a..cfd58fdb35899e6342419b56987795cb785e4b9a 100644 (file)
@@ -28,7 +28,7 @@ Abstract:
 \r
 #define UNIX_PEI_LOAD_FILE_GUID \\r
   { \\r
 \r
 #define UNIX_PEI_LOAD_FILE_GUID \\r
   { \\r
-    0xf2f48768, 0x8985, 0x11db, {0xb8, 0xda, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \
+    0xf2f48768, 0x8985, 0x11db, {0xb8, 0xda, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \\r
   }\r
 \r
 typedef\r
   }\r
 \r
 typedef\r
index 866bd613982f2dda20be94921ada6da8cb51caec..ba4d4131316bd6012b567919da90394f27b3b8a7 100644 (file)
@@ -26,7 +26,7 @@ Abstract:
 \r
 #define PEI_UNIX_THUNK_PPI_GUID \\r
   { \\r
 \r
 #define PEI_UNIX_THUNK_PPI_GUID \\r
   { \\r
-    0xf2f830f2, 0x8985, 0x11db, {0x80, 0x6b, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \
+    0xf2f830f2, 0x8985, 0x11db, {0x80, 0x6b, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \\r
   }\r
 \r
 typedef\r
   }\r
 \r
 typedef\r
index 1758ecb7c4b25d64d4bad4c9dd02fe9316c87360..c25b06f07116ccbdd9bd21d293ae387f9d8bce1a 100644 (file)
@@ -22,7 +22,7 @@ Abstract:
 \r
 #define EFI_UNIX_IO_PROTOCOL_GUID \\r
   { \\r
 \r
 #define EFI_UNIX_IO_PROTOCOL_GUID \\r
   { \\r
-    0xf2e23f54, 0x8985, 0x11db, {0xac, 0x79, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \
+    0xf2e23f54, 0x8985, 0x11db, {0xac, 0x79, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \\r
   }\r
 \r
 typedef struct {\r
   }\r
 \r
 typedef struct {\r
@@ -44,7 +44,7 @@ extern EFI_GUID gEfiUnixIoProtocolGuid;
 //\r
 #define EFI_UNIX_VIRTUAL_DISKS_GUID \\r
   { \\r
 //\r
 #define EFI_UNIX_VIRTUAL_DISKS_GUID \\r
   { \\r
-    0xf2ba331a, 0x8985, 0x11db, {0xa4, 0x06, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \
+    0xf2ba331a, 0x8985, 0x11db, {0xa4, 0x06, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \\r
   }\r
 \r
 extern EFI_GUID gEfiUnixVirtualDisksGuid;\r
   }\r
 \r
 extern EFI_GUID gEfiUnixVirtualDisksGuid;\r
@@ -54,7 +54,7 @@ extern EFI_GUID gEfiUnixVirtualDisksGuid;
 //\r
 #define EFI_UNIX_PHYSICAL_DISKS_GUID \\r
   { \\r
 //\r
 #define EFI_UNIX_PHYSICAL_DISKS_GUID \\r
   { \\r
-    0xf2bdcc96, 0x8985, 0x11db, {0x87, 0x19, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \
+    0xf2bdcc96, 0x8985, 0x11db, {0x87, 0x19, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \\r
   }\r
 \r
 extern EFI_GUID gEfiUnixPhysicalDisksGuid;\r
   }\r
 \r
 extern EFI_GUID gEfiUnixPhysicalDisksGuid;\r
@@ -64,7 +64,7 @@ extern EFI_GUID gEfiUnixPhysicalDisksGuid;
 //\r
 #define EFI_UNIX_FILE_SYSTEM_GUID \\r
   { \\r
 //\r
 #define EFI_UNIX_FILE_SYSTEM_GUID \\r
   { \\r
-    0xf2c16b9e, 0x8985, 0x11db, {0x92, 0xc8, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \
+    0xf2c16b9e, 0x8985, 0x11db, {0x92, 0xc8, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \\r
   }\r
 \r
 extern EFI_GUID gEfiUnixFileSystemGuid;\r
   }\r
 \r
 extern EFI_GUID gEfiUnixFileSystemGuid;\r
@@ -84,7 +84,7 @@ extern EFI_GUID gEfiUnixSerialPortGuid;
 //\r
 #define EFI_UNIX_UGA_GUID \\r
   { \\r
 //\r
 #define EFI_UNIX_UGA_GUID \\r
   { \\r
-    0xf2c8b80e, 0x8985, 0x11db, {0x93, 0xf1, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \
+    0xf2c8b80e, 0x8985, 0x11db, {0x93, 0xf1, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \\r
   }\r
 \r
 extern EFI_GUID gEfiUnixUgaGuid;\r
   }\r
 \r
 extern EFI_GUID gEfiUnixUgaGuid;\r
@@ -94,7 +94,7 @@ extern EFI_GUID gEfiUnixUgaGuid;
 //\r
 #define EFI_UNIX_GOP_GUID \\r
   { \\r
 //\r
 #define EFI_UNIX_GOP_GUID \\r
   { \\r
-    0xbace07c2, 0x8987, 0x11db, {0xa5, 0x9a, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \
+    0xbace07c2, 0x8987, 0x11db, {0xa5, 0x9a, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \\r
   }\r
 \r
 extern EFI_GUID gEfiUnixGopGuid;\r
   }\r
 \r
 extern EFI_GUID gEfiUnixGopGuid;\r
@@ -104,7 +104,7 @@ extern EFI_GUID gEfiUnixGopGuid;
 //\r
 #define EFI_UNIX_CONSOLE_GUID \\r
   { \\r
 //\r
 #define EFI_UNIX_CONSOLE_GUID \\r
   { \\r
-    0xf2cc5d06, 0x8985, 0x11db, {0xbb, 0x19, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \
+    0xf2cc5d06, 0x8985, 0x11db, {0xbb, 0x19, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \\r
   }\r
 \r
 extern EFI_GUID gEfiUnixConsoleGuid;\r
   }\r
 \r
 extern EFI_GUID gEfiUnixConsoleGuid;\r
@@ -114,7 +114,7 @@ extern EFI_GUID gEfiUnixConsoleGuid;
 //\r
 #define EFI_UNIX_MEMORY_GUID \\r
   { \\r
 //\r
 #define EFI_UNIX_MEMORY_GUID \\r
   { \\r
-    0xf2d006cc, 0x8985, 0x11db, {0xa4, 0x72, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \
+    0xf2d006cc, 0x8985, 0x11db, {0xa4, 0x72, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \\r
   }\r
 \r
 extern EFI_GUID gEfiUnixMemoryGuid;\r
   }\r
 \r
 extern EFI_GUID gEfiUnixMemoryGuid;\r
@@ -124,7 +124,7 @@ extern EFI_GUID gEfiUnixMemoryGuid;
 //\r
 #define EFI_UNIX_CPU_MODEL_GUID \\r
   { \\r
 //\r
 #define EFI_UNIX_CPU_MODEL_GUID \\r
   { \\r
-    0xf2d3b330, 0x8985, 0x11db, {0x8a, 0xa3, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \
+    0xf2d3b330, 0x8985, 0x11db, {0x8a, 0xa3, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \\r
   }\r
 \r
 extern EFI_GUID gEfiUnixCPUModelGuid;\r
   }\r
 \r
 extern EFI_GUID gEfiUnixCPUModelGuid;\r
@@ -134,7 +134,7 @@ extern EFI_GUID gEfiUnixCPUModelGuid;
 //\r
 #define EFI_UNIX_CPU_SPEED_GUID \\r
   { \\r
 //\r
 #define EFI_UNIX_CPU_SPEED_GUID \\r
   { \\r
-    0xf2d74e5a, 0x8985, 0x11db, {0x97, 0x05, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \
+    0xf2d74e5a, 0x8985, 0x11db, {0x97, 0x05, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \\r
   }\r
 \r
 extern EFI_GUID gEfiUnixCPUSpeedGuid;\r
   }\r
 \r
 extern EFI_GUID gEfiUnixCPUSpeedGuid;\r
index ba325bff87f0306758ad03565f74d2df9e6d84bb..29a9791292635b3cd594cf19fa482db06fed60d4 100644 (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                          
 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        
 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        
@@ -31,7 +32,13 @@ Abstract:
 #include <sys/termios.h>
 #include <stdio.h>
 #include <sys/time.h>
 #include <sys/termios.h>
 #include <stdio.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 <poll.h>
 #include <sys/types.h>
 #include <unistd.h>
 #include <poll.h>
 #include <sys/types.h>
@@ -42,12 +49,24 @@ Abstract:
 #include <errno.h>
 #include <string.h>
 #include <stdlib.h>
 #include <errno.h>
 #include <string.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 <dlfcn.h>
 
 #include <utime.h>
 #include <dlfcn.h>
 
+#include <Base.h>
+#include <Library/PeCoffLib.h>
+
+
 #define EFI_UNIX_THUNK_PROTOCOL_GUID \
   { \
     0xf2e98868, 0x8985, 0x11db, {0x9a, 0x59, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \
 #define EFI_UNIX_THUNK_PROTOCOL_GUID \
   { \
     0xf2e98868, 0x8985, 0x11db, {0x9a, 0x59, 0x00, 0x40, 0xd0, 0x2b, 0x18, 0x35 } \
@@ -167,7 +186,11 @@ void
 
 typedef 
 int 
 
 typedef 
 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 
 int 
 
 typedef 
 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;
   UnixDlerror                         Dlerror;
   UnixDlsym                           Dlsym;
   UnixDlopen                          Dlopen;
   UnixDlerror                         Dlerror;
   UnixDlsym                           Dlsym;
+  UnixPeCoffGetEntryPoint                 PeCoffGetEntryPoint;
+  UnixPeCoffRelocateImageExtraAction      PeCoffRelocateImageExtraAction;
+  UnixPeCoffLoaderUnloadImageExtraAction  PeCoffUnloadImageExtraAction;
+       
+       
 } EFI_UNIX_THUNK_PROTOCOL;
 
 extern EFI_GUID gEfiUnixThunkProtocolGuid;
 } EFI_UNIX_THUNK_PROTOCOL;
 
 extern EFI_GUID gEfiUnixThunkProtocolGuid;
index 29a0c16e0f38921aac30aac225a2e83ab32468fd..7ab91b900d694bbb332802959d443f9f50f84295 100644 (file)
@@ -29,7 +29,7 @@ Abstract:
 //  UnixIo.h depends on UnixThunk.h\r
 //\r
 \r
 //  UnixIo.h depends on UnixThunk.h\r
 //\r
 \r
-#include <Common/UnixInclude.h>
+#include <Common/UnixInclude.h>\r
 #include <Protocol/UnixThunk.h>\r
 #include <Protocol/UnixIo.h>\r
 \r
 #include <Protocol/UnixThunk.h>\r
 #include <Protocol/UnixIo.h>\r
 \r
index 014390cf4fdb9b2d5b15bc5094ad73ad29687334..b700975fc847cb358792fc9e8cadd422a0ca2b0e 100644 (file)
@@ -1,6 +1,7 @@
 /**@file\r
 \r
 Copyright (c) 2006 - 2009, Intel Corporation\r
 /**@file\r
 \r
 Copyright (c) 2006 - 2009, Intel Corporation\r
+Portions copyright (c) 2008-2009 Apple Inc. All rights reserved.\r
 All rights reserved. This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
 All rights reserved. This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -22,12 +23,10 @@ Abstract:
 \r
 **/\r
 \r
 \r
 **/\r
 \r
-#include <FrameworkDxe.h>\r
-#include <Guid/StatusCodeDataTypeId.h>\r
+#include <PiDxe.h>\r
 #include <UnixDxe.h>\r
 #include <Library/PeCoffLib.h>\r
 \r
 #include <UnixDxe.h>\r
 #include <Library/PeCoffLib.h>\r
 \r
-\r
 #include <Library/BaseLib.h>\r
 #include <Library/DebugLib.h>\r
 #include <Library/HobLib.h>\r
 #include <Library/BaseLib.h>\r
 #include <Library/DebugLib.h>\r
 #include <Library/HobLib.h>\r
@@ -35,9 +34,12 @@ Abstract:
 #include <Library/PeCoffExtraActionLib.h>\r
 \r
 //\r
 #include <Library/PeCoffExtraActionLib.h>\r
 \r
 //\r
+\r
 // Cache of UnixThunk protocol \r
 // Cache of UnixThunk protocol \r
+\r
 //\r
 //\r
-EFI_UNIX_THUNK_PROTOCOL   *mUnix;\r
+\r
+EFI_UNIX_THUNK_PROTOCOL   *mUnix = NULL;\r
 \r
 \r
 /**\r
 \r
 \r
 /**\r
@@ -82,35 +84,10 @@ PeCoffLoaderRelocateImageExtraAction (
   IN OUT PE_COFF_LOADER_IMAGE_CONTEXT  *ImageContext\r
   )\r
 {\r
   IN OUT PE_COFF_LOADER_IMAGE_CONTEXT  *ImageContext\r
   )\r
 {\r
-  VOID * Handle;\r
-  VOID * Entry;\r
-\r
-  ASSERT (ImageContext != NULL);\r
-\r
-  Handle = NULL;\r
-  Entry  = NULL;\r
-  \r
-  DEBUG ((EFI_D_ERROR, "Loading %a 0x%08lx - entry point 0x%08lx\n",\r
-          ImageContext->PdbPointer,\r
-          (UINTN)ImageContext->ImageAddress,\r
-          (UINTN)ImageContext->EntryPoint));\r
-\r
-  Handle = mUnix->Dlopen(ImageContext->PdbPointer, RTLD_NOW);\r
-  \r
-  if (Handle) {\r
-    Entry = mUnix->Dlsym(Handle, "_ModuleEntryPoint");\r
-  } else {\r
-       DEBUG ((EFI_D_ERROR, "%a\n", mUnix->Dlerror()));\r
-  }\r
-  \r
-  if (Entry != NULL) {\r
-    ImageContext->EntryPoint = Entry;\r
-    DEBUG ((EFI_D_ERROR, "Change %a Entrypoint to :0x%08lx\n", ImageContext->PdbPointer, Entry));\r
+  mUnix->PeCoffRelocateImageExtraAction (ImageContext);\r
   }\r
 \r
 \r
   }\r
 \r
 \r
-  return;\r
- }  \r
 \r
 /**\r
   Performs additional actions just before a PE/COFF image is unloaded.  Any resources\r
 \r
 /**\r
   Performs additional actions just before a PE/COFF image is unloaded.  Any resources\r
@@ -128,5 +105,5 @@ PeCoffLoaderUnloadImageExtraAction (
   IN OUT PE_COFF_LOADER_IMAGE_CONTEXT  *ImageContext\r
   )\r
 {\r
   IN OUT PE_COFF_LOADER_IMAGE_CONTEXT  *ImageContext\r
   )\r
 {\r
-  ASSERT (ImageContext != NULL);\r
+  mUnix->PeCoffUnloadImageExtraAction (ImageContext);\r
 }\r
 }\r
index 93c514692ceaab31d331746105fc1ddfead59166..83d69639820b10375beffbcfa1f3a5f8e11a95f4 100644 (file)
@@ -2,7 +2,7 @@
 # PeCoff extra action libary for DXE phase that run Unix emulator.
 #
 # Lib to provide memory journal status code reporting Routines
 # PeCoff extra action libary for DXE phase that run Unix emulator.
 #
 # 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
 # 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
 # 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
@@ -39,8 +39,6 @@
 [Packages]
   UnixPkg/UnixPkg.dec
   MdePkg/MdePkg.dec
 [Packages]
   UnixPkg/UnixPkg.dec
   MdePkg/MdePkg.dec
-  IntelFrameworkPkg/IntelFrameworkPkg.dec
-  IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec
 
 [LibraryClasses]
   DebugLib
 
 [LibraryClasses]
   DebugLib
index be9cba831c93c4e6c991efb217f01d4fd74e86c6..ef0d6c17cb55f5712aff6364a2668e8c1c7bcafd 100644 (file)
@@ -1,6 +1,7 @@
 /*++\r
 \r
 /*++\r
 \r
-Copyright (c) 2006 - 2008, Intel Corporation\r
+Copyright (c) 2006 - 2009, Intel Corporation\r
+Portions copyright (c) 2008-2009 Apple Inc. All rights reserved.\r
 All rights reserved. This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
 All rights reserved. This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -54,38 +55,24 @@ Returns:
 \r
 --*/\r
 {\r
 \r
 --*/\r
 {\r
+       PEI_UNIX_THUNK_PPI      *UnixThunkPpi;\r
   EFI_STATUS              Status;\r
   EFI_STATUS              Status;\r
-  EFI_PEI_PPI_DESCRIPTOR  *PpiDescriptor;\r
-  UNIX_PEI_LOAD_FILE_PPI *PeiUnixService;\r
-  EFI_PHYSICAL_ADDRESS    ImageAddress;\r
-  UINT64                  ImageSize;\r
-  EFI_PHYSICAL_ADDRESS    ImageEntryPoint;\r
-\r
-  ASSERT (Pe32Data   != NULL);\r
-  ASSERT (EntryPoint != NULL);\r
+  EFI_UNIX_THUNK_PROTOCOL *Unix;\r
 \r
 \r
+  //\r
+  // Locate Unix ThunkPpi for retrieving standard output handle\r
+  //\r
   Status = PeiServicesLocatePpi (\r
   Status = PeiServicesLocatePpi (\r
-             &gUnixPeiLoadFilePpiGuid,\r
+              &gPeiUnixThunkPpiGuid,\r
              0,\r
              0,\r
-             &PpiDescriptor,\r
-             (void **)&PeiUnixService\r
+              NULL,\r
+              (VOID **) &UnixThunkPpi\r
              );\r
              );\r
-\r
   ASSERT_EFI_ERROR (Status);\r
 \r
   ASSERT_EFI_ERROR (Status);\r
 \r
-  Status = PeiUnixService->PeiLoadFileService (\r
-                           Pe32Data,\r
-                           &ImageAddress,\r
-                           &ImageSize,\r
-                           &ImageEntryPoint\r
-                           );\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
+  Unix  = (EFI_UNIX_THUNK_PROTOCOL *)UnixThunkPpi->UnixThunk ();\r
 \r
 \r
-  *EntryPoint = (VOID*)(UINTN)ImageEntryPoint;\r
-  return Status;\r
+  return Unix->PeCoffGetEntryPoint (Pe32Data, EntryPoint);\r
 }\r
 \r
 /**\r
 }\r
 \r
 /**\r
@@ -255,6 +242,8 @@ PeCoffLoaderGetPdbPointer (
           return (VOID *) ((CHAR8 *)CodeViewEntryPointer + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY));\r
         case CODEVIEW_SIGNATURE_RSDS:\r
           return (VOID *) ((CHAR8 *)CodeViewEntryPointer + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_RSDS_ENTRY));\r
           return (VOID *) ((CHAR8 *)CodeViewEntryPointer + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY));\r
         case CODEVIEW_SIGNATURE_RSDS:\r
           return (VOID *) ((CHAR8 *)CodeViewEntryPointer + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_RSDS_ENTRY));\r
+        case CODEVIEW_SIGNATURE_MTOC:\r
+          return (VOID *) ((CHAR8 *)CodeViewEntryPointer + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_MTOC_ENTRY));\r
         default:\r
           break;\r
         }\r
         default:\r
           break;\r
         }\r
index 3b2af0301bf8b776ef10adbe67d9daf19feca7c3..dea03fb142e384817ab12428b224855056c5e900 100644 (file)
@@ -1,6 +1,7 @@
 /**@file\r
 \r
 Copyright (c) 2006 - 2009, Intel Corporation\r
 /**@file\r
 \r
 Copyright (c) 2006 - 2009, Intel Corporation\r
+Portions copyright (c) 2008-2009 Apple Inc. All rights reserved.\r
 All rights reserved. This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
 All rights reserved. This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -36,7 +37,7 @@ Abstract:
 EFI_UNIX_THUNK_PROTOCOL   *mUnix = NULL;\r
 \r
 /**\r
 EFI_UNIX_THUNK_PROTOCOL   *mUnix = NULL;\r
 \r
 /**\r
-  The function caches the pointer of the WinNT thunk functions\r
+  The function caches the pointer of the Unix thunk functions\r
   It will ASSERT() if Unix thunk ppi is not installed.\r
 \r
   @retval EFI_SUCCESS   WinNT thunk protocol is found and cached.\r
   It will ASSERT() if Unix thunk ppi is not installed.\r
 \r
   @retval EFI_SUCCESS   WinNT thunk protocol is found and cached.\r
@@ -83,38 +84,12 @@ PeCoffLoaderRelocateImageExtraAction (
   IN OUT PE_COFF_LOADER_IMAGE_CONTEXT  *ImageContext\r
   )\r
 {\r
   IN OUT PE_COFF_LOADER_IMAGE_CONTEXT  *ImageContext\r
   )\r
 {\r
-  VOID * Handle;\r
-  VOID * Entry;\r
-\r
-  ASSERT (ImageContext != NULL);\r
-\r
-  Handle = NULL;\r
-  Entry  = NULL;\r
-  \r
   if (mUnix == NULL) {\r
     UnixPeCoffGetUnixThunkStucture ();\r
   }\r
   if (mUnix == NULL) {\r
     UnixPeCoffGetUnixThunkStucture ();\r
   }\r
-  DEBUG ((EFI_D_ERROR, "Loading %a 0x%08lx - entry point 0x%08lx\n",\r
-          ImageContext->PdbPointer,\r
-          (UINTN)ImageContext->ImageAddress,\r
-          (UINTN)ImageContext->EntryPoint));\r
-\r
-  Handle = mUnix->Dlopen (ImageContext->PdbPointer, RTLD_NOW);\r
-  \r
-  if (Handle) {\r
-    Entry = mUnix->Dlsym(Handle, "_ModuleEntryPoint");\r
-  } else {\r
-       DEBUG ((EFI_D_ERROR, "%a\n", mUnix->Dlerror()));\r
+  mUnix->PeCoffRelocateImageExtraAction (ImageContext);\r
   }\r
   }\r
-  \r
-  if (Entry != NULL) {\r
-    ImageContext->EntryPoint = Entry;\r
-    DEBUG ((EFI_D_ERROR, "Change %a Entrypoint to :0x%08lx\n", ImageContext->PdbPointer, Entry));\r
-  }\r
-\r
 \r
 \r
-  return;\r
- }  \r
 \r
 /**\r
   Performs additional actions just before a PE/COFF image is unloaded.  Any resources\r
 \r
 /**\r
   Performs additional actions just before a PE/COFF image is unloaded.  Any resources\r
@@ -132,5 +107,8 @@ PeCoffLoaderUnloadImageExtraAction (
   IN OUT PE_COFF_LOADER_IMAGE_CONTEXT  *ImageContext\r
   )\r
 {\r
   IN OUT PE_COFF_LOADER_IMAGE_CONTEXT  *ImageContext\r
   )\r
 {\r
-  ASSERT (ImageContext != NULL);\r
+  if (mUnix == NULL) {\r
+    UnixPeCoffGetUnixThunkStucture ();\r
+  }\r
+  mUnix->PeCoffUnloadImageExtraAction (ImageContext);\r
 }\r
 }\r
index 1ecdd296810f3d1a7f6a1621dea9469efa1da865..722d586e1757672382c3a06bde24bdc1dfda14bd 100644 (file)
@@ -2,7 +2,7 @@
 # PeCoff extra action libary for Pei phase that run UNIX emulator.
 #
 # Lib to provide memory journal status code reporting Routines
 # PeCoff extra action libary for Pei phase that run UNIX emulator.
 #
 # 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
 # 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
 # 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
@@ -37,8 +37,6 @@
 [Packages]
   MdePkg/MdePkg.dec
   UnixPkg/UnixPkg.dec
 [Packages]
   MdePkg/MdePkg.dec
   UnixPkg/UnixPkg.dec
-  IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec
-  IntelFrameworkPkg/IntelFrameworkPkg.dec
 
 [LibraryClasses]
   BaseLib
 
 [LibraryClasses]
   BaseLib
index 1a5604d8f21d0468dad4ba0b45aae553a47845b7..834b5c68972edfb6f7ccf4899959b00b3a289e32 100644 (file)
@@ -50,7 +50,7 @@
   BaseMemoryLib\r
   DebugLib\r
   PcdLib\r
   BaseMemoryLib\r
   DebugLib\r
   PcdLib\r
-  GenericBdsLib
+  GenericBdsLib\r
   DevicePathLib\r
 \r
 \r
   DevicePathLib\r
 \r
 \r
index 9051dbf33fa30b5675c0dc0671b585ff4507e984..df60c1c96cfa5fbf8f91956f569ebee74eea607b 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
 /*++\r
 \r
-Copyright (c) 2006, Intel Corporation                                                         \r
+Copyright (c) 2006 - 2009, Intel Corporation                                                         \r
 All rights reserved. This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
 All rights reserved. This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
@@ -32,22 +32,22 @@ UINT16                      gPlatformBootTimeOutDefault = 10;
 //\r
 UNIX_PLATFORM_UGA_DEVICE_PATH gUgaDevicePath0 = \r
 {\r
 //\r
 UNIX_PLATFORM_UGA_DEVICE_PATH gUgaDevicePath0 = \r
 {\r
-  {
+  {\r
       HARDWARE_DEVICE_PATH,\r
       HW_VENDOR_DP,\r
       HARDWARE_DEVICE_PATH,\r
       HW_VENDOR_DP,\r
-      {
+      {\r
         (UINT8) (sizeof (VENDOR_DEVICE_PATH)),\r
         (UINT8) (sizeof (VENDOR_DEVICE_PATH)),\r
-        (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8),\r
-      },
+        (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8)\r
+      },\r
       EFI_UNIX_THUNK_PROTOCOL_GUID\r
   },\r
   {\r
       HARDWARE_DEVICE_PATH,\r
       HW_VENDOR_DP,\r
       EFI_UNIX_THUNK_PROTOCOL_GUID\r
   },\r
   {\r
       HARDWARE_DEVICE_PATH,\r
       HW_VENDOR_DP,\r
-      {
+      {\r
         (UINT8) (sizeof (UNIX_VENDOR_DEVICE_PATH_NODE)),\r
         (UINT8) (sizeof (UNIX_VENDOR_DEVICE_PATH_NODE)),\r
-        (UINT8) ((sizeof (UNIX_VENDOR_DEVICE_PATH_NODE)) >> 8),\r
-      },
+        (UINT8) ((sizeof (UNIX_VENDOR_DEVICE_PATH_NODE)) >> 8)\r
+      },\r
       EFI_UNIX_UGA_GUID,\r
       0\r
   },\r
       EFI_UNIX_UGA_GUID,\r
       0\r
   },\r
@@ -58,19 +58,19 @@ UNIX_PLATFORM_UGA_DEVICE_PATH gUgaDevicePath1 = {
   {\r
       HARDWARE_DEVICE_PATH,\r
       HW_VENDOR_DP,\r
   {\r
       HARDWARE_DEVICE_PATH,\r
       HW_VENDOR_DP,\r
-      {
+      {\r
         (UINT8) (sizeof (VENDOR_DEVICE_PATH)),\r
         (UINT8) (sizeof (VENDOR_DEVICE_PATH)),\r
-        (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8),\r
-      },
+        (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8)\r
+      },\r
       EFI_UNIX_THUNK_PROTOCOL_GUID\r
   },\r
   {\r
       HARDWARE_DEVICE_PATH,\r
       HW_VENDOR_DP,\r
       EFI_UNIX_THUNK_PROTOCOL_GUID\r
   },\r
   {\r
       HARDWARE_DEVICE_PATH,\r
       HW_VENDOR_DP,\r
-      {
+      {\r
         (UINT8) (sizeof (UNIX_VENDOR_DEVICE_PATH_NODE)),\r
         (UINT8) (sizeof (UNIX_VENDOR_DEVICE_PATH_NODE)),\r
-        (UINT8) ((sizeof (UNIX_VENDOR_DEVICE_PATH_NODE)) >> 8),\r
-      },
+        (UINT8) ((sizeof (UNIX_VENDOR_DEVICE_PATH_NODE)) >> 8)\r
+      },\r
       EFI_UNIX_UGA_GUID,\r
       1\r
   },\r
       EFI_UNIX_UGA_GUID,\r
       1\r
   },\r
@@ -80,20 +80,20 @@ UNIX_PLATFORM_UGA_DEVICE_PATH gUgaDevicePath1 = {
 UNIX_CONSOLE_DEVICE_PATH   gUnixConsoleDevicePath = {\r
   {\r
       HARDWARE_DEVICE_PATH,\r
 UNIX_CONSOLE_DEVICE_PATH   gUnixConsoleDevicePath = {\r
   {\r
       HARDWARE_DEVICE_PATH,\r
-      HW_VENDOR_DP,
+      HW_VENDOR_DP,\r
       {\r
         (UINT8) (sizeof (VENDOR_DEVICE_PATH)),\r
       {\r
         (UINT8) (sizeof (VENDOR_DEVICE_PATH)),\r
-        (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8),\r
-      },
+        (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8)\r
+      },\r
       EFI_UNIX_THUNK_PROTOCOL_GUID\r
   },\r
   {\r
       HARDWARE_DEVICE_PATH,\r
       EFI_UNIX_THUNK_PROTOCOL_GUID\r
   },\r
   {\r
       HARDWARE_DEVICE_PATH,\r
-      HW_VENDOR_DP,
+      HW_VENDOR_DP,\r
       {\r
         (UINT8) (sizeof (UNIX_VENDOR_DEVICE_PATH_NODE)),\r
       {\r
         (UINT8) (sizeof (UNIX_VENDOR_DEVICE_PATH_NODE)),\r
-        (UINT8) ((sizeof (UNIX_VENDOR_DEVICE_PATH_NODE)) >> 8),\r
-      },
+        (UINT8) ((sizeof (UNIX_VENDOR_DEVICE_PATH_NODE)) >> 8)\r
+      },\r
       EFI_UNIX_CONSOLE_GUID,\r
       0  \r
   },   \r
       EFI_UNIX_CONSOLE_GUID,\r
       0  \r
   },   \r
index 9a3e16e7926c5c54b6a7c195e37085e504649ee9..8623e91036197da75f0fea33fd936ef1ba1c92be 100644 (file)
@@ -64,7 +64,7 @@
 \r
 \r
 [Packages]\r
 \r
 \r
 [Packages]\r
-  MdePkg/MdePkg.dec
+  MdePkg/MdePkg.dec\r
   MdeModulePkg/MdeModulePkg.dec\r
   IntelFrameworkPkg/IntelFrameworkPkg.dec\r
   IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec\r
   MdeModulePkg/MdeModulePkg.dec\r
   IntelFrameworkPkg/IntelFrameworkPkg.dec\r
   IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec\r
index b94e1f1776524ec88e641e593b6b46a18c0f520e..d34f6eeaa6c52aaedbb27929849d3e6a3af3fec8 100644 (file)
@@ -89,7 +89,7 @@ Returns:
 \r
   }\r
 \r
 \r
   }\r
 \r
-  gUnix->GetLocalTime (Time);
+  gUnix->GetLocalTime (Time);\r
 \r
   if (Capabilities != NULL) {\r
     Capabilities->Resolution  = 1;\r
 \r
   if (Capabilities != NULL) {\r
     Capabilities->Resolution  = 1;\r
index f583b649eb538c4b4e16865f49cfae46658bfee8..329ca0a89d30ae776d5d93136cf4daac7ab957fc 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
 /*++\r
 \r
-Copyright (c) 2004 - 2008, Intel Corporation                                                         \r
+Copyright (c) 2004 - 2009, Intel Corporation                                                         \r
 All rights reserved. This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
 All rights reserved. This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
@@ -113,9 +113,30 @@ Returns:
 \r
 --*/\r
 {\r
 \r
 --*/\r
 {\r
+  EFI_STATUS  Status;\r
+  UINTN       HandleCount;\r
+  EFI_HANDLE  *HandleBuffer;\r
+  UINTN       Index;\r
+\r
   //\r
   //\r
-  // BUGBUG Need to kill all console windows later\r
+  // Disconnect all\r
   //\r
   //\r
+  Status = gBS->LocateHandleBuffer (\r
+                  AllHandles,\r
+                  NULL,\r
+                  NULL,\r
+                  &HandleCount,\r
+                  &HandleBuffer\r
+                  );\r
+  if (!EFI_ERROR (Status)) {\r
+    for (Index = 0; Index < HandleCount; Index++) {\r
+      Status = gBS->DisconnectController (HandleBuffer[Index], NULL, NULL);\r
+    }\r
+  \r
+    gBS->FreePool (HandleBuffer);\r
+  }\r
+\r
+\r
   //\r
   // Discard ResetType, always return 0 as exit code\r
   //\r
   //\r
   // Discard ResetType, always return 0 as exit code\r
   //\r
@@ -124,6 +145,7 @@ Returns:
   //\r
   // Should never go here\r
   //\r
   //\r
   // Should never go here\r
   //\r
-  while (1)
-    ;
+  ASSERT (FALSE);\r
+\r
+  return;\r
 }\r
 }\r
diff --git a/UnixPkg/Sec/Ia32/Stack.S b/UnixPkg/Sec/Ia32/Stack.S
new file mode 100644 (file)
index 0000000..4716af9
--- /dev/null
@@ -0,0 +1,95 @@
+#------------------------------------------------------------------------------\r
+#\r
+# Copyright (c) 2008 - 2009, Intel Corporation\r
+# Portions copyright (c) 2008-2009 Apple Inc.\r
+# All rights reserved. This program and the accompanying materials\r
+# are licensed and made available under the terms and conditions of the BSD License\r
+# which accompanies this distribution.  The full text of the license may be found at\r
+# http://opensource.org/licenses/bsd-license.php\r
+#\r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+# Module Name:\r
+#\r
+#   Stack.asm\r
+#\r
+# Abstract:\r
+#\r
+#   Switch the stack from temporary memory to permenent memory.\r
+#\r
+#------------------------------------------------------------------------------\r
+\r
+#------------------------------------------------------------------------------\r
+# VOID\r
+# EFIAPI\r
+# SecSwitchStack (\r
+#   UINT32   TemporaryMemoryBase,\r
+#   UINT32   PermenentMemoryBase\r
+#   );\r
+#------------------------------------------------------------------------------    \r
+\r
+#include <ProcessorBind.h>\r
+\r
+ASM_GLOBAL ASM_PFX(SecSwitchStack)\r
+ASM_PFX(SecSwitchStack):\r
+#\r
+# Save three register: eax, ebx, ecx\r
+#    \r
+    push  %eax\r
+    push  %ebx\r
+    push  %ecx\r
+    push  %edx\r
+    \r
+#\r
+# !!CAUTION!! this function address's is pushed into stack after\r
+# migration of whole temporary memory, so need save it to permenent\r
+# memory at first!\r
+#    \r
+    \r
+    movl  20(%esp), %ebx            # Save the first parameter\r
+    movl  24(%esp), %ecx            # Save the second parameter\r
+    \r
+#\r
+# Save this function's return address into permenent memory at first.\r
+# Then, Fixup the esp point to permenent memory\r
+#\r
+\r
+    movl  %esp, %eax\r
+    subl  %ebx, %eax\r
+    addl  %ecx, %eax\r
+    movl  (%esp), %edx                 # copy pushed register's value to permenent memory\r
+    movl  %edx, (%eax)\r
+    movl  4(%esp), %edx\r
+    movl  %edx, 4(%eax)\r
+    movl  8(%esp), %edx\r
+    movl  %edx, 8(%eax)\r
+    movl  12(%esp), %edx\r
+    movl  %edx, 12(%eax)\r
+    movl  16(%esp), %edx\r
+    movl  %edx, 16(%eax)\r
+    movl  %eax, %esp                   # From now, esp is pointed to permenent memory\r
+\r
+#\r
+# Fixup the ebp point to permenent memory\r
+#\r
+#ifndef __APPLE__\r
+    movl   %ebp, %eax\r
+    subl   %ebx, %eax\r
+    addl   %ecx, %eax\r
+    movl   %eax, %ebp                  # From now, ebp is pointed to permenent memory\r
+    \r
+#\r
+# Fixup callee's ebp point for PeiDispatch\r
+#    \r
+    movl   (%ebp), %eax\r
+    subl   %ebx, %eax\r
+    addl   %ecx, %eax\r
+    movl   %eax, (%ebp)                # From now, Temporary's PPI caller's stack is in permenent memory\r
+#endif    \r
+    \r
+    pop   %edx\r
+    pop   %ecx\r
+    pop   %ebx\r
+    pop   %eax\r
+    ret\r
index 4e09ddc3e137ea843768cc0da564e6131f0387ee..b1490aef56e6c92daf1901306e25a623f299ef58 100644 (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
 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
 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
@@ -14,7 +15,7 @@ Module Name:
   SecMain.c
 
 Abstract:
   SecMain.c
 
 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.
 
   This program processes host environment variables and figures out
   Ok since all the other modules for NT32 are NOT Posix applications.
 
   This program processes host environment variables and figures out
@@ -35,21 +36,29 @@ Abstract:
 #include "SecMain.h"
 #include <sys/mman.h>
 #include <Ppi/UnixPeiLoadFile.h>
 #include "SecMain.h"
 #include <sys/mman.h>
 #include <Ppi/UnixPeiLoadFile.h>
+#include <Framework/StatusCode.h>
 #include <Ppi/TemporaryRamSupport.h>
 #include <dlfcn.h>
 #include <Ppi/TemporaryRamSupport.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,
     &gUnixPeiLoadFilePpiGuid,
   {
     EFI_PEI_PPI_DESCRIPTOR_PPI,
     &gUnixPeiLoadFilePpiGuid,
-    &mSecNtLoadFilePpi
+    &mSecUnixLoadFilePpi
   },
   {
     EFI_PEI_PPI_DESCRIPTOR_PPI,
     &gPeiUnixAutoScanPpiGuid,
   },
   {
     EFI_PEI_PPI_DESCRIPTOR_PPI,
     &gPeiUnixAutoScanPpiGuid,
-    &mSecNtAutoScanPpi
+    &mSecUnixAutoScanPpi
   },
   {
     EFI_PEI_PPI_DESCRIPTOR_PPI,
     &gPeiUnixThunkPpiGuid,
   },
   {
     EFI_PEI_PPI_DESCRIPTOR_PPI,
     &gPeiUnixThunkPpiGuid,
-    &mSecWinNtThunkPpi
+    &mSecUnixThunkPpi
   },
   {
     EFI_PEI_PPI_DESCRIPTOR_PPI,
   },
   {
     EFI_PEI_PPI_DESCRIPTOR_PPI,
@@ -107,6 +116,12 @@ UNIX_FD_INFO                                *gFdInfo;
 UINTN                                     gSystemMemoryCount = 0;
 UNIX_SYSTEM_MEMORY                       *gSystemMemory;
 
 UINTN                                     gSystemMemoryCount = 0;
 UNIX_SYSTEM_MEMORY                       *gSystemMemory;
 
+
+
+UINTN                        mImageContextModHandleArraySize = 0;
+IMAGE_CONTEXT_TO_MOD_HANDLE  *mImageContextModHandleArray = NULL;
+
+
 VOID
 EFIAPI
 SecSwitchStack (
 VOID
 EFIAPI
 SecSwitchStack (
@@ -134,17 +149,16 @@ SecNt32PeCoffRelocateImage (
   );
 
 
   );
 
 
-INTN
-EFIAPI
+int
 main (
 main (
-  IN  INTN  Argc,
-  IN  CHAR8 **Argv,
-  IN  CHAR8 **Envp
+  IN  int   Argc,
+  IN  char  **Argv,
+  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:
   Argc - Number of command line arguments
 
 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.
   //  on a real platform this would be SRAM, or using the cache as RAM.
 
   //
   // 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.
-  //  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;
   InitialStackMemory = (UINTN)MapMemory(0, 
   //
   InitialStackMemorySize  = STACK_SIZE;
   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);
     
   for (StackPointer = (UINTN*) (UINTN) InitialStackMemory;
     (unsigned long)InitialStackMemory);
     
   for (StackPointer = (UINTN*) (UINTN) InitialStackMemory;
-     StackPointer < (UINTN*) ((UINTN) InitialStackMemory + (UINT64) InitialStackMemorySize);
+     StackPointer < (UINTN*)(UINTN)((UINTN) InitialStackMemory + (UINT64) InitialStackMemorySize);
      StackPointer ++) {
     *StackPointer = 0x5AA55AA5;
   }
      StackPointer ++) {
     *StackPointer = 0x5AA55AA5;
   }
@@ -255,7 +282,7 @@ Returns:
                      &gFdInfo[Index].Size
                      );
     if (EFI_ERROR (Status)) {
                      &gFdInfo[Index].Size
                      );
     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.
 
 Arguments:
   the process will try and allocate the memory starting at BaseAddress.
 
 Arguments:
@@ -415,12 +442,12 @@ Returns:
 EFI_STATUS
 EFIAPI
 SecPeiReportStatusCode (
 EFI_STATUS
 EFIAPI
 SecPeiReportStatusCode (
-  IN EFI_PEI_SERVICES           **PeiServices,
+  IN CONST EFI_PEI_SERVICES     **PeiServices,
   IN EFI_STATUS_CODE_TYPE       CodeType,
   IN EFI_STATUS_CODE_VALUE      Value,
   IN UINT32                     Instance,
   IN EFI_STATUS_CODE_TYPE       CodeType,
   IN EFI_STATUS_CODE_VALUE      Value,
   IN UINT32                     Instance,
-  IN EFI_GUID                   * CallerId,
-  IN EFI_STATUS_CODE_DATA       * Data OPTIONAL
+  IN CONST EFI_GUID             *CallerId,
+  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,
             &PeiImageAddress,
             &PeiCoreSize,
             PeiCorePe32File,
             &PeiImageAddress,
             &PeiCoreSize,
@@ -633,7 +660,7 @@ Returns:
 
 EFI_STATUS
 EFIAPI
 
 EFI_STATUS
 EFIAPI
-SecWinNtPeiAutoScan (
+SecUnixPeiAutoScan (
   IN  UINTN                 Index,
   OUT EFI_PHYSICAL_ADDRESS  *MemoryBase,
   OUT UINT64                *MemorySize
   IN  UINTN                 Index,
   OUT EFI_PHYSICAL_ADDRESS  *MemoryBase,
   OUT UINT64                *MemorySize
@@ -646,7 +673,7 @@ Routine Description:
   It uses gSystemMemory[] and gSystemMemoryCount that were created by
   parsing the host environment variable EFI_MEMORY_SIZE.
   The size comes from the varaible and the address comes from the call to
   It uses gSystemMemory[] and gSystemMemoryCount that were created by
   parsing the host environment variable EFI_MEMORY_SIZE.
   The size comes from the varaible and the address comes from the call to
-  WinNtOpenFile.
+  UnixOpenFile.
 
 Arguments:
   Index      - Which memory region to use
 
 Arguments:
   Index      - Which memory region to use
@@ -680,19 +707,18 @@ Returns:
 
 VOID *
 EFIAPI
 
 VOID *
 EFIAPI
-SecWinNtWinNtThunkAddress (
+SecUnixUnixThunkAddress (
   VOID
   )
 /*++
 
 Routine Description:
   Since the SEC is the only Unix program in stack it must export
   VOID
   )
 /*++
 
 Routine Description:
   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
-  is for. gWinNt is initailized in WinNtThunk.c.
+  an interface to do POSIX calls.  gUnix is initailized in UnixThunk.c.
 
 Arguments:
   InterfaceSize - sizeof (EFI_WIN_NT_THUNK_PROTOCOL);
 
 Arguments:
   InterfaceSize - sizeof (EFI_WIN_NT_THUNK_PROTOCOL);
-  InterfaceBase - Address of the gWinNt global
+  InterfaceBase - Address of the gUnix global
 
 Returns:
   EFI_SUCCESS - Data returned
 
 Returns:
   EFI_SUCCESS - Data returned
@@ -704,12 +730,11 @@ Returns:
 
 
 EFI_STATUS
 
 
 EFI_STATUS
-EFIAPI
-SecWinNtPeiLoadFile (
+SecUnixPeiLoadFile (
   IN  VOID                    *Pe32Data,
   IN  VOID                    *Pe32Data,
-  IN  EFI_PHYSICAL_ADDRESS    *ImageAddress,
-  IN  UINT64                  *ImageSize,
-  IN  EFI_PHYSICAL_ADDRESS    *EntryPoint
+  OUT EFI_PHYSICAL_ADDRESS    *ImageAddress,
+  OUT UINT64                  *ImageSize,
+  OUT EFI_PHYSICAL_ADDRESS    *EntryPoint
   )
 /*++
 
   )
 /*++
 
@@ -759,10 +784,7 @@ Returns:
     return Status;
   }
 
     return Status;
   }
 
-  Status = SecNt32PeCoffRelocateImage(&ImageContext);
-  if (EFI_ERROR (Status)) {
-    return Status;
-  }
+  SecPeCoffRelocateImageExtraAction (&ImageContext);
 
   //
   // 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
 EFIAPI
 EFI_STATUS
 EFIAPI
-SecWinNtFdAddress (
+SecUnixFdAddress (
   IN     UINTN                 Index,
   IN OUT EFI_PHYSICAL_ADDRESS  *FdBase,
   IN OUT UINT64                *FdSize
   IN     UINTN                 Index,
   IN OUT EFI_PHYSICAL_ADDRESS  *FdBase,
   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
 SecUnixLoaderBreak (
 
 VOID
 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, 
      "Loading %s 0x%08lx - entry point 0x%08lx\n",
      ImageContext->PdbPointer,
   fprintf (stderr, 
      "Loading %s 0x%08lx - entry point 0x%08lx\n",
      ImageContext->PdbPointer,
@@ -918,23 +1195,63 @@ SecNt32PeCoffRelocateImage (
   }
   
   if (Entry != NULL) {
   }
   
   if (Entry != NULL) {
-    ImageContext->EntryPoint = Entry;
-    printf("Change %s Entrypoint to :0x%08lx\n", ImageContext->PdbPointer, Entry);
+    ImageContext->EntryPoint = (UINTN)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
index 236a50ee43bfb04eb832612647df1404fbdc1185..c7a72c93a6b0bbeaab3c3b4dc41b550ea0632b2c 100644 (file)
@@ -1,6 +1,7 @@
 /*++\r
 \r
 /*++\r
 \r
-Copyright (c) 2006 - 2008, Intel Corporation                                                         \r
+Copyright (c) 2006 - 2009, Intel Corporation                                                         \r
+Portions copyright (c) 2008-2009 Apple Inc.\r
 All rights reserved. This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
 All rights reserved. This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
@@ -28,6 +29,7 @@ Abstract:
 #include <Library/PrintLib.h>\r
 #include <Library/PcdLib.h>\r
 #include <Library/DebugLib.h>\r
 #include <Library/PrintLib.h>\r
 #include <Library/PcdLib.h>\r
 #include <Library/DebugLib.h>\r
+#include <Library/ReportStatusCodeLib.h>\r
 \r
 #define STACK_SIZE                0x20000      \r
 \r
 \r
 #define STACK_SIZE                0x20000      \r
 \r
@@ -42,10 +44,17 @@ typedef struct {
 } UNIX_SYSTEM_MEMORY;\r
 \r
 \r
 } UNIX_SYSTEM_MEMORY;\r
 \r
 \r
+#define MAX_IMAGE_CONTEXT_TO_MOD_HANDLE_ARRAY_SIZE 0x100\r
+\r
+typedef struct {\r
+  PE_COFF_LOADER_IMAGE_CONTEXT   *ImageContext;\r
+  VOID                           *ModHandle;\r
+} IMAGE_CONTEXT_TO_MOD_HANDLE;\r
+\r
 \r
 EFI_STATUS\r
 EFIAPI\r
 \r
 EFI_STATUS\r
 EFIAPI\r
-SecWinNtPeiLoadFile (\r
+SecUnixPeiLoadFile (\r
   VOID                  *Pe32Data,  // TODO: add IN/OUT modifier to Pe32Data\r
   EFI_PHYSICAL_ADDRESS  *ImageAddress,  // TODO: add IN/OUT modifier to ImageAddress\r
   UINT64                *ImageSize,  // TODO: add IN/OUT modifier to ImageSize\r
   VOID                  *Pe32Data,  // TODO: add IN/OUT modifier to Pe32Data\r
   EFI_PHYSICAL_ADDRESS  *ImageAddress,  // TODO: add IN/OUT modifier to ImageAddress\r
   UINT64                *ImageSize,  // TODO: add IN/OUT modifier to ImageSize\r
@@ -73,7 +82,7 @@ Returns:
 \r
 EFI_STATUS\r
 EFIAPI\r
 \r
 EFI_STATUS\r
 EFIAPI\r
-SecWinNtPeiAutoScan (\r
+SecUnixPeiAutoScan (\r
   IN  UINTN                 Index,\r
   OUT EFI_PHYSICAL_ADDRESS  *MemoryBase,\r
   OUT UINT64                *MemorySize\r
   IN  UINTN                 Index,\r
   OUT EFI_PHYSICAL_ADDRESS  *MemoryBase,\r
   OUT UINT64                *MemorySize\r
@@ -99,7 +108,7 @@ Returns:
 \r
 VOID *\r
 EFIAPI\r
 \r
 VOID *\r
 EFIAPI\r
-SecWinNtWinNtThunkAddress (\r
+SecUnixUnixThunkAddress (\r
   VOID\r
   )\r
 /*++\r
   VOID\r
   )\r
 /*++\r
@@ -122,7 +131,7 @@ Returns:
 \r
 EFI_STATUS\r
 EFIAPI\r
 \r
 EFI_STATUS\r
 EFIAPI\r
-SecWinNtWinNtFwhAddress (\r
+SecUnixUnixFwhAddress (\r
   IN OUT UINT64                *FwhSize,\r
   IN OUT EFI_PHYSICAL_ADDRESS  *FwhBase\r
   )\r
   IN OUT UINT64                *FwhSize,\r
   IN OUT EFI_PHYSICAL_ADDRESS  *FwhBase\r
   )\r
@@ -147,12 +156,12 @@ Returns:
 EFI_STATUS\r
 EFIAPI\r
 SecPeiReportStatusCode (\r
 EFI_STATUS\r
 EFIAPI\r
 SecPeiReportStatusCode (\r
-  IN EFI_PEI_SERVICES         **PeiServices,\r
+  IN CONST EFI_PEI_SERVICES     **PeiServices,\r
   IN EFI_STATUS_CODE_TYPE     CodeType,\r
   IN EFI_STATUS_CODE_VALUE    Value,\r
   IN UINT32                   Instance,\r
   IN EFI_STATUS_CODE_TYPE     CodeType,\r
   IN EFI_STATUS_CODE_VALUE    Value,\r
   IN UINT32                   Instance,\r
-  IN EFI_GUID                 * CallerId,\r
-  IN EFI_STATUS_CODE_DATA     * Data OPTIONAL\r
+  IN CONST EFI_GUID             *CallerId,\r
+  IN CONST EFI_STATUS_CODE_DATA *Data OPTIONAL\r
   )\r
 /*++\r
 \r
   )\r
 /*++\r
 \r
@@ -176,12 +185,11 @@ Returns:
 --*/\r
 ;\r
 \r
 --*/\r
 ;\r
 \r
-INTN\r
-EFIAPI\r
+int\r
 main (\r
 main (\r
-  IN  INTN  Argc,\r
-  IN  CHAR8 **Argv,\r
-  IN  CHAR8 **Envp\r
+  IN  int   Argc,\r
+  IN  char  **Argv,\r
+  IN  char  **Envp\r
   )\r
 /*++\r
 \r
   )\r
 /*++\r
 \r
@@ -331,7 +339,7 @@ Returns:
 \r
 EFI_STATUS\r
 EFIAPI\r
 \r
 EFI_STATUS\r
 EFIAPI\r
-SecWinNtPeCoffLoaderLoadAsDll (\r
+SecUnixPeCoffLoaderLoadAsDll (\r
   IN CHAR8    *PdbFileName,\r
   IN VOID     **ImageEntryPoint,\r
   OUT VOID    **ModHandle\r
   IN CHAR8    *PdbFileName,\r
   IN VOID     **ImageEntryPoint,\r
   OUT VOID    **ModHandle\r
@@ -357,7 +365,7 @@ Returns:
 \r
 EFI_STATUS\r
 EFIAPI\r
 \r
 EFI_STATUS\r
 EFIAPI\r
-SecWinNtPeCoffLoaderFreeLibrary (\r
+SecUnixPeCoffLoaderFreeLibrary (\r
   OUT VOID    *ModHandle\r
   )\r
 /*++\r
   OUT VOID    *ModHandle\r
   )\r
 /*++\r
@@ -379,7 +387,7 @@ Returns:
 \r
 EFI_STATUS\r
 EFIAPI\r
 \r
 EFI_STATUS\r
 EFIAPI\r
-SecWinNtFdAddress (\r
+SecUnixFdAddress (\r
   IN     UINTN                 Index,\r
   IN OUT EFI_PHYSICAL_ADDRESS  *FdBase,\r
   IN OUT UINT64                *FdSize\r
   IN     UINTN                 Index,\r
   IN OUT EFI_PHYSICAL_ADDRESS  *FdBase,\r
   IN OUT UINT64                *FdSize\r
@@ -509,4 +517,25 @@ SecTemporaryRamSupport (
   IN UINTN                    CopySize\r
   );\r
 \r
   IN UINTN                    CopySize\r
   );\r
 \r
+\r
+RETURN_STATUS\r
+EFIAPI\r
+SecPeCoffGetEntryPoint (\r
+  IN     VOID  *Pe32Data,\r
+  IN OUT VOID  **EntryPoint\r
+  );\r
+\r
+VOID\r
+EFIAPI\r
+SecPeCoffRelocateImageExtraAction (\r
+  IN OUT PE_COFF_LOADER_IMAGE_CONTEXT  *ImageContext\r
+  );\r
+\r
+VOID\r
+EFIAPI\r
+SecPeCoffLoaderUnloadImageExtraAction (\r
+  IN OUT PE_COFF_LOADER_IMAGE_CONTEXT  *ImageContext\r
+  );\r
+\r
+\r
 extern EFI_UNIX_THUNK_PROTOCOL  *gUnix;\r
 extern EFI_UNIX_THUNK_PROTOCOL  *gUnix;\r
index a0c92687a98c942ed30eeaf8a6e25891b6fb7f00..c7a9b40df7b16b2dd0d001a190229e762d0f9a9d 100644 (file)
@@ -2,7 +2,8 @@
 # Entry Point of Unix Emulator\r
 #\r
 # Main executable file of Unix Emulator that loads PEI core after initialization finished.\r
 # Entry Point of Unix Emulator\r
 #\r
 # Main executable file of Unix Emulator that loads PEI core after initialization finished.\r
-# Copyright (c) 2008, Intel Corporation\r
+# Copyright (c) 2008 - 2009, Intel Corporation\r
+# Portions copyright (c) 2008-2009 Apple Inc.\r
 #\r
 #  All rights reserved. This program and the accompanying materials\r
 #  are licensed and made available under the terms and conditions of the BSD License\r
 #\r
 #  All rights reserved. This program and the accompanying materials\r
 #  are licensed and made available under the terms and conditions of the BSD License\r
   UnixThunk.c\r
   FwVol.c\r
   SecMain.c\r
   UnixThunk.c\r
   FwVol.c\r
   SecMain.c\r
-  Stack.S\r
+  \r
+[Sources.Ia32]  \r
+  Ia32/Gasket.S\r
+  Ia32/Stack.S\r
 \r
 [Packages]\r
   MdePkg/MdePkg.dec\r
 \r
 [Packages]\r
   MdePkg/MdePkg.dec\r
    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\r
    GCC:*_*_IA32_PP_FLAGS == -m32 -E -x assembler-with-cpp -include $(DEST_DIR_DEBUG)/AutoGen.h\r
    GCC:*_*_IA32_ASM_FLAGS == -c -x assembler -imacros $(DEST_DIR_DEBUG)/AutoGen.h\r
    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\r
    GCC:*_*_IA32_PP_FLAGS == -m32 -E -x assembler-with-cpp -include $(DEST_DIR_DEBUG)/AutoGen.h\r
    GCC:*_*_IA32_ASM_FLAGS == -c -x assembler -imacros $(DEST_DIR_DEBUG)/AutoGen.h\r
+\r
+#\r
+# Need to do this link via gcc and not ld as the pathing to libraries changes from OS version to OS version\r
+#\r
+   XCODE:*_*_IA32_DLINK_PATH == gcc\r
+   XCODE:*_*_IA32_DLINK_FLAGS == -arch i386  -L/usr/X11R6/lib -lXext -lX11 -lIOKit -framework Carbon           \r
+   XCODE:*_*_IA32_ASM_FLAGS == -arch i386 -g\r
index 1c68b328d35eadd6a02abfe857e6e65a5ab6f28e..386e0bc14595f56fb847b416c688bb0790cad233 100644 (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/shm.h>
 #include <sys/ipc.h>
 #include <sys/shm.h>
-#include <sys/dir.h>
 #include <stdio.h>
 #include <stdlib.h>
 
 #include <stdio.h>
 #include <stdlib.h>
 
@@ -123,8 +136,15 @@ TryCreateShmImage(UGA_IO_PRIVATE *drv)
       XDestroyImage(drv->image);
       return 0;
     }
       XDestroyImage(drv->image);
       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 ?  */
   shmctl (drv->xshm_info.shmid, IPC_RMID, NULL);
   /* Can this fail ?  */
   shmctl (drv->xshm_info.shmid, IPC_RMID, NULL);
+#endif
 
   drv->xshm_info.shmaddr = (char*)drv->image_data;
   drv->image->data = (char*)drv->image_data;
 
   drv->xshm_info.shmaddr = (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);
   XCloseDisplay(drv->display);
     }
   XDestroyWindow(drv->display, drv->win);
   XCloseDisplay(drv->display);
+  
+#ifdef __APPLE__
+  // Free up the shared memory
+  shmctl (drv->xshm_info.shmid, IPC_RMID, NULL);
+#endif
+  
   free(drv);
   return EFI_SUCCESS;
 }
   free(drv);
   return EFI_SUCCESS;
 }
@@ -534,16 +560,45 @@ UgaCreate (EFI_UNIX_UGA_IO_PROTOCOL **Uga, CONST CHAR16 *Title)
   char *display_name = NULL;
   int title_len;
 
   char *display_name = NULL;
   int title_len;
 
-  drv = (UGA_IO_PRIVATE *)
-    calloc (1, sizeof (UGA_IO_PRIVATE));
+  drv = (UGA_IO_PRIVATE *)calloc (1, sizeof (UGA_IO_PRIVATE));
   if (drv == NULL)
     return EFI_OUT_OF_RESOURCES;
 
   if (drv == NULL)
     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.UgaSize = UgaSize;
   drv->UgaIo.UgaCheckKey = UgaCheckKey;
   drv->UgaIo.UgaGetKey = UgaGetKey;
   drv->UgaIo.UgaBlt = UgaBlt;
   drv->UgaIo.UgaClose = UgaClose;
   drv->UgaIo.UgaSize = UgaSize;
   drv->UgaIo.UgaCheckKey = UgaCheckKey;
   drv->UgaIo.UgaGetKey = UgaGetKey;
   drv->UgaIo.UgaBlt = UgaBlt;
+#endif
+  
+  
 
   drv->key_count = 0;
   drv->key_rd = 0;
 
   drv->key_count = 0;
   drv->key_rd = 0;
index 8cf64b9d2e6dc45eb411384d324f4b81c5de5e89..5dfba7a73436e7adab2ee3c3a92f2d848a35eeea 100644 (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                          
 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        
 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        
@@ -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
 UgaCreate(struct _EFI_UNIX_UGA_IO_PROTOCOL **UgaIo, CONST CHAR16 *Title);
 
 EFI_UNIX_THUNK_PROTOCOL mUnixThunkTable = {
   EFI_UNIX_THUNK_PROTOCOL_SIGNATURE,
 extern EFI_STATUS
 UgaCreate(struct _EFI_UNIX_UGA_IO_PROTOCOL **UgaIo, CONST CHAR16 *Title);
 
 EFI_UNIX_THUNK_PROTOCOL mUnixThunkTable = {
   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 */
   exit, /* Exit */
   SetTimer,
   msSleep, /* Sleep */
   exit, /* Exit */
   SetTimer,
@@ -166,8 +292,8 @@ EFI_UNIX_THUNK_PROTOCOL mUnixThunkTable = {
   (UnixWrite)write,
   getenv,
   (UnixOpen)open,
   (UnixWrite)write,
   getenv,
   (UnixOpen)open,
-  lseek,
-  ftruncate,
+  (UnixSeek)lseek,
+  (UnixFtruncate)ftruncate,
   close,
   mkdir,
   rmdir,
   close,
   mkdir,
   rmdir,
@@ -195,7 +321,11 @@ EFI_UNIX_THUNK_PROTOCOL mUnixThunkTable = {
   tcsetattr,
   dlopen,
   dlerror,
   tcsetattr,
   dlopen,
   dlerror,
-  dlsym
+  dlsym,
+  SecPeCoffGetEntryPoint,
+  SecPeCoffRelocateImageExtraAction,
+  SecPeCoffLoaderUnloadImageExtraAction
+#endif
 };
 
 
 };
 
 
index 53b5656f7cccaa7425a8f987c0f22679cd49b4ad..7f43a368e2e6bd8ff3f2466560f472998ec870db 100644 (file)
@@ -62,7 +62,7 @@ UINT64                  mTimerPeriodMs;
 \r
 \r
 VOID\r
 \r
 \r
 VOID\r
-TimerCallback (UINT64 DeltaMs)
+TimerCallback (UINT64 DeltaMs)\r
 /*++\r
 \r
 Routine Description:\r
 /*++\r
 \r
 Routine Description:\r
@@ -84,12 +84,12 @@ Returns:
 --*/\r
 {\r
   EFI_TPL           OriginalTPL;\r
 --*/\r
 {\r
   EFI_TPL           OriginalTPL;\r
-  EFI_TIMER_NOTIFY  CallbackFunction;
-
+  EFI_TIMER_NOTIFY  CallbackFunction;\r
+\r
 \r
   OriginalTPL = gBS->RaiseTPL (TPL_HIGH_LEVEL);\r
 \r
 \r
   OriginalTPL = gBS->RaiseTPL (TPL_HIGH_LEVEL);\r
 \r
-  if (OriginalTPL < TPL_HIGH_LEVEL) {
+  if (OriginalTPL < TPL_HIGH_LEVEL) {\r
     CallbackFunction = mTimerNotifyFunction;\r
 \r
     //\r
     CallbackFunction = mTimerNotifyFunction;\r
 \r
     //\r
@@ -99,7 +99,7 @@ Returns:
     if (CallbackFunction != NULL) {\r
       CallbackFunction ((UINT64) (DeltaMs * 10000));\r
     }\r
     if (CallbackFunction != NULL) {\r
       CallbackFunction ((UINT64) (DeltaMs * 10000));\r
     }\r
-  }
+  }\r
 \r
   gBS->RestoreTPL (OriginalTPL);\r
 \r
 \r
   gBS->RestoreTPL (OriginalTPL);\r
 \r
@@ -164,13 +164,13 @@ Returns:
     return EFI_ALREADY_STARTED;\r
   }\r
 \r
     return EFI_ALREADY_STARTED;\r
   }\r
 \r
-  if (NotifyFunction == NULL) {
-    /* Disable timer.  */
-    gUnix->SetTimer (0, TimerCallback);
-  } else if (mTimerNotifyFunction == NULL) {
-    /* Enable Timer.  */
-    gUnix->SetTimer (mTimerPeriodMs, TimerCallback);
-  }
+  if (NotifyFunction == NULL) {\r
+    /* Disable timer.  */\r
+    gUnix->SetTimer (0, TimerCallback);\r
+  } else if (mTimerNotifyFunction == NULL) {\r
+    /* Enable Timer.  */\r
+    gUnix->SetTimer (mTimerPeriodMs, TimerCallback);\r
+  }\r
   mTimerNotifyFunction = NotifyFunction;\r
 \r
   return EFI_SUCCESS;\r
   mTimerNotifyFunction = NotifyFunction;\r
 \r
   return EFI_SUCCESS;\r
@@ -224,13 +224,13 @@ Returns:
   // If TimerPeriod is 0, then the timer thread should be canceled\r
   // If the TimerPeriod is valid, then create and/or adjust the period of the timer thread\r
   //\r
   // If TimerPeriod is 0, then the timer thread should be canceled\r
   // If the TimerPeriod is valid, then create and/or adjust the period of the timer thread\r
   //\r
-  if (TimerPeriod == 0
-      || ((TimerPeriod > TIMER_MINIMUM_VALUE)
+  if (TimerPeriod == 0\r
+      || ((TimerPeriod > TIMER_MINIMUM_VALUE)\r
          && (TimerPeriod < TIMER_MAXIMUM_VALUE))) {\r
     mTimerPeriodMs = DivU64x32 (TimerPeriod + 5000, 10000);\r
          && (TimerPeriod < TIMER_MAXIMUM_VALUE))) {\r
     mTimerPeriodMs = DivU64x32 (TimerPeriod + 5000, 10000);\r
-
-    gUnix->SetTimer (mTimerPeriodMs, TimerCallback);
-  }
+\r
+    gUnix->SetTimer (mTimerPeriodMs, TimerCallback);\r
+  }\r
 \r
   return EFI_SUCCESS;\r
 }\r
 \r
   return EFI_SUCCESS;\r
 }\r
@@ -369,6 +369,6 @@ Returns:
   if (EFI_ERROR (Status)) {\r
     return Status;\r
   }\r
   if (EFI_ERROR (Status)) {\r
     return Status;\r
   }\r
-
+\r
   return EFI_SUCCESS;\r
 }\r
   return EFI_SUCCESS;\r
 }\r
index 0e9a32c66a3b9bd77a49ef3e41b891ca70163953..e4c5df99c4fd6f912c93a8b515d87d8ee99b8e33 100644 (file)
@@ -148,7 +148,7 @@ UnixBlockIoDriverDiagnosticsRunDiagnostics (
   if (DiagnosticType != EfiDriverDiagnosticTypeStandard) {\r
     *ErrorType  = &gEfiBlockIoProtocolGuid;\r
     *BufferSize = 0x60;\r
   if (DiagnosticType != EfiDriverDiagnosticTypeStandard) {\r
     *ErrorType  = &gEfiBlockIoProtocolGuid;\r
     *BufferSize = 0x60;\r
-    gBS->AllocatePool (EfiBootServicesData, (UINTN) (*BufferSize),
+    gBS->AllocatePool (EfiBootServicesData, (UINTN) (*BufferSize),\r
                       (void *)Buffer);\r
     CopyMem (*Buffer, L"Unix Block I/O Driver Diagnostics Failed\n", *BufferSize);\r
     return EFI_DEVICE_ERROR;\r
                       (void *)Buffer);\r
     CopyMem (*Buffer, L"Unix Block I/O Driver Diagnostics Failed\n", *BufferSize);\r
     return EFI_DEVICE_ERROR;\r
index a483a876dcdda9ea5250da332d7b7dfcf42a0b6c..c3bd3d38c6170fd678176e9437b04649e06691f1 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
 /*++\r
 \r
-Copyright (c) 2004 - 2007, Intel Corporation                                                         \r
+Copyright (c) 2004 - 2009, Intel Corporation                                                         \r
 All rights reserved. This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
 All rights reserved. This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
@@ -1276,6 +1276,7 @@ This function extends the capability of SetFilePointer to accept 64 bit paramete
   EFI_STATUS    Status;\r
   off_t         res;\r
 \r
   EFI_STATUS    Status;\r
   off_t         res;\r
 \r
+  Status = EFI_SUCCESS;\r
   res = Private->UnixThunk->Lseek(Private->fd, DistanceToMove, MoveMethod);\r
   if (res == -1) {\r
     Status = EFI_INVALID_PARAMETER;\r
   res = Private->UnixThunk->Lseek(Private->fd, DistanceToMove, MoveMethod);\r
   if (res == -1) {\r
     Status = EFI_INVALID_PARAMETER;\r
index 70ab77ef368a0c15824dd5a3afa1cd126bece7ea..693f20e55c6f1c542109a9753193aee946beb47f 100644 (file)
@@ -56,7 +56,7 @@ typedef struct {
   UINTN                       ReadMode;\r
   UINTN                       Mode;\r
 \r
   UINTN                       ReadMode;\r
   UINTN                       Mode;\r
 \r
-  int                         fd;
+  int                         fd;\r
 \r
   UINT64                      LastBlock;\r
   UINTN                       BlockSize;\r
 \r
   UINT64                      LastBlock;\r
   UINTN                       BlockSize;\r
index 7a3c7da8b9959280366257a3a311de085067b423..a3ab0e173ed774fef4295aa0cc73dfb03e93ba44 100644 (file)
@@ -94,7 +94,7 @@ typedef struct {
   UINTN RowsY;\r
 } UNIX_SIMPLE_TEXT_OUT_MODE;\r
 \r
   UINTN RowsY;\r
 } UNIX_SIMPLE_TEXT_OUT_MODE;\r
 \r
-#if 0
+#if 0\r
 //\r
 // Simple Text Out protocol member functions\r
 //\r
 //\r
 // Simple Text Out protocol member functions\r
 //\r
@@ -319,7 +319,7 @@ Returns:
 --*/\r
 ;\r
 \r
 --*/\r
 ;\r
 \r
-#endif
+#endif\r
 //\r
 // Simple Text Out constructor and destructor.\r
 //\r
 //\r
 // Simple Text Out constructor and destructor.\r
 //\r
@@ -365,7 +365,7 @@ Returns:
 --*/\r
 ;\r
 \r
 --*/\r
 ;\r
 \r
-#if 0
+#if 0\r
 //\r
 // Simple Text In protocol member functions.\r
 //\r
 //\r
 // Simple Text In protocol member functions.\r
 //\r
@@ -441,7 +441,7 @@ Returns:
 --*/\r
 ;\r
 \r
 --*/\r
 ;\r
 \r
-#endif
+#endif\r
 //\r
 // Simple Text In constructor\r
 //\r
 //\r
 // Simple Text In constructor\r
 //\r
index 821ff2c805772cec830f3b9bbf01dcc87f655526..6ab68956e954de12a34aa77f2d3ce9749a455752 100644 (file)
@@ -27,7 +27,7 @@ Abstract:
 --*/\r
 \r
 #include "Console.h"\r
 --*/\r
 \r
 #include "Console.h"\r
-#include <sys/poll.h>
+#include <sys/poll.h>\r
 \r
 //\r
 // Private worker functions\r
 \r
 //\r
 // Private worker functions\r
@@ -68,7 +68,7 @@ Returns:
 \r
 EFI_STATUS\r
 UnixConvertInputRecordToEfiKey (\r
 \r
 EFI_STATUS\r
 UnixConvertInputRecordToEfiKey (\r
-  IN  char c,
+  IN  char c,\r
   OUT EFI_INPUT_KEY   *Key\r
   )\r
 /*++\r
   OUT EFI_INPUT_KEY   *Key\r
   )\r
 /*++\r
@@ -92,8 +92,8 @@ Returns:
 --*/\r
 {\r
   Key->ScanCode     = 0;\r
 --*/\r
 {\r
   Key->ScanCode     = 0;\r
-  if (c == '\n')
-    c = '\r';
+  if (c == '\n')\r
+    c = '\r';\r
   Key->UnicodeChar  = c;\r
   return EFI_SUCCESS;\r
 }\r
   Key->UnicodeChar  = c;\r
   return EFI_SUCCESS;\r
 }\r
@@ -124,7 +124,7 @@ Returns:
 {\r
   EFI_STATUS                      Status;\r
   UNIX_SIMPLE_TEXT_PRIVATE_DATA *Private;\r
 {\r
   EFI_STATUS                      Status;\r
   UNIX_SIMPLE_TEXT_PRIVATE_DATA *Private;\r
-  char c;
+  char c;\r
 \r
   Private = UNIX_SIMPLE_TEXT_IN_PRIVATE_DATA_FROM_THIS (This);\r
 \r
 \r
   Private = UNIX_SIMPLE_TEXT_IN_PRIVATE_DATA_FROM_THIS (This);\r
 \r
@@ -133,7 +133,7 @@ Returns:
     return Status;\r
   }\r
 \r
     return Status;\r
   }\r
 \r
-  if (Private->UnixThunk->Read (0, &c, 1) != 1)
+  if (Private->UnixThunk->Read (0, &c, 1) != 1)\r
     return EFI_NOT_READY;\r
   Status = UnixConvertInputRecordToEfiKey (c, Key);\r
 \r
     return EFI_NOT_READY;\r
   Status = UnixConvertInputRecordToEfiKey (c, Key);\r
 \r
@@ -193,11 +193,11 @@ Returns:
 \r
 --*/\r
 {\r
 \r
 --*/\r
 {\r
-  struct pollfd pfd;
+  struct pollfd pfd;\r
 \r
 \r
-  pfd.fd = 0;
-  pfd.events = POLLIN;
-  if (Private->UnixThunk->Poll (&pfd, 1, 0) <= 0) {
+  pfd.fd = 0;\r
+  pfd.events = POLLIN;\r
+  if (Private->UnixThunk->Poll (&pfd, 1, 0) <= 0) {\r
     return EFI_NOT_READY;\r
   }\r
   return EFI_SUCCESS;\r
     return EFI_NOT_READY;\r
   }\r
   return EFI_SUCCESS;\r
index 693cf60d01ccf3b76543cb85fb460a3a4aedb553..93ace4d80b02127305121ab9c59b2560fc567802 100644 (file)
@@ -26,13 +26,13 @@ Abstract:
 // Private worker functions.\r
 //\r
 \r
 // Private worker functions.\r
 //\r
 \r
-#if 0
+#if 0\r
 VOID\r
 UnixSimpleTextOutScrollScreen (\r
   IN OUT  UNIX_SIMPLE_TEXT_PRIVATE_DATA *Console\r
   );\r
 \r
 VOID\r
 UnixSimpleTextOutScrollScreen (\r
   IN OUT  UNIX_SIMPLE_TEXT_PRIVATE_DATA *Console\r
   );\r
 \r
-#endif
+#endif\r
 VOID\r
 UnixSimpleTextOutPutChar (\r
   IN OUT  UNIX_SIMPLE_TEXT_PRIVATE_DATA     *Console,\r
 VOID\r
 UnixSimpleTextOutPutChar (\r
   IN OUT  UNIX_SIMPLE_TEXT_PRIVATE_DATA     *Console,\r
@@ -51,7 +51,7 @@ UnixSimpleTextOutSetMode (
   IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL           *This,\r
   IN UINTN                                  ModeNumber\r
   );\r
   IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL           *This,\r
   IN UINTN                                  ModeNumber\r
   );\r
-
+\r
 //\r
 // Modeule Global for Simple Text Out Mode.\r
 //\r
 //\r
 // Modeule Global for Simple Text Out Mode.\r
 //\r
@@ -60,12 +60,12 @@ UnixSimpleTextOutSetMode (
 \r
 UNIX_SIMPLE_TEXT_OUT_MODE  mUnixSimpleTextOutSupportedModes[] = {\r
   { 80, 25 },         \r
 \r
 UNIX_SIMPLE_TEXT_OUT_MODE  mUnixSimpleTextOutSupportedModes[] = {\r
   { 80, 25 },         \r
-#if 0
+#if 0\r
   { 80, 50 },         \r
   { 80, 43 },         \r
   { 100, 100 },       \r
   { 100, 999 }         \r
   { 80, 50 },         \r
   { 80, 43 },         \r
   { 100, 100 },       \r
   { 100, 999 }         \r
-#endif
+#endif\r
 };\r
 \r
 EFI_STATUS\r
 };\r
 \r
 EFI_STATUS\r
@@ -131,7 +131,7 @@ Returns:
 \r
   for (Str = String; *Str != '\0'; Str++) {\r
     switch (*Str) {\r
 \r
   for (Str = String; *Str != '\0'; Str++) {\r
     switch (*Str) {\r
-#if 0
+#if 0\r
     case '\n':\r
       if (Private->Position.Y == (Private->MaxScreenSize.Y - 1)) {\r
         UnixSimpleTextOutScrollScreen (Private);\r
     case '\n':\r
       if (Private->Position.Y == (Private->MaxScreenSize.Y - 1)) {\r
         UnixSimpleTextOutScrollScreen (Private);\r
@@ -155,7 +155,7 @@ Returns:
       }\r
       break;\r
 \r
       }\r
       break;\r
 \r
-#endif
+#endif\r
     default:\r
       UnixSimpleTextOutPutChar (Private, *Str);\r
     }\r
     default:\r
       UnixSimpleTextOutPutChar (Private, *Str);\r
     }\r
@@ -186,11 +186,11 @@ Returns:
 \r
 --*/\r
 {\r
 \r
 --*/\r
 {\r
-  char c = Char;
-  Console->UnixThunk->Write (1, &c, 1);
+  char c = Char;\r
+  Console->UnixThunk->Write (1, &c, 1);\r
 }\r
 \r
 }\r
 \r
-#if 0
+#if 0\r
 VOID\r
 UnixSimpleTextOutScrollScreen (\r
   IN OUT  UNIX_SIMPLE_TEXT_PRIVATE_DATA *Console\r
 VOID\r
 UnixSimpleTextOutScrollScreen (\r
   IN OUT  UNIX_SIMPLE_TEXT_PRIVATE_DATA *Console\r
@@ -212,8 +212,8 @@ Returns:
 --*/\r
 {\r
 }\r
 --*/\r
 {\r
 }\r
-#endif
-
+#endif\r
+\r
 \r
 EFI_STATUS\r
 EFIAPI\r
 \r
 EFI_STATUS\r
 EFIAPI\r
@@ -358,9 +358,9 @@ Returns:
 \r
   Private               = UNIX_SIMPLE_TEXT_OUT_PRIVATE_DATA_FROM_THIS (This);\r
 \r
 \r
   Private               = UNIX_SIMPLE_TEXT_OUT_PRIVATE_DATA_FROM_THIS (This);\r
 \r
-#if 0
+#if 0\r
   Private->Attribute    = (WORD) Attribute;\r
   Private->Attribute    = (WORD) Attribute;\r
-#endif
+#endif\r
   This->Mode->Attribute = (INT32) Attribute;\r
 \r
   return EFI_SUCCESS;\r
   This->Mode->Attribute = (INT32) Attribute;\r
 \r
   return EFI_SUCCESS;\r
@@ -393,10 +393,10 @@ Returns:
   Private = UNIX_SIMPLE_TEXT_OUT_PRIVATE_DATA_FROM_THIS (This);\r
 \r
   This->SetCursorPosition (This, 0, 0);\r
   Private = UNIX_SIMPLE_TEXT_OUT_PRIVATE_DATA_FROM_THIS (This);\r
 \r
   This->SetCursorPosition (This, 0, 0);\r
-  Private->UnixThunk->Write (1, "\e[2J", 4);
-
+  Private->UnixThunk->Write (1, "\e[2J", 4);\r
 \r
 \r
-#if 0
+\r
+#if 0\r
   Private->UnixThunk->FillConsoleOutputCharacter (\r
                         Private->NtOutHandle,\r
                         ' ',\r
   Private->UnixThunk->FillConsoleOutputCharacter (\r
                         Private->NtOutHandle,\r
                         ' ',\r
@@ -411,7 +411,7 @@ Returns:
                         Private->Possition,\r
                         &ConsoleWindow\r
                         );\r
                         Private->Possition,\r
                         &ConsoleWindow\r
                         );\r
-#endif
+#endif\r
 \r
   return EFI_SUCCESS;\r
 }\r
 \r
   return EFI_SUCCESS;\r
 }\r
@@ -441,36 +441,36 @@ Returns:
 \r
 --*/\r
 {\r
 \r
 --*/\r
 {\r
-  char buf[12];
+  char buf[12];\r
   UNIX_SIMPLE_TEXT_PRIVATE_DATA *Private;\r
 \r
   Private                   = UNIX_SIMPLE_TEXT_OUT_PRIVATE_DATA_FROM_THIS (This);\r
 \r
   UNIX_SIMPLE_TEXT_PRIVATE_DATA *Private;\r
 \r
   Private                   = UNIX_SIMPLE_TEXT_OUT_PRIVATE_DATA_FROM_THIS (This);\r
 \r
-#if 0
+#if 0\r
   Private->Position.X      = (WORD) Column;\r
   Private->Position.X      = (WORD) Column;\r
-#endif
+#endif\r
   This->Mode->CursorColumn  = (INT32) Column;\r
 \r
   This->Mode->CursorColumn  = (INT32) Column;\r
 \r
-#if 0
+#if 0\r
   Private->Position.Y      = (WORD) Row;\r
   Private->Position.Y      = (WORD) Row;\r
-#endif
+#endif\r
   This->Mode->CursorRow     = (INT32) Row;\r
   This->Mode->CursorRow     = (INT32) Row;\r
-#if 0
+#if 0\r
   Private->UnixThunk->SetConsoleCursorPosition (Private->NtOutHandle, Private->Possition);\r
   Private->UnixThunk->SetConsoleCursorPosition (Private->NtOutHandle, Private->Possition);\r
-#endif
-\r
-  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);
-
+#endif\r
+\r
+  buf[0] = '\e';\r
+  buf[1] = '[';\r
+  buf[2] = '0' + ((Row / 100) % 10);\r
+  buf[3] = '0' + ((Row / 10) % 10);\r
+  buf[4] = '0' + ((Row / 1) % 10);\r
+  buf[5] = ';';\r
+  buf[6] = '0' + ((Column / 100) % 10);\r
+  buf[7] = '0' + ((Column / 10) % 10);\r
+  buf[8] = '0' + ((Column / 1) % 10);\r
+  buf[9] = 'H';\r
+  Private->UnixThunk->Write (1, buf, 10);\r
+\r
   return EFI_SUCCESS;\r
 }\r
 \r
   return EFI_SUCCESS;\r
 }\r
 \r
@@ -498,19 +498,19 @@ Returns:
 --*/\r
 {\r
   UNIX_SIMPLE_TEXT_PRIVATE_DATA *Private;\r
 --*/\r
 {\r
   UNIX_SIMPLE_TEXT_PRIVATE_DATA *Private;\r
-#if 0
+#if 0\r
   CONSOLE_CURSOR_INFO             Info;\r
   CONSOLE_CURSOR_INFO             Info;\r
-#endif
+#endif\r
 \r
   Private                   = UNIX_SIMPLE_TEXT_OUT_PRIVATE_DATA_FROM_THIS (This);\r
   Private->CursorEnable     = Enable;\r
   This->Mode->CursorVisible = Enable;\r
 \r
 \r
   Private                   = UNIX_SIMPLE_TEXT_OUT_PRIVATE_DATA_FROM_THIS (This);\r
   Private->CursorEnable     = Enable;\r
   This->Mode->CursorVisible = Enable;\r
 \r
-#if 0
+#if 0\r
   Private->UnixThunk->GetConsoleCursorInfo (Private->NtOutHandle, &Info);\r
   Info.bVisible = Enable;\r
   Private->UnixThunk->SetConsoleCursorInfo (Private->NtOutHandle, &Info);\r
   Private->UnixThunk->GetConsoleCursorInfo (Private->NtOutHandle, &Info);\r
   Info.bVisible = Enable;\r
   Private->UnixThunk->SetConsoleCursorInfo (Private->NtOutHandle, &Info);\r
-#endif
+#endif\r
 \r
   return EFI_SUCCESS;\r
 }\r
 \r
   return EFI_SUCCESS;\r
 }\r
@@ -539,13 +539,13 @@ Returns:
   CHAR16                        *WindowName;\r
 \r
   //WindowName          = Private->UnixIo->EnvString;\r
   CHAR16                        *WindowName;\r
 \r
   //WindowName          = Private->UnixIo->EnvString;\r
-#if 0
+#if 0\r
   Private->Attribute  = FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_INTENSITY;\r
   if (*WindowName == '?') {\r
     Private->Attribute  = BACKGROUND_RED | FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_GREEN;\r
     WindowName          = L"EFI Emulator Error Console";\r
   }\r
   Private->Attribute  = FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_INTENSITY;\r
   if (*WindowName == '?') {\r
     Private->Attribute  = BACKGROUND_RED | FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_GREEN;\r
     WindowName          = L"EFI Emulator Error Console";\r
   }\r
-#endif
+#endif\r
     WindowName          = L"EFI Emulator Error Console";\r
 \r
   AddUnicodeString (\r
     WindowName          = L"EFI Emulator Error Console";\r
 \r
   AddUnicodeString (\r
@@ -576,7 +576,7 @@ Returns:
   SimpleTextOut->Mode->MaxMode    = MAX_SIMPLE_TEXT_OUT_MODE;\r
   SimpleTextOut->Mode->Attribute  = 0; //FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_INTENSITY;\r
 \r
   SimpleTextOut->Mode->MaxMode    = MAX_SIMPLE_TEXT_OUT_MODE;\r
   SimpleTextOut->Mode->Attribute  = 0; //FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_INTENSITY;\r
 \r
-#if 0
+#if 0\r
   //\r
   // Open the window an initialize it!\r
   //\r
   //\r
   // Open the window an initialize it!\r
   //\r
@@ -588,7 +588,7 @@ Returns:
                                                 NULL\r
                                                 );\r
   Private->UnixThunk->SetConsoleTitle (WindowName);\r
                                                 NULL\r
                                                 );\r
   Private->UnixThunk->SetConsoleTitle (WindowName);\r
-#endif
+#endif\r
 \r
   return SimpleTextOut->SetMode (SimpleTextOut, 0);\r
 }\r
 \r
   return SimpleTextOut->SetMode (SimpleTextOut, 0);\r
 }\r
@@ -613,8 +613,8 @@ Returns:
 \r
 --*/\r
 {\r
 \r
 --*/\r
 {\r
-#if 0
+#if 0\r
   Console->UnixThunk->CloseHandle (Console->NtOutHandle);\r
   Console->UnixThunk->CloseHandle (Console->NtOutHandle);\r
-#endif
+#endif\r
   return EFI_SUCCESS;\r
 }\r
   return EFI_SUCCESS;\r
 }\r
index 636a6cb8803a73fe1af9b720a0a8af933e3f07b1..6a9748a323afe40eeeece9f41a5707bf5d1a743f 100644 (file)
@@ -62,6 +62,6 @@
   gEfiSimpleTextInProtocolGuid                  # PROTOCOL BY_START\r
   gEfiSimpleTextOutProtocolGuid                 # PROTOCOL BY_START\r
   gEfiUnixIoProtocolGuid                        # PROTOCOL TO_START\r
   gEfiSimpleTextInProtocolGuid                  # PROTOCOL BY_START\r
   gEfiSimpleTextOutProtocolGuid                 # PROTOCOL BY_START\r
   gEfiUnixIoProtocolGuid                        # PROTOCOL TO_START\r
-
-[Guids]
+\r
+[Guids]\r
   gEfiUnixConsoleGuid\r
   gEfiUnixConsoleGuid\r
index fa4e3aad362651fc3b27a8bf2dd7df64da80558a..edbfd0ad1353bfb715bea6e085946292d9b775cb 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
 /*++\r
 \r
-Copyright (c) 2006 - 2007, Intel Corporation\r
+Copyright (c) 2006 - 2009, Intel Corporation\r
 All rights reserved. This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
 All rights reserved. This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -46,7 +46,6 @@ Abstract:
 --*/\r
 \r
 #include "UnixSerialIo.h"\r
 --*/\r
 \r
 #include "UnixSerialIo.h"\r
-#include <termio.h>\r
 \r
 EFI_DRIVER_BINDING_PROTOCOL gUnixSerialIoDriverBinding = {\r
   UnixSerialIoDriverBindingSupported,\r
 \r
 EFI_DRIVER_BINDING_PROTOCOL gUnixSerialIoDriverBinding = {\r
   UnixSerialIoDriverBindingSupported,\r
@@ -454,7 +453,7 @@ Returns:
   UnixHandle = UnixIo->UnixThunk->Open (AsciiDevName, O_RDWR | O_NOCTTY, 0);\r
   \r
   if (UnixHandle == -1) {\r
   UnixHandle = UnixIo->UnixThunk->Open (AsciiDevName, O_RDWR | O_NOCTTY, 0);\r
   \r
   if (UnixHandle == -1) {\r
-    DEBUG ((EFI_D_INFO, "Faile to open serial device, %s!\r\n", UnixIo->EnvString ));\r
+    DEBUG ((EFI_D_INFO, "Failed to open serial device, %s!\r\n", UnixIo->EnvString ));\r
     UnixIo->UnixThunk->Perror (AsciiDevName);\r
     Status = EFI_DEVICE_ERROR;\r
     goto Error;\r
     UnixIo->UnixThunk->Perror (AsciiDevName);\r
     Status = EFI_DEVICE_ERROR;\r
     goto Error;\r
@@ -1125,6 +1124,7 @@ Returns:
     return EFI_DEVICE_ERROR;\r
   }\r
 \r
     return EFI_DEVICE_ERROR;\r
   }\r
 \r
+  Bits = 0;\r
   if ((Status & TIOCM_CTS) == TIOCM_CTS) {\r
     Bits |= EFI_SERIAL_CLEAR_TO_SEND;\r
   }\r
   if ((Status & TIOCM_CTS) == TIOCM_CTS) {\r
     Bits |= EFI_SERIAL_CLEAR_TO_SEND;\r
   }\r
@@ -1206,6 +1206,7 @@ Returns:
 --*/\r
 {\r
   UNIX_SERIAL_IO_PRIVATE_DATA   *Private;\r
 --*/\r
 {\r
   UNIX_SERIAL_IO_PRIVATE_DATA   *Private;\r
+  EFI_STATUS                    Status;\r
   UINT8                         *ByteBuffer;\r
   UINT32                        TotalBytesWritten;\r
   UINT32                        BytesToGo;\r
   UINT8                         *ByteBuffer;\r
   UINT32                        TotalBytesWritten;\r
   UINT32                        BytesToGo;\r
@@ -1219,6 +1220,7 @@ Returns:
   Private           = UNIX_SERIAL_IO_PRIVATE_DATA_FROM_THIS (This); \r
 \r
   ByteBuffer        = (UINT8 *) Buffer;\r
   Private           = UNIX_SERIAL_IO_PRIVATE_DATA_FROM_THIS (This); \r
 \r
   ByteBuffer        = (UINT8 *) Buffer;\r
+  Status = EFI_SUCCESS;\r
   TotalBytesWritten = 0;\r
 \r
   if (Private->SoftwareLoopbackEnable || Private->HardwareLoopbackEnable) {\r
   TotalBytesWritten = 0;\r
 \r
   if (Private->SoftwareLoopbackEnable || Private->HardwareLoopbackEnable) {\r
@@ -1250,6 +1252,10 @@ Returns:
                                            &ByteBuffer[TotalBytesWritten],\r
                                            BytesToGo\r
                                            );\r
                                            &ByteBuffer[TotalBytesWritten],\r
                                            BytesToGo\r
                                            );\r
+      if (BytesWritten == -1) {\r
+        Status = EFI_DEVICE_ERROR;\r
+        break;\r
+      }\r
 \r
       if (Private->HardwareFlowControl) {\r
         //\r
 \r
       if (Private->HardwareFlowControl) {\r
         //\r
@@ -1269,7 +1275,7 @@ Returns:
 \r
   gBS->RestoreTPL (Tpl);\r
 \r
 \r
   gBS->RestoreTPL (Tpl);\r
 \r
-  return EFI_SUCCESS;\r
+  return Status;\r
 }\r
 \r
 EFI_STATUS\r
 }\r
 \r
 EFI_STATUS\r
index 3a6c11ac3799313bf321a86790a63a7a8f920e7a..bcd8018e4c0df87bb2ec2dc2d95c27806fd42d4c 100644 (file)
@@ -1,6 +1,7 @@
 /*++\r
 \r
 /*++\r
 \r
-Copyright (c) 2006 - 2008, Intel Corporation                                                         \r
+Copyright (c) 2006 - 2009, Intel Corporation                                                         \r
+Portions copyright (c) 2008-2009 Apple Inc.\r
 All rights reserved. This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
 All rights reserved. This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
@@ -23,8 +24,13 @@ Abstract:
 #include <sys/types.h>\r
 #include <sys/stat.h>\r
 #include <stdio.h>\r
 #include <sys/types.h>\r
 #include <sys/stat.h>\r
 #include <stdio.h>\r
+\r
+#ifdef __APPLE__\r
+#else\r
 #include <stdlib.h>\r
 #include <termio.h>\r
 #include <stdlib.h>\r
 #include <termio.h>\r
+#endif\r
+\r
 #include <fcntl.h>\r
 #include <errno.h>\r
 \r
 #include <fcntl.h>\r
 #include <errno.h>\r
 \r
index 9d9325c105ecb7666da8a6f88d0c0cbe0cf88628..d01fd4e7510b3d4b7b3384410a75f477211943b3 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
 /*++\r
 \r
-Copyright (c) 2006 - 2007, Intel Corporation                                                         \r
+Copyright (c) 2006 - 2009, Intel Corporation                                                         \r
 All rights reserved. This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
 All rights reserved. This program and the accompanying materials                          \r
 are licensed and made available under the terms and conditions of the BSD License         \r
 which accompanies this distribution.  The full text of the license may be found at        \r
@@ -566,6 +566,8 @@ Done:
 \r
       gBS->FreePool (PrivateFile);\r
     }\r
 \r
       gBS->FreePool (PrivateFile);\r
     }\r
+    \r
+    *Root = NULL;\r
   }\r
 \r
   gBS->RestoreTPL (OldTpl);\r
   }\r
 \r
   gBS->RestoreTPL (OldTpl);\r
@@ -1262,7 +1264,12 @@ Returns:
   CHAR8                   *FullFileName;\r
   EFI_TPL                 OldTpl;\r
 \r
   CHAR8                   *FullFileName;\r
   EFI_TPL                 OldTpl;\r
 \r
-  if (This == NULL || BufferSize == NULL || Buffer == NULL) {\r
+  if (This == NULL || BufferSize == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+  \r
+  if ((*BufferSize != 0) && (Buffer == NULL)) {\r
+    // Buffer can be NULL  if *BufferSize is zero\r
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
index 59fe085b70dff362c0e71e31cc386d8713af30ec..1b6395540d82d8e3648eb0dd2cf18c3ece697c6e 100644 (file)
@@ -68,13 +68,13 @@ typedef struct {
   EFI_UNIX_THUNK_PROTOCOL        *UnixThunk;\r
   EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *SimpleFileSystem;\r
   EFI_FILE                        EfiFile;\r
   EFI_UNIX_THUNK_PROTOCOL        *UnixThunk;\r
   EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *SimpleFileSystem;\r
   EFI_FILE                        EfiFile;\r
-  INTN                            fd;
-  DIR                             *Dir;
+  INTN                            fd;\r
+  DIR                             *Dir;\r
   BOOLEAN                         IsRootDirectory;\r
   BOOLEAN                         IsDirectoryPath;\r
   BOOLEAN                         IsOpenedByRead;\r
   char                            *FileName;\r
   BOOLEAN                         IsRootDirectory;\r
   BOOLEAN                         IsDirectoryPath;\r
   BOOLEAN                         IsOpenedByRead;\r
   char                            *FileName;\r
-  struct dirent                   *Dirent;
+  struct dirent                   *Dirent;\r
 } UNIX_EFI_FILE_PRIVATE;\r
 \r
 #define UNIX_EFI_FILE_PRIVATE_DATA_FROM_THIS(a) \\r
 } UNIX_EFI_FILE_PRIVATE;\r
 \r
 #define UNIX_EFI_FILE_PRIVATE_DATA_FROM_THIS(a) \\r
index 16990a497840b062ac21981fdfac98d5fd7a3f03..3baa974818960c8ddf1b4c6460b84770c97ffdd7 100644 (file)
@@ -35,7 +35,7 @@ Abstract:
 #include <Library/UefiDriverEntryPoint.h>\r
 #include <Library/UnixLib.h>\r
 #include <Library/MemoryAllocationLib.h>\r
 #include <Library/UefiDriverEntryPoint.h>\r
 #include <Library/UnixLib.h>\r
 #include <Library/MemoryAllocationLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>
+#include <Library/UefiBootServicesTableLib.h>\r
 #include <Library/DevicePathLib.h>\r
 \r
 //\r
 #include <Library/DevicePathLib.h>\r
 \r
 //\r
index fd803b1b13408b1801df6d08c094cd73d36ee6cb..0b424afaf8e82835912e1a4ee0fbe0b66d2fcb6f 100644 (file)
@@ -47,8 +47,8 @@
   UnixLib\r
   UefiDriverEntryPoint\r
   UefiLib\r
   UnixLib\r
   UefiDriverEntryPoint\r
   UefiLib\r
-  DebugLib
-  DevicePathLib
+  DebugLib\r
+  DevicePathLib\r
 \r
 \r
 \r
 \r
 \r
 \r