From: "xianglai" <lixianglai@loongson.cn>
To: devel@edk2.groups.io
Cc: maobibo@loongson.cn
Subject: [edk2-platforms][PATCH V1 16/16] Platform/Loongson: Support for saving variables to flash.
Date: Fri, 9 Sep 2022 11:12:12 +0800 [thread overview]
Message-ID: <ded518989ef8db4d85996f5d4d74c127afc48cc0.1662691771.git.lixianglai@loongson.cn> (raw)
In-Reply-To: <cover.1662691771.git.lixianglai@loongson.cn>
Added the function of saving non-volatile variables.
Signed-off-by: xianglai li <lixianglai@loongson.cn>
---
Platform/Loongson/LoongArchQemuPkg/Loongson.dec | 6 ++++++
Platform/Loongson/LoongArchQemuPkg/Loongson.dsc | 2 +-
Platform/Loongson/LoongArchQemuPkg/Loongson.fdf | 14 ++++++++++++++
.../Loongson/LoongArchQemuPkg/Loongson.fdf.inc | 11 +++++++++++
.../Loongson/LoongArchQemuPkg/VarStore.fdf.inc | 10 +++++-----
5 files changed, 37 insertions(+), 6 deletions(-)
diff --git a/Platform/Loongson/LoongArchQemuPkg/Loongson.dec b/Platform/Loongson/LoongArchQemuPkg/Loongson.dec
index 508a770a22..c3e523b39b 100644
--- a/Platform/Loongson/LoongArchQemuPkg/Loongson.dec
+++ b/Platform/Loongson/LoongArchQemuPkg/Loongson.dec
@@ -32,6 +32,8 @@
[Protocols]
[PcdsFixedAtBuild, PcdsDynamic]
+ gLoongArchQemuPkgTokenSpaceGuid.PcdFlashFdBase|0x0|UINT64|0
+ gLoongArchQemuPkgTokenSpaceGuid.PcdFlashBlockSize|0x0|UINT32|2
gLoongArchQemuPkgTokenSpaceGuid.PcdFlashPeiFvBase|0x0|UINT64|0x00000003
gLoongArchQemuPkgTokenSpaceGuid.PcdFlashPeiFvSize|0x0|UINT32|0x00000004
gLoongArchQemuPkgTokenSpaceGuid.PcdFlashDxeFvOffset|0x0|UINT64|0x00000007
@@ -50,6 +52,10 @@
gLoongArchQemuPkgTokenSpaceGuid.PcdSecPeiTempRamSize|0|UINT32|0x0000001d
gLoongArchQemuPkgTokenSpaceGuid.PcdUefiRamTop|0x0|UINT64|0x0000001e
gLoongArchQemuPkgTokenSpaceGuid.PcdRamRegionsBottom|0x0|UINT64|0x00000022
+ gLoongArchQemuPkgTokenSpaceGuid.PcdOvmfFlashNvStorageVariableBase|0x0|UINT64|0x00000024
+ gLoongArchQemuPkgTokenSpaceGuid.PcdAllVarSize|0x0|UINT32|0x00000025
+ gLoongArchQemuPkgTokenSpaceGuid.PcdOvmfFlashNvStorageFtwSpareBase|0x0|UINT64|0x00000026
+ gLoongArchQemuPkgTokenSpaceGuid.PcdOvmfFlashNvStorageFtwWorkingBase|0x0|UINT64|0x00000027
gLoongArchQemuPkgTokenSpaceGuid.PcdFlashSecFvBase|0x0|UINT64|0x00000028
gLoongArchQemuPkgTokenSpaceGuid.PcdFlashSecFvSize|0x0|UINT32|0x00000029
diff --git a/Platform/Loongson/LoongArchQemuPkg/Loongson.dsc b/Platform/Loongson/LoongArchQemuPkg/Loongson.dsc
index ed06558f18..ec6234a26e 100644
--- a/Platform/Loongson/LoongArchQemuPkg/Loongson.dsc
+++ b/Platform/Loongson/LoongArchQemuPkg/Loongson.dsc
@@ -447,7 +447,7 @@
#
# Variable
#
-# Platform/Loongson/LoongArchQemuPkg/Drivers/QemuFlashFvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf
+ Platform/Loongson/LoongArchQemuPkg/Drivers/QemuFlashFvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf
OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.inf {
<LibraryClasses>
PlatformFvbLib|OvmfPkg/Library/EmuVariableFvbLib/EmuVariableFvbLib.inf
diff --git a/Platform/Loongson/LoongArchQemuPkg/Loongson.fdf b/Platform/Loongson/LoongArchQemuPkg/Loongson.fdf
index ba2942e455..12920a0833 100644
--- a/Platform/Loongson/LoongArchQemuPkg/Loongson.fdf
+++ b/Platform/Loongson/LoongArchQemuPkg/Loongson.fdf
@@ -31,6 +31,19 @@ gLoongArchQemuPkgTokenSpaceGuid.PcdFlashDxeFvBase|gLoongArchQemuPkgTokenSpaceGui
FV = FVMAIN_COMPACT
!include VarStore.fdf.inc
+
+#####################################################################################################
+[FD.QEMU_EFI_VARS]
+BaseAddress = $(VARIABLE_BASE_ADDRESS)
+Size = $(VAR_ALL_SIZE)
+ErasePolarity = 1
+BlockSize = $(BLOCK_SIZE)
+NumBlocks = $(VAR_ALL_BLOCKS)
+
+DEFINE VARIABLE_OFFSET = 0
+!include VarStore.fdf.inc
+DEFINE VARIABLE_OFFSET = 0x003a0000
+
#####################################################################################################
[FV.SECFV]
FvNameGuid = 587d4265-5e71-41da-9c35-4258551f1e22
@@ -87,6 +100,7 @@ INF MdeModulePkg/Core/Pei/PeiMain.inf
INF MdeModulePkg/Universal/PCD/Pei/Pcd.inf
INF MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
INF Platform/Loongson/LoongArchQemuPkg/PlatformPei/PlatformPei.inf
+
#####################################################################################################
[FV.DXEFV]
FvNameGuid = 5d19a5b3-130f-459b-a292-9270a9e6bc62
diff --git a/Platform/Loongson/LoongArchQemuPkg/Loongson.fdf.inc b/Platform/Loongson/LoongArchQemuPkg/Loongson.fdf.inc
index 964d69ed44..4b926a85ff 100644
--- a/Platform/Loongson/LoongArchQemuPkg/Loongson.fdf.inc
+++ b/Platform/Loongson/LoongArchQemuPkg/Loongson.fdf.inc
@@ -34,6 +34,7 @@ DEFINE VAR_ALL_SIZE = 0x60000
############################################################################
#Set Var Flash layout
+DEFINE VARIABLE_BASE_ADDRESS = 0x1c3a0000
DEFINE VARIABLE_SIZE = 0x00010000
DEFINE VAR_ALL_BLOCKS = 0x60
@@ -53,11 +54,21 @@ DEFINE EVENT_LOG_OFFSET = $(FWTWORKING_OFFSET) + $(FWTWORKING_SIZE)
DEFINE EVENT_LOG_SIZE = 0x8000
# Set Variable
+SET gLoongArchQemuPkgTokenSpaceGuid.PcdFlashFdBase = $(FD_BASE_ADDRESS)
+
+SET gLoongArchQemuPkgTokenSpaceGuid.PcdOvmfFlashNvStorageVariableBase = $(FD_BASE_ADDRESS) + $(VARIABLE_OFFSET)
+SET gLoongArchQemuPkgTokenSpaceGuid.PcdAllVarSize = $(VAR_ALL_SIZE)
+
+SET gLoongArchQemuPkgTokenSpaceGuid.PcdFlashBlockSize = $(BLOCK_SIZE)
SET gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64 = 0
SET gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize = $(VARIABLE_SIZE)
# Set FtwSpare
+SET gLoongArchQemuPkgTokenSpaceGuid.PcdOvmfFlashNvStorageFtwSpareBase = $(FD_BASE_ADDRESS) + $(SPARE_OFFSET)
+SET gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase64 = 0
SET gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize = $(SPARE_SIZE)
# Set FtwWorking
+SET gLoongArchQemuPkgTokenSpaceGuid.PcdOvmfFlashNvStorageFtwWorkingBase = $(FD_BASE_ADDRESS) + $(SPARE_OFFSET) + $(SPARE_SIZE)
+SET gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase64 = 0
SET gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize = $(FWTWORKING_SIZE)
diff --git a/Platform/Loongson/LoongArchQemuPkg/VarStore.fdf.inc b/Platform/Loongson/LoongArchQemuPkg/VarStore.fdf.inc
index 625fa23543..a4e0158cf8 100644
--- a/Platform/Loongson/LoongArchQemuPkg/VarStore.fdf.inc
+++ b/Platform/Loongson/LoongArchQemuPkg/VarStore.fdf.inc
@@ -38,16 +38,16 @@ DATA = {
# FORMATTED: 0x5A #HEALTHY: 0xFE #Reserved: UINT16 #Reserved1: UINT32
0x5a, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
}
-$(RESERVE1_OFFSET)|$(RESERVE1_SIZE)
+$(VARIABLE_OFFSET) + $(VARIABLE_SIZE)|$(RESERVE1_SIZE)
#NV_RESERVE1_STORE
-$(RESERVE2_OFFSET)|$(RESERVE2_SIZE)
+$(VARIABLE_OFFSET) + $(VARIABLE_SIZE) + $(RESERVE1_SIZE)|$(RESERVE2_SIZE)
#NV_RESERVE2_STORE
-$(SPARE_OFFSET)|$(SPARE_SIZE)
+$(VARIABLE_OFFSET) + $(VARIABLE_SIZE) + $(RESERVE1_SIZE) + $(RESERVE2_SIZE)|$(SPARE_SIZE)
#NV_FTW_SPARE
-$(FWTWORKING_OFFSET)|$(FWTWORKING_SIZE)
+$(VARIABLE_OFFSET) + $(VARIABLE_SIZE) + $(RESERVE1_SIZE) + $(RESERVE2_SIZE) + $(SPARE_SIZE)|$(FWTWORKING_SIZE)
#NV_FTW_WORKING
DATA = {
# EFI_FAULT_TOLERANT_WORKING_BLOCK_HEADER->Signature = gEdkiiWorkingBlockSignatureGuid =
@@ -60,5 +60,5 @@ DATA = {
0xe0, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
}
-$(EVENT_LOG_OFFSET)|$(EVENT_LOG_SIZE)
+$(VARIABLE_OFFSET) + $(VARIABLE_SIZE) + $(RESERVE1_SIZE) + $(RESERVE2_SIZE) + $(SPARE_SIZE) + $(FWTWORKING_SIZE)|$(EVENT_LOG_SIZE)
#NV_EVENT_LOG
--
2.31.1
prev parent reply other threads:[~2022-09-09 3:12 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-09 3:11 [edk2-platforms][PATCH V1 00/16] Platform: Add Loongson support xianglai
2022-09-09 3:11 ` [edk2-platforms][PATCH V1 01/16] Platform/Loongson: Add Serial Port library xianglai
2022-09-09 8:44 ` 回复: [edk2-devel] " gaoliming
2022-09-09 9:08 ` xianglai
2022-09-09 10:40 ` Chao Li
2022-09-09 3:11 ` [edk2-platforms][PATCH V1 02/16] Platform/Loongson: Support SEC And Add Readme.md xianglai
2022-09-09 3:11 ` [edk2-platforms][PATCH V1 03/16] Platform/Loongson: Add PeiServicesTablePointerLib xianglai
2022-09-09 3:12 ` [edk2-platforms][PATCH V1 04/16] Platform/Loongson: Add QemuFwCfgLib xianglai
2022-09-09 3:12 ` [edk2-platforms][PATCH V1 05/16] Platform/Loongson: Add MmuLib xianglai
2022-09-09 3:12 ` [edk2-platforms][PATCH V1 06/16] Platform/Loongson: Add StableTimerLib xianglai
2022-09-09 16:49 ` [edk2-devel] " Michael D Kinney
2022-09-13 2:35 ` xianglai
[not found] ` <17144AF1748B76B9.3485@groups.io>
2022-09-13 9:46 ` xianglai
2022-09-09 3:12 ` [edk2-platforms][PATCH V1 07/16] Platform/Loongson: Support PEI phase xianglai
2022-09-09 3:12 ` [edk2-platforms][PATCH V1 08/16] Platform/Loongson: Add CPU DXE driver xianglai
2022-09-09 3:12 ` [edk2-platforms][PATCH V1 09/16] Platform/Loongson: Add PciCpuIoDxe driver xianglai
2022-09-09 3:12 ` [edk2-platforms][PATCH V1 10/16] Platform/Loongson: Add timer Dxe driver xianglai
2022-09-09 3:12 ` [edk2-platforms][PATCH V1 11/16] Platform/Loongson: Add RealTime Clock lib xianglai
2022-09-09 3:12 ` [edk2-platforms][PATCH V1 12/16] Platform/Loongson: Add Platform Boot Manager Lib xianglai
2022-09-09 3:12 ` [edk2-platforms][PATCH V1 13/16] Platform/Loongson: Add Reset System Lib xianglai
2022-09-09 3:12 ` [edk2-platforms][PATCH V1 14/16] Platform/Loongson: Support Dxe xianglai
2022-09-09 3:12 ` [edk2-platforms][PATCH V1 15/16] Platform/Loongson: Add QemuFlashFvbServicesRuntimeDxe driver xianglai
2022-09-09 3:12 ` xianglai [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ded518989ef8db4d85996f5d4d74c127afc48cc0.1662691771.git.lixianglai@loongson.cn \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox