InOsEmuPkg: Rename EmuPthreadThunk to EmuThreadThunk

This reflects that the threading system may vary in the
OS/thunk layer.

Signed-off-by: jljusten

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11662 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
jljusten 2011-05-16 04:47:40 +00:00
parent a80e595de8
commit 10d1be3ed9
10 changed files with 173 additions and 169 deletions

View File

@ -2,16 +2,17 @@
# Component description file for Cpu module. # Component description file for Cpu module.
# #
# This CPU module abstracts the interrupt subsystem of a platform and the CPU-specific setjump-long pair. # This CPU module abstracts the interrupt subsystem of a platform and the CPU-specific setjump-long pair.
# Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR> #
# Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
# #
# This program and the accompanying materials # This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License # 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 # which accompanies this distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php # http://opensource.org/licenses/bsd-license.php
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
# #
#
## ##
[Defines] [Defines]
@ -62,7 +63,7 @@
gEfiHiiProtocolGuid # PROTOCOL SOMETIMES_CONSUMED gEfiHiiProtocolGuid # PROTOCOL SOMETIMES_CONSUMED
gEfiCpuIo2ProtocolGuid # PROTOCOL ALWAYS_PRODUCED gEfiCpuIo2ProtocolGuid # PROTOCOL ALWAYS_PRODUCED
gEfiCpuArchProtocolGuid # PROTOCOL ALWAYS_PRODUCED gEfiCpuArchProtocolGuid # PROTOCOL ALWAYS_PRODUCED
gEmuPthreadThunkProtocolGuid gEmuThreadThunkProtocolGuid
gEfiMpServiceProtocolGuid gEfiMpServiceProtocolGuid
[Pcd] [Pcd]

View File

