From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from loongson.cn (loongson.cn [114.242.206.163]) by mx.groups.io with SMTP id smtpd.web12.3491.1665720103737626449 for ; Thu, 13 Oct 2022 21:01:44 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: loongson.cn, ip: 114.242.206.163, mailfrom: lixianglai@loongson.cn) Received: from localhost.localdomain (unknown [10.2.5.185]) by localhost.localdomain (Coremail) with SMTP id AQAAf8Bx32sZ30hjMt8tAA--.26776S18; Fri, 14 Oct 2022 12:01:42 +0800 (CST) From: "xianglai" To: devel@edk2.groups.io Cc: quic_llindhol@quicinc.com, michael.d.kinney@intel.com, kraxel@redhat.com, ardb@kernel.org, maobibo@loongson.cn Subject: [edk2-platforms][PATCH V3 16/16] Platform/Loongson: Support for saving variables to flash. Date: Fri, 14 Oct 2022 12:01:29 +0800 Message-Id: <3e5845792ab4defa48841da306109d352873efb5.1665719826.git.lixianglai@loongson.cn> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 X-CM-TRANSID: AQAAf8Bx32sZ30hjMt8tAA--.26776S18 X-Coremail-Antispam: 1UD129KBjvJXoWxtrWUJryxWF1UAry8Zw4DCFg_yoW3Aw48pr 4UuFn7Kr1kKr4Utr1Yy34DWwnxAryak3s8Jw43tr17WF9rJ3WDG3yjqa15Ary7A347tryx tr409w4UuF1qv3DanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnUUvcSsGvfC2KfnxnUUI43ZEXa7xR_UUUUUUUUU== X-CM-SenderInfo: 5ol0xt5qjotxo6or00hjvr0hdfq/ Content-Transfer-Encoding: quoted-printable Added the function of saving non-volatile variables. REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4054 Signed-off-by: xianglai li --- 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/Loo= ngson/LoongArchQemuPkg/Loongson.dec index 5065f99042..2fd80e7ea2 100644 --- a/Platform/Loongson/LoongArchQemuPkg/Loongson.dec +++ b/Platform/Loongson/LoongArchQemuPkg/Loongson.dec @@ -32,6 +32,8 @@ [Protocols]=0D =0D [PcdsFixedAtBuild, PcdsDynamic]=0D + gLoongArchQemuPkgTokenSpaceGuid.PcdFlashFdBase|0x0|UINT64|0=0D + gLoongArchQemuPkgTokenSpaceGuid.PcdFlashBlockSize|0x0|UINT32|2=0D gLoongArchQemuPkgTokenSpaceGuid.PcdFlashPeiFvBase|0x0|UINT64|0x00000003= =0D gLoongArchQemuPkgTokenSpaceGuid.PcdFlashPeiFvSize|0x0|UINT32|0x00000004= =0D gLoongArchQemuPkgTokenSpaceGuid.PcdFlashDxeFvOffset|0x0|UINT64|0x0000000= 7=0D @@ -48,6 +50,10 @@ gLoongArchQemuPkgTokenSpaceGuid.PcdSecPeiTempRamSize|0|UINT32|0x0000001d= =0D gLoongArchQemuPkgTokenSpaceGuid.PcdUefiRamTop|0x0|UINT64|0x0000001e=0D gLoongArchQemuPkgTokenSpaceGuid.PcdRamRegionsBottom|0x0|UINT64|0x0000002= 2=0D + gLoongArchQemuPkgTokenSpaceGuid.PcdOvmfFlashNvStorageVariableBase|0x0|UI= NT64|0x00000024=0D + gLoongArchQemuPkgTokenSpaceGuid.PcdAllVarSize|0x0|UINT32|0x00000025=0D + gLoongArchQemuPkgTokenSpaceGuid.PcdOvmfFlashNvStorageFtwSpareBase|0x0|UI= NT64|0x00000026=0D + gLoongArchQemuPkgTokenSpaceGuid.PcdOvmfFlashNvStorageFtwWorkingBase|0x0|= UINT64|0x00000027=0D gLoongArchQemuPkgTokenSpaceGuid.PcdFlashSecFvBase|0x0|UINT64|0x00000028= =0D gLoongArchQemuPkgTokenSpaceGuid.PcdFlashSecFvSize|0x0|UINT32|0x00000029= =0D =0D diff --git a/Platform/Loongson/LoongArchQemuPkg/Loongson.dsc b/Platform/Loo= ngson/LoongArchQemuPkg/Loongson.dsc index 59beafb34f..46b326f0a5 100644 --- a/Platform/Loongson/LoongArchQemuPkg/Loongson.dsc +++ b/Platform/Loongson/LoongArchQemuPkg/Loongson.dsc @@ -444,7 +444,7 @@ #=0D # Variable=0D #=0D -# Platform/Loongson/LoongArchQemuPkg/Drivers/QemuFlashFvbServicesRuntimeD= xe/FvbServicesRuntimeDxe.inf=0D + Platform/Loongson/LoongArchQemuPkg/Drivers/QemuFlashFvbServicesRuntimeDx= e/FvbServicesRuntimeDxe.inf=0D OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.inf {=0D =0D PlatformFvbLib|OvmfPkg/Library/EmuVariableFvbLib/EmuVariableFvbLib.i= nf=0D diff --git a/Platform/Loongson/LoongArchQemuPkg/Loongson.fdf b/Platform/Loo= ngson/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|gLoong= ArchQemuPkgTokenSpaceGui FV =3D FVMAIN_COMPACT=0D =0D !include VarStore.fdf.inc=0D +=0D +##########################################################################= ###########################=0D +[FD.QEMU_EFI_VARS]=0D +BaseAddress =3D $(VARIABLE_BASE_ADDRESS)=0D +Size =3D $(VAR_ALL_SIZE)=0D +ErasePolarity =3D 1=0D +BlockSize =3D $(BLOCK_SIZE)=0D +NumBlocks =3D $(VAR_ALL_BLOCKS)=0D +=0D +DEFINE VARIABLE_OFFSET =3D 0=0D +!include VarStore.fdf.inc=0D +DEFINE VARIABLE_OFFSET =3D 0x003a0000=0D +=0D ##########################################################################= ###########################=0D [FV.SECFV]=0D FvNameGuid =3D 587d4265-5e71-41da-9c35-4258551f1e22=0D @@ -87,6 +100,7 @@ INF MdeModulePkg/Core/Pei/PeiMain.inf INF MdeModulePkg/Universal/PCD/Pei/Pcd.inf=0D INF MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf=0D INF Platform/Loongson/LoongArchQemuPkg/PlatformPei/PlatformPei.inf=0D +=0D ##########################################################################= ###########################=0D [FV.DXEFV]=0D FvNameGuid =3D 5d19a5b3-130f-459b-a292-9270a9e6bc62=0D 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 =3D 0x60000 =0D ##########################################################################= ##=0D #Set Var Flash layout=0D +DEFINE VARIABLE_BASE_ADDRESS =3D 0x1c3a0000=0D DEFINE VARIABLE_SIZE =3D 0x00010000=0D DEFINE VAR_ALL_BLOCKS =3D 0x60=0D =0D @@ -53,11 +54,21 @@ DEFINE EVENT_LOG_OFFSET =3D $(FWTWORKING_OFFS= ET) + $(FWTWORKING_SIZE) DEFINE EVENT_LOG_SIZE =3D 0x8000=0D =0D # Set Variable=0D +SET gLoongArchQemuPkgTokenSpaceGuid.PcdFlashFdBase =3D $(FD_BASE_ADDRESS)= =0D +=0D +SET gLoongArchQemuPkgTokenSpaceGuid.PcdOvmfFlashNvStorageVariableBase =3D = $(FD_BASE_ADDRESS) + $(VARIABLE_OFFSET)=0D +SET gLoongArchQemuPkgTokenSpaceGuid.PcdAllVarSize =3D $(VAR_ALL_SIZE)=0D +=0D +SET gLoongArchQemuPkgTokenSpaceGuid.PcdFlashBlockSize =3D $(BLOCK_SIZE)=0D SET gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64 =3D 0=0D SET gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize =3D $(VAR= IABLE_SIZE)=0D =0D # Set FtwSpare=0D +SET gLoongArchQemuPkgTokenSpaceGuid.PcdOvmfFlashNvStorageFtwSpareBase =3D= $(FD_BASE_ADDRESS) + $(SPARE_OFFSET)=0D +SET gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase64 =3D 0=0D SET gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize =3D $(SPA= RE_SIZE)=0D =0D # Set FtwWorking=0D +SET gLoongArchQemuPkgTokenSpaceGuid.PcdOvmfFlashNvStorageFtwWorkingBase = =3D $(FD_BASE_ADDRESS) + $(SPARE_OFFSET) + $(SPARE_SIZE)=0D +SET gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase64 =3D 0= =0D SET gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize =3D $(F= WTWORKING_SIZE)=0D 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 =3D { # FORMATTED: 0x5A #HEALTHY: 0xFE #Reserved: UINT16 #Reserved1: UINT32=0D 0x5a, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00=0D }=0D -$(RESERVE1_OFFSET)|$(RESERVE1_SIZE)=0D +$(VARIABLE_OFFSET) + $(VARIABLE_SIZE)|$(RESERVE1_SIZE)=0D #NV_RESERVE1_STORE=0D =0D -$(RESERVE2_OFFSET)|$(RESERVE2_SIZE)=0D +$(VARIABLE_OFFSET) + $(VARIABLE_SIZE) + $(RESERVE1_SIZE)|$(RESERVE2_SIZE)= =0D #NV_RESERVE2_STORE=0D =0D -$(SPARE_OFFSET)|$(SPARE_SIZE)=0D +$(VARIABLE_OFFSET) + $(VARIABLE_SIZE) + $(RESERVE1_SIZE) + $(RESERVE2_SIZE= )|$(SPARE_SIZE)=0D #NV_FTW_SPARE=0D =0D -$(FWTWORKING_OFFSET)|$(FWTWORKING_SIZE)=0D +$(VARIABLE_OFFSET) + $(VARIABLE_SIZE) + $(RESERVE1_SIZE) + $(RESERVE2_SIZE= ) + $(SPARE_SIZE)|$(FWTWORKING_SIZE)=0D #NV_FTW_WORKING=0D DATA =3D {=0D # EFI_FAULT_TOLERANT_WORKING_BLOCK_HEADER->Signature =3D gEdkiiWorkingBl= ockSignatureGuid =3D=0D @@ -60,5 +60,5 @@ DATA =3D { 0xe0, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00=0D }=0D =0D -$(EVENT_LOG_OFFSET)|$(EVENT_LOG_SIZE)=0D +$(VARIABLE_OFFSET) + $(VARIABLE_SIZE) + $(RESERVE1_SIZE) + $(RESERVE2_SIZE= ) + $(SPARE_SIZE) + $(FWTWORKING_SIZE)|$(EVENT_LOG_SIZE)=0D #NV_EVENT_LOG=0D --=20 2.31.1