summaryrefslogtreecommitdiff
path: root/InOsEmuPkg/Unix
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/Unix
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/Unix')
-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
6 files changed, 181 insertions, 5 deletions
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