PiSmmCore.c revision 4fd606d1f5abe38e1f42c38de1d2e895166bd0f4
/** @file
SMM Core Main Entry Point
Copyright (c) 2009 - 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
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include "PiSmmCore.h"
//
// Physical pointer to private structure shared between SMM IPL and the SMM Core
//
//
// SMM Core global variable for SMM System Table. Only accessed as a physical structure in SMRAM.
//
{
sizeof (gSmmCoreSmst.Hdr)
},
NULL, // SmmFirmwareVendor
0, // SmmFirmwareRevision
{
{
},
{
}
},
NULL, // SmmStartupThisAp
0, // CurrentlyExecutingCpu
0, // NumberOfCpus
NULL, // CpuSaveStateSize
NULL, // CpuSaveState
0, // NumberOfTableEntries
NULL, // SmmConfigurationTable
};
//
// Flag to determine if the platform has performed a legacy boot.
// If this flag is TRUE, then the runtime code and runtime data associated with the
// SMM IPL are converted to free memory, so the SMM COre must guarantee that is
//
//
// Table of SMI Handlers that are registered by the SMM Core when it is initialized
//
};
/**
Place holder function until all the SMM System Table Service are available.
Note: This function is only used by SMRAM invocation. It is never used by DXE invocation.
@param Arg1 Undefined
@param Arg2 Undefined
@param Arg3 Undefined
@param Arg4 Undefined
@param Arg5 Undefined
@return EFI_NOT_AVAILABLE_YET
**/
)
{
//
// This function should never be executed. If it does, then the architectural protocols
// have not been designed correctly.
//
return EFI_NOT_AVAILABLE_YET;
}
/**
Software SMI handler that is called when a Legacy Boot event is signalled. The SMM
Core uses this signal to know that a Legacy Boot has been performed and that
gSmmCorePrivate that is shared between the UEFI and SMM execution environments can
not be accessed from SMM anymore since that structure is considered free memory by
a legacy OS.
@param DispatchHandle The unique handle assigned to this handler by SmiHandlerRegister().
@param Context Points to an optional handler context which was specified when the handler was registered.
@param CommBuffer A pointer to a collection of data in memory that will
be conveyed from a non-SMM environment into an SMM environment.
@param CommBufferSize The size of the CommBuffer.
@return Status Code
**/
)
{
return EFI_SUCCESS;
}
/**
Software SMI handler that is called when the DxeSmmReadyToLock protocol is added
or if gEfiEventReadyToBootGuid is signalled. This function unregisters the
Software SMIs that are nor required after SMRAM is locked and installs the
SMM Ready To Lock Protocol so SMM Drivers are informed that SMRAM is about
to be locked. It also verifies the the SMM CPU I/O 2 Protocol has been installed
and NULLs gBS and gST because they can not longer be used after SMRAM is locked.
@param DispatchHandle The unique handle assigned to this handler by SmiHandlerRegister().
@param Context Points to an optional handler context which was specified when the handler was registered.
@param CommBuffer A pointer to a collection of data in memory that will
be conveyed from a non-SMM environment into an SMM environment.
@param CommBufferSize The size of the CommBuffer.
@return Status Code
**/
)
{
//
// Unregister SMI Handlers that are no required after the SMM driver dispatch is stopped
//
}
}
//
// Install SMM Ready to lock protocol
//
);
//
// Make sure SMM CPU I/O 2 Procol has been installed into the handle database
//
//
// Print a message on a debug build if the SMM CPU I/O 2 Protocol is not installed
//
DEBUG_CODE_BEGIN ();
}
DEBUG_CODE_END ();
//
// Assert if the CPU I/O 2 Protocol is not installed
//
//
// Display any drivers that were not dispatched because dependency expression
// evaluated to false if this is a debug build
//
DEBUG_CODE_BEGIN ();
DEBUG_CODE_END ();
//
// Not allowed to use gST or gBS after lock
//
return Status;
}
/**
The main entry point to SMM Foundation.
Note: This function is only used by SMRAM invocation. It is never used by DXE invocation.
@param SmmEntryContext Processor information and functionality
needed by SMM Foundation.
**/
)
{
//
// Update SMST using the context
//
//
// Call platform hook before Smm Dispatch
//
//
// If a legacy boot has occured, then make sure gSmmCorePrivate is not accessed
//
if (mInLegacyBoot) {
//
// Asynchronous SMI
//
return;
}
//
// Mark the InSmm flag as TRUE, it will be used by SmmBase2 protocol
//
//
// Check to see if this is a Synchronous SMI sent through the SMM Communication
// Protocol or an Asynchronous SMI
//
//
// Synchronous SMI for SMM Core or request from Communicate protocol
//
NULL,
);
//
// Update CommunicationBuffer, BufferSize and ReturnStatus
// Communicate service finished, reset the pointer to CommBuffer to NULL
//
gSmmCorePrivate->ReturnStatus = (Status == EFI_WARN_INTERRUPT_SOURCE_QUIESCED) ? EFI_SUCCESS : EFI_NOT_FOUND;
} else {
//
// Asynchronous SMI
//
}
//
// Call platform hook after Smm Dispatch
//
//
// Clear the InSmm flag as we are going to leave SMM
//
}
/**
The Entry Point for SMM Core
Install DXE Protocols and reload SMM Core into SMRAM and register SMM Core
EntryPoint on the SMI vector.
Note: This function is called for both DXE invocation and SMRAM invocation.
@param ImageHandle The firmware allocated handle for the EFI image.
@param SystemTable A pointer to the EFI System Table.
@retval EFI_SUCCESS The entry point is executed successfully.
@retval Other Some error occurred when executing this entry point.
**/
SmmMain (
)
{
//
// Get SMM Core Private context passed in from SMM IPL in ImageHandle.
//
//
// Fill in SMRAM physical address for the SMM Services Table and the SMM Entry Point.
//
//
// Initialize memory service using free SMRAM
//
//
// Register all SMI Handlers required by the SMM Core
//
);
}
return EFI_SUCCESS;
}