public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@redhat.com>
To: devel@edk2.groups.io, lersek@redhat.com
Cc: Anthony Perard <anthony.perard@citrix.com>,
	Ard Biesheuvel <ard.biesheuvel@linaro.org>,
	Jordan Justen <jordan.l.justen@intel.com>,
	Julien Grall <julien.grall@arm.com>
Subject: Re: [edk2-devel] [PATCH 12/16] OvmfPkg/EnrollDefaultKeys: describe functions with leading comment blocks
Date: Tue, 30 Apr 2019 07:12:54 +0200	[thread overview]
Message-ID: <0a9e51f9-5677-6946-db7f-ae0179afb82e@redhat.com> (raw)
In-Reply-To: <20190427005328.27005-13-lersek@redhat.com>

On 4/27/19 2:53 AM, Laszlo Ersek wrote:
> The GetExact(), GetSettings(), PrintSettings(), and ShellAppMain()
> functions lack leading comment blocks. Supply those.
> 
> While at it, make sure that every such comment block is preceded by two
> blank lines.
> 
> Cc: Anthony Perard <anthony.perard@citrix.com>
> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> Cc: Jordan Justen <jordan.l.justen@intel.com>
> Cc: Julien Grall <julien.grall@arm.com>
> Bugzilla: https://bugzilla.tianocore.org/show_bug.cgi?id=1747
> Signed-off-by: Laszlo Ersek <lersek@redhat.com>
> ---
>  OvmfPkg/EnrollDefaultKeys/EnrollDefaultKeys.c | 73 ++++++++++++++++++++
>  1 file changed, 73 insertions(+)
> 
> diff --git a/OvmfPkg/EnrollDefaultKeys/EnrollDefaultKeys.c b/OvmfPkg/EnrollDefaultKeys/EnrollDefaultKeys.c
> index e4f6a50e008b..07297c631f38 100644
> --- a/OvmfPkg/EnrollDefaultKeys/EnrollDefaultKeys.c
> +++ b/OvmfPkg/EnrollDefaultKeys/EnrollDefaultKeys.c
> @@ -13,16 +13,17 @@
>  #include <Library/DebugLib.h>                    // ASSERT()
>  #include <Library/MemoryAllocationLib.h>         // FreePool()
>  #include <Library/ShellCEntryLib.h>              // ShellAppMain()
>  #include <Library/UefiLib.h>                     // AsciiPrint()
>  #include <Library/UefiRuntimeServicesTableLib.h> // gRT
>  
>  #include "EnrollDefaultKeys.h"
>  
> +
>  /**
>    Enroll a set of certificates in a global variable, overwriting it.
>  
>    The variable will be rewritten with NV+BS+RT+AT attributes.
>  
>    @param[in] VariableName  The name of the variable to overwrite.
>  
>    @param[in] VendorGuid    The namespace (ie. vendor GUID) of the variable to
> @@ -188,16 +189,54 @@ Out:
>    if (EFI_ERROR (Status)) {
>      AsciiPrint ("error: %a(\"%s\", %g): %r\n", __FUNCTION__, VariableName,
>        VendorGuid, Status);
>    }
>    return Status;
>  }
>  
>  
> +/**
> +  Read a UEFI variable into a caller-allocated buffer, enforcing an exact size.
> +
> +  @param[in] VariableName  The name of the variable to read; passed to
> +                           gRT->GetVariable().
> +
> +  @param[in] VendorGuid    The vendor (namespace) GUID of the variable to read;
> +                           passed to gRT->GetVariable().
> +
> +  @param[out] Data         The caller-allocated buffer that is supposed to
> +                           receive the variable's contents. On error, the
> +                           contents of Data are indeterminate.
> +
> +  @param[in] DataSize      The size in bytes that the caller requires the UEFI
> +                           variable to have. The caller is responsible for
> +                           providing room for DataSize bytes in Data.
> +
> +  @param[in] AllowMissing  If FALSE, the variable is required to exist. If
> +                           TRUE, the variable is permitted to be missing.
> +
> +  @retval EFI_SUCCESS           The UEFI variable exists, has the required size
> +                                (DataSize), and has been read into Data.
> +
> +  @retval EFI_SUCCESS           The UEFI variable doesn't exist, and
> +                                AllowMissing is TRUE. DataSize bytes in Data
> +                                have been zeroed out.
> +
> +  @retval EFI_NOT_FOUND         The UEFI variable doesn't exist, and
> +                                AllowMissing is FALSE.
> +
> +  @retval EFI_BUFFER_TOO_SMALL  The UEFI variable exists, but its size is
> +                                greater than DataSize.
> +
> +  @retval EFI_PROTOCOL_ERROR    The UEFI variable exists, but its size is
> +                                smaller than DataSize.
> +
> +  @return                       Error codes propagated from gRT->GetVariable().
> +**/
>  STATIC
>  EFI_STATUS
>  GetExact (
>    IN CHAR16   *VariableName,
>    IN EFI_GUID *VendorGuid,
>    OUT VOID    *Data,
>    IN UINTN    DataSize,
>    IN BOOLEAN  AllowMissing
> @@ -223,16 +262,41 @@ GetExact (
>      AsciiPrint ("error: GetVariable(\"%s\", %g): expected size 0x%Lx, "
>        "got 0x%Lx\n", VariableName, VendorGuid, (UINT64)DataSize, (UINT64)Size);
>      return EFI_PROTOCOL_ERROR;
>    }
>  
>    return EFI_SUCCESS;
>  }
>  
> +
> +/**
> +  Populate a SETTINGS structure from the underlying UEFI variables.
> +
> +  The following UEFI variables are standard variables:
> +  - L"SetupMode"  (EFI_SETUP_MODE_NAME)
> +  - L"SecureBoot" (EFI_SECURE_BOOT_MODE_NAME)
> +  - L"VendorKeys" (EFI_VENDOR_KEYS_VARIABLE_NAME)
> +
> +  The following UEFI variables are edk2 extensions:
> +  - L"SecureBootEnable" (EFI_SECURE_BOOT_ENABLE_NAME)
> +  - L"CustomMode"       (EFI_CUSTOM_MODE_NAME)
> +
> +  The L"SecureBootEnable" UEFI variable is permitted to be missing, in which
> +  case the corresponding field in the SETTINGS object will be zeroed out. The
> +  rest of the covered UEFI variables are required to exist; otherwise, the
> +  function will fail.
> +
> +  @param[out] Settings  The SETTINGS object to fill.
> +
> +  @retval EFI_SUCCESS  Settings has been populated.
> +
> +  @return              Error codes propagated from the GetExact() function. The
> +                       contents of Settings are indeterminate.
> +**/
>  STATIC
>  EFI_STATUS
>  GetSettings (
>    OUT SETTINGS *Settings
>    )
>  {
>    EFI_STATUS Status;
>  
> @@ -261,28 +325,37 @@ GetSettings (
>      return Status;
>    }
>  
>    Status = GetExact (EFI_VENDOR_KEYS_VARIABLE_NAME, &gEfiGlobalVariableGuid,
>               &Settings->VendorKeys, sizeof Settings->VendorKeys, FALSE);
>    return Status;
>  }
>  
> +
> +/**
> +  Print the contents of a SETTINGS structure to the UEFI console.
> +
> +  @param[in] Settings  The SETTINGS object to print the contents of.
> +**/
>  STATIC
>  VOID
>  PrintSettings (
>    IN CONST SETTINGS *Settings
>    )
>  {
>    AsciiPrint ("info: SetupMode=%d SecureBoot=%d SecureBootEnable=%d "
>      "CustomMode=%d VendorKeys=%d\n", Settings->SetupMode, Settings->SecureBoot,
>      Settings->SecureBootEnable, Settings->CustomMode, Settings->VendorKeys);
>  }
>  
>  
> +/**
> +  Entry point function of this shell application.
> +**/
>  INTN
>  EFIAPI
>  ShellAppMain (
>    IN UINTN  Argc,
>    IN CHAR16 **Argv
>    )
>  {
>    EFI_STATUS Status;
> 

Reviewed-by: Philippe Mathieu-Daude <philmd@redhat.com>

  reply	other threads:[~2019-04-30  5:12 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-27  0:53 [PATCH 00/16] OvmfPkg, ArmVirtPkg: upstream the EnrollDefaultKeys app Laszlo Ersek
2019-04-27  0:53 ` [PATCH 01/16] OvmfPkg: introduce EnrollDefaultKeys application Laszlo Ersek
2019-04-30  5:21   ` [edk2-devel] " Philippe Mathieu-Daudé
2019-04-27  0:53 ` [PATCH 02/16] OvmfPkg/EnrollDefaultKeys: update @file comment blocks Laszlo Ersek
2019-04-30  5:13   ` [edk2-devel] " Philippe Mathieu-Daudé
2019-04-27  0:53 ` [PATCH 03/16] OvmfPkg/EnrollDefaultKeys: refresh INF file Laszlo Ersek
2019-04-29 12:25   ` [edk2-devel] " Philippe Mathieu-Daudé
2019-04-27  0:53 ` [PATCH 04/16] ArmVirtPkg: build EnrollDefaultKeys.efi Laszlo Ersek
2019-04-29 12:26   ` [edk2-devel] " Philippe Mathieu-Daudé
2019-04-27  0:53 ` [PATCH 05/16] OvmfPkg/EnrollDefaultKeys: clean up minor whitespace wart Laszlo Ersek
2019-04-29 12:26   ` [edk2-devel] " Philippe Mathieu-Daudé
2019-04-27  0:53 ` [PATCH 06/16] OvmfPkg/EnrollDefaultKeys: clean up global variable name prefixes Laszlo Ersek
2019-04-29 12:27   ` [edk2-devel] " Philippe Mathieu-Daudé
2019-04-27  0:53 ` [PATCH 07/16] OvmfPkg/EnrollDefaultKeys: clean up acronym capitalization in identifiers Laszlo Ersek
2019-04-30  5:10   ` [edk2-devel] " Philippe Mathieu-Daudé
2019-04-27  0:53 ` [PATCH 08/16] OvmfPkg/EnrollDefaultKeys: remove unneeded EFIAPI call. conv. specifiers Laszlo Ersek
2019-04-29 12:28   ` [edk2-devel] " Philippe Mathieu-Daudé
2019-04-27  0:53 ` [PATCH 09/16] OvmfPkg/EnrollDefaultKeys: extract typedefs to a header file Laszlo Ersek
2019-04-29 12:30   ` [edk2-devel] " Philippe Mathieu-Daudé
2019-04-27  0:53 ` [PATCH 10/16] OvmfPkg/EnrollDefaultKeys: split out certificate and signature constants Laszlo Ersek
2019-04-29 12:33   ` [edk2-devel] " Philippe Mathieu-Daudé
2019-04-27  0:53 ` [PATCH 11/16] OvmfPkg/EnrollDefaultKeys: extract MICROSOFT_VENDOR_GUID Laszlo Ersek
2019-04-30  5:11   ` [edk2-devel] " Philippe Mathieu-Daudé
2019-04-27  0:53 ` [PATCH 12/16] OvmfPkg/EnrollDefaultKeys: describe functions with leading comment blocks Laszlo Ersek
2019-04-30  5:12   ` Philippe Mathieu-Daudé [this message]
2019-04-27  0:53 ` [PATCH 13/16] OvmfPkg/EnrollDefaultKeys: document the steps of the entry point function Laszlo Ersek
2019-04-29 12:36   ` [edk2-devel] " Philippe Mathieu-Daudé
2019-04-27  0:53 ` [PATCH 14/16] OvmfPkg: introduce OVMF_PK_KEK1_APP_PREFIX_GUID Laszlo Ersek
2019-04-30  5:24   ` [edk2-devel] " Philippe Mathieu-Daudé
2019-04-27  0:53 ` [PATCH 15/16] OvmfPkg/EnrollDefaultKeys: enroll PK/KEK1 from the Type 11 SMBIOS table Laszlo Ersek
2019-04-30  5:34   ` [edk2-devel] " Philippe Mathieu-Daudé
2019-04-27  0:53 ` [PATCH 16/16] OvmfPkg/EnrollDefaultKeys: remove Red Hat's hard-coded PK/KEK1 Laszlo Ersek
2019-04-30  5:35   ` [edk2-devel] " Philippe Mathieu-Daudé
2019-04-27  1:07 ` [edk2-devel] [PATCH 00/16] OvmfPkg, ArmVirtPkg: upstream the EnrollDefaultKeys app Laszlo Ersek
2019-04-27  8:14 ` Ard Biesheuvel
2019-04-30  7:51 ` [edk2-devel] " Gary Lin
2019-04-30 12:32 ` Laszlo Ersek
2019-04-30 19:42   ` Ard Biesheuvel
2019-04-30 20:04     ` Laszlo Ersek

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=0a9e51f9-5677-6946-db7f-ae0179afb82e@redhat.com \
    --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