diff options
author | andrewfish <andrewfish@6f19259b-4bc3-4df7-8a09-765794883524> | 2011-06-17 18:21:16 +0000 |
---|---|---|
committer | andrewfish <andrewfish@6f19259b-4bc3-4df7-8a09-765794883524> | 2011-06-17 18:21:16 +0000 |
commit | 57c7d70ff9bcd4365d75b854046bbb390cb579c6 (patch) | |
tree | f55a5d5c20115d918df260ef03071015b36ee1d3 /InOsEmuPkg/Unix | |
parent | d8387fa4af2abae05dc6ec502b27adea455cdaaa (diff) | |
download | edk2-platforms-57c7d70ff9bcd4365d75b854046bbb390cb579c6.tar.xz |
InOsEmuPkg: Implement gIdleLoopEventGuid.
Added a CpuSleep () API to the Emulator Thunk. We needed to do this as the Stall() works hard to not get broken by the timer tic (POSIX signal). nanosleep() gets interrupted by the timer signal so it is a good emulator of a CpuSleep(); I was also able to remove some stalls in the X11 keyboard and mouse checking events, now that the gIdleLoopEventGuid was added.
Signed-off-by: andrewfish
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11846 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'InOsEmuPkg/Unix')
-rw-r--r-- | InOsEmuPkg/Unix/Sec/EmuThunk.c | 17 | ||||
-rw-r--r-- | InOsEmuPkg/Unix/Sec/Gasket.h | 6 | ||||
-rw-r--r-- | InOsEmuPkg/Unix/Sec/X11GraphicsWindow.c | 63 | ||||
-rw-r--r-- | InOsEmuPkg/Unix/Sec/X64/Gasket.S | 16 |
4 files changed, 60 insertions, 42 deletions
diff --git a/InOsEmuPkg/Unix/Sec/EmuThunk.c b/InOsEmuPkg/Unix/Sec/EmuThunk.c index 579f67fa1a..ca8be55a0f 100644 --- a/InOsEmuPkg/Unix/Sec/EmuThunk.c +++ b/InOsEmuPkg/Unix/Sec/EmuThunk.c @@ -286,6 +286,22 @@ SecSleep ( } } + +VOID +SecCpuSleep ( + VOID + ) +{ + struct timespec rq, rm; + + // nanosleep gets interrupted by the timer tic + rq.tv_sec = 1; + rq.tv_nsec = 0; + + nanosleep (&rq, &rm); +} + + VOID SecExit ( UINTN Status @@ -362,6 +378,7 @@ EMU_THUNK_PROTOCOL gEmuThunkProtocol = { GasketQueryPerformanceFrequency, GasketQueryPerformanceCounter, GasketSecSleep, + GasketSecCpuSleep, GasketSecExit, GasketSecGetTime, GasketSecSetTime, diff --git a/InOsEmuPkg/Unix/Sec/Gasket.h b/InOsEmuPkg/Unix/Sec/Gasket.h index 2234bbe8c6..0862b2c9ac 100644 --- a/InOsEmuPkg/Unix/Sec/Gasket.h +++ b/InOsEmuPkg/Unix/Sec/Gasket.h @@ -108,6 +108,12 @@ VOID EFIAPI
GasketSecSleep (
IN UINT64 Milliseconds
+
+ );
+VOID
+EFIAPI
+GasketSecCpuSleep (
+ VOID
);
VOID
diff --git a/InOsEmuPkg/Unix/Sec/X11GraphicsWindow.c b/InOsEmuPkg/Unix/Sec/X11GraphicsWindow.c index 72c4544ce5..10c591d403 100644 --- a/InOsEmuPkg/Unix/Sec/X11GraphicsWindow.c +++ b/InOsEmuPkg/Unix/Sec/X11GraphicsWindow.c @@ -624,24 +624,6 @@ X11ColorToPixel ( return Pixel; } -EFI_STATUS -CheckKeyInternal ( - IN GRAPHICS_IO_PRIVATE *Drv, - IN BOOLEAN delay - ) -{ - HandleEvents (Drv); - - if (Drv->key_count != 0) { - return EFI_SUCCESS; - } - - if (delay) { - // EFI is polling. Be CPU-friendly. - SecSleep (20); - } - return EFI_NOT_READY; -} EFI_STATUS X11CheckKey ( @@ -652,7 +634,13 @@ X11CheckKey ( Drv = (GRAPHICS_IO_PRIVATE *)GraphicsIo; - return CheckKeyInternal (Drv, TRUE); + HandleEvents (Drv); + + if (Drv->key_count != 0) { + return EFI_SUCCESS; + } + + return EFI_NOT_READY; } EFI_STATUS @@ -667,7 +655,7 @@ X11GetKey ( Drv = (GRAPHICS_IO_PRIVATE *)GraphicsIo; - EfiStatus = CheckKeyInternal (Drv, FALSE); + EfiStatus = X11CheckKey (GraphicsIo); if (EFI_ERROR (EfiStatus)) { return EfiStatus; } @@ -879,24 +867,6 @@ X11Blt ( return EFI_SUCCESS; } -EFI_STATUS -CheckPointerInternal ( - IN GRAPHICS_IO_PRIVATE *Drv, - IN BOOLEAN delay - ) -{ - HandleEvents (Drv); - if (Drv->pointer_state_changed != 0) { - return EFI_SUCCESS; - } - - if ( delay ) { - // EFI is polling. Be CPU-friendly. - SecSleep (20); - } - - return EFI_NOT_READY; -} EFI_STATUS X11CheckPointer ( @@ -907,23 +877,32 @@ X11CheckPointer ( Drv = (GRAPHICS_IO_PRIVATE *)GraphicsIo; - return CheckPointerInternal (Drv, TRUE); + HandleEvents (Drv); + if (Drv->pointer_state_changed != 0) { + return EFI_SUCCESS; + } + + return EFI_NOT_READY; } + EFI_STATUS -X11GetPointerState (EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsIo, EFI_SIMPLE_POINTER_STATE *state) +X11GetPointerState ( + IN EMU_GRAPHICS_WINDOW_PROTOCOL *GraphicsIo, + IN EFI_SIMPLE_POINTER_STATE *State + ) { EFI_STATUS EfiStatus; GRAPHICS_IO_PRIVATE *Drv; Drv = (GRAPHICS_IO_PRIVATE *)GraphicsIo; - EfiStatus = CheckPointerInternal (Drv, FALSE); + EfiStatus = X11CheckPointer (GraphicsIo); if (EfiStatus != EFI_SUCCESS) { return EfiStatus; } - memcpy (state, &Drv->pointer_state, sizeof (EFI_SIMPLE_POINTER_STATE)); + memcpy (State, &Drv->pointer_state, sizeof (EFI_SIMPLE_POINTER_STATE)); Drv->pointer_state.RelativeMovementX = 0; Drv->pointer_state.RelativeMovementY = 0; diff --git a/InOsEmuPkg/Unix/Sec/X64/Gasket.S b/InOsEmuPkg/Unix/Sec/X64/Gasket.S index a51807ab47..d30aed617b 100644 --- a/InOsEmuPkg/Unix/Sec/X64/Gasket.S +++ b/InOsEmuPkg/Unix/Sec/X64/Gasket.S @@ -227,6 +227,22 @@ ASM_PFX(GasketSecSleep): ret +ASM_GLOBAL ASM_PFX(GasketSecCpuSleep) +ASM_PFX(GasketSecCpuSleep): + 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(SecCpuSleep) + + popq %rdi // restore state + popq %rsi + popq %rbp + ret + + ASM_GLOBAL ASM_PFX(GasketSecExit) ASM_PFX(GasketSecExit): pushq %rbp // stack frame is for the debugger |