TianoCore EDK2 master
Loading...
Searching...
No Matches
WinThunk.c File Reference
#include "WinHost.h"

Go to the source code of this file.

Functions

UINTN SecWriteStdErr (IN UINT8 *Buffer, IN UINTN NumberOfBytes)
 
EFI_STATUS SecConfigStdIn (VOID)
 
UINTN SecWriteStdOut (IN UINT8 *Buffer, IN UINTN NumberOfBytes)
 
BOOLEAN SecPollStdIn (VOID)
 
UINTN SecReadStdIn (IN UINT8 *Buffer, IN UINTN NumberOfBytes)
 
VOID * SecAlloc (IN UINTN Size)
 
BOOLEAN SecFree (IN VOID *Ptr)
 
VOID CALLBACK MMTimerThread (UINT wTimerID, UINT msg, DWORD_PTR dwUser, DWORD_PTR dw1, DWORD_PTR dw2)
 
VOID SecSetTimer (IN UINT64 TimerPeriod, IN EMU_SET_TIMER_CALLBACK Callback)
 
VOID SecInitializeThunk (VOID)
 
VOID SecEnableInterrupt (VOID)
 
VOID SecDisableInterrupt (VOID)
 
UINT64 SecQueryPerformanceFrequency (VOID)
 
UINT64 SecQueryPerformanceCounter (VOID)
 
VOID SecSleep (IN UINT64 Nanoseconds)
 
VOID SecCpuSleep (VOID)
 
VOID SecExit (UINTN Status)
 
VOID SecGetTime (OUT EFI_TIME *Time, OUT EFI_TIME_CAPABILITIES *Capabilities OPTIONAL)
 
EFI_STATUS SecSetTime (IN EFI_TIME *Time)
 

Variables

STATIC BOOLEAN mEmulatorStdInConfigured = FALSE
 
STATIC DWORD mOldStdInMode
 
STATIC UINT64 mPerformanceFrequency = 0
 
BOOLEAN mCancelTimerThread = FALSE
 
EMU_SET_TIMER_CALLBACK * mTimerNotifyFunction = NULL
 
HANDLE mNtMainThreadHandle
 
UINT32 mNtLastTick
 
CRITICAL_SECTION mNtCriticalSection
 
UINT mMMTimerThreadID = 0
 
volatile BOOLEAN mInterruptEnabled = FALSE
 
EMU_THUNK_PROTOCOL gEmuThunkProtocol
 

Detailed Description

Copyright (c) 2006 - 2023, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

Module Name:

WinThunk.c

Abstract:

Since the SEC is the only windows program in our emulation we must use a Tiano mechanism to export operating system services to other modules. This is the role of the EMU_THUNK_PROTOCOL.

The gEmuThunkProtocol exists so that a change to EMU_THUNK_PROTOCOL will cause an error in initializing the array if all the member functions are not added. It looks like adding a element to end and not initializing it may cause the table to be initalized with the members at the end being set to zero. This is bad as jumping to zero will case EmulatorPkg to crash.

Definition in file WinThunk.c.

Function Documentation

◆ MMTimerThread()

VOID CALLBACK MMTimerThread ( UINT  wTimerID,
UINT  msg,
DWORD_PTR  dwUser,
DWORD_PTR  dw1,
DWORD_PTR  dw2 
)

Definition at line 268 of file WinThunk.c.

◆ SecAlloc()

VOID * SecAlloc ( IN UINTN  Size)

Definition at line 210 of file WinThunk.c.

◆ SecConfigStdIn()

EFI_STATUS SecConfigStdIn ( VOID  )

Definition at line 56 of file WinThunk.c.

◆ SecCpuSleep()

VOID SecCpuSleep ( VOID  )

Definition at line 486 of file WinThunk.c.

◆ SecDisableInterrupt()

VOID SecDisableInterrupt ( VOID  )

Definition at line 444 of file WinThunk.c.

◆ SecEnableInterrupt()

VOID SecEnableInterrupt ( VOID  )

Definition at line 436 of file WinThunk.c.

◆ SecExit()

VOID SecExit ( UINTN  Status)

Definition at line 494 of file WinThunk.c.

◆ SecFree()

BOOLEAN SecFree ( IN VOID *  Ptr)

Definition at line 218 of file WinThunk.c.