@ -1,7 +1,8 @@
/*++ @file /*++ @file
Copyright (c) 2006, Intel Corporation. All rights reserved.<BR> Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
Portions copyright (c) 2011, Apple Inc. All rights reserved. Portions copyright (c) 2011, Apple Inc. All rights reserved.
This program and the accompanying materials This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License 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 which accompanies this distribution. The full text of the license may be found at
@ -23,7 +24,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Protocol/Smbios.h> #include <Protocol/Smbios.h>
#include <Protocol/FrameworkHii.h> #include <Protocol/FrameworkHii.h>
#include <Protocol/MpService.h> #include <Protocol/MpService.h>
#include <Protocol/EmuPthreadThunk.h> #include <Protocol/EmuThread.h>
#include <Protocol/CpuIo2.h> #include <Protocol/CpuIo2.h>
#include <Guid/DataHubRecords.h> #include <Guid/DataHubRecords.h>

View File

@ -1,6 +1,7 @@
/** @file /** @file
Construct MP Services Protocol on top of pthreads. This code makes APs show up Construct MP Services Protocol on top of the EMU Thread protocol.
in the emulator. PcdEmuApCount is the number of APs the emulator should produce. This code makes APs show up in the emulator. PcdEmuApCount is the
number of APs the emulator should produce.
The MP Services Protocol provides a generalized way of performing following tasks: The MP Services Protocol provides a generalized way of performing following tasks:
- Retrieving information of multi-processor environment and MP-related status of - Retrieving information of multi-processor environment and MP-related status of
@ -44,7 +45,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
MP_SYSTEM_DATA gMPSystem; MP_SYSTEM_DATA gMPSystem;
EMU_PTREAD_THUNK_PROTOCOL *gPthread = NULL; EMU_THREAD_THUNK_PROTOCOL *gThread = NULL;
EFI_EVENT gReadToBootEvent; EFI_EVENT gReadToBootEvent;
BOOLEAN gReadToBoot = FALSE; BOOLEAN gReadToBoot = FALSE;
UINTN gPollInterval; UINTN gPollInterval;
@ -74,10 +75,10 @@ SetApProcedure (
IN VOID *ProcedureArgument IN VOID *ProcedureArgument
) )
{ {
gPthread->MutextLock (Processor->ProcedureLock); gThread->MutexLock (Processor->ProcedureLock);
Processor->Parameter = ProcedureArgument; Processor->Parameter = ProcedureArgument;
Processor->Procedure = Procedure; Processor->Procedure = Procedure;
gPthread->MutexUnlock (Processor->ProcedureLock); gThread->MutexUnlock (Processor->ProcedureLock);
} }
@ -97,9 +98,9 @@ GetNextBlockedNumber (
continue; continue;
} }
gPthread->MutextLock (Data->StateLock); gThread->MutexLock (Data->StateLock);
ProcessorState = Data->State; ProcessorState = Data->State;
gPthread->MutexUnlock (Data->StateLock); gThread->MutexUnlock (Data->StateLock);
if (ProcessorState == CPU_STATE_BLOCKED) { if (ProcessorState == CPU_STATE_BLOCKED) {
*NextNumber = Number; *NextNumber = Number;
@ -433,9 +434,9 @@ CpuMpServicesStartupAllAps (
if (ProcessorData->State == CPU_STATE_IDLE) { if (ProcessorData->State == CPU_STATE_IDLE) {
gMPSystem.StartCount++; gMPSystem.StartCount++;
gPthread->MutextLock (&ProcessorData->StateLock); gThread->MutexLock (&ProcessorData->StateLock);
ProcessorData->State = APInitialState; ProcessorData->State = APInitialState;
gPthread->MutexUnlock (&ProcessorData->StateLock); gThread->MutexUnlock (&ProcessorData->StateLock);
if (SingleThread) { if (SingleThread) {
APInitialState = CPU_STATE_BLOCKED; APInitialState = CPU_STATE_BLOCKED;
@ -462,9 +463,9 @@ CpuMpServicesStartupAllAps (
continue; continue;
} }
gPthread->MutextLock (ProcessorData->StateLock); gThread->MutexLock (ProcessorData->StateLock);
ProcessorState = ProcessorData->State; ProcessorState = ProcessorData->State;
gPthread->MutexUnlock (ProcessorData->StateLock); gThread->MutexUnlock (ProcessorData->StateLock);
switch (ProcessorState) { switch (ProcessorState) {
case CPU_STATE_READY: case CPU_STATE_READY:
@ -649,14 +650,14 @@ CpuMpServicesStartupThisAP (
SetApProcedure (&gMPSystem.ProcessorData[ProcessorNumber], Procedure, ProcedureArgument); SetApProcedure (&gMPSystem.ProcessorData[ProcessorNumber], Procedure, ProcedureArgument);
while (TRUE) { while (TRUE) {
gPthread->MutextLock (&gMPSystem.ProcessorData[ProcessorNumber].StateLock); gThread->MutexLock (&gMPSystem.ProcessorData[ProcessorNumber].StateLock);
if (gMPSystem.ProcessorData[ProcessorNumber].State == CPU_STATE_FINISHED) { if (gMPSystem.ProcessorData[ProcessorNumber].State == CPU_STATE_FINISHED) {
gMPSystem.ProcessorData[ProcessorNumber].State = CPU_STATE_IDLE; gMPSystem.ProcessorData[ProcessorNumber].State = CPU_STATE_IDLE;
gPthread->MutexUnlock (&gMPSystem.ProcessorData[ProcessorNumber].StateLock); gThread->MutexUnlock (&gMPSystem.ProcessorData[ProcessorNumber].StateLock);
break; break;
} }
gPthread->MutexUnlock (&gMPSystem.ProcessorData[ProcessorNumber].StateLock); gThread->MutexUnlock (&gMPSystem.ProcessorData[ProcessorNumber].StateLock);
if ((TimeoutInMicroseconds != 0) && (Timeout < 0)) { if ((TimeoutInMicroseconds != 0) && (Timeout < 0)) {
gMPSystem.WaitEvent = WaitEvent; gMPSystem.WaitEvent = WaitEvent;
@ -821,7 +822,7 @@ CpuMpServicesEnableDisableAP (
return EFI_UNSUPPORTED; return EFI_UNSUPPORTED;
} }
gPthread->MutextLock (&gMPSystem.ProcessorData[ProcessorNumber].StateLock); gThread->MutexLock (&gMPSystem.ProcessorData[ProcessorNumber].StateLock);
if (EnableAP) { if (EnableAP) {
if ((gMPSystem.ProcessorData[ProcessorNumber].Info.StatusFlag & PROCESSOR_ENABLED_BIT) == 0 ) { if ((gMPSystem.ProcessorData[ProcessorNumber].Info.StatusFlag & PROCESSOR_ENABLED_BIT) == 0 ) {
@ -840,7 +841,7 @@ CpuMpServicesEnableDisableAP (
gMPSystem.ProcessorData[ProcessorNumber].Info.StatusFlag |= (*HealthFlag & PROCESSOR_HEALTH_STATUS_BIT); gMPSystem.ProcessorData[ProcessorNumber].Info.StatusFlag |= (*HealthFlag & PROCESSOR_HEALTH_STATUS_BIT);
} }
gPthread->MutexUnlock (&gMPSystem.ProcessorData[ProcessorNumber].StateLock); gThread->MutexUnlock (&gMPSystem.ProcessorData[ProcessorNumber].StateLock);
return EFI_SUCCESS; return EFI_SUCCESS;
} }
@ -884,7 +885,7 @@ CpuMpServicesWhoAmI (
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
} }
ProcessorId = gPthread->Self (); ProcessorId = gThread->Self ();
for (Index = 0; Index < gMPSystem.NumberOfProcessors; Index++) { for (Index = 0; Index < gMPSystem.NumberOfProcessors; Index++) {
if (gMPSystem.ProcessorData[Index].Info.ProcessorId == ProcessorId) { if (gMPSystem.ProcessorData[Index].Info.ProcessorId == ProcessorId) {
break; break;
@ -942,12 +943,12 @@ CpuCheckAllAPsStatus (
// context. Meaning deadlock. Which is a bad thing. // context. Meaning deadlock. Which is a bad thing.
// So, try lock it. If we can get it, cool, do our thing. // So, try lock it. If we can get it, cool, do our thing.
// otherwise, just dump out & try again on the next iteration. // otherwise, just dump out & try again on the next iteration.
Status = gPthread->MutexTryLock (gMPSystem.ProcessorData[ProcessorNumber].StateLock); Status = gThread->MutexTryLock (gMPSystem.ProcessorData[ProcessorNumber].StateLock);
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
return; return;
} }
ProcessorState = gMPSystem.ProcessorData[ProcessorNumber].State; ProcessorState = gMPSystem.ProcessorData[ProcessorNumber].State;
gPthread->MutexUnlock (gMPSystem.ProcessorData[ProcessorNumber].StateLock); gThread->MutexUnlock (gMPSystem.ProcessorData[ProcessorNumber].StateLock);
switch (ProcessorState) { switch (ProcessorState) {
case CPU_STATE_READY: case CPU_STATE_READY:
@ -960,9 +961,9 @@ CpuCheckAllAPsStatus (
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
NextData = &gMPSystem.ProcessorData[NextNumber]; NextData = &gMPSystem.ProcessorData[NextNumber];
gPthread->MutextLock (&NextData->ProcedureLock); gThread->MutexLock (&NextData->ProcedureLock);
NextData->State = CPU_STATE_READY; NextData->State = CPU_STATE_READY;
gPthread->MutexUnlock (&NextData->ProcedureLock); gThread->MutexUnlock (&NextData->ProcedureLock);
SetApProcedure (NextData, gMPSystem.Procedure, gMPSystem.ProcedureArgument); SetApProcedure (NextData, gMPSystem.Procedure, gMPSystem.ProcedureArgument);
} }
@ -1009,12 +1010,12 @@ CpuCheckThisAPStatus (
// So, try lock it. If we can get it, cool, do our thing. // So, try lock it. If we can get it, cool, do our thing.
// otherwise, just dump out & try again on the next iteration. // otherwise, just dump out & try again on the next iteration.
// //
Status = gPthread->MutexTryLock (ProcessorData->StateLock); Status = gThread->MutexTryLock (ProcessorData->StateLock);
if (EFI_ERROR(Status)) { if (EFI_ERROR(Status)) {
return; return;
} }
ProcessorState = ProcessorData->State; ProcessorState = ProcessorData->State;
gPthread->MutexUnlock (ProcessorData->StateLock); gThread->MutexUnlock (ProcessorData->StateLock);
if (ProcessorState == CPU_STATE_FINISHED) { if (ProcessorState == CPU_STATE_FINISHED) {
Status = gBS->SetTimer (ProcessorData->CheckThisAPEvent, TimerCancel, 0); Status = gBS->SetTimer (ProcessorData->CheckThisAPEvent, TimerCancel, 0);
@ -1023,9 +1024,9 @@ CpuCheckThisAPStatus (
Status = gBS->SignalEvent (gMPSystem.WaitEvent); Status = gBS->SignalEvent (gMPSystem.WaitEvent);
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
gPthread->MutextLock (ProcessorData->StateLock); gThread->MutexLock (ProcessorData->StateLock);
ProcessorData->State = CPU_STATE_IDLE; ProcessorData->State = CPU_STATE_IDLE;
gPthread->MutexUnlock (ProcessorData->StateLock); gThread->MutexUnlock (ProcessorData->StateLock);
} }
return ; return ;
@ -1051,7 +1052,7 @@ FillInProcessorInformation (
ProcessorData = &gMPSystem.ProcessorData[ProcessorNumber]; ProcessorData = &gMPSystem.ProcessorData[ProcessorNumber];
gMPSystem.ProcessorData[ProcessorNumber].Info.ProcessorId = gPthread->Self (); gMPSystem.ProcessorData[ProcessorNumber].Info.ProcessorId = gThread->Self ();
gMPSystem.ProcessorData[ProcessorNumber].Info.StatusFlag = PROCESSOR_ENABLED_BIT | PROCESSOR_HEALTH_STATUS_BIT; gMPSystem.ProcessorData[ProcessorNumber].Info.StatusFlag = PROCESSOR_ENABLED_BIT | PROCESSOR_HEALTH_STATUS_BIT;
if (BSP) { if (BSP) {
gMPSystem.ProcessorData[ProcessorNumber].Info.StatusFlag |= PROCESSOR_AS_BSP_BIT; gMPSystem.ProcessorData[ProcessorNumber].Info.StatusFlag |= PROCESSOR_AS_BSP_BIT;
@ -1064,8 +1065,8 @@ FillInProcessorInformation (
gMPSystem.ProcessorData[ProcessorNumber].Procedure = NULL; gMPSystem.ProcessorData[ProcessorNumber].Procedure = NULL;
gMPSystem.ProcessorData[ProcessorNumber].Parameter = NULL; gMPSystem.ProcessorData[ProcessorNumber].Parameter = NULL;
gMPSystem.ProcessorData[ProcessorNumber].StateLock = gPthread->MutexInit (); gMPSystem.ProcessorData[ProcessorNumber].StateLock = gThread->MutexInit ();
gMPSystem.ProcessorData[ProcessorNumber].ProcedureLock = gPthread->MutexInit (); gMPSystem.ProcessorData[ProcessorNumber].ProcedureLock = gThread->MutexInit ();
return EFI_SUCCESS; return EFI_SUCCESS;
} }
@ -1084,31 +1085,31 @@ CpuDriverApIdolLoop (
ProcessorNumber = (UINTN)Context; ProcessorNumber = (UINTN)Context;
ProcessorData = &gMPSystem.ProcessorData[ProcessorNumber]; ProcessorData = &gMPSystem.ProcessorData[ProcessorNumber];
ProcessorData->Info.ProcessorId = gPthread->Self (); ProcessorData->Info.ProcessorId = gThread->Self ();
while (TRUE) { while (TRUE) {
// //
// Make a local copy on the stack to be extra safe // Make a local copy on the stack to be extra safe
// //
gPthread->MutextLock (ProcessorData->ProcedureLock); gThread->MutexLock (ProcessorData->ProcedureLock);
Procedure = ProcessorData->Procedure; Procedure = ProcessorData->Procedure;
Parameter = ProcessorData->Parameter; Parameter = ProcessorData->Parameter;
gPthread->MutexUnlock (ProcessorData->ProcedureLock); gThread->MutexUnlock (ProcessorData->ProcedureLock);
if (Procedure != NULL) { if (Procedure != NULL) {
gPthread->MutextLock (ProcessorData->StateLock); gThread->MutexLock (ProcessorData->StateLock);
ProcessorData->State = CPU_STATE_BUSY; ProcessorData->State = CPU_STATE_BUSY;
gPthread->MutexUnlock (ProcessorData->StateLock); gThread->MutexUnlock (ProcessorData->StateLock);
Procedure (Parameter); Procedure (Parameter);
gPthread->MutextLock (ProcessorData->ProcedureLock); gThread->MutexLock (ProcessorData->ProcedureLock);
ProcessorData->Procedure = NULL; ProcessorData->Procedure = NULL;
gPthread->MutexUnlock (ProcessorData->ProcedureLock); gThread->MutexUnlock (ProcessorData->ProcedureLock);
gPthread->MutextLock (ProcessorData->StateLock); gThread->MutexLock (ProcessorData->StateLock);
ProcessorData->State = CPU_STATE_FINISHED; ProcessorData->State = CPU_STATE_FINISHED;
gPthread->MutexUnlock (ProcessorData->StateLock); gThread->MutexUnlock (ProcessorData->StateLock);
} }
// Poll 5 times a seconds, 200ms // Poll 5 times a seconds, 200ms
@ -1163,7 +1164,7 @@ InitializeMpSystemData (
FillInProcessorInformation (FALSE, Index); FillInProcessorInformation (FALSE, Index);
Status = gPthread->CreateThread ( Status = gThread->CreateThread (
(VOID *)&gMPSystem.ProcessorData[Index].Info.ProcessorId, (VOID *)&gMPSystem.ProcessorData[Index].Info.ProcessorId,
NULL, NULL,
CpuDriverApIdolLoop, CpuDriverApIdolLoop,
@ -1217,13 +1218,13 @@ CpuMpServicesInit (
MaxCpus = 1; // BSP MaxCpus = 1; // BSP
IoThunk = GetIoThunkInstance (&gEmuPthreadThunkProtocolGuid, 0); IoThunk = GetIoThunkInstance (&gEmuThreadThunkProtocolGuid, 0);
if (IoThunk != NULL) { if (IoThunk != NULL) {
Status = IoThunk->Open (IoThunk); Status = IoThunk->Open (IoThunk);
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
if (IoThunk->ConfigString != NULL) { if (IoThunk->ConfigString != NULL) {
MaxCpus += StrDecimalToUintn (IoThunk->ConfigString); MaxCpus += StrDecimalToUintn (IoThunk->ConfigString);
gPthread = IoThunk->Interface; gThread = IoThunk->Interface;
} }
} }
} }

View File

@ -2,7 +2,7 @@
# #
# This is the Emu Emulation Environment Platform # This is the Emu Emulation Environment Platform
# #
# Copyright (c) 2008 - 2010, Intel Corporation. All rights reserved.<BR> # Copyright (c) 2008 - 2011, Intel Corporation. All rights reserved.<BR>
# Portions copyright (c) 2011, Apple Inc. All rights reserved. # Portions copyright (c) 2011, Apple Inc. All rights reserved.
# #
# This program and the accompanying materials are licensed and made available # This program and the accompanying materials are licensed and made available
@ -35,7 +35,7 @@
gEmuThunkProtocolGuid = { 0x398DCA31, 0x3505, 0xDB47, { 0xBD, 0x93, 0x1D, 0x38, 0x5F, 0x79, 0x13, 0x15 } } gEmuThunkProtocolGuid = { 0x398DCA31, 0x3505, 0xDB47, { 0xBD, 0x93, 0x1D, 0x38, 0x5F, 0x79, 0x13, 0x15 } }
gEmuIoThunkProtocolGuid = { 0x453368F6, 0x7C85, 0x434A, { 0xA9, 0x8A, 0x72, 0xD1, 0xB7, 0xFF, 0xA9, 0x26 } } gEmuIoThunkProtocolGuid = { 0x453368F6, 0x7C85, 0x434A, { 0xA9, 0x8A, 0x72, 0xD1, 0xB7, 0xFF, 0xA9, 0x26 } }
gEmuGraphicsWindowProtocolGuid = { 0x30FD316A, 0x6728, 0x2E41, { 0xA6, 0x90, 0x0D, 0x13, 0x33, 0xD8, 0xCA, 0xC1 } } gEmuGraphicsWindowProtocolGuid = { 0x30FD316A, 0x6728, 0x2E41, { 0xA6, 0x90, 0x0D, 0x13, 0x33, 0xD8, 0xCA, 0xC1 } }
gEmuPthreadThunkProtocolGuid = { 0x3B1E4B7C, 0x09D8, 0x944F, { 0xA4, 0x08, 0x13, 0x09, 0xEB, 0x8B, 0x44, 0x27 } } gEmuThreadThunkProtocolGuid = { 0x3B1E4B7C, 0x09D8, 0x944F, { 0xA4, 0x08, 0x13, 0x09, 0xEB, 0x8B, 0x44, 0x27 } }
[Ppis] [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 } }

View File

@ -1,106 +0,0 @@
/** @file
Emulator Thunk to abstract OS services from pure EFI code
Copyright (c) 2010 - 2011, Apple Inc. All rights reserved.<BR>
Copyright (c) 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.
**/
#ifndef __EMU_PTHREAD_THUNK__
#define __EMU_PTHREAD_THUNK__
#define EMU_PTHREAD_THUNK_PROTOCO_GUID \
{ 0x3B1E4B7C, 0x09D8, 0x944F, { 0xA4, 0x08, 0x13, 0x09, 0xEB, 0x8B, 0x44, 0x27 } }
typedef struct _EMU_PTREAD_THUNK_PROTOCOL EMU_PTREAD_THUNK_PROTOCOL;
typedef
UINTN
(EFIAPI *PTREAD_THUNK_MUTEXT_LOCK) (
IN VOID *Mutex
);
typedef
UINTN
(EFIAPI *PTREAD_THUNK_MUTEXT_UNLOCK) (
IN VOID *Mutex
);
typedef
UINTN
(EFIAPI *PTREAD_THUNK_MUTEX_TRY_LOCK) (
IN VOID *Mutex
);
typedef
VOID *
(EFIAPI *PTREAD_THUNK_MUTEX_INIT) (
IN VOID
);
typedef
UINTN
(EFIAPI *PTREAD_THUNK_MUTEX_DISTROY) (
IN VOID *Mutex
);
typedef
VOID *
(EFIAPI *PTREAD_THUNK_THEAD_ENTRY) (
IN VOID *Context
);
typedef
UINTN
(EFIAPI *PTREAD_THUNK_CREATE_THREAD) (
IN VOID *Thread,
IN VOID *Attribute,
IN PTREAD_THUNK_THEAD_ENTRY Start,
IN VOID *Context
);
typedef
VOID
(EFIAPI *PTREAD_THUNK_EXIT_THREAD) (
IN VOID *ValuePtr
);
typedef
UINTN
(EFIAPI *PTREAD_THUNK_SELF) (
VOID
);
struct _EMU_PTREAD_THUNK_PROTOCOL {
PTREAD_THUNK_MUTEXT_LOCK MutextLock;
PTREAD_THUNK_MUTEXT_UNLOCK MutexUnlock;
PTREAD_THUNK_MUTEX_TRY_LOCK MutexTryLock;
PTREAD_THUNK_MUTEX_INIT MutexInit;
PTREAD_THUNK_MUTEX_DISTROY MutexDistroy;
PTREAD_THUNK_CREATE_THREAD CreateThread;
PTREAD_THUNK_EXIT_THREAD ExitThread;
PTREAD_THUNK_SELF Self;
};
extern EFI_GUID gEmuPthreadThunkProtocolGuid;
#endif

