2011-09-02 09:49:32 +02:00
|
|
|
/** @file
|
|
|
|
TCG MOR (Memory Overwrite Request) Control Driver.
|
|
|
|
|
|
|
|
This driver initilize MemoryOverwriteRequestControl variable. It
|
|
|
|
will clear MOR_CLEAR_MEMORY_BIT bit if it is set.
|
|
|
|
|
2014-03-17 06:46:53 +01:00
|
|
|
Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
|
2011-09-02 09:49:32 +02:00
|
|
|
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
|
|
|
|
http://opensource.org/licenses/bsd-license.php
|
|
|
|
|
|
|
|
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 "TcgMor.h"
|
|
|
|
|
2012-09-12 12:20:34 +02:00
|
|
|
UINT8 mMorControl;
|
|
|
|
|
|
|
|
/**
|
|
|
|
Ready to Boot Event notification handler.
|
|
|
|
|
|
|
|
Sequence of OS boot events is measured in this event notification handler.
|
|
|
|
|
|
|
|
@param[in] Event Event whose notification function is being invoked
|
|
|
|
@param[in] Context Pointer to the notification function's context
|
|
|
|
|
|
|
|
**/
|
|
|
|
VOID
|
|
|
|
EFIAPI
|
|
|
|
OnReadyToBoot (
|
|
|
|
IN EFI_EVENT Event,
|
|
|
|
IN VOID *Context
|
|
|
|
)
|
|
|
|
{
|
2014-03-17 06:46:53 +01:00
|
|
|
EFI_STATUS Status;
|
2012-09-12 12:20:34 +02:00
|
|
|
UINTN DataSize;
|
|
|
|
|
|
|
|
if (MOR_CLEAR_MEMORY_VALUE (mMorControl) == 0x0) {
|
|
|
|
//
|
|
|
|
// MorControl is expected, directly return to avoid unnecessary variable operation
|
|
|
|
//
|
|
|
|
return ;
|
|
|
|
}
|
|
|
|
//
|
|
|
|
// Clear MOR_CLEAR_MEMORY_BIT
|
|
|
|
//
|
|
|
|
DEBUG ((EFI_D_INFO, "TcgMor: Clear MorClearMemory bit\n"));
|
|
|
|
mMorControl &= 0xFE;
|
|
|
|
|
|
|
|
DataSize = sizeof (mMorControl);
|
2014-03-17 06:46:53 +01:00
|
|
|
Status = gRT->SetVariable (
|
|
|
|
MEMORY_OVERWRITE_REQUEST_VARIABLE_NAME,
|
|
|
|
&gEfiMemoryOverwriteControlDataGuid,
|
|
|
|
EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
|
|
|
|
DataSize,
|
|
|
|
&mMorControl
|
|
|
|
);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
DEBUG ((EFI_D_ERROR, "TcgMor: Clear MOR_CLEAR_MEMORY_BIT failure, Status = %r\n"));
|
|
|
|
}
|
2012-09-12 12:20:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-02 09:49:32 +02:00
|
|
|
/**
|
|
|
|
Entry Point for TCG MOR Control driver.
|
|
|
|
|
|
|
|
@param[in] ImageHandle Image handle of this driver.
|
|
|
|
@param[in] SystemTable A Pointer to the EFI System Table.
|
|
|
|
|
|
|
|
@retval EFI_SUCEESS
|
|
|
|
@return Others Some error occurs.
|
|
|
|
**/
|
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
MorDriverEntryPoint (
|
|
|
|
IN EFI_HANDLE ImageHandle,
|
|
|
|
IN EFI_SYSTEM_TABLE *SystemTable
|
|
|
|
)
|
|
|
|
{
|
|
|
|
EFI_STATUS Status;
|
|
|
|
UINTN DataSize;
|
2012-09-12 12:20:34 +02:00
|
|
|
EFI_EVENT Event;
|
2011-09-02 09:49:32 +02:00
|
|
|
|
|
|
|
///
|
|
|
|
/// The firmware is required to create the MemoryOverwriteRequestControl UEFI variable.
|
|
|
|
///
|
|
|
|
|
2012-09-12 12:20:34 +02:00
|
|
|
DataSize = sizeof (mMorControl);
|
2011-09-02 09:49:32 +02:00
|
|
|
Status = gRT->GetVariable (
|
|
|
|
MEMORY_OVERWRITE_REQUEST_VARIABLE_NAME,
|
|
|
|
&gEfiMemoryOverwriteControlDataGuid,
|
|
|
|
NULL,
|
|
|
|
&DataSize,
|
2012-09-12 12:20:34 +02:00
|
|
|
&mMorControl
|
2011-09-02 09:49:32 +02:00
|
|
|
);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
//
|
|
|
|
// Set default value to 0
|
|
|
|
//
|
2012-09-12 12:20:34 +02:00
|
|
|
mMorControl = 0;
|
|
|
|
Status = gRT->SetVariable (
|
|
|
|
MEMORY_OVERWRITE_REQUEST_VARIABLE_NAME,
|
|
|
|
&gEfiMemoryOverwriteControlDataGuid,
|
|
|
|
EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
|
|
|
|
DataSize,
|
|
|
|
&mMorControl
|
|
|
|
);
|
2014-03-17 06:46:53 +01:00
|
|
|
DEBUG ((EFI_D_INFO, "TcgMor: Create MOR variable! Status = %r\n", Status));
|
2011-09-02 09:49:32 +02:00
|
|
|
} else {
|
|
|
|
//
|
2012-09-12 12:20:34 +02:00
|
|
|
// Create a Ready To Boot Event and Clear the MorControl bit in the call back function.
|
2011-09-02 09:49:32 +02:00
|
|
|
//
|
2012-09-12 12:20:34 +02:00
|
|
|
DEBUG ((EFI_D_INFO, "TcgMor: Create ReadyToBoot Event for MorControl Bit cleanning!\n"));
|
|
|
|
Status = EfiCreateEventReadyToBootEx (
|
|
|
|
TPL_CALLBACK,
|
|
|
|
OnReadyToBoot,
|
|
|
|
NULL,
|
|
|
|
&Event
|
|
|
|
);
|
|
|
|
}
|
2011-09-02 09:49:32 +02:00
|
|
|
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
|