Update the library to compliant with SMMCis 0.91 and 0.9 both. 0.91 requires the InSmm() could not be invoked in runtime.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@4699 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
yshang1 2008-02-18 07:28:27 +00:00
parent f9619f52af
commit 404d4e5c60
1 changed files with 13 additions and 20 deletions

View File

@ -30,7 +30,7 @@ STATIC
EFI_STATUS_CODE_DATA *mStatusCodeData; EFI_STATUS_CODE_DATA *mStatusCodeData;
STATIC STATIC
EFI_SMM_BASE_PROTOCOL *mSmmBase; BOOLEAN mInSmm;
STATIC STATIC
EFI_RUNTIME_SERVICES *mRT; EFI_RUNTIME_SERVICES *mRT;
@ -50,16 +50,11 @@ InternalGetReportStatusCode (
) )
{ {
EFI_STATUS_CODE_PROTOCOL *StatusCodeProtocol; EFI_STATUS_CODE_PROTOCOL *StatusCodeProtocol;
BOOLEAN InSmm;
EFI_STATUS Status; EFI_STATUS Status;
if (mSmmBase) { if (mInSmm) {
mSmmBase->InSmm (mSmmBase, &InSmm); return (EFI_REPORT_STATUS_CODE) OemHookStatusCodeReport;
if (InSmm) { } else if (mRT->Hdr.Revision < 0x20000) {
return (EFI_REPORT_STATUS_CODE) OemHookStatusCodeReport;
}
}
if (mRT->Hdr.Revision < 0x20000) {
return ((FRAMEWORK_EFI_RUNTIME_SERVICES*)mRT)->ReportStatusCode; return ((FRAMEWORK_EFI_RUNTIME_SERVICES*)mRT)->ReportStatusCode;
} else if (!mHaveExitedBootServices) { } else if (!mHaveExitedBootServices) {
Status = gBS->LocateProtocol (&gEfiStatusCodeRuntimeProtocolGuid, NULL, (VOID**)&StatusCodeProtocol); Status = gBS->LocateProtocol (&gEfiStatusCodeRuntimeProtocolGuid, NULL, (VOID**)&StatusCodeProtocol);
@ -89,9 +84,6 @@ ReportStatusCodeLibVirtualAddressChange (
if (NULL != mReportStatusCode) { if (NULL != mReportStatusCode) {
mRT->ConvertPointer (0, (VOID **) &mReportStatusCode); mRT->ConvertPointer (0, (VOID **) &mReportStatusCode);
} }
if (NULL != mSmmBase) {
mRT->ConvertPointer (0, (VOID **) &mSmmBase);
}
mRT->ConvertPointer (0, (VOID **) &mStatusCodeData); mRT->ConvertPointer (0, (VOID **) &mStatusCodeData);
mRT->ConvertPointer (0, (VOID **) &mRT); mRT->ConvertPointer (0, (VOID **) &mRT);
} }
@ -128,20 +120,20 @@ ReportStatusCodeLibConstruct (
IN EFI_SYSTEM_TABLE *SystemTable IN EFI_SYSTEM_TABLE *SystemTable
) )
{ {
EFI_STATUS Status; EFI_SMM_BASE_PROTOCOL *SmmBase;
BOOLEAN InSmm; EFI_STATUS Status;
// //
// SMM driver depends on the SMM BASE protocol. // SMM driver depends on the SMM BASE protocol.
// the SMM driver must be success to locate protocol. // the SMM driver must be success to locate protocol.
// //
ASSERT (gBS != NULL); ASSERT (gBS != NULL);
Status = gBS->LocateProtocol (&gEfiSmmBaseProtocolGuid, NULL, (VOID **) &mSmmBase); Status = gBS->LocateProtocol (&gEfiSmmBaseProtocolGuid, NULL, (VOID **) &SmmBase);
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
mSmmBase->InSmm (mSmmBase, &InSmm); SmmBase->InSmm (SmmBase, &mInSmm);
if (InSmm) { if (mInSmm) {
Status = mSmmBase->SmmAllocatePool ( Status = SmmBase->SmmAllocatePool (
mSmmBase, SmmBase,
EfiRuntimeServicesData, EfiRuntimeServicesData,
sizeof (EFI_STATUS_CODE_DATA) + EFI_STATUS_CODE_DATA_MAX_SIZE, sizeof (EFI_STATUS_CODE_DATA) + EFI_STATUS_CODE_DATA_MAX_SIZE,
(VOID **) &mStatusCodeData (VOID **) &mStatusCodeData
@ -156,7 +148,8 @@ ReportStatusCodeLibConstruct (
// Library should not use the gRT directly, since it // Library should not use the gRT directly, since it
// may be converted by other library instance. // may be converted by other library instance.
// //
mRT = gRT; mRT = gRT;
mInSmm = FALSE;
gBS->AllocatePool (EfiRuntimeServicesData, sizeof (EFI_STATUS_CODE_DATA) + EFI_STATUS_CODE_DATA_MAX_SIZE, (VOID **)&mStatusCodeData); gBS->AllocatePool (EfiRuntimeServicesData, sizeof (EFI_STATUS_CODE_DATA) + EFI_STATUS_CODE_DATA_MAX_SIZE, (VOID **)&mStatusCodeData);
ASSERT (NULL != mStatusCodeData); ASSERT (NULL != mStatusCodeData);