]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Add support for SerialPortLib that maps into POSIX StdIn and StdOut. Add a device...
authorandrewfish <andrewfish@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 8 Jun 2011 02:34:12 +0000 (02:34 +0000)
committerandrewfish <andrewfish@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 8 Jun 2011 02:34:12 +0000 (02:34 +0000)
I plan to try and make only the Variable store and logs writable, and make the executable/compressed FV read only in a future checkin.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11760 6f19259b-4bc3-4df7-8a09-765794883524

17 files changed:
InOsEmuPkg/CpuRuntimeDxe/Cpu.c
InOsEmuPkg/EmuBlockIoDxe/EmuBlockIo.c
InOsEmuPkg/EmuSimpleFileSystemDxe/EmuSimpleFileSystem.c
InOsEmuPkg/InOsEmuPkg.dec
InOsEmuPkg/Include/Protocol/EmuThunk.h
InOsEmuPkg/Library/DevicePathTextLib/DevicePathTextLib.c [new file with mode: 0644]
InOsEmuPkg/Library/DevicePathTextLib/DevicePathTextLib.inf [new file with mode: 0644]
InOsEmuPkg/Library/DxeEmuSerialPortLib/DxeEmuSerialPortLib.c
InOsEmuPkg/Library/DxeEmuSerialPortLib/DxeEmuSerialPortLib.inf
InOsEmuPkg/Library/DxeEmuStdErrSerialPortLib/DxeEmuStdErrSerialPortLib.c [new file with mode: 0644]
InOsEmuPkg/Library/DxeEmuStdErrSerialPortLib/DxeEmuStdErrSerialPortLib.inf [new file with mode: 0644]
InOsEmuPkg/Unix/Sec/EmuThunk.c
InOsEmuPkg/Unix/Sec/Gasket.h
InOsEmuPkg/Unix/Sec/SecMain.c
InOsEmuPkg/Unix/Sec/X64/Gasket.S
InOsEmuPkg/Unix/UnixX64.dsc
InOsEmuPkg/Unix/UnixX64.fdf

