mirror of https://github.com/acidanthera/audk.git
Add more assert to check table pointer.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2071 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
83a4143f53
commit
f62485d39a
|
@ -1,6 +1,7 @@
|
||||||
/*++
|
/**@file
|
||||||
|
Library utility functions for Runtime driver.
|
||||||
Copyright (c) 2006, Intel Corporation
|
|
||||||
|
Copyright (c) 2006 Intel Corporation. <BR>
|
||||||
All rights reserved. This program and the accompanying materials
|
All rights reserved. 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
|
||||||
|
@ -9,46 +10,31 @@ 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.
|
||||||
|
|
||||||
Module Name:
|
**/
|
||||||
|
|
||||||
RuntimeLib.c
|
|
||||||
|
|
||||||
--*/
|
|
||||||
|
|
||||||
#include <RuntimeLibInternal.h>
|
#include <RuntimeLibInternal.h>
|
||||||
|
|
||||||
//
|
///
|
||||||
// Driver Lib Module Globals
|
/// Driver Lib Module Globals
|
||||||
//
|
///
|
||||||
|
|
||||||
STATIC EFI_EVENT mEfiVirtualNotifyEvent;
|
STATIC EFI_EVENT mEfiVirtualNotifyEvent;
|
||||||
STATIC BOOLEAN mEfiGoneVirtual = FALSE;
|
STATIC BOOLEAN mEfiGoneVirtual = FALSE;
|
||||||
STATIC BOOLEAN mEfiAtRuntime = FALSE;
|
STATIC BOOLEAN mEfiAtRuntime = FALSE;
|
||||||
EFI_RUNTIME_SERVICES *mRT;
|
EFI_RUNTIME_SERVICES *mRT;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Set AtRuntime flag as TRUE after ExitBootServices
|
||||||
|
|
||||||
|
@param[in] Event The Event that is being processed
|
||||||
|
@param[in] Context Event Context
|
||||||
|
**/
|
||||||
VOID
|
VOID
|
||||||
EFIAPI
|
EFIAPI
|
||||||
RuntimeDriverExitBootServices (
|
RuntimeDriverExitBootServices (
|
||||||
IN EFI_EVENT Event,
|
IN EFI_EVENT Event,
|
||||||
IN VOID *Context
|
IN VOID *Context
|
||||||
)
|
)
|
||||||
/*++
|
|
||||||
|
|
||||||
Routine Description:
|
|
||||||
|
|
||||||
Set AtRuntime flag as TRUE after ExitBootServices
|
|
||||||
|
|
||||||
Arguments:
|
|
||||||
|
|
||||||
Event - The Event that is being processed
|
|
||||||
|
|
||||||
Context - Event Context
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
|
|
||||||
None
|
|
||||||
|
|
||||||
--*/
|
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
// Clear out BootService globals
|
// Clear out BootService globals
|
||||||
|
@ -58,6 +44,14 @@ Returns:
|
||||||
mEfiAtRuntime = TRUE;
|
mEfiAtRuntime = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Fixup internal data so that EFI can be call in virtual mode.
|
||||||
|
Call the passed in Child Notify event and convert any pointers in
|
||||||
|
lib to virtual mode.
|
||||||
|
|
||||||
|
@param[in] Event The Event that is being processed
|
||||||
|
@param[in] Context Event Context
|
||||||
|
**/
|
||||||
STATIC
|
STATIC
|
||||||
VOID
|
VOID
|
||||||
EFIAPI
|
EFIAPI
|
||||||
|
@ -65,25 +59,6 @@ RuntimeLibVirtualNotifyEvent (
|
||||||
IN EFI_EVENT Event,
|
IN EFI_EVENT Event,
|
||||||
IN VOID *Context
|
IN VOID *Context
|
||||||
)
|
)
|
||||||
/*++
|
|
||||||
|
|
||||||
Routine Description:
|
|
||||||
|
|
||||||
Fixup internal data so that EFI can be call in virtual mode.
|
|
||||||
Call the passed in Child Notify event and convert any pointers in
|
|
||||||
lib to virtual mode.
|
|
||||||
|
|
||||||
Arguments:
|
|
||||||
|
|
||||||
Event - The Event that is being processed
|
|
||||||
|
|
||||||
Context - Event Context
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
|
|
||||||
None
|
|
||||||
|
|
||||||
--*/
|
|
||||||
{
|
{
|
||||||
UINTN Index;
|
UINTN Index;
|
||||||
EFI_EVENT_NOTIFY ChildNotifyEventHandler;
|
EFI_EVENT_NOTIFY ChildNotifyEventHandler;
|
||||||
|
@ -103,77 +78,59 @@ Returns:
|
||||||
mEfiGoneVirtual = TRUE;
|
mEfiGoneVirtual = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Intialize runtime Driver Lib if it has not yet been initialized.
|
||||||
|
|
||||||
|
@param[in] ImageHandle The firmware allocated handle for the EFI image.
|
||||||
|
@param[in] SystemTable A pointer to the EFI System Table.
|
||||||
|
|
||||||
|
@return EFI_STATUS always returns EFI_SUCCESS except EFI_ALREADY_STARTED if already started.
|
||||||
|
**/
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
EFIAPI
|
EFIAPI
|
||||||
RuntimeDriverLibConstruct (
|
RuntimeDriverLibConstruct (
|
||||||
IN EFI_HANDLE ImageHandle,
|
IN EFI_HANDLE ImageHandle,
|
||||||
IN EFI_SYSTEM_TABLE *SystemTable
|
IN EFI_SYSTEM_TABLE *SystemTable
|
||||||
)
|
)
|
||||||
/*++
|
|
||||||
|
|
||||||
Routine Description:
|
|
||||||
|
|
||||||
Intialize runtime Driver Lib if it has not yet been initialized.
|
|
||||||
|
|
||||||
Arguments:
|
|
||||||
|
|
||||||
ImageHandle - The firmware allocated handle for the EFI image.
|
|
||||||
|
|
||||||
SystemTable - A pointer to the EFI System Table.
|
|
||||||
|
|
||||||
GoVirtualChildEvent - Caller can register a virtual notification event.
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
|
|
||||||
EFI_STATUS always returns EFI_SUCCESS except EFI_ALREADY_STARTED if already started.
|
|
||||||
|
|
||||||
--*/
|
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
|
|
||||||
|
ASSERT (SystemTable != NULL);
|
||||||
mRT = SystemTable->RuntimeServices;
|
mRT = SystemTable->RuntimeServices;
|
||||||
|
ASSERT (mRT != NULL);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Register SetVirtualAddressMap () notify function
|
// Register SetVirtualAddressMap () notify function
|
||||||
//
|
//
|
||||||
if (_gDriverSetVirtualAddressMapEvent[0] != NULL) {
|
if (_gDriverSetVirtualAddressMapEvent[0] != NULL) {
|
||||||
Status = gBS->CreateEvent (
|
ASSERT (gBS != NULL);
|
||||||
EFI_EVENT_SIGNAL_VIRTUAL_ADDRESS_CHANGE,
|
Status = gBS->CreateEvent (
|
||||||
EFI_TPL_NOTIFY,
|
EFI_EVENT_SIGNAL_VIRTUAL_ADDRESS_CHANGE,
|
||||||
RuntimeLibVirtualNotifyEvent,
|
EFI_TPL_NOTIFY,
|
||||||
NULL,
|
RuntimeLibVirtualNotifyEvent,
|
||||||
&mEfiVirtualNotifyEvent
|
NULL,
|
||||||
);
|
&mEfiVirtualNotifyEvent
|
||||||
|
);
|
||||||
|
|
||||||
ASSERT_EFI_ERROR (Status);
|
ASSERT_EFI_ERROR (Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
This routine will free some resources which have been allocated in
|
||||||
|
EfiInitializeRuntimeDriverLib(). If a runtime driver exits with an error,
|
||||||
|
it must call this routine to free the allocated resource before the exiting.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS Shutdown the Runtime Driver Lib successfully
|
||||||
|
@retval EFI_UNSUPPORTED Runtime Driver lib was not initialized at all
|
||||||
|
**/
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
EFIAPI
|
EFIAPI
|
||||||
RuntimeDriverLibDeconstruct (
|
RuntimeDriverLibDeconstruct (
|
||||||
VOID
|
VOID
|
||||||
)
|
)
|
||||||
/*++
|
|
||||||
|
|
||||||
Routine Description:
|
|
||||||
|
|
||||||
This routine will free some resources which have been allocated in
|
|
||||||
EfiInitializeRuntimeDriverLib(). If a runtime driver exits with an error,
|
|
||||||
it must call this routine to free the allocated resource before the exiting.
|
|
||||||
|
|
||||||
Arguments:
|
|
||||||
|
|
||||||
None
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
|
|
||||||
EFI_SUCCESS - Shotdown the Runtime Driver Lib successfully
|
|
||||||
EFI_UNSUPPORTED - Runtime Driver lib was not initialized at all
|
|
||||||
|
|
||||||
--*/
|
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
|
|
||||||
|
@ -181,51 +138,38 @@ Returns:
|
||||||
// Close SetVirtualAddressMap () notify function
|
// Close SetVirtualAddressMap () notify function
|
||||||
//
|
//
|
||||||
if (_gDriverSetVirtualAddressMapEvent[0] != NULL) {
|
if (_gDriverSetVirtualAddressMapEvent[0] != NULL) {
|
||||||
Status = gBS->CloseEvent (mEfiVirtualNotifyEvent);
|
ASSERT (gBS != NULL);
|
||||||
ASSERT_EFI_ERROR (Status);
|
Status = gBS->CloseEvent (mEfiVirtualNotifyEvent);
|
||||||
|
ASSERT_EFI_ERROR (Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Return TRUE if ExitBootServices () has been called
|
||||||
|
|
||||||
|
@retval TRUE If ExitBootServices () has been called
|
||||||
|
**/
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
EFIAPI
|
EFIAPI
|
||||||
EfiAtRuntime (
|
EfiAtRuntime (
|
||||||
VOID
|
VOID
|
||||||
)
|
)
|
||||||
/*++
|
|
||||||
|
|
||||||
Routine Description:
|
|
||||||
Return TRUE if ExitBootServices () has been called
|
|
||||||
|
|
||||||
Arguments:
|
|
||||||
NONE
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
TRUE - If ExitBootServices () has been called
|
|
||||||
|
|
||||||
--*/
|
|
||||||
{
|
{
|
||||||
return mEfiAtRuntime;
|
return mEfiAtRuntime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Return TRUE if SetVirtualAddressMap () has been called
|
||||||
|
|
||||||
|
@retval TRUE If SetVirtualAddressMap () has been called
|
||||||
|
**/
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
EFIAPI
|
EFIAPI
|
||||||
EfiGoneVirtual (
|
EfiGoneVirtual (
|
||||||
VOID
|
VOID
|
||||||
)
|
)
|
||||||
/*++
|
|
||||||
|
|
||||||
Routine Description:
|
|
||||||
Return TRUE if SetVirtualAddressMap () has been called
|
|
||||||
|
|
||||||
Arguments:
|
|
||||||
NONE
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
TRUE - If SetVirtualAddressMap () has been called
|
|
||||||
|
|
||||||
--*/
|
|
||||||
{
|
{
|
||||||
return mEfiGoneVirtual;
|
return mEfiGoneVirtual;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue