summaryrefslogtreecommitdiff
path: root/InOsEmuPkg/Unix/Sec/EmuThunk.c
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/Sec/EmuThunk.c
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/Sec/EmuThunk.c')
-rw-r--r--InOsEmuPkg/Unix/Sec/EmuThunk.c69
1 files changed, 68 insertions, 1 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,