index bcb8b5104659a432dc4840e0182fc83de7e50ac9..472b1c3b736d5a57bdd1b7b16905d2bb427fb4c8 100644 (file)
@@ -323,7 +323,7 @@ InitializeCpu (
   //\r
   // Convert frequency in Hz to a clock period in femtoseconds.\r
   //\r
   //\r
   // Convert frequency in Hz to a clock period in femtoseconds.\r
   //\r
-  mTimerPeriod = DivU64x64Remainder (1000000000000000, Frequency, NULL);\r
+  mTimerPeriod = DivU64x64Remainder (1000000000000000ULL, Frequency, NULL);\r
 \r
   CpuUpdateSmbios ();\r
   \r
 \r
   CpuUpdateSmbios ();\r
   \r
index 8efc7b10e507e75a022d0f8f6d1e34634afd7f7a..e8917326f203a4b32dd9f861a579b2ecc7c6c74c 100644 (file)
@@ -503,7 +503,7 @@ EmuBlockIoDriverBindingStart (
 {\r
   EFI_STATUS                  Status;\r
   EMU_IO_THUNK_PROTOCOL       *EmuIoThunk;\r
 {\r
   EFI_STATUS                  Status;\r
   EMU_IO_THUNK_PROTOCOL       *EmuIoThunk;\r
-  EMU_BLOCK_IO_PRIVATE        *Private;\r
+  EMU_BLOCK_IO_PRIVATE        *Private = NULL;\r
 \r
   //\r
   // Grab the protocols we need\r
 \r
   //\r
   // Grab the protocols we need\r
index 935cd122014f767afa6915babfb66902819be7a5..ba032614332bf2c37919d6e3cf664c61def839c5 100644 (file)
@@ -718,7 +718,7 @@ EmuSimpleFileSystemDriverBindingStart (
     goto Done;\r
   }\r
 \r
     goto Done;\r
   }\r
 \r
-  Private = AllocatePool (sizeof (EMU_SIMPLE_FILE_SYSTEM_PRIVATE));\r
+  Private = AllocateZeroPool (sizeof (EMU_SIMPLE_FILE_SYSTEM_PRIVATE));\r
   if (Private == NULL) {\r
     goto Done;\r
   }\r
   if (Private == NULL) {\r
     goto Done;\r
   }\r
index 9660939d578030c87d1744c86d485ac1b46fd414..e476dd20f00fc2dc70f698d508c2f13445cfc511 100644 (file)
   PpiListLib|Include/Library/PpiListLib.h\r
 \r
 [Protocols]\r
   PpiListLib|Include/Library/PpiListLib.h\r
 \r
 [Protocols]\r
-  gEmuThunkProtocolGuid          = { 0x398DCA31, 0x3505, 0xDB47, { 0xBD, 0x93, 0x1D, 0x38, 0x5F, 0x79, 0x13, 0x15 } }\r
+  gEmuThunkProtocolGuid          = { 0x5CF32E0B, 0x8EDF, 0x2E44, { 0x9C, 0xDA, 0x93, 0x20, 0x5E, 0x99, 0xEC, 0x1C } }\r
   gEmuIoThunkProtocolGuid        = { 0x453368F6, 0x7C85, 0x434A, { 0xA9, 0x8A, 0x72, 0xD1, 0xB7, 0xFF, 0xA9, 0x26 } }\r
   gEmuGraphicsWindowProtocolGuid = { 0x30FD316A, 0x6728, 0x2E41, { 0xA6, 0x90, 0x0D, 0x13, 0x33, 0xD8, 0xCA, 0xC1 } }\r
   gEmuThreadThunkProtocolGuid    = { 0x3B1E4B7C, 0x09D8, 0x944F, { 0xA4, 0x08, 0x13, 0x09, 0xEB, 0x8B, 0x44, 0x27 } }\r
   gEmuBlockIoProtocolGuid        = { 0x6888A4AE, 0xAFCE, 0xE84B, { 0x91, 0x02, 0xF7, 0xB9, 0xDA, 0xE6, 0xA0, 0x30 } }\r
 \r
 [Ppis]\r
   gEmuIoThunkProtocolGuid        = { 0x453368F6, 0x7C85, 0x434A, { 0xA9, 0x8A, 0x72, 0xD1, 0xB7, 0xFF, 0xA9, 0x26 } }\r
   gEmuGraphicsWindowProtocolGuid = { 0x30FD316A, 0x6728, 0x2E41, { 0xA6, 0x90, 0x0D, 0x13, 0x33, 0xD8, 0xCA, 0xC1 } }\r
   gEmuThreadThunkProtocolGuid    = { 0x3B1E4B7C, 0x09D8, 0x944F, { 0xA4, 0x08, 0x13, 0x09, 0xEB, 0x8B, 0x44, 0x27 } }\r
   gEmuBlockIoProtocolGuid        = { 0x6888A4AE, 0xAFCE, 0xE84B, { 0x91, 0x02, 0xF7, 0xB9, 0xDA, 0xE6, 0xA0, 0x30 } }\r
 \r
 [Ppis]\r
-  gEmuThunkPpiGuid                  = { 0xE113F896, 0x75CF, 0xF640, { 0x81, 0x7F, 0xC8, 0x5A, 0x79, 0xE8, 0xAE, 0x67 } }\r
+  gEmuThunkPpiGuid               = { 0xE113F896, 0x75CF, 0xF640, { 0x81, 0x7F, 0xC8, 0x5A, 0x79, 0xE8, 0xAE, 0x67 } }\r
 \r
 [Guids]\r
   gInOsEmuPkgTokenSpaceGuid  = { 0x4F792E68, 0xE8C8, 0x794E, { 0xB1, 0xD8, 0x37, 0x03, 0xF3, 0xF2, 0xD5, 0xA5 } }\r
 \r
 [Guids]\r
   gInOsEmuPkgTokenSpaceGuid  = { 0x4F792E68, 0xE8C8, 0x794E, { 0xB1, 0xD8, 0x37, 0x03, 0xF3, 0xF2, 0xD5, 0xA5 } }\r
index 411cd3e625865f64fc137f8143d49748db6cf8d5..3e2718ed66f2813fc326e63872fa51f0ecc3923e 100644 (file)
@@ -17,7 +17,7 @@
 #define __EMU_THUNK_PROTOCOL_H__\r
 \r
 #define EMU_THUNK_PROTOCOL_GUID  \\r
 #define __EMU_THUNK_PROTOCOL_H__\r
 \r
 #define EMU_THUNK_PROTOCOL_GUID  \\r
 { 0xA37D7CCD, 0x8E91, 0xFB48, { 0xA0, 0xBD, 0x64, 0xC1, 0x83, 0xA3, 0xB4, 0x3F } }\r
{ 0x5CF32E0B, 0x8EDF, 0x2E44, { 0x9C, 0xDA, 0x93, 0x20, 0x5E, 0x99, 0xEC, 0x1C } }\r
 \r
 // neded for things like EFI_TIME_CAPABILITIES\r
 #include <Uefi.h>\r
 \r
 // neded for things like EFI_TIME_CAPABILITIES\r
 #include <Uefi.h>\r
@@ -45,11 +45,39 @@ typedef struct _EMU_THUNK_PROTOCOL  EMU_THUNK_PROTOCOL;
 \r
 \r
 typedef \r
 \r
 \r
 typedef \r
-EFI_STATUS\r
+UINTN\r
 (EFIAPI *EMU_WRITE_STD_ERROR) (\r
 (EFIAPI *EMU_WRITE_STD_ERROR) (\r
+  IN UINT8     *Buffer,\r
+  IN UINTN     NumberOfBytes\r
+  );  \r
+  \r
+typedef \r
+EFI_STATUS\r
+(EFIAPI *EMU_CONFIG_STD_IN) (\r
+  VOID\r
+  );\r
+  \r
+typedef \r
+UINTN\r
+(EFIAPI *EMU_WRITE_STD_OUT) (\r
   IN UINT8     *Buffer,\r
   IN UINTN     NumberOfBytes\r
   );\r
   IN UINT8     *Buffer,\r
   IN UINTN     NumberOfBytes\r
   );\r
+  \r
+typedef \r
+UINTN\r
+(EFIAPI *EMU_READ_STD_IN) (\r
+  OUT UINT8     *Buffer,\r
+  IN  UINTN     NumberOfBytes\r
+  );\r
+\r
+typedef \r
+BOOLEAN\r
+(EFIAPI *EMU_POLL_STD_IN) (\r
+  VOID\r
+  );\r
+\r
+\r
 \r
 typedef \r
 EFI_STATUS\r
 \r
 typedef \r
 EFI_STATUS\r
@@ -166,6 +194,10 @@ EFI_STATUS
 struct _EMU_THUNK_PROTOCOL {\r
   // Used for early debug printing\r
   EMU_WRITE_STD_ERROR               WriteStdErr;\r
 struct _EMU_THUNK_PROTOCOL {\r
   // Used for early debug printing\r
   EMU_WRITE_STD_ERROR               WriteStdErr;\r
+  EMU_CONFIG_STD_IN                 ConfigStdIn;\r
+  EMU_WRITE_STD_OUT                 WriteStdOut;\r
+  EMU_READ_STD_IN                   ReadStdIn;\r
+  EMU_POLL_STD_IN                   PollStdIn;\r
   \r
   ///\r
   /// PE/COFF loader hooks to get symbols loaded\r
   \r
   ///\r
   /// PE/COFF loader hooks to get symbols loaded\r
diff --git a/InOsEmuPkg/Library/DevicePathTextLib/DevicePathTextLib.c b/InOsEmuPkg/Library/DevicePathTextLib/DevicePathTextLib.c
new file mode 100644 (file)
index 0000000..999af35
--- /dev/null
@@ -0,0 +1,78 @@
+/** @file\r
+  Null Platform Hook Library instance.\r
+\r
+  Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>\r
+  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
+**/\r
+\r
+#include <Base.h>\r
+\r
+#include <Protocol/EmuThunk.h>\r
+#include <Protocol/EmuGraphicsWindow.h>\r
+#include <Protocol/EmuBlockIo.h>\r
+#include <Protocol/SimpleFileSystem.h>\r
+#include <Protocol/EmuThread.h>\r
+\r
+#include <Library/DevicePathTextLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+\r
+\r
+/**\r
+  Converts a Vendor device path structure to its string representative.\r
+\r
+  @param Str             The string representative of input device.\r
+  @param DevPath         The input device path structure.\r
+  @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
+                         of the display node is used, where applicable. If DisplayOnly\r
+                         is FALSE, then the longer text representation of the display node\r
+                         is used.\r
+  @param AllowShortcuts  If AllowShortcuts is TRUE, then the shortcut forms of text\r
+                         representation for a device node can be used, where applicable.\r
+\r
+  @return EFI_NOT_FOUND if no string representation exists.\r
+  @return EFI_SUCCESS   a string representation was created.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+DevPathToTextVendorLib (\r
+  IN OUT POOL_PRINT  *Str,\r
+  IN VOID            *DevPath,\r
+  IN BOOLEAN         DisplayOnly,\r
+  IN BOOLEAN         AllowShortcuts\r
+  )\r
+{\r
+  EMU_VENDOR_DEVICE_PATH_NODE  *Vendor;\r
+  CHAR16                       *Type;\r
+\r
+  Vendor = (EMU_VENDOR_DEVICE_PATH_NODE *)DevPath;\r
+  if (CompareGuid (&Vendor->VendorDevicePath.Guid, &gEmuThunkProtocolGuid)) {\r
+    CatPrint (Str, L"EmuThunk()");\r
+    return EFI_SUCCESS;\r
+  }\r
+  if (CompareGuid (&Vendor->VendorDevicePath.Guid, &gEmuGraphicsWindowProtocolGuid)) {\r
+    CatPrint (Str, L"EmuGraphics(%d)", Vendor->Instance);\r
+    return EFI_SUCCESS;\r
+  }\r
+  if (CompareGuid (&Vendor->VendorDevicePath.Guid, &gEfiSimpleFileSystemProtocolGuid)) {\r
+    CatPrint (Str, L"EmuFs(%d)", Vendor->Instance);\r
+    return EFI_SUCCESS;\r
+  }\r
+  if (CompareGuid (&Vendor->VendorDevicePath.Guid, &gEmuBlockIoProtocolGuid)) {\r
+    CatPrint (Str, L"EmuBlk(%d)", Vendor->Instance);\r
+    return EFI_SUCCESS;\r
+  }\r
+  if (CompareGuid (&Vendor->VendorDevicePath.Guid, &gEmuThreadThunkProtocolGuid)) {\r
+    CatPrint (Str, L"EmuThread()");\r
+    return EFI_SUCCESS;\r
+  }\r
+  \r
+  return EFI_NOT_FOUND;\r
+}\r
+\r
diff --git a/InOsEmuPkg/Library/DevicePathTextLib/DevicePathTextLib.inf b/InOsEmuPkg/Library/DevicePathTextLib/DevicePathTextLib.inf
new file mode 100644 (file)
index 0000000..546cbf1
--- /dev/null
@@ -0,0 +1,45 @@
+## @file\r
+#  Null DevicePathToText library.\r
+#\r
+#  Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>\r
+#\r
+#  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
+#  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
+##\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = DevicePathTextLib\r
+  FILE_GUID                      = DCD1F939-1732-CA4D-81B7-C757AEC84DBC\r
+  MODULE_TYPE                    = BASE\r
+  VERSION_STRING                 = 1.0\r
+  LIBRARY_CLASS                  = DevicePathTextLib\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
+#\r
+\r
+[Sources]\r
+  DevicePathTextLib.c\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  MdeModulePkg/MdeModulePkg.dec\r
+  InOsEmuPkg/InOsEmuPkg.dec\r
+\r
+[LibraryClasses]\r
+  BaseMemoryLib\r
+\r
+[Protocols]\r
+  gEmuThunkProtocolGuid\r
+  gEmuGraphicsWindowProtocolGuid\r
+  gEfiSimpleFileSystemProtocolGuid\r
+  gEmuBlockIoProtocolGuid\r
+  gEmuThreadThunkProtocolGuid
\ No newline at end of file
index b4ef86e12832ef99f6f86b81a2f96e7817feb465..ccf4fa08ebb6cbbf39b4fa5e97ce35c497399b75 100644 (file)
@@ -39,7 +39,7 @@ SerialPortInitialize (
   VOID\r
   )\r
 {\r
   VOID\r
   )\r
 {\r
-  return RETURN_SUCCESS;\r
+  return gEmuThunk->ConfigStdIn ();\r
 }\r
 \r
 /**\r
 }\r
 \r
 /**\r
@@ -66,7 +66,7 @@ SerialPortWrite (
   IN UINTN     NumberOfBytes\r
   )\r
 {\r
   IN UINTN     NumberOfBytes\r
   )\r
 {\r
-  return gEmuThunk->WriteStdErr (Buffer, NumberOfBytes);\r
+  return gEmuThunk->WriteStdOut (Buffer, NumberOfBytes);\r
 }\r
 \r
 \r
 }\r
 \r
 \r
@@ -93,7 +93,7 @@ SerialPortRead (
   IN  UINTN     NumberOfBytes\r
   )\r
 {\r
   IN  UINTN     NumberOfBytes\r
   )\r
 {\r
-  return 0;\r
+  return gEmuThunk->ReadStdIn (Buffer, NumberOfBytes);\r
 }\r
 \r
 /**\r
 }\r
 \r
 /**\r
@@ -113,7 +113,7 @@ SerialPortPoll (
   VOID\r
   )\r
 {\r
   VOID\r
   )\r
 {\r
-  return FALSE;\r
+  return gEmuThunk->PollStdIn ();\r
 }\r
 \r
 \r
 }\r
 \r
 \r
index 115ad284838af5358b83e0a6261d758c976b7cc2..0f928dd27f9a1e1ca75107032a5f465df9fcaae2 100644 (file)
@@ -16,7 +16,7 @@
 \r
 [Defines]\r
   INF_VERSION                    = 0x00010005\r
 \r
 [Defines]\r
   INF_VERSION                    = 0x00010005\r
-  BASE_NAME                      = DxeEmuSerialPortLibNull\r
+  BASE_NAME                      = DxeEmuSerialPortLib\r
   FILE_GUID                      = DF08A29A-F60B-E649-AA79-A1490E863A5D\r
   MODULE_TYPE                    = PEIM\r
   VERSION_STRING                 = 1.0\r
   FILE_GUID                      = DF08A29A-F60B-E649-AA79-A1490E863A5D\r
   MODULE_TYPE                    = PEIM\r
   VERSION_STRING                 = 1.0\r
diff --git a/InOsEmuPkg/Library/DxeEmuStdErrSerialPortLib/DxeEmuStdErrSerialPortLib.c b/InOsEmuPkg/Library/DxeEmuStdErrSerialPortLib/DxeEmuStdErrSerialPortLib.c
new file mode 100644 (file)
index 0000000..b4ef86e
--- /dev/null
@@ -0,0 +1,119 @@
+/** @file\r
+  Serial Port Lib that thunks back to Emulator services to write to StdErr. \r
+  All read functions are stubed out. \r
+\r
+  Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+  Portions copyright (c) 2011, Apple Inc. All rights reserved.<BR>\r
+  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
+**/\r
+\r
+\r
+#include <PiDxe.h>\r
+#include <Library/SerialPortLib.h>\r
+#include <Library/EmuThunkLib.h>\r
+\r
+\r
+\r
+\r
+/**\r
+  Initialize the serial device hardware.\r
+  \r
+  If no initialization is required, then return RETURN_SUCCESS.\r
+  If the serial device was successfully initialized, then return RETURN_SUCCESS.\r
+  If the serial device could not be initialized, then return RETURN_DEVICE_ERROR.\r
+  \r
+  @retval RETURN_SUCCESS        The serial device was initialized.\r
+  @retval RETURN_DEVICE_ERROR   The serial device could not be initialized.\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+SerialPortInitialize (\r
+  VOID\r
+  )\r
+{\r
+  return RETURN_SUCCESS;\r
+}\r
+\r
+/**\r
+  Write data from buffer to serial device. \r
\r
+  Writes NumberOfBytes data bytes from Buffer to the serial device.  \r
+  The number of bytes actually written to the serial device is returned.\r
+  If the return value is less than NumberOfBytes, then the write operation failed.\r
+  If Buffer is NULL, then ASSERT(). \r
+  If NumberOfBytes is zero, then return 0.\r
+\r
+  @param  Buffer           The pointer to the data buffer to be written.\r
+  @param  NumberOfBytes    The number of bytes to written to the serial device.\r
+\r
+  @retval 0                NumberOfBytes is 0.\r
+  @retval >0               The number of bytes written to the serial device.  \r
+                           If this value is less than NumberOfBytes, then the read operation failed.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+SerialPortWrite (\r
+  IN UINT8     *Buffer,\r
+  IN UINTN     NumberOfBytes\r
+  )\r
+{\r
+  return gEmuThunk->WriteStdErr (Buffer, NumberOfBytes);\r
+}\r
+\r
+\r
+/**\r
+  Read data from serial device and save the datas in buffer.\r
\r
+  Reads NumberOfBytes data bytes from a serial device into the buffer\r
+  specified by Buffer. The number of bytes actually read is returned. \r
+  If the return value is less than NumberOfBytes, then the rest operation failed.\r
+  If Buffer is NULL, then ASSERT(). \r
+  If NumberOfBytes is zero, then return 0.\r
+\r
+  @param  Buffer           The pointer to the data buffer to store the data read from the serial device.\r
+  @param  NumberOfBytes    The number of bytes which will be read.\r
+\r
+  @retval 0                Read data failed; No data is to be read.\r
+  @retval >0               The actual number of bytes read from serial device.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+SerialPortRead (\r
+  OUT UINT8     *Buffer,\r
+  IN  UINTN     NumberOfBytes\r
+  )\r
+{\r
+  return 0;\r
+}\r
+\r
+/**\r
+  Polls a serial device to see if there is any data waiting to be read.\r
+\r
+  Polls a serial device to see if there is any data waiting to be read.\r
+  If there is data waiting to be read from the serial device, then TRUE is returned.\r
+  If there is no data waiting to be read from the serial device, then FALSE is returned.\r
+\r
+  @retval TRUE             Data is waiting to be read from the serial device.\r
+  @retval FALSE            There is no data waiting to be read from the serial device.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+SerialPortPoll (\r
+  VOID\r
+  )\r
+{\r
+  return FALSE;\r
+}\r
+\r
+\r
diff --git a/InOsEmuPkg/Library/DxeEmuStdErrSerialPortLib/DxeEmuStdErrSerialPortLib.inf b/InOsEmuPkg/Library/DxeEmuStdErrSerialPortLib/DxeEmuStdErrSerialPortLib.inf
new file mode 100644 (file)
index 0000000..e1b4034
--- /dev/null
@@ -0,0 +1,40 @@
+## @file\r
+#  Write only instance of Serial Port Library with empty functions.\r
+#\r
+#  Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+#  Portions copyright (c) 2011, Apple Inc. All rights reserved. \r
+#\r
+#  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
+#  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
+#\r
+##\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = DxeEmuStdErrSerialPortLib\r
+  FILE_GUID                      = 4EED5138-C512-9E4F-AB13-149B87D40453\r
+  MODULE_TYPE                    = PEIM\r
+  VERSION_STRING                 = 1.0\r
+  LIBRARY_CLASS                  = SerialPortLib| DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER SMM_CORE UEFI_APPLICATION UEFI_DRIVE\r
+\r
+\r
+[Sources]\r
+  DxeEmuStdErrSerialPortLib.c\r
+\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  InOsEmuPkg/InOsEmuPkg.dec\r
+  \r
+[LibraryClasses]\r
+  EmuThunkLib\r
+\r
+\r
+\r
+  \r
+\r
index abae70b89abcc805fca513a6622d49ef06fcb07f..579f67fa1adafda1bdaf9a531825a76a1f7bbb6d 100644 (file)
@@ -49,12 +49,75 @@ SecWriteStdErr (
 {
   ssize_t Return;
   
 {
   ssize_t Return;
   
-  Return = write (1, (const void *)Buffer, (size_t)NumberOfBytes);
+  Return = write (STDERR_FILENO, (const void *)Buffer, (size_t)NumberOfBytes);
   
   return (Return == -1) ? 0 : Return;
 }
 
 
   
   return (Return == -1) ? 0 : Return;
 }
 
 
+EFI_STATUS
+SecConfigStdIn (
+  VOID
+  )
+{
+  struct termios tty;
+  
+  //
+  // Need to turn off line buffering, ECHO, and make it unbuffered.
+  //
+  tcgetattr (STDIN_FILENO, &tty);
+  tty.c_lflag &= ~(ICANON | ECHO);
+  tcsetattr (STDIN_FILENO, TCSANOW, &tty);
+  
+//  setvbuf (STDIN_FILENO, NULL, _IONBF, 0);
+  
+  // now ioctl FIONREAD will do what we need
+  return EFI_SUCCESS;
+}
+
+UINTN
+SecWriteStdOut (
+  IN UINT8     *Buffer,
+  IN UINTN     NumberOfBytes
+  )
+{
+  ssize_t Return;
+  
+  Return = write (STDOUT_FILENO, (const void *)Buffer, (size_t)NumberOfBytes);
+  
+  return (Return == -1) ? 0 : Return;
+}
+
+UINTN
+SecReadStdIn (
+  IN UINT8     *Buffer,
+  IN UINTN     NumberOfBytes
+  )
+{
+  ssize_t Return;
+  
+  Return = read (STDIN_FILENO, Buffer, (size_t)NumberOfBytes);
+  
+  return (Return == -1) ? 0 : Return;
+}
+
+BOOLEAN
+SecPollStdIn (
+  VOID
+  )
+{
+  int Result;
+  int Bytes;
+  
+  Result = ioctl (STDIN_FILENO, FIONREAD, &Bytes);
+  if (Result == -1) {
+    return FALSE;
+  }
+  
+  return (BOOLEAN)(Bytes > 0);
+}
+
+
 
 void
 settimer_handler (int sig)
 
 void
 settimer_handler (int sig)
@@ -287,6 +350,10 @@ SecGetNextProtocol (
 
 EMU_THUNK_PROTOCOL gEmuThunkProtocol = {
   GasketSecWriteStdErr,
 
 EMU_THUNK_PROTOCOL gEmuThunkProtocol = {
   GasketSecWriteStdErr,
+  GasketSecConfigStdIn,
+  GasketSecWriteStdOut,
+  GasketSecReadStdIn,
+  GasketSecPollStdIn,
   GasketSecPeCoffGetEntryPoint,
   GasketSecPeCoffRelocateImageExtraAction,
   GasketSecPeCoffUnloadImageExtraAction,
   GasketSecPeCoffGetEntryPoint,
   GasketSecPeCoffRelocateImageExtraAction,
   GasketSecPeCoffUnloadImageExtraAction,
index e506e774b6d20da2ca3d8e25c3135b3bdf77eecf..5cc42dd575aceac21b017c10f7450f80264812d9 100644 (file)
 //\r
 \r
 UINTN\r
 //\r
 \r
 UINTN\r
+EFIAPI\r
 GasketSecWriteStdErr (\r
   IN UINT8     *Buffer,\r
   IN UINTN     NumberOfBytes\r
   );\r
 \r
 GasketSecWriteStdErr (\r
   IN UINT8     *Buffer,\r
   IN UINTN     NumberOfBytes\r
   );\r
 \r
+EFI_STATUS\r
+EFIAPI\r
+GasketSecConfigStdIn (\r
+  VOID\r
+  );\r
+\r
+UINTN\r
+EFIAPI\r
+GasketSecWriteStdOut (\r
+  IN UINT8     *Buffer,\r
+  IN UINTN     NumberOfBytes\r
+  );\r
+  \r
+UINTN\r
+EFIAPI\r
+GasketSecReadStdIn (\r
+  IN UINT8     *Buffer,\r
+  IN UINTN     NumberOfBytes\r
+  );\r
+\r
+BOOLEAN\r
+EFIAPI\r
+GasketSecPollStdIn (\r
+  VOID\r
+  );\r
+\r
+\r
+\r
 RETURN_STATUS\r
 EFIAPI\r
 GasketSecPeCoffGetEntryPoint (\r
 RETURN_STATUS\r
 EFIAPI\r
 GasketSecPeCoffGetEntryPoint (\r
index ff5eff0c07fe8e437e033ffbb7a2ecd885e21930..41b66b3bc0fd9c12ef60d5690f5049be80159f70 100644 (file)
@@ -354,18 +354,19 @@ MapFile (
   VOID    *res;
   UINTN   FileSize;
 
   VOID    *res;
   UINTN   FileSize;
 
-  fd = open (FileName, O_RDONLY);
+  fd = open (FileName, O_RDWR);
   if (fd < 0) {
     return EFI_NOT_FOUND;
   }
   FileSize = lseek (fd, 0, SEEK_END);
 
 
   if (fd < 0) {
     return EFI_NOT_FOUND;
   }
   FileSize = lseek (fd, 0, SEEK_END);
 
 
-  res = MapMemory (fd, FileSize, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE);
+  res = MapMemory (fd, FileSize, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_SHARED);
 
   close (fd);
 
 
   close (fd);
 
-  if (res == MAP_FAILED) {
+  if (res == NULL) {
+    perror ("MapFile() Failed");
     return EFI_DEVICE_ERROR;
   }
   
     return EFI_DEVICE_ERROR;
   }
   
index e5515e259b47c02567d086812de8dae2e58383d9..093b05ca07725ab2eee8de0276db96774b90a4b5 100644 (file)
@@ -60,6 +60,73 @@ ASM_PFX(GasketSecWriteStdErr):
   ret
 
 
   ret
 
 
+ASM_GLOBAL ASM_PFX(GasketSecConfigStdIn)
+ASM_PFX(GasketSecConfigStdIn):
+  pushq   %rbp            // stack frame is for the debugger
+  movq    %rsp, %rbp
+
+  pushq    %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
+  pushq    %rdi
+
+  call  ASM_PFX(SecConfigStdIn)
+  
+  popq  %rdi            // restore state
+  popq  %rsi
+  popq  %rbp
+  ret
+
+ASM_GLOBAL ASM_PFX(GasketSecWriteStdOut)
+ASM_PFX(GasketSecWriteStdOut):
+  pushq   %rbp            // stack frame is for the debugger
+  movq    %rsp, %rbp
+
+  pushq    %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
+  pushq    %rdi
+
+  movq    %rcx, %rdi    // Swizzle args 
+  movq    %rdx, %rsi     
+
+  call  ASM_PFX(SecWriteStdOut)
+  
+  popq  %rdi            // restore state
+  popq  %rsi
+  popq  %rbp
+  ret
+
+ASM_GLOBAL ASM_PFX(GasketSecReadStdIn)
+ASM_PFX(GasketSecReadStdIn):
+  pushq   %rbp            // stack frame is for the debugger
+  movq    %rsp, %rbp
+
+  pushq    %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
+  pushq    %rdi
+
+  movq    %rcx, %rdi    // Swizzle args 
+  movq    %rdx, %rsi     
+
+  call  ASM_PFX(SecReadStdIn)
+  
+  popq  %rdi            // restore state
+  popq  %rsi
+  popq  %rbp
+  ret
+
+ASM_GLOBAL ASM_PFX(GasketSecPollStdIn)
+ASM_PFX(GasketSecPollStdIn):
+  pushq   %rbp            // stack frame is for the debugger
+  movq    %rsp, %rbp
+
+  pushq    %rsi          // %rsi & %rdi are volatile in Unix and callee-save in EFI ABI
+  pushq    %rdi
+
+  call  ASM_PFX(SecPollStdIn)
+  
+  popq  %rdi            // restore state
+  popq  %rsi
+  popq  %rbp
+  ret
+
+
 ASM_GLOBAL ASM_PFX(GasketSecSetTimer)
 ASM_PFX(GasketSecSetTimer):
   pushq   %rbp            // stack frame is for the debugger
 ASM_GLOBAL ASM_PFX(GasketSecSetTimer)
 ASM_PFX(GasketSecSetTimer):
   pushq   %rbp            // stack frame is for the debugger
index b58f6011f226db4375bec6c11e1d020f128a362f..8bb1391af9c8b60751d325a497ede5080d93f841 100644 (file)
   DebugAgentLib|MdeModulePkg/Library/DebugAgentLibNull/DebugAgentLibNull.inf\r
   DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf\r
 \r
   DebugAgentLib|MdeModulePkg/Library/DebugAgentLibNull/DebugAgentLibNull.inf\r
   DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf\r
 \r
+#####  DevicePathTextLib|InOsEmuPkg/Library/DevicePathTextLib/DevicePathTextLib.inf\r
 \r
 [LibraryClasses.common.SEC]\r
   PeiServicesLib|InOsEmuPkg/Library/SecPeiServicesLib/SecPeiServicesLib.inf\r
 \r
 [LibraryClasses.common.SEC]\r
   PeiServicesLib|InOsEmuPkg/Library/SecPeiServicesLib/SecPeiServicesLib.inf\r
   gInOsEmuPkgTokenSpaceGuid.PcdEmuCpuModel|L"Intel(R) Processor Model"\r
   gInOsEmuPkgTokenSpaceGuid.PcdEmuCpuSpeed|L"3000"\r
 \r
   gInOsEmuPkgTokenSpaceGuid.PcdEmuCpuModel|L"Intel(R) Processor Model"\r
   gInOsEmuPkgTokenSpaceGuid.PcdEmuCpuSpeed|L"3000"\r
 \r
+  #  0-PCANSI, 1-VT100, 2-VT00+, 3-UTF8\r
+  gEfiMdePkgTokenSpaceGuid.PcdDefaultTerminalType|1\r
+\r
 ################################################################################\r
 #\r
 # Pcd Dynamic Section - list of all EDK II PCD Entries defined by this Platform\r
 ################################################################################\r
 #\r
 # Pcd Dynamic Section - list of all EDK II PCD Entries defined by this Platform\r
   MdeModulePkg/Universal/ReportStatusCodeRouter/RuntimeDxe/ReportStatusCodeRouterRuntimeDxe.inf\r
   MdeModulePkg/Universal/StatusCodeHandler/RuntimeDxe/StatusCodeHandlerRuntimeDxe.inf {\r
    <LibraryClasses>\r
   MdeModulePkg/Universal/ReportStatusCodeRouter/RuntimeDxe/ReportStatusCodeRouterRuntimeDxe.inf\r
   MdeModulePkg/Universal/StatusCodeHandler/RuntimeDxe/StatusCodeHandlerRuntimeDxe.inf {\r
    <LibraryClasses>\r
-      SerialPortLib|InOsEmuPkg/Library/DxeEmuSerialPortLib/DxeEmuSerialPortLib.inf    \r
+      SerialPortLib|InOsEmuPkg/Library/DxeEmuStdErrSerialPortLib/DxeEmuStdErrSerialPortLib.inf    \r
   }\r
 \r
   InOsEmuPkg/MetronomeDxe/Metronome.inf\r
   }\r
 \r
   InOsEmuPkg/MetronomeDxe/Metronome.inf\r
   MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf\r
   MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf\r
   MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf\r
   MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf\r
   MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf\r
   MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf\r
+  EmbeddedPkg/SerialDxe/SerialDxe.inf {\r
+   <LibraryClasses>\r
+      DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf\r
+      SerialPortLib|InOsEmuPkg/Library/DxeEmuSerialPortLib/DxeEmuSerialPortLib.inf    \r
+  }\r
+  \r
   MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf\r
   IntelFrameworkModulePkg/Universal/BdsDxe/BdsDxe.inf\r
   MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf\r
   MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf\r
   IntelFrameworkModulePkg/Universal/BdsDxe/BdsDxe.inf\r
   MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf\r
index d3696927ee0df72599a619cca443912af9975d5a..4058815ee5e1c93090c094e10ea1f80b37170afc 100644 (file)
@@ -207,6 +207,8 @@ INF  MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
 INF  MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf\r
 INF  MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf\r
 INF  MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf\r
 INF  MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf\r
 INF  MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf\r
 INF  MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf\r
+\r
+INF  EmbeddedPkg/SerialDxe/SerialDxe.inf\r
 INF  MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf\r
 INF  MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf\r
 INF  MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf\r
 INF  MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf\r
 INF  MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf\r
 INF  MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf\r