diff options
author | Chen Fan <chen.fan.fnst@cn.fujitsu.com> | 2014-11-13 18:28:33 +0000 |
---|---|---|
committer | jljusten <jljusten@Edk2> | 2014-11-13 18:28:33 +0000 |
commit | d16cf36d2a226cf6a527099407b6b0b70a0f9faa (patch) | |
tree | 08bf05d5191b56e921e009796a149fbbb19b1d99 /UefiCpuPkg/CpuDxe/CpuMp.c | |
parent | acb2172d15ed793c8ae0484700d42dcc105f2ea1 (diff) | |
download | edk2-d16cf36d2a226cf6a527099407b6b0b70a0f9faa.tar.gz edk2-d16cf36d2a226cf6a527099407b6b0b70a0f9faa.tar.bz2 edk2-d16cf36d2a226cf6a527099407b6b0b70a0f9faa.zip |
UefiCpuPkg/MpService: Simply Lock usage
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Chen Fan <chen.fan.fnst@cn.fujitsu.com>
Reviewed-by: Jeff Fan <jeff.fan@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16363 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'UefiCpuPkg/CpuDxe/CpuMp.c')
-rw-r--r-- | UefiCpuPkg/CpuDxe/CpuMp.c | 89 |
1 files changed, 47 insertions, 42 deletions
diff --git a/UefiCpuPkg/CpuDxe/CpuMp.c b/UefiCpuPkg/CpuDxe/CpuMp.c index 7ceda3550d..a37e45aebd 100644 --- a/UefiCpuPkg/CpuDxe/CpuMp.c +++ b/UefiCpuPkg/CpuDxe/CpuMp.c @@ -38,6 +38,36 @@ EFI_MP_SERVICES_PROTOCOL mMpServicesTemplate = { };
/**
+ Get Mp Service Lock.
+
+ @param CpuData the pointer to CPU_DATA_BLOCK of specified processor
+
+**/
+VOID
+GetMpSpinLock (
+ IN CPU_DATA_BLOCK *CpuData
+ )
+{
+ while (!AcquireSpinLockOrFail (&CpuData->CpuDataLock)) {
+ CpuPause ();
+ }
+}
+
+/**
+ Release Mp Service Lock.
+
+ @param CpuData the pointer to CPU_DATA_BLOCK of specified processor
+
+**/
+VOID
+ReleaseMpSpinLock (
+ IN CPU_DATA_BLOCK *CpuData
+ )
+{
+ ReleaseSpinLock (&CpuData->CpuDataLock);
+}
+
+/**
Check whether caller processor is BSP.
@retval TRUE the caller is BSP
@@ -75,12 +105,9 @@ GetApState ( {
CPU_STATE State;
- while (!AcquireSpinLockOrFail (&CpuData->CpuDataLock)) {
- CpuPause ();
- }
-
+ GetMpSpinLock (CpuData);
State = CpuData->State;
- ReleaseSpinLock (&CpuData->CpuDataLock);
+ ReleaseMpSpinLock (CpuData);
return State;
}
@@ -98,12 +125,9 @@ SetApState ( IN CPU_STATE State
)
{
- while (!AcquireSpinLockOrFail (&CpuData->CpuDataLock)) {
- CpuPause ();
- }
-
+ GetMpSpinLock (CpuData);
CpuData->State = State;
- ReleaseSpinLock (&CpuData->CpuDataLock);
+ ReleaseMpSpinLock (CpuData);
}
/**
@@ -122,13 +146,10 @@ SetApProcedure ( IN VOID *ProcedureArgument
)
{
- while (!AcquireSpinLockOrFail (&CpuData->CpuDataLock)) {
- CpuPause ();
- }
-
+ GetMpSpinLock (CpuData);
CpuData->Parameter = ProcedureArgument;
CpuData->Procedure = Procedure;
- ReleaseSpinLock (&CpuData->CpuDataLock);
+ ReleaseMpSpinLock (CpuData);
}
/**
@@ -149,12 +170,9 @@ TestCpuStatusFlag ( {
UINT32 Ret;
- while (!AcquireSpinLockOrFail (&CpuData->CpuDataLock)) {
- CpuPause ();
- }
-
+ GetMpSpinLock (CpuData);
Ret = CpuData->Info.StatusFlag & Flags;
- ReleaseSpinLock (&CpuData->CpuDataLock);
+ ReleaseMpSpinLock (CpuData);
return !!(Ret);
}
@@ -172,12 +190,9 @@ CpuStatusFlagOr ( IN UINT32 Flags
)
{
- while (!AcquireSpinLockOrFail (&CpuData->CpuDataLock)) {
- CpuPause ();
- }
-
+ GetMpSpinLock (CpuData);
CpuData->Info.StatusFlag |= Flags;
- ReleaseSpinLock (&CpuData->CpuDataLock);
+ ReleaseMpSpinLock (CpuData);
}
/**
@@ -193,12 +208,9 @@ CpuStatusFlagAndNot ( IN UINT32 Flags
)
{
- while (!AcquireSpinLockOrFail (&CpuData->CpuDataLock)) {
- CpuPause ();
- }
-
+ GetMpSpinLock (CpuData);
CpuData->Info.StatusFlag &= ~Flags;
- ReleaseSpinLock (&CpuData->CpuDataLock);
+ ReleaseMpSpinLock (CpuData);
}
/**
@@ -1127,25 +1139,18 @@ ProcessorToIdleState ( AsmApDoneWithCommonStack ();
while (TRUE) {
- while (!AcquireSpinLockOrFail (&CpuData->CpuDataLock)) {
- CpuPause ();
- }
-
+ GetMpSpinLock (CpuData);
ProcedureArgument = CpuData->Parameter;
Procedure = CpuData->Procedure;
- ReleaseSpinLock (&CpuData->CpuDataLock);
+ ReleaseMpSpinLock (CpuData);
if (Procedure != NULL) {
Procedure (ProcedureArgument);
- while (!AcquireSpinLockOrFail (&CpuData->CpuDataLock)) {
- CpuPause ();
- }
-
+ GetMpSpinLock (CpuData);
CpuData->Procedure = NULL;
- ReleaseSpinLock (&CpuData->CpuDataLock);
-
- SetApState (CpuData, CpuStateFinished);
+ CpuData->State = CpuStateFinished;
+ ReleaseMpSpinLock (CpuData);
}
CpuPause ();
|