View File

@ -0,0 +1,103 @@
/** @file
Emulator Thunk to abstract OS services from pure EFI code
Copyright (c) 2010 - 2011, Apple Inc. All rights reserved.<BR>
Copyright (c) 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.
**/
#ifndef __EMU_THREAD_THUNK__
#define __EMU_THREAD_THUNK__
typedef struct _EMU_THREAD_THUNK_PROTOCOL EMU_THREAD_THUNK_PROTOCOL;
typedef
UINTN
(EFIAPI *THREAD_THUNK_MUTEX_LOCK) (
IN VOID *Mutex
);
typedef
UINTN
(EFIAPI *THREAD_THUNK_MUTEX_UNLOCK) (
IN VOID *Mutex
);
typedef
UINTN
(EFIAPI *THREAD_THUNK_MUTEX_TRY_LOCK) (
IN VOID *Mutex
);
typedef
VOID *
(EFIAPI *THREAD_THUNK_MUTEX_INIT) (
IN VOID
);
typedef
UINTN
(EFIAPI *THREAD_THUNK_MUTEX_DISTROY) (
IN VOID *Mutex
);
typedef
VOID *
(EFIAPI *THREAD_THUNK_THREAD_ENTRY) (
IN VOID *Context
);
typedef
UINTN
(EFIAPI *THREAD_THUNK_CREATE_THREAD) (
IN VOID *Thread,
IN VOID *Attribute,
IN THREAD_THUNK_THREAD_ENTRY Start,
IN VOID *Context
);
typedef
VOID
(EFIAPI *THREAD_THUNK_EXIT_THREAD) (
IN VOID *ValuePtr
);
typedef
UINTN
(EFIAPI *THREAD_THUNK_SELF) (
VOID
);
struct _EMU_THREAD_THUNK_PROTOCOL {
THREAD_THUNK_MUTEX_LOCK MutexLock;
THREAD_THUNK_MUTEX_UNLOCK MutexUnlock;
THREAD_THUNK_MUTEX_TRY_LOCK MutexTryLock;
THREAD_THUNK_MUTEX_INIT MutexInit;
THREAD_THUNK_MUTEX_DISTROY MutexDistroy;
THREAD_THUNK_CREATE_THREAD CreateThread;
THREAD_THUNK_EXIT_THREAD ExitThread;
THREAD_THUNK_SELF Self;
};
extern EFI_GUID gEmuThreadThunkProtocolGuid;
#endif

