summaryrefslogtreecommitdiffstats
path: root/OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.h
diff options
context:
space:
mode:
authorLaszlo Ersek <lersek@redhat.com>2017-05-06 13:17:58 +0200
committerLaszlo Ersek <lersek@redhat.com>2017-05-18 23:38:45 +0200
commit7e8329267ecb62670263bfc6afec93f37bfa19d2 (patch)
tree44345b038a04fc24fac734ce43262f59df71eb18 /OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.h
parent89f385ce0ad7bf2c93a80ff7733e45f2af88937a (diff)
downloadedk2-7e8329267ecb62670263bfc6afec93f37bfa19d2.tar.gz
edk2-7e8329267ecb62670263bfc6afec93f37bfa19d2.tar.bz2
edk2-7e8329267ecb62670263bfc6afec93f37bfa19d2.zip
OvmfPkg/EmuVariableFvbRuntimeDxe: change block size to 4KB
EmuVariableFvbRuntimeDxe currently produces a Firmware Volume Block protocol that is based on a block map of two blocks, each block having PcdFlashNvStorageFtwSpareSize for size. (The total size is 2 * PcdFlashNvStorageFtwSpareSize.) FaultTolerantWriteDxe in turn expects the block size to be a power of two. In the 4MB build of OVMF, PcdFlashNvStorageFtwSpareSize is 264KB, which is not a power of two. In order to equip EmuVariableFvbRuntimeDxe for this build, shrink the block size to 4KB (EFI_PAGE_SIZE), and grow the block count from 2 to EFI_SIZE_TO_PAGES(2 * PcdFlashNvStorageFtwSpareSize). The total size remains 2 * PcdFlashNvStorageFtwSpareSize --------------------------------- * EFI_PAGE_SIZE EFI_PAGE_SIZE Right now EmuVariableFvbRuntimeDxe open-codes the block count of 2 in various limit checks, so introduce a few new macros: - EMU_FVB_NUM_TOTAL_BLOCKS, for the LHS of the above product, - EMU_FVB_NUM_SPARE_BLOCKS for the half of that. Also rework the FVB protocol members to support an arbitrary count of blocks. Keep the invariant intact that the first half of the firmware volume hosts the variable store and the FTW working block, and that the second half maps the FTW spare area. Cc: Jordan Justen <jordan.l.justen@intel.com> Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=527 Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Laszlo Ersek <lersek@redhat.com> Regression-tested-by: Gary Lin <glin@suse.com> Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
Diffstat (limited to 'OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.h')
-rw-r--r--OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.h10
1 files changed, 8 insertions, 2 deletions
diff --git a/OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.h b/OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.h
index 4247d21d72..beb11e3f9a 100644
--- a/OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.h
+++ b/OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.h
@@ -58,8 +58,14 @@ typedef struct {
//
// Constants
//
-#define EMU_FVB_BLOCK_SIZE (FixedPcdGet32 (PcdFlashNvStorageFtwSpareSize))
-#define EMU_FVB_SIZE (2 * FixedPcdGet32 (PcdFlashNvStorageFtwSpareSize))
+#define EMU_FVB_BLOCK_SIZE \
+ EFI_PAGE_SIZE
+#define EMU_FVB_NUM_SPARE_BLOCKS \
+ EFI_SIZE_TO_PAGES ((UINTN)FixedPcdGet32 (PcdFlashNvStorageFtwSpareSize))
+#define EMU_FVB_NUM_TOTAL_BLOCKS \
+ (2 * EMU_FVB_NUM_SPARE_BLOCKS)
+#define EMU_FVB_SIZE \
+ (EMU_FVB_NUM_TOTAL_BLOCKS * EMU_FVB_BLOCK_SIZE)
#define FTW_WRITE_QUEUE_SIZE \
(FixedPcdGet32 (PcdFlashNvStorageFtwWorkingSize) - \
sizeof (EFI_FAULT_TOLERANT_WORKING_BLOCK_HEADER))