From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f44.google.com (mail-pj1-f44.google.com [209.85.216.44]) by mx.groups.io with SMTP id smtpd.web10.85401.1673614716158155131 for ; Fri, 13 Jan 2023 04:58:36 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20210112 header.b=WlPqCjuQ; spf=pass (domain: gmail.com, ip: 209.85.216.44, mailfrom: theojehl76@gmail.com) Received: by mail-pj1-f44.google.com with SMTP id s13-20020a17090a6e4d00b0022900843652so5391481pjm.1 for ; Fri, 13 Jan 2023 04:58:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=PYvTppuPFFrg+xTL6Jp9vn8qDQKg4iaCOe1MJK0CPCk=; b=WlPqCjuQ97Zhoc88Iqr5r4uVzBzAwDvlyjuSCdE6FlgDgQVdYlPbkykl0xPDkjbe5f zwzEU+3ZuVkyrxyhVJcv89827zLkEoYqx9MRQPDzRhxWcyFHYvIDJ5fcl4HgJ1bRqqrP w2YgiiyNu6u2hRpHpqfy+WdOh2gJx/fsS9o73JbnV4hYSCQa2FBnjnaYI8RSo4ksU/l1 0uZjkKENygAOj7dsiomGlpYFKj4Wvtr34T3OgZOKuofnCSlWZZxVgaP2jhpP9I5m9Q84 3T1nOSkwiLOAXGJ47LaBnekxeasZXCezvH44pkEkKfxwo6fJY87H4csJY1sm15YtWG4q Nvvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=PYvTppuPFFrg+xTL6Jp9vn8qDQKg4iaCOe1MJK0CPCk=; b=yYGEzgJyxtE2sYQktlzim/T0qDiKFEaVBRKiYFa85eeJyDo1zPPVCnypetBanHuI+h /dmu6p5nvwLObdNC3CRNVAbHAoasUqh/pQl5FxN2k9ENHUwlS/KvjJQZpxLzFR3uBBAA h8f8YfTCegz9Agobdb6RoIp38coMuKwggbP9USfcM3OshaDiHsFyiw5CEGB/Fn0rhQia 5ddNXL9qS1Os9eFJoOSzumvG7hV+wnLWVA7l/cuWUWVESWN1bvVX4LLpGRJnZPNnwkWr RMXHAaQqce0HLwrhwzcfLP95xBqzZXn1rtIWu4D9+JPc0XmJ8DiU2K72M9lodyK7fi20 3Hpw== X-Gm-Message-State: AFqh2kpyQ5XR9GINIpl2Fl7WK9Q8eA0N5qVOe63AZuNgM6MQ1ycLYXqB sQtlKRXdpNzrQQo5q3xnnUEEGTnmXytvO5CLwSU= X-Google-Smtp-Source: AMrXdXuQfAxK/F80OcDVn0+gw0d7BaGggaT4yuuTE1mPA0z2er2Nhs8On7KpHJp+1/bG+vqgr+un2J34A7Vdyxw+Ebk= X-Received: by 2002:a17:902:bcc9:b0:194:4fa8:bf91 with SMTP id o9-20020a170902bcc900b001944fa8bf91mr699616pls.82.1673614715302; Fri, 13 Jan 2023 04:58:35 -0800 (PST) MIME-Version: 1.0 References: <20230112231359.452800-1-pedro.falcato@gmail.com> <20230112231359.452800-3-pedro.falcato@gmail.com> In-Reply-To: <20230112231359.452800-3-pedro.falcato@gmail.com> From: =?UTF-8?B?VGjDqW8gSmVobA==?= Date: Fri, 13 Jan 2023 13:58:24 +0100 Message-ID: Subject: Re: [PATCH edk2-platforms 2/2] QemuOpenBoardPkg: Trivial code cleanup To: Pedro Falcato Cc: devel@edk2.groups.io, Isaac Oram Content-Type: multipart/alternative; boundary="00000000000098bb5c05f224ca73" --00000000000098bb5c05f224ca73 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Reviewed-by: Theo Jehl Le ven. 13 janv. 2023 =C3=A0 00:14, Pedro Falcato = a =C3=A9crit : > Small cleanups around PlatformInitPei. > > Signed-off-by: Pedro Falcato > Cc: Isaac Oram > Cc: Theo Jehl > --- > .../QemuOpenBoardPkg/PlatformInitPei/Cpu.c | 2 +- > .../QemuOpenBoardPkg/PlatformInitPei/Memory.c | 9 ++---- > .../PlatformInitPei/PlatformInit.h | 28 ++++++++++++++----- > 3 files changed, 25 insertions(+), 14 deletions(-) > > diff --git a/Platform/Qemu/QemuOpenBoardPkg/PlatformInitPei/Cpu.c > b/Platform/Qemu/QemuOpenBoardPkg/PlatformInitPei/Cpu.c > index e203b2654226..2fc62a0a3e77 100644 > --- a/Platform/Qemu/QemuOpenBoardPkg/PlatformInitPei/Cpu.c > +++ b/Platform/Qemu/QemuOpenBoardPkg/PlatformInitPei/Cpu.c > @@ -20,7 +20,7 @@ > /** > Probe Qemu FW CFG device for current CPU count and report to MpInitLib= . > > - @return EFI_SUCCESS Detection was successful. > + @retval EFI_SUCCESS Detection was successful. > @retval EFI_UNSUPPORTED QEMU FW CFG device is not present. > */ > EFI_STATUS > diff --git a/Platform/Qemu/QemuOpenBoardPkg/PlatformInitPei/Memory.c > b/Platform/Qemu/QemuOpenBoardPkg/PlatformInitPei/Memory.c > index 4f312c36016e..223cace0ca98 100644 > --- a/Platform/Qemu/QemuOpenBoardPkg/PlatformInitPei/Memory.c > +++ b/Platform/Qemu/QemuOpenBoardPkg/PlatformInitPei/Memory.c > @@ -86,8 +86,8 @@ GetTopNonHoleAddr ( > STATIC > VOID > ReserveMmioRegion ( > - EFI_PHYSICAL_ADDRESS Start, > - UINT64 Length > + IN EFI_PHYSICAL_ADDRESS Start, > + IN UINT64 Length > ) > { > EFI_RESOURCE_TYPE ResourceType; > @@ -121,7 +121,6 @@ InstallMemory ( > ) > { > EFI_STATUS Status; > - CONST EFI_PEI_SERVICES **PeiServicesTable; > EFI_E820_ENTRY64 E820Entry; > EFI_E820_ENTRY64 LargestE820Entry; > QEMU_FW_CFG_FILE FwCfgFile; > @@ -250,9 +249,7 @@ InstallMemory ( > LargestE820Entry.BaseAddr + LargestE820Entry.Length - 1 > )); > > - PeiServicesTable =3D GetPeiServicesTablePointer (); > - > - Status =3D (*PeiServices)->InstallPeiMemory (PeiServicesTable, > LargestE820Entry.BaseAddr, LargestE820Entry.Length); > + Status =3D (*PeiServices)->InstallPeiMemory (PeiServices, > LargestE820Entry.BaseAddr, LargestE820Entry.Length); > > ASSERT_EFI_ERROR (Status); > > diff --git a/Platform/Qemu/QemuOpenBoardPkg/PlatformInitPei/PlatformInit.= h > b/Platform/Qemu/QemuOpenBoardPkg/PlatformInitPei/PlatformInit.h > index f4044df3dbf5..f17df707188a 100644 > --- a/Platform/Qemu/QemuOpenBoardPkg/PlatformInitPei/PlatformInit.h > +++ b/Platform/Qemu/QemuOpenBoardPkg/PlatformInitPei/PlatformInit.h > @@ -20,19 +20,27 @@ > > #define PCI_MMIO_TOP_ADDRESS 0xFC000000 > > -EFI_STATUS > -EFIAPI > -PlatformInit ( > - IN EFI_PEI_FILE_HANDLE FileHandle, > - IN CONST EFI_PEI_SERVICES **PeiServices > - ); > +/** > + Return the memory size below 4GB. > > + @return Size of memory below 4GB, in bytes. > +**/ > UINT32 > EFIAPI > GetMemoryBelow4Gb ( > VOID > ); > > +/** > + Install EFI memory by probing QEMU FW CFG devices for valid E820 > entries. > + It also reserves space for MMIO regions such as VGA, BIOS and APIC. > + > + @param[in] PeiServices PEI Services pointer. > + > + @retval EFI_SUCCESS Memory initialization succeded. > + @retval EFI_UNSUPPORTED Installation failed (etc/e820 file was not > found). > + @retval EFI_NOT_FOUND QEMU FW CFG device is not present. > +**/ > EFI_STATUS > EFIAPI > InstallMemory ( > @@ -58,6 +66,12 @@ InitializePci ( > QEMU_PLATFORM Platform > ); > > +/** > + Probe Qemu FW CFG device for current CPU count and report to MpInitLib= . > + > + @retval EFI_SUCCESS Detection was successful. > + @retval EFI_UNSUPPORTED QEMU FW CFG device is not present. > + */ > EFI_STATUS > EFIAPI > MaxCpuInit ( > @@ -74,4 +88,4 @@ GetTopNonHoleAddr ( > VOID > ); > > -#endif //QEMU_OPEN_BOARD_PKG_PLATFORM_INIT_H_ > +#endif // QEMU_OPEN_BOARD_PKG_PLATFORM_INIT_H_ > -- > 2.39.0 > > --00000000000098bb5c05f224ca73 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Reviewed-by: Theo Jehl <theojehl76@gmail.com>

Le=C2=A0ven. 13 = janv. 2023 =C3=A0=C2=A000:14, Pedro Falcato <pedro.falcato@gmail.com> a =C3=A9crit=C2=A0:
Small cleanups around PlatformInitPei.

Signed-off-by: Pedro Falcato <pedro.falcato@gmail.com>
Cc: Isaac Oram <isaac.w.oram@intel.com>
Cc: Theo Jehl <theojehl76@gmail.com>
---
=C2=A0.../QemuOpenBoardPkg/PlatformInitPei/Cpu.c=C2=A0 =C2=A0 |=C2=A0 2 +-<= br> =C2=A0.../QemuOpenBoardPkg/PlatformInitPei/Memory.c |=C2=A0 9 ++----
=C2=A0.../PlatformInitPei/PlatformInit.h=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 | 28 ++++++++++++++-----
=C2=A03 files changed, 25 insertions(+), 14 deletions(-)

diff --git a/Platform/Qemu/QemuOpenBoardPkg/PlatformInitPei/Cpu.c b/Platfor= m/Qemu/QemuOpenBoardPkg/PlatformInitPei/Cpu.c
index e203b2654226..2fc62a0a3e77 100644
--- a/Platform/Qemu/QemuOpenBoardPkg/PlatformInitPei/Cpu.c
+++ b/Platform/Qemu/QemuOpenBoardPkg/PlatformInitPei/Cpu.c
@@ -20,7 +20,7 @@
=C2=A0/**
=C2=A0 =C2=A0Probe Qemu FW CFG device for current CPU count and report to M= pInitLib.

-=C2=A0 @return EFI_SUCCESS=C2=A0 =C2=A0 =C2=A0 Detection was successful. +=C2=A0 @retval EFI_SUCCESS=C2=A0 =C2=A0 =C2=A0 Detection was successful. =C2=A0 =C2=A0@retval EFI_UNSUPPORTED=C2=A0 QEMU FW CFG device is not presen= t.
=C2=A0 */
=C2=A0EFI_STATUS
diff --git a/Platform/Qemu/QemuOpenBoardPkg/PlatformInitPei/Memory.c b/Plat= form/Qemu/QemuOpenBoardPkg/PlatformInitPei/Memory.c
index 4f312c36016e..223cace0ca98 100644
--- a/Platform/Qemu/QemuOpenBoardPkg/PlatformInitPei/Memory.c
+++ b/Platform/Qemu/QemuOpenBoardPkg/PlatformInitPei/Memory.c
@@ -86,8 +86,8 @@ GetTopNonHoleAddr (
=C2=A0STATIC
=C2=A0VOID
=C2=A0ReserveMmioRegion (
-=C2=A0 EFI_PHYSICAL_ADDRESS=C2=A0 Start,
-=C2=A0 UINT64=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Lengt= h
+=C2=A0 IN EFI_PHYSICAL_ADDRESS=C2=A0 Start,
+=C2=A0 IN UINT64=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Le= ngth
=C2=A0 =C2=A0)
=C2=A0{
=C2=A0 =C2=A0EFI_RESOURCE_TYPE=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Res= ourceType;
@@ -121,7 +121,6 @@ InstallMemory (
=C2=A0 =C2=A0)
=C2=A0{
=C2=A0 =C2=A0EFI_STATUS=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0Status;
-=C2=A0 CONST EFI_PEI_SERVICES=C2=A0 =C2=A0 =C2=A0 =C2=A0**PeiServicesTable= ;
=C2=A0 =C2=A0EFI_E820_ENTRY64=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0E820Entry;
=C2=A0 =C2=A0EFI_E820_ENTRY64=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0LargestE820Entry;
=C2=A0 =C2=A0QEMU_FW_CFG_FILE=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0FwCfgFile;
@@ -250,9 +249,7 @@ InstallMemory (
=C2=A0 =C2=A0 =C2=A0LargestE820Entry.BaseAddr + LargestE820Entry.Length - 1=
=C2=A0 =C2=A0 =C2=A0));

-=C2=A0 PeiServicesTable =3D GetPeiServicesTablePointer ();
-
-=C2=A0 Status =3D (*PeiServices)->InstallPeiMemory (PeiServicesTable, L= argestE820Entry.BaseAddr, LargestE820Entry.Length);
+=C2=A0 Status =3D (*PeiServices)->InstallPeiMemory (PeiServices, Larges= tE820Entry.BaseAddr, LargestE820Entry.Length);

=C2=A0 =C2=A0ASSERT_EFI_ERROR (Status);

diff --git a/Platform/Qemu/QemuOpenBoardPkg/PlatformInitPei/PlatformInit.h = b/Platform/Qemu/QemuOpenBoardPkg/PlatformInitPei/PlatformInit.h
index f4044df3dbf5..f17df707188a 100644
--- a/Platform/Qemu/QemuOpenBoardPkg/PlatformInitPei/PlatformInit.h
+++ b/Platform/Qemu/QemuOpenBoardPkg/PlatformInitPei/PlatformInit.h
@@ -20,19 +20,27 @@

=C2=A0#define PCI_MMIO_TOP_ADDRESS=C2=A0 0xFC000000

-EFI_STATUS
-EFIAPI
-PlatformInit (
-=C2=A0 IN=C2=A0 =C2=A0 =C2=A0 =C2=A0EFI_PEI_FILE_HANDLE=C2=A0 FileHandle,<= br> -=C2=A0 IN CONST EFI_PEI_SERVICES=C2=A0 =C2=A0 =C2=A0**PeiServices
-=C2=A0 );
+/**
+=C2=A0 Return the memory size below 4GB.

+=C2=A0 @return Size of memory below 4GB, in bytes.
+**/
=C2=A0UINT32
=C2=A0EFIAPI
=C2=A0GetMemoryBelow4Gb (
=C2=A0 =C2=A0VOID
=C2=A0 =C2=A0);

+/**
+=C2=A0 Install EFI memory by probing QEMU FW CFG devices for valid E820 en= tries.
+=C2=A0 It also reserves space for MMIO regions such as VGA, BIOS and APIC.=
+
+=C2=A0 @param[in] PeiServices=C2=A0 =C2=A0 =C2=A0 PEI Services pointer. +
+=C2=A0 @retval EFI_SUCCESS=C2=A0 =C2=A0 =C2=A0Memory initialization succed= ed.
+=C2=A0 @retval EFI_UNSUPPORTED Installation failed (etc/e820 file was not = found).
+=C2=A0 @retval EFI_NOT_FOUND=C2=A0 =C2=A0QEMU FW CFG device is not present= .
+**/
=C2=A0EFI_STATUS
=C2=A0EFIAPI
=C2=A0InstallMemory (
@@ -58,6 +66,12 @@ InitializePci (
=C2=A0 =C2=A0QEMU_PLATFORM=C2=A0 Platform
=C2=A0 =C2=A0);

+/**
+=C2=A0 Probe Qemu FW CFG device for current CPU count and report to MpInit= Lib.
+
+=C2=A0 @retval EFI_SUCCESS=C2=A0 =C2=A0 =C2=A0 Detection was successful. +=C2=A0 @retval EFI_UNSUPPORTED=C2=A0 QEMU FW CFG device is not present. + */
=C2=A0EFI_STATUS
=C2=A0EFIAPI
=C2=A0MaxCpuInit (
@@ -74,4 +88,4 @@ GetTopNonHoleAddr (
=C2=A0 =C2=A0VOID
=C2=A0 =C2=A0);

-#endif //QEMU_OPEN_BOARD_PKG_PLATFORM_INIT_H_
+#endif // QEMU_OPEN_BOARD_PKG_PLATFORM_INIT_H_
--
2.39.0

--00000000000098bb5c05f224ca73--