Smi.c revision 4fd606d1f5abe38e1f42c38de1d2e895166bd0f4
/** @file
SMI management.
Copyright (c) 2009 - 2010, 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"
//
// SMM_HANDLER - used for each SMM handler
//
typedef struct {
} SMI_ENTRY;
typedef struct {
} SMI_HANDLER;
/**
Finds the SMI entry for the requested handler type.
@param HandlerType The type of the interrupt
@param Create Create a new entry if not found
@return SMI entry
**/
)
{
//
// Search the SMI entry list for the matching GUID
//
Link != &mSmiEntryList;
//
// This is the SMI entry
//
break;
}
}
//
// If the protocol entry was not found and Create is TRUE, then
// allocate a new entry
//
//
// Initialize new SMI entry structure
//
//
// Add it to SMI entry list
//
}
}
return SmiEntry;
}
/**
Manage SMI of a particular type.
@param HandlerType Points to the handler type or NULL for root SMI handlers.
@param Context Points to an optional context buffer.
@param CommBuffer Points to the optional communication buffer.
@param CommBufferSize Points to the size of the optional communication buffer.
@retval EFI_SUCCESS Interrupt source was processed successfully but not quiesced.
@retval EFI_INTERRUPT_PENDING One or more SMI sources could not be quiesced.
@retval EFI_WARN_INTERRUPT_SOURCE_PENDING Interrupt source was not handled or quiesced.
@retval EFI_WARN_INTERRUPT_SOURCE_QUIESCED Interrupt source was handled and quiesced.
**/
)
{
if (HandlerType == NULL) {
//
// Root SMI handler
//
);
return Status;
}
}
return Status;
}
//
// Non-root SMI handler
//
//
// There is no handler registered for this interrupt source
//
}
);
switch (Status) {
case EFI_INTERRUPT_PENDING:
//
// If a handler returns EFI_INTERRUPT_PENDING, the interrupt could not be
// quiesced, then no additional handlers will be processed,
// and EFI_INTERRUPT_PENDING will be returned
//
return EFI_INTERRUPT_PENDING;
case EFI_SUCCESS:
//
// If handler return EFI_SUCCESS, the interrupt was handled and quiesced,
// no other handlers should still be called,
// and EFI_WARN_INTERRUPT_SOURCE_QUIESCED will be returned
//
//
// If at least one of the handlers report EFI_WARN_INTERRUPT_SOURCE_QUIESCED,
// then this function will return EFI_WARN_INTERRUPT_SOURCE_QUIESCED
//
break;
default:
break;
}
}
if (InterruptQuiesced) {
} else {
//
// If no handler report EFI_WARN_INTERRUPT_SOURCE_QUIESCED, then this
// function will return EFI_INTERRUPT_PENDING
//
}
return Status;
}
/**
Registers a handler to execute within SMM.
@param Handler Handler service funtion pointer.
@param HandlerType Points to the handler type or NULL for root SMI handlers.
@param DispatchHandle On return, contains a unique handle which can be used to later unregister the handler function.
@retval EFI_SUCCESS Handler register success.
@retval EFI_INVALID_PARAMETER Handler or DispatchHandle is NULL.
**/
)
{
return EFI_INVALID_PARAMETER;
}
if (SmiHandler == NULL) {
return EFI_OUT_OF_RESOURCES;
}
if (HandlerType == NULL) {
//
// This is root SMI handler
//
} else {
//
// None root SMI handler
//
return EFI_OUT_OF_RESOURCES;
}
}
return EFI_SUCCESS;
}
/**
Unregister a handler in SMM.
@param DispatchHandle The handle that was specified when the handler was registered.
@retval EFI_SUCCESS Handler function was successfully unregistered.
@retval EFI_INVALID_PARAMETER DispatchHandle does not refer to a valid handle.
**/
)
{
if (SmiHandler == NULL) {
return EFI_INVALID_PARAMETER;
}
return EFI_INVALID_PARAMETER;
}
//
// This is root SMI handler
//
return EFI_SUCCESS;
}
//
// No handler registered for this interrupt now, remove the SMI_ENTRY
//
}
return EFI_SUCCESS;
}