[edk2-devel] [PATCH v5 21/28] OvmfPkg: Add QemuFwCfgParseString to QemuFwCfgSimpleParserLib

Taylor Beebe posted 28 patches 2 years, 4 months ago
Only 27 patches received!
[edk2-devel] [PATCH v5 21/28] OvmfPkg: Add QemuFwCfgParseString to QemuFwCfgSimpleParserLib
Posted by Taylor Beebe 2 years, 4 months ago
QemuFwCfgParseString allows reading strings from the fw_cfg file.
This function is needed for parsing the memory protection profile
name.

Signed-off-by: Taylor Beebe <taylor.d.beebe@gmail.com>
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
---
 OvmfPkg/Library/QemuFwCfgSimpleParserLib/QemuFwCfgSimpleParser.c | 11 +++++++++++
 OvmfPkg/Include/Library/QemuFwCfgSimpleParserLib.h               |  8 ++++++++
 2 files changed, 19 insertions(+)

diff --git a/OvmfPkg/Library/QemuFwCfgSimpleParserLib/QemuFwCfgSimpleParser.c b/OvmfPkg/Library/QemuFwCfgSimpleParserLib/QemuFwCfgSimpleParser.c
index c9e0091b82d1..63c8711a9f2e 100644
--- a/OvmfPkg/Library/QemuFwCfgSimpleParserLib/QemuFwCfgSimpleParser.c
+++ b/OvmfPkg/Library/QemuFwCfgSimpleParserLib/QemuFwCfgSimpleParser.c
@@ -426,3 +426,14 @@ QemuFwCfgParseUintn (
   *Value = (UINTN)Uint64;
   return RETURN_SUCCESS;
 }
+
+RETURN_STATUS
+EFIAPI
+QemuFwCfgParseString (
+  IN     CONST CHAR8  *FileName,
+  IN OUT UINTN        *BufferSize,
+  OUT    CHAR8        *Buffer
+  )
+{
+  return QemuFwCfgGetAsString (FileName, BufferSize, Buffer);
+}
diff --git a/OvmfPkg/Include/Library/QemuFwCfgSimpleParserLib.h b/OvmfPkg/Include/Library/QemuFwCfgSimpleParserLib.h
index bcbf3bc4fc96..ea9fcf7b402e 100644
--- a/OvmfPkg/Include/Library/QemuFwCfgSimpleParserLib.h
+++ b/OvmfPkg/Include/Library/QemuFwCfgSimpleParserLib.h
@@ -125,4 +125,12 @@ QemuFwCfgParseUintn (
   OUT UINTN        *Value
   );
 
+RETURN_STATUS
+EFIAPI
+QemuFwCfgParseString (
+  IN     CONST CHAR8  *FileName,
+  IN OUT UINTN        *BufferSize,
+  OUT    CHAR8        *Buffer
+  );
+
 #endif // QEMU_FW_CFG_SIMPLE_PARSER_LIB_H_
-- 
2.42.0.windows.2



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#109426): https://edk2.groups.io/g/devel/message/109426
Mute This Topic: https://groups.io/mt/101843365/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-
Re: [edk2-devel] [PATCH v5 21/28] OvmfPkg: Add QemuFwCfgParseString to QemuFwCfgSimpleParserLib
Posted by Laszlo Ersek 2 years, 4 months ago
On 10/9/23 02:07, Taylor Beebe wrote:
> QemuFwCfgParseString allows reading strings from the fw_cfg file.
> This function is needed for parsing the memory protection profile
> name.
> 
> Signed-off-by: Taylor Beebe <taylor.d.beebe@gmail.com>
> Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
> Cc: Jiewen Yao <jiewen.yao@intel.com>
> Cc: Jordan Justen <jordan.l.justen@intel.com>
> Cc: Gerd Hoffmann <kraxel@redhat.com>
> ---
>  OvmfPkg/Library/QemuFwCfgSimpleParserLib/QemuFwCfgSimpleParser.c | 11 +++++++++++
>  OvmfPkg/Include/Library/QemuFwCfgSimpleParserLib.h               |  8 ++++++++
>  2 files changed, 19 insertions(+)
> 
> diff --git a/OvmfPkg/Library/QemuFwCfgSimpleParserLib/QemuFwCfgSimpleParser.c b/OvmfPkg/Library/QemuFwCfgSimpleParserLib/QemuFwCfgSimpleParser.c
> index c9e0091b82d1..63c8711a9f2e 100644
> --- a/OvmfPkg/Library/QemuFwCfgSimpleParserLib/QemuFwCfgSimpleParser.c
> +++ b/OvmfPkg/Library/QemuFwCfgSimpleParserLib/QemuFwCfgSimpleParser.c
> @@ -426,3 +426,14 @@ QemuFwCfgParseUintn (
>    *Value = (UINTN)Uint64;
>    return RETURN_SUCCESS;
>  }
> +
> +RETURN_STATUS
> +EFIAPI
> +QemuFwCfgParseString (
> +  IN     CONST CHAR8  *FileName,
> +  IN OUT UINTN        *BufferSize,
> +  OUT    CHAR8        *Buffer
> +  )
> +{
> +  return QemuFwCfgGetAsString (FileName, BufferSize, Buffer);
> +}
> diff --git a/OvmfPkg/Include/Library/QemuFwCfgSimpleParserLib.h b/OvmfPkg/Include/Library/QemuFwCfgSimpleParserLib.h
> index bcbf3bc4fc96..ea9fcf7b402e 100644
> --- a/OvmfPkg/Include/Library/QemuFwCfgSimpleParserLib.h
> +++ b/OvmfPkg/Include/Library/QemuFwCfgSimpleParserLib.h
> @@ -125,4 +125,12 @@ QemuFwCfgParseUintn (
>    OUT UINTN        *Value
>    );
>  
> +RETURN_STATUS
> +EFIAPI
> +QemuFwCfgParseString (
> +  IN     CONST CHAR8  *FileName,
> +  IN OUT UINTN        *BufferSize,
> +  OUT    CHAR8        *Buffer
> +  );
> +
>  #endif // QEMU_FW_CFG_SIMPLE_PARSER_LIB_H_

Instead of this, please:

- Rename QemuFwCfgGetAsString() to QemuFwCfgParseString(); make it
extern, and EFIAPI. Update internal calls.

- Move the leading comment on QemuFwCfgGetAsString() from the C file to
the header file. As posted, the newly declared function would not have
documentation in the header file, which is inconsistent with the rest of
the header.

- Place the new function declaration at the top of the header file. As
posted, the new declaration falls under the comment

//
// The following functions behave identically to QemuFwCfgParseUint8(),
// only their range checks use MAX_UINT16, MAX_UINT32, MAX_UINT64, MAX_UINTN,
// respectively.
//

which is wrong.

Thanks
Laszlo



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#109445): https://edk2.groups.io/g/devel/message/109445
Mute This Topic: https://groups.io/mt/101843365/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/leave/3901457/1787277/102458076/xyzzy [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-