◆ SecGetTime()

VOID SecGetTime ( OUT EFI_TIME Time,
OUT EFI_TIME_CAPABILITIES *Capabilities  OPTIONAL 
)

Definition at line 517 of file WinThunk.c.

◆ SecInitializeThunk()

VOID SecInitializeThunk ( VOID  )

Definition at line 418 of file WinThunk.c.

◆ SecPollStdIn()

BOOLEAN SecPollStdIn ( VOID  )

Definition at line 138 of file WinThunk.c.

◆ SecQueryPerformanceCounter()

UINT64 SecQueryPerformanceCounter ( VOID  )

Definition at line 466 of file WinThunk.c.

◆ SecQueryPerformanceFrequency()

UINT64 SecQueryPerformanceFrequency ( VOID  )

Definition at line 452 of file WinThunk.c.

◆ SecReadStdIn()

UINTN SecReadStdIn ( IN UINT8 *  Buffer,
IN UINTN  NumberOfBytes 
)

Definition at line 179 of file WinThunk.c.

◆ SecSetTime()

EFI_STATUS SecSetTime ( IN EFI_TIME Time)

Definition at line 550 of file WinThunk.c.

◆ SecSetTimer()

VOID SecSetTimer ( IN UINT64  TimerPeriod,
IN EMU_SET_TIMER_CALLBACK  Callback 
)

Definition at line 355 of file WinThunk.c.

◆ SecSleep()

VOID SecSleep ( IN UINT64  Nanoseconds)

Definition at line 478 of file WinThunk.c.

◆ SecWriteStdErr()

UINTN SecWriteStdErr ( IN UINT8 *  Buffer,
IN UINTN  NumberOfBytes 
)

Definition at line 35 of file WinThunk.c.

◆ SecWriteStdOut()

UINTN SecWriteStdOut ( IN UINT8 *  Buffer,
IN UINTN  NumberOfBytes 
)

Definition at line 117 of file WinThunk.c.

Variable Documentation

◆ gEmuThunkProtocol

EMU_THUNK_PROTOCOL gEmuThunkProtocol
Initial value:
= {
SecWriteStdErr,
SecConfigStdIn,
SecWriteStdOut,
SecReadStdIn,
SecPollStdIn,
SecAlloc,
SecFree,
SecPeCoffGetEntryPoint,
SecEnableInterrupt,
SecDisableInterrupt,
SecQueryPerformanceFrequency,
SecQueryPerformanceCounter,
SecSleep,
SecCpuSleep,
SecExit,
SecGetTime,
SecSetTime,
SecSetTimer,
GetNextThunkProtocol
}
VOID EFIAPI PeCoffLoaderUnloadImageExtraAction(IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext)
VOID EFIAPI PeCoffLoaderRelocateImageExtraAction(IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext)
#define NULL
Definition: Base.h:319

Definition at line 586 of file WinThunk.c.

◆ mCancelTimerThread

BOOLEAN mCancelTimerThread = FALSE

Definition at line 236 of file WinThunk.c.

◆ mEmulatorStdInConfigured

STATIC BOOLEAN mEmulatorStdInConfigured = FALSE

Definition at line 26 of file WinThunk.c.

◆ mInterruptEnabled

volatile BOOLEAN mInterruptEnabled = FALSE

Definition at line 264 of file WinThunk.c.

◆ mMMTimerThreadID

UINT mMMTimerThreadID = 0

Definition at line 262 of file WinThunk.c.

◆ mNtCriticalSection

CRITICAL_SECTION mNtCriticalSection

Definition at line 257 of file WinThunk.c.

◆ mNtLastTick

UINT32 mNtLastTick

Definition at line 251 of file WinThunk.c.

◆ mNtMainThreadHandle

HANDLE mNtMainThreadHandle

Definition at line 246 of file WinThunk.c.

◆ mOldStdInMode

STATIC DWORD mOldStdInMode

Definition at line 27 of file WinThunk.c.

◆ mPerformanceFrequency

STATIC UINT64 mPerformanceFrequency = 0

Definition at line 32 of file WinThunk.c.

◆ mTimerNotifyFunction

EMU_SET_TIMER_CALLBACK* mTimerNotifyFunction = NULL

Definition at line 241 of file WinThunk.c.