summaryrefslogtreecommitdiff
path: root/InOsEmuPkg
diff options
context:
space:
mode:
authorandrewfish <andrewfish@6f19259b-4bc3-4df7-8a09-765794883524>2011-06-08 02:34:12 +0000
committerandrewfish <andrewfish@6f19259b-4bc3-4df7-8a09-765794883524>2011-06-08 02:34:12 +0000
commit7e284acb40a3d27009de3cfe48275fed3c5d004b (patch)
tree3fbfdf3fdf298705d4f2539dc36cca5e9d479d26 /InOsEmuPkg
parent6f18b50d023159f6b19c04da5ab930cc58e2743b (diff)
downloadedk2-platforms-7e284acb40a3d27009de3cfe48275fed3c5d004b.tar.xz
Add support for SerialPortLib that maps into POSIX StdIn and StdOut. Add a device path text to lib as a holding point waiting on getting it reviewed for other packages. Some minor fixes. Also map the FV as writable, so the Variable store becomes writable.
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
Diffstat (limited to 'InOsEmuPkg')
-rw-r--r--InOsEmuPkg/CpuRuntimeDxe/Cpu.c2
-rw-r--r--InOsEmuPkg/EmuBlockIoDxe/EmuBlockIo.c2
-rw-r--r--InOsEmuPkg/EmuSimpleFileSystemDxe/EmuSimpleFileSystem.c2
-rw-r--r--InOsEmuPkg/InOsEmuPkg.dec4
-rw-r--r--InOsEmuPkg/Include/Protocol/EmuThunk.h36
-rw-r--r--InOsEmuPkg/Library/DevicePathTextLib/DevicePathTextLib.c78
-rw-r--r--InOsEmuPkg/Library/DevicePathTextLib/DevicePathTextLib.inf45
-rw-r--r--InOsEmuPkg/Library/DxeEmuSerialPortLib/DxeEmuSerialPortLib.c8
-rw-r--r--InOsEmuPkg/Library/DxeEmuSerialPortLib/DxeEmuSerialPortLib.inf2
-rw-r--r--InOsEmuPkg/Library/DxeEmuStdErrSerialPortLib/DxeEmuStdErrSerialPortLib.c119
-rw-r--r--InOsEmuPkg/Library/DxeEmuStdErrSerialPortLib/DxeEmuStdErrSerialPortLib.inf40
-rw-r--r--InOsEmuPkg/Unix/Sec/EmuThunk.c69
-rw-r--r--InOsEmuPkg/Unix/Sec/Gasket.h29
-rw-r--r--InOsEmuPkg/Unix/Sec/SecMain.c7
-rw-r--r--InOsEmuPkg/Unix/Sec/X64/Gasket.S67
-rw-r--r--InOsEmuPkg/Unix/UnixX64.dsc12
-rw-r--r--InOsEmuPkg/Unix/UnixX64.fdf2
17 files changed, 507 insertions, 17 deletions
diff --git a/InOsEmuPkg/CpuRuntimeDxe/Cpu.c b/InOsEmuPkg/CpuRuntimeDxe/Cpu.c
index bcb8b51046..472b1c3b73 100644
--- a/InOsEmuPkg/CpuRuntimeDxe/Cpu.c
+++ b/InOsEmuPkg/CpuRuntimeDxe/Cpu.c
@@ -323,7 +323,7 @@ InitializeCpu (
//
// Convert frequency in Hz to a clock period in femtoseconds.
//
- mTimerPeriod = DivU64x64Remainder (1000000000000000, Frequency, NULL);
+ mTimerPeriod = DivU64x64Remainder (1000000000000000ULL, Frequency, NULL);
CpuUpdateSmbios ();
diff --git a/InOsEmuPkg/EmuBlockIoDxe/EmuBlockIo.c b/InOsEmuPkg/EmuBlockIoDxe/EmuBlockIo.c
index 8efc7b10e5..e8917326f2 100644
--- a/InOsEmuPkg/EmuBlockIoDxe/EmuBlockIo.c
+++ b/InOsEmuPkg/EmuBlockIoDxe/EmuBlockIo.c
@@ -503,7 +503,7 @@ EmuBlockIoDriverBindingStart (
{
EFI_STATUS Status;
EMU_IO_THUNK_PROTOCOL *EmuIoThunk;
- EMU_BLOCK_IO_PRIVATE *Private;
+ EMU_BLOCK_IO_PRIVATE *Private = NULL;
//
// Grab the protocols we need
diff --git a/InOsEmuPkg/EmuSimpleFileSystemDxe/EmuSimpleFileSystem.c b/InOsEmuPkg/EmuSimpleFileSystemDxe/EmuSimpleFileSystem.c
index 935cd12201..ba03261433 100644
--- a/InOsEmuPkg/EmuSimpleFileSystemDxe/EmuSimpleFileSystem.c
+++ b/InOsEmuPkg/EmuSimpleFileSystemDxe/EmuSimpleFileSystem.c
@@ -718,7 +718,7 @@ EmuSimpleFileSystemDriverBindingStart (
goto Done;
}
- Private = AllocatePool (sizeof (EMU_SIMPLE_FILE_SYSTEM_PRIVATE));
+ Private = AllocateZeroPool (sizeof (EMU_SIMPLE_FILE_SYSTEM_PRIVATE));
if (Private == NULL) {
goto Done;
}
diff --git a/InOsEmuPkg/InOsEmuPkg.dec b/InOsEmuPkg/InOsEmuPkg.dec
index 9660939d57..e476dd20f0 100644
--- a/InOsEmuPkg/InOsEmuPkg.dec
+++ b/InOsEmuPkg/InOsEmuPkg.dec
@@ -32,14 +32,14 @@
PpiListLib|Include/Library/PpiListLib.h
[Protocols]
- gEmuThunkProtocolGuid = { 0x398DCA31, 0x3505, 0xDB47, { 0xBD, 0x93, 0x1D, 0x38, 0x5F, 0x79, 0x13, 0x15 } }
+ gEmuThunkProtocolGuid = { 0x5CF32E0B, 0x8EDF, 0x2E44, { 0x9C, 0xDA, 0x93, 0x20, 0x5E, 0x99, 0xEC, 0x1C } }
gEmuIoThunkProtocolGuid = { 0x453368F6, 0x7C85, 0x434A, { 0xA9, 0x8A, 0x72, 0xD1, 0xB7, 0xFF, 0xA9, 0x26 } }
gEmuGraphicsWindowProtocolGuid = { 0x30FD316A, 0x6728, 0x2E41, { 0xA6, 0x90, 0x0D, 0x13, 0x33, 0xD8, 0xCA, 0xC1 } }
gEmuThreadThunkProtocolGuid = { 0x3B1E4B7C, 0x09D8, 0x944F, { 0xA4, 0x08, 0x13, 0x09, 0xEB, 0x8B, 0x44, 0x27 } }
gEmuBlockIoProtocolGuid = { 0x6888A4AE, 0xAFCE, 0xE84B, { 0x91, 0x02, 0xF7, 0xB9, 0xDA, 0xE6, 0xA0, 0x30 } }
[Ppis]
- gEmuThunkPpiGuid = { 0xE113F896, 0x75CF, 0xF640, { 0x81, 0x7F, 0xC8, 0x5A, 0x79, 0xE8, 0xAE, 0x67 } }
+ gEmuThunkPpiGuid = { 0xE113F896, 0x75CF, 0xF640, { 0x81, 0x7F, 0xC8, 0x5A, 0x79, 0xE8, 0xAE, 0x67 } }
[Guids]
gInOsEmuPkgTokenSpaceGuid = { 0x4F792E68, 0xE8C8, 0x794E, { 0xB1, 0xD8, 0x37, 0x03, 0xF3, 0xF2, 0xD5, 0xA5 } }
diff --git a/InOsEmuPkg/Include/Protocol/EmuThunk.h b/InOsEmuPkg/Include/Protocol/EmuThunk.h
index 411cd3e625..3e2718ed66 100644
--- a/InOsEmuPkg/Include/Protocol/EmuThunk.h
+++ b/InOsEmuPkg/Include/Protocol/EmuThunk.h
@@ -17,7 +17,7 @@
#define __EMU_THUNK_PROTOCOL_H__
#define EMU_THUNK_PROTOCOL_GUID \
- { 0xA37D7CCD, 0x8E91, 0xFB48, { 0xA0, 0xBD, 0x64, 0xC1, 0x83, 0xA3, 0xB4, 0x3F } }
+ { 0x5CF32E0B, 0x8EDF, 0x2E44, { 0x9C, 0xDA, 0x93, 0x20, 0x5E, 0x99, 0xEC, 0x1C } }
// neded for things like EFI_TIME_CAPABILITIES
#include <Uefi.h>
@@ -45,11 +45,39 @@ typedef struct _EMU_THUNK_PROTOCOL EMU_THUNK_PROTOCOL;
typedef
-EFI_STATUS
+UINTN
(EFIAPI *EMU_WRITE_STD_ERROR) (
IN UINT8 *Buffer,
IN UINTN NumberOfBytes
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EMU_CONFIG_STD_IN) (
+ VOID
+ );
+
+typedef
+UINTN
+(EFIAPI *EMU_WRITE_STD_OUT) (
+ IN UINT8 *Buffer,
+ IN UINTN NumberOfBytes
);
+
+typedef
+UINTN
+(EFIAPI *EMU_READ_STD_IN) (
+ OUT UINT8 *Buffer,
+ IN UINTN NumberOfBytes
+ );
+
+typedef
+BOOLEAN
+(EFIAPI *EMU_POLL_STD_IN) (
+ VOID
+ );
+
+
typedef
EFI_STATUS
@@ -166,6 +194,10 @@ EFI_STATUS
struct _EMU_THUNK_PROTOCOL {
// Used for early debug printing
EMU_WRITE_STD_ERROR WriteStdErr;
+ EMU_CONFIG_STD_IN ConfigStdIn;
+ EMU_WRITE_STD_OUT WriteStdOut;
+ EMU_READ_STD_IN ReadStdIn;
+ EMU_POLL_STD_IN PollStdIn;
///
/// PE/COFF loader hooks to get symbols loaded
diff --git a/InOsEmuPkg/Library/DevicePathTextLib/DevicePathTextLib.c b/InOsEmuPkg/Library/DevicePathTextLib/DevicePathTextLib.c
new file mode 100644
index 0000000000..999af355aa
--- /dev/null
+++ b/InOsEmuPkg/Library/DevicePathTextLib/DevicePathTextLib.c
@@ -0,0 +1,78 @@
+/** @file
+ Null Platform Hook Library instance.
+
+ Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
+ 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 <Base.h>
+
+#include <Protocol/EmuThunk.h>
+#include <Protocol/EmuGraphicsWindow.h>
+#include <Protocol/EmuBlockIo.h>
+#include <Protocol/SimpleFileSystem.h>
+#include <Protocol/EmuThread.h>
+
+#include <Library/DevicePathTextLib.h>
+#include <Library/BaseMemoryLib.h>
+
+
+/**
+ Converts a Vendor device path structure to its string representative.
+
+ @param Str The string representative of input device.
+ @param DevPath The input device path structure.
+ @param DisplayOnly If DisplayOnly is TRUE, then the shorter text representation
+ of the display node is used, where applicable. If DisplayOnly
+ is FALSE, then the longer text representation of the display node
+ is used.
+ @param AllowShortcuts If AllowShortcuts is TRUE, then the shortcut forms of text
+ representation for a device node can be used, where applicable.
+
+ @return EFI_NOT_FOUND if no string representation exists.
+ @return EFI_SUCCESS a string representation was created.
+**/
+EFI_STATUS
+EFIAPI
+DevPathToTextVendorLib (
+ IN OUT POOL_PRINT *Str,
+ IN VOID *DevPath,
+ IN BOOLEAN DisplayOnly,
+ IN BOOLEAN AllowShortcuts
+ )
+{
+ EMU_VENDOR_DEVICE_PATH_NODE *Vendor;
+ CHAR16 *Type;
+
+ Vendor = (EMU_VENDOR_DEVICE_PATH_NODE *)DevPath;
+ if (CompareGuid (&Vendor->VendorDevicePath.Guid, &gEmuThunkProtocolGuid)) {
+ CatPrint (Str, L"EmuThunk()");
+ return EFI_SUCCESS;
+ }
+ if (CompareGuid (&Vendor->VendorDevicePath.Guid, &gEmuGraphicsWindowProtocolGuid)) {
+ CatPrint (Str, L"EmuGraphics(%d)", Vendor->Instance);
+ return EFI_SUCCESS;
+ }
+ if (CompareGuid (&Vendor->VendorDevicePath.Guid, &gEfiSimpleFileSystemProtocolGuid)) {
+ CatPrint (Str, L"EmuFs(%d)", Vendor->Instance);
+ return EFI_SUCCESS;
+ }
+ if (CompareGuid (&Vendor->VendorDevicePath.Guid, &gEmuBlockIoProtocolGuid)) {
+ CatPrint (Str, L"EmuBlk(%d)", Vendor->Instance);
+ return EFI_SUCCESS;
+ }
+ if (CompareGuid (&Vendor->VendorDevicePath.Guid, &gEmuThreadThunkProtocolGuid)) {
+ CatPrint (Str, L"EmuThread()");
+ return EFI_SUCCESS;
+ }
+
+ return EFI_NOT_FOUND;
+}
+
diff --git a/InOsEmuPkg/Library/DevicePathTextLib/DevicePathTextLib.inf b/InOsEmuPkg/Library/DevicePathTextLib/DevicePathTextLib.inf
new file mode 100644
index 0000000000..546cbf1d8b
--- /dev/null
+++ b/InOsEmuPkg/Library/DevicePathTextLib/DevicePathTextLib.inf
@@ -0,0 +1,45 @@
+## @file
+# Null DevicePathToText library.
+#
+# Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
+#
+# 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.
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = DevicePathTextLib
+ FILE_GUID = DCD1F939-1732-CA4D-81B7-C757AEC84DBC
+ MODULE_TYPE = BASE
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = DevicePathTextLib
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+# VALID_ARCHITECTURES = IA32 X64 IPF EBC
+#
+
+[Sources]
+ DevicePathTextLib.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+ InOsEmuPkg/InOsEmuPkg.dec
+
+[LibraryClasses]
+ BaseMemoryLib
+
+[Protocols]
+ gEmuThunkProtocolGuid
+ gEmuGraphicsWindowProtocolGuid
+ gEfiSimpleFileSystemProtocolGuid
+ gEmuBlockIoProtocolGuid
+ gEmuThreadThunkProtocolGuid \ No newline at end of file
diff --git a/InOsEmuPkg/Library/DxeEmuSerialPortLib/DxeEmuSerialPortLib.c b/InOsEmuPkg/Library/DxeEmuSerialPortLib/DxeEmuSerialPortLib.c
index b4ef86e128..ccf4fa08eb 100644
--- a/InOsEmuPkg/Library/DxeEmuSerialPortLib/DxeEmuSerialPortLib.c
+++ b/InOsEmuPkg/Library/DxeEmuSerialPortLib/DxeEmuSerialPortLib.c
@@ -39,7 +39,7 @@ SerialPortInitialize (
VOID
)
{
- return RETURN_SUCCESS;
+ return gEmuThunk->ConfigStdIn ();
}
/**
@@ -66,7 +66,7 @@ SerialPortWrite (
IN UINTN NumberOfBytes
)
{
- return gEmuThunk->WriteStdErr (Buffer, NumberOfBytes);
+ return gEmuThunk->WriteStdOut (Buffer, NumberOfBytes);
}
@@ -93,7 +93,7 @@ SerialPortRead (
IN UINTN NumberOfBytes
)
{
- return 0;
+ return gEmuThunk->ReadStdIn (Buffer, NumberOfBytes);
}
/**
@@ -113,7 +113,7 @@ SerialPortPoll (
VOID
)
{
- return FALSE;
+ return gEmuThunk->PollStdIn ();
}
diff --git a/InOsEmuPkg/Library/DxeEmuSerialPortLib/DxeEmuSerialPortLib.inf b/InOsEmuPkg/Library/DxeEmuSerialPortLib/DxeEmuSerialPortLib.inf
index 115ad28483..0f928dd27f 100644
--- a/InOsEmuPkg/Library/DxeEmuSerialPortLib/DxeEmuSerialPortLib.inf
+++ b/InOsEmuPkg/Library/DxeEmuSerialPortLib/DxeEmuSerialPortLib.inf
@@ -16,7 +16,7 @@
[Defines]
INF_VERSION = 0x00010005
- BASE_NAME = DxeEmuSerialPortLibNull
+ BASE_NAME = DxeEmuSerialPortLib
FILE_GUID = DF08A29A-F60B-E649-AA79-A1490E863A5D
MODULE_TYPE = PEIM
VERSION_STRING = 1.0
diff --git a/InOsEmuPkg/Library/DxeEmuStdErrSerialPortLib/DxeEmuStdErrSerialPortLib.c b/InOsEmuPkg/Library/DxeEmuStdErrSerialPortLib/DxeEmuStdErrSerialPortLib.c
new file mode 100644
index 0000000000..b4ef86e128
--- /dev/null
+++ b/InOsEmuPkg/Library/DxeEmuStdErrSerialPortLib/DxeEmuStdErrSerialPortLib.c
@@ -0,0 +1,119 @@
+/** @file
+ Serial Port Lib that thunks back to Emulator services to write to StdErr.
+ All read functions are stubed out.
+
+ Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
+ Portions copyright (c) 2011, Apple Inc. All rights reserved.<BR>
+ 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 <PiDxe.h>
+#include <Library/SerialPortLib.h>
+#include <Library/EmuThunkLib.h>
+
+
+
+
+/**
+ Initialize the serial device hardware.
+
+ If no initialization is required, then return RETURN_SUCCESS.
+ If the serial device was successfully initialized, then return RETURN_SUCCESS.
+ If the serial device could not be initialized, then return RETURN_DEVICE_ERROR.
+
+ @retval RETURN_SUCCESS The serial device was initialized.
+ @retval RETURN_DEVICE_ERROR The serial device could not be initialized.
+
+**/
+RETURN_STATUS
+EFIAPI
+SerialPortInitialize (
+ VOID
+ )
+{
+ return RETURN_SUCCESS;
+}
+
+/**
+ Write data from buffer to serial device.
+
+ Writes NumberOfBytes data bytes from Buffer to the serial device.
+ The number of bytes actually written to the serial device is returned.
+ If the return value is less than NumberOfBytes, then the write operation failed.
+ If Buffer is NULL, then ASSERT().
+ If NumberOfBytes is zero, then return 0.
+
+ @param Buffer The pointer to the data buffer to be written.
+ @param NumberOfBytes The number of bytes to written to the serial device.
+
+ @retval 0 NumberOfBytes is 0.
+ @retval >0 The number of bytes written to the serial device.
+ If this value is less than NumberOfBytes, then the read operation failed.
+
+**/
+UINTN
+EFIAPI
+SerialPortWrite (
+ IN UINT8 *Buffer,
+ IN UINTN NumberOfBytes
+ )
+{
+ return gEmuThunk->WriteStdErr (Buffer, NumberOfBytes);
+}
+
+
+/**
+ Read data from serial device and save the datas in buffer.
+
+ Reads NumberOfBytes data bytes from a serial device into the buffer
+ specified by Buffer. The number of bytes actually read is returned.
+ If the return value is less than NumberOfBytes, then the rest operation failed.
+ If Buffer is NULL, then ASSERT().
+ If NumberOfBytes is zero, then return 0.
+
+ @param Buffer The pointer to the data buffer to store the data read from the serial device.
+ @param NumberOfBytes The number of bytes which will be read.
+
+ @retval 0 Read data failed; No data is to be read.
+ @retval >0 The actual number of bytes read from serial device.
+
+**/
+UINTN
+EFIAPI
+SerialPortRead (
+ OUT UINT8 *Buffer,
+ IN UINTN NumberOfBytes
+ )
+{
+ return 0;
+}
+
+/**
+ Polls a serial device to see if there is any data waiting to be read.
+
+ Polls a serial device to see if there is any data waiting to be read.
+ If there is data waiting to be read from the serial device, then TRUE is returned.
+ If there is no data waiting to be read from the serial device, then FALSE is returned.
+
+ @retval TRUE Data is waiting to be read from the serial device.
+ @retval FALSE There is no data waiting to be read from the serial device.
+
+**/
+BOOLEAN
+EFIAPI
+SerialPortPoll (
+ VOID
+ )
+{
+ return FALSE;
+}
+
+
diff --git a/InOsEmuPkg/Library/DxeEmuStdErrSerialPortLib/DxeEmuStdErrSerialPortLib.inf b/InOsEmuPkg/Library/DxeEmuStdErrSerialPortLib/DxeEmuStdErrSerialPortLib.inf
new file mode 100644
index 0000000000..e1b403475d
--- /dev/null
+++ b/InOsEmuPkg/Library/DxeEmuStdErrSerialPortLib/DxeEmuStdErrSerialPortLib.inf
@@ -0,0 +1,40 @@
+## @file
+# Write only instance of Serial Port Library with empty functions.
+#
+# Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
+# Portions copyright (c) 2011, Apple Inc. All rights reserved.
+#
+# This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php.
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = DxeEmuStdErrSerialPortLib
+ FILE_GUID = 4EED5138-C512-9E4F-AB13-149B87D40453
+ MODULE_TYPE = PEIM
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = SerialPortLib| DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER SMM_CORE UEFI_APPLICATION UEFI_DRIVE
+
+
+[Sources]
+ DxeEmuStdErrSerialPortLib.c
+
+
+[Packages]
+ MdePkg/MdePkg.dec
+ InOsEmuPkg/InOsEmuPkg.dec
+
+[LibraryClasses]
+ EmuThunkLib
+
+
+
+
+
diff --git a/InOsEmuPkg/Unix/Sec/EmuThunk.c b/InOsEmuPkg/Unix/Sec/EmuThunk.c
index abae70b89a..579f67fa1a 100644
--- a/InOsEmuPkg/Unix/Sec/EmuThunk.c
+++ b/InOsEmuPkg/Unix/Sec/EmuThunk.c
@@ -49,12 +49,75 @@ SecWriteStdErr (
{
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;
}
+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)
@@ -287,6 +350,10 @@ SecGetNextProtocol (
EMU_THUNK_PROTOCOL gEmuThunkProtocol = {
GasketSecWriteStdErr,
+ GasketSecConfigStdIn,
+ GasketSecWriteStdOut,
+ GasketSecReadStdIn,
+ GasketSecPollStdIn,
GasketSecPeCoffGetEntryPoint,
GasketSecPeCoffRelocateImageExtraAction,
GasketSecPeCoffUnloadImageExtraAction,
diff --git a/InOsEmuPkg/Unix/Sec/Gasket.h b/InOsEmuPkg/Unix/Sec/Gasket.h
index e506e774b6..5cc42dd575 100644
--- a/InOsEmuPkg/Unix/Sec/Gasket.h
+++ b/InOsEmuPkg/Unix/Sec/Gasket.h
@@ -21,11 +21,40 @@
//
UINTN
+EFIAPI
GasketSecWriteStdErr (
IN UINT8 *Buffer,
IN UINTN NumberOfBytes
);
+EFI_STATUS
+EFIAPI
+GasketSecConfigStdIn (
+ VOID
+ );
+
+UINTN
+EFIAPI
+GasketSecWriteStdOut (
+ IN UINT8 *Buffer,
+ IN UINTN NumberOfBytes
+ );
+
+UINTN
+EFIAPI
+GasketSecReadStdIn (
+ IN UINT8 *Buffer,
+ IN UINTN NumberOfBytes
+ );
+
+BOOLEAN
+EFIAPI
+GasketSecPollStdIn (
+ VOID
+ );
+
+
+
RETURN_STATUS
EFIAPI
GasketSecPeCoffGetEntryPoint (
diff --git a/InOsEmuPkg/Unix/Sec/SecMain.c b/InOsEmuPkg/Unix/Sec/SecMain.c
index ff5eff0c07..41b66b3bc0 100644
--- a/InOsEmuPkg/Unix/Sec/SecMain.c
+++ b/InOsEmuPkg/Unix/Sec/SecMain.c
@@ -354,18 +354,19 @@ MapFile (
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);
- 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);
- if (res == MAP_FAILED) {
+ if (res == NULL) {
+ perror ("MapFile() Failed");
return EFI_DEVICE_ERROR;
}
diff --git a/InOsEmuPkg/Unix/Sec/X64/Gasket.S b/InOsEmuPkg/Unix/Sec/X64/Gasket.S
index e5515e259b..093b05ca07 100644
--- a/InOsEmuPkg/Unix/Sec/X64/Gasket.S
+++ b/InOsEmuPkg/Unix/Sec/X64/Gasket.S
@@ -60,6 +60,73 @@ ASM_PFX(GasketSecWriteStdErr):
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
diff --git a/InOsEmuPkg/Unix/UnixX64.dsc b/InOsEmuPkg/Unix/UnixX64.dsc
index b58f6011f2..8bb1391af9 100644
--- a/InOsEmuPkg/Unix/UnixX64.dsc
+++ b/InOsEmuPkg/Unix/UnixX64.dsc
@@ -109,6 +109,7 @@
DebugAgentLib|MdeModulePkg/Library/DebugAgentLibNull/DebugAgentLibNull.inf
DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
+##### DevicePathTextLib|InOsEmuPkg/Library/DevicePathTextLib/DevicePathTextLib.inf
[LibraryClasses.common.SEC]
PeiServicesLib|InOsEmuPkg/Library/SecPeiServicesLib/SecPeiServicesLib.inf
@@ -229,6 +230,9 @@
gInOsEmuPkgTokenSpaceGuid.PcdEmuCpuModel|L"Intel(R) Processor Model"
gInOsEmuPkgTokenSpaceGuid.PcdEmuCpuSpeed|L"3000"
+ # 0-PCANSI, 1-VT100, 2-VT00+, 3-UTF8
+ gEfiMdePkgTokenSpaceGuid.PcdDefaultTerminalType|1
+
################################################################################
#
# Pcd Dynamic Section - list of all EDK II PCD Entries defined by this Platform
@@ -316,7 +320,7 @@
MdeModulePkg/Universal/ReportStatusCodeRouter/RuntimeDxe/ReportStatusCodeRouterRuntimeDxe.inf
MdeModulePkg/Universal/StatusCodeHandler/RuntimeDxe/StatusCodeHandlerRuntimeDxe.inf {
<LibraryClasses>
- SerialPortLib|InOsEmuPkg/Library/DxeEmuSerialPortLib/DxeEmuSerialPortLib.inf
+ SerialPortLib|InOsEmuPkg/Library/DxeEmuStdErrSerialPortLib/DxeEmuStdErrSerialPortLib.inf
}
InOsEmuPkg/MetronomeDxe/Metronome.inf
@@ -341,6 +345,12 @@
MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf
MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf
MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf
+ EmbeddedPkg/SerialDxe/SerialDxe.inf {
+ <LibraryClasses>
+ DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf
+ SerialPortLib|InOsEmuPkg/Library/DxeEmuSerialPortLib/DxeEmuSerialPortLib.inf
+ }
+
MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf
IntelFrameworkModulePkg/Universal/BdsDxe/BdsDxe.inf
MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf
diff --git a/InOsEmuPkg/Unix/UnixX64.fdf b/InOsEmuPkg/Unix/UnixX64.fdf
index d3696927ee..4058815ee5 100644
--- a/InOsEmuPkg/Unix/UnixX64.fdf
+++ b/InOsEmuPkg/Unix/UnixX64.fdf
@@ -207,6 +207,8 @@ INF MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
INF MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf
INF MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf
INF MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf
+
+INF EmbeddedPkg/SerialDxe/SerialDxe.inf
INF MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf
INF MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf
INF MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf