OVMF support for QEMU system firmware flash device\r
\r
Copyright (c) 2009 - 2013, Intel Corporation. All rights reserved.<BR>\r
- This program and the accompanying materials\r
- are licensed and made available under the terms and conditions of the BSD License\r
- which accompanies this distribution. The full text of the license may be found at\r
- http://opensource.org/licenses/bsd-license.php\r
\r
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+ SPDX-License-Identifier: BSD-2-Clause-Patent\r
\r
**/\r
\r
-#include "PiDxe.h"\r
-#include <Library/DebugLib.h>\r
#include <Library/BaseMemoryLib.h>\r
+#include <Library/DebugLib.h>\r
#include <Library/PcdLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/UefiRuntimeLib.h>\r
-#include <Guid/EventGroup.h>\r
\r
#include "QemuFlash.h"\r
\r
#define CLEARED_ARRAY_STATUS 0x00\r
\r
\r
-STATIC UINT8 *mFlashBase = NULL;\r
+UINT8 *mFlashBase;\r
+\r
STATIC UINTN mFdBlockSize = 0;\r
STATIC UINTN mFdBlockCount = 0;\r
\r
-\r
-VOID\r
-QemuFlashConvertPointers (\r
- VOID\r
- )\r
-{\r
- EfiConvertPointer (0x0, (VOID **) &mFlashBase);\r
-}\r
-\r
-\r
STATIC\r
volatile UINT8*\r
QemuFlashPtr (\r
IN UINTN Offset\r
)\r
{\r
- return mFlashBase + (Lba * mFdBlockSize) + Offset;\r
+ return mFlashBase + ((UINTN)Lba * mFdBlockSize) + Offset;\r
}\r
\r
\r
// Restore flash to read mode\r
//\r
if (*NumBytes > 0) {\r
- *Ptr = READ_ARRAY_CMD;\r
+ *(Ptr - 1) = READ_ARRAY_CMD;\r
}\r
\r
return EFI_SUCCESS;\r
ASSERT(PcdGet32 (PcdOvmfFirmwareFdSize) % mFdBlockSize == 0);\r
mFdBlockCount = PcdGet32 (PcdOvmfFirmwareFdSize) / mFdBlockSize;\r
\r
+ //\r
+ // execute module specific hooks before probing the flash\r
+ //\r
+ QemuFlashBeforeProbe (\r
+ (EFI_PHYSICAL_ADDRESS)(UINTN) mFlashBase,\r
+ mFdBlockSize,\r
+ mFdBlockCount\r
+ );\r
+\r
if (!QemuFlashDetected ()) {\r
+ ASSERT (!FeaturePcdGet (PcdSmmSmramRequire));\r
return EFI_WRITE_PROTECTED;\r
}\r
\r