View File

@ -1,6 +1,7 @@
/** @file /** @file
Copyright (c) 2008 - 2011, Apple Inc. All rights reserved.<BR> Copyright (c) 2008 - 2011, Apple Inc. All rights reserved.<BR>
Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License are licensed and made available under the terms and conditions of the BSD License
@ -277,7 +278,7 @@ EFIAPI
GasketPthreadCreate ( GasketPthreadCreate (
IN VOID *Thread, IN VOID *Thread,
IN VOID *Attribute, IN VOID *Attribute,
IN PTREAD_THUNK_THEAD_ENTRY Start, IN THREAD_THUNK_THREAD_ENTRY Start,
IN VOID *Context IN VOID *Context
); );

View File

@ -2,6 +2,8 @@
POSIX Pthreads to emulate APs and implement threads POSIX Pthreads to emulate APs and implement threads
Copyright (c) 2011, Apple Inc. All rights reserved. Copyright (c) 2011, Apple Inc. All rights reserved.
Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License 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 which accompanies this distribution. The full text of the license may be found at
@ -81,7 +83,7 @@ PthreadMutexDestroy (
// Can't store this data on PthreadCreate stack so we need a global // Can't store this data on PthreadCreate stack so we need a global
typedef struct { typedef struct {
pthread_mutex_t Mutex; pthread_mutex_t Mutex;
PTREAD_THUNK_THEAD_ENTRY Start; THREAD_THUNK_THREAD_ENTRY Start;
} THREAD_MANGLE; } THREAD_MANGLE;
THREAD_MANGLE mThreadMangle = { THREAD_MANGLE mThreadMangle = {
@ -94,7 +96,7 @@ SecFakePthreadStart (
VOID *Context VOID *Context
) )
{ {
PTREAD_THUNK_THEAD_ENTRY Start; THREAD_THUNK_THREAD_ENTRY Start;
sigset_t SigMask; sigset_t SigMask;
// Save global on the stack before we unlock // Save global on the stack before we unlock
@ -120,7 +122,7 @@ UINTN
PthreadCreate ( PthreadCreate (
IN VOID *Thread, IN VOID *Thread,
IN VOID *Attribute, IN VOID *Attribute,
IN PTREAD_THUNK_THEAD_ENTRY Start, IN THREAD_THUNK_THREAD_ENTRY Start,
IN VOID *Context IN VOID *Context
) )
{ {
@ -178,7 +180,7 @@ PthreadSelf (
} }
EMU_PTREAD_THUNK_PROTOCOL gPthreadThunk = { EMU_THREAD_THUNK_PROTOCOL gPthreadThunk = {
GasketPthreadMutexLock, GasketPthreadMutexLock,
GasketPthreadMutexUnLock, GasketPthreadMutexUnLock,
GasketPthreadMutexTryLock, GasketPthreadMutexTryLock,
@ -221,7 +223,7 @@ PthreadClose (
EMU_IO_THUNK_PROTOCOL gPthreadThunkIo = { EMU_IO_THUNK_PROTOCOL gPthreadThunkIo = {
&gEmuPthreadThunkProtocolGuid, &gEmuThreadThunkProtocolGuid,
NULL, NULL,
NULL, NULL,
0, 0,

View File

@ -1,7 +1,8 @@
/*++ @file /*++ @file
Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR> Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
Portions copyright (c) 2008 - 2011, Apple Inc. All rights reserved.<BR> Portions copyright (c) 2008 - 2011, Apple Inc. All rights reserved.<BR>
This program and the accompanying materials This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License 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 which accompanies this distribution. The full text of the license may be found at
@ -44,7 +45,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Protocol/EmuThunk.h> #include <Protocol/EmuThunk.h>
#include <Protocol/EmuIoThunk.h> #include <Protocol/EmuIoThunk.h>
#include <Protocol/EmuGraphicsWindow.h> #include <Protocol/EmuGraphicsWindow.h>
#include <Protocol/EmuPthreadThunk.h> #include <Protocol/EmuThread.h>
#include <Guid/FileInfo.h> #include <Guid/FileInfo.h>
#include <Guid/FileSystemInfo.h> #include <Guid/FileSystemInfo.h>

View File

@ -67,7 +67,7 @@
gEmuIoThunkProtocolGuid gEmuIoThunkProtocolGuid
gEmuIoThunkProtocolGuid gEmuIoThunkProtocolGuid
gEmuGraphicsWindowProtocolGuid gEmuGraphicsWindowProtocolGuid
gEmuPthreadThunkProtocolGuid gEmuThreadThunkProtocolGuid
gEfiSimpleFileSystemProtocolGuid gEfiSimpleFileSystemProtocolGuid