public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Laszlo Ersek <lersek@redhat.com>
To: Ard Biesheuvel <ard.biesheuvel@linaro.org>, edk2-devel@ml01.01.org
Subject: Re: [PATCH 3/4] ArmVirtPkg/FdtClient: add methods to iterate over memory nodes
Date: Thu, 15 Sep 2016 15:57:22 +0200	[thread overview]
Message-ID: <d719937f-c496-bc69-64ef-d3e13c03d543@redhat.com> (raw)
In-Reply-To: <1473946233-10547-4-git-send-email-ard.biesheuvel@linaro.org>

On 09/15/16 15:30, Ard Biesheuvel wrote:
> Add high level methods to iterate over all 'reg' properties of all DT
> nodes whose device_type properties have the value "memory". Since we are
> modifying the FdtClient protocol, update the protocol and the only existing
> implementation at the same time.
> 
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> ---
>  ArmVirtPkg/FdtClientDxe/FdtClientDxe.c  | 76 ++++++++++++++++++++
>  ArmVirtPkg/Include/Protocol/FdtClient.h | 26 +++++++
>  2 files changed, 102 insertions(+)
> 
> diff --git a/ArmVirtPkg/FdtClientDxe/FdtClientDxe.c b/ArmVirtPkg/FdtClientDxe/FdtClientDxe.c
> index 382e9af6bf84..099cce7821d6 100644
> --- a/ArmVirtPkg/FdtClientDxe/FdtClientDxe.c
> +++ b/ArmVirtPkg/FdtClientDxe/FdtClientDxe.c
> @@ -194,6 +194,80 @@ FindCompatibleNodeReg (
>  
>  STATIC
>  EFI_STATUS
> +EFIAPI
> +FindNextMemoryNodeReg (
> +  IN  FDT_CLIENT_PROTOCOL     *This,
> +  IN  INT32                   PrevNode,
> +  OUT INT32                   *Node,
> +  OUT CONST VOID              **Reg,
> +  OUT UINTN                   *AddressCells,
> +  OUT UINTN                   *SizeCells,
> +  OUT UINT32                  *RegSize
> +  )
> +{
> +  INT32          Prev, Next;
> +  CONST CHAR8    *DeviceType;
> +  INT32          Len;
> +  EFI_STATUS     Status;
> +
> +  ASSERT (mDeviceTreeBase != NULL);
> +  ASSERT (Node != NULL);
> +
> +  for (Prev = PrevNode;; Prev = Next) {
> +    Next = fdt_next_node (mDeviceTreeBase, Prev, NULL);
> +    if (Next < 0) {
> +      break;
> +    }
> +
> +    DeviceType = fdt_getprop (mDeviceTreeBase, Next, "device_type", &Len);
> +    if (DeviceType != NULL && AsciiStrCmp (DeviceType, "memory") == 0) {

HighMemDxe uses AsciiStrnCmp (Type, "memory", Len) here.

If we're sure that we're not looking "memory*" types here, then the
change is fine. Are we sure?

> +

The empty line is likely unintended.

> +      //
> +      // Get the 'reg' property of this memory node. For now, we will assume
> +      // 8 byte quantities for base and size, respectively.
> +      // TODO use #cells root properties instead
> +      //
> +      Status = GetNodeProperty (This, Next, "reg", Reg, RegSize);
> +      if (EFI_ERROR (Status)) {
> +        DEBUG ((EFI_D_WARN,
> +          "%a: ignoring memory node with no 'reg' property\n",
> +          __FUNCTION__));
> +        continue;
> +      }
> +      if ((*RegSize % 16) != 0) {
> +        DEBUG ((EFI_D_WARN,
> +          "%a: ignoring memory node with invalid 'reg' property (size == 0x%x)\n",
> +          __FUNCTION__, RegSize));

This should be *RegSize.

With the above confirmed / fixed:

Reviewed-by: Laszlo Ersek <lersek@redhat.com>


  reply	other threads:[~2016-09-15 13:57 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-15 13:30 [PATCH 0/4] ArmVirtPkg: FdtClientDxe & HighMemDxe updates Ard Biesheuvel
2016-09-15 13:30 ` [PATCH 1/4] ArmVirtPkg/FdtClientDxe: fix check for size of "reg" properties Ard Biesheuvel
2016-09-15 13:38   ` Laszlo Ersek
2016-09-15 13:40     ` Ard Biesheuvel
2016-09-15 13:30 ` [PATCH 2/4] ArmVirtPkg/FdtClientDxe: report address and size cell count directly Ard Biesheuvel
2016-09-15 13:42   ` Laszlo Ersek
2016-09-15 13:30 ` [PATCH 3/4] ArmVirtPkg/FdtClient: add methods to iterate over memory nodes Ard Biesheuvel
2016-09-15 13:57   ` Laszlo Ersek [this message]
2016-09-15 14:04     ` Ard Biesheuvel
2016-09-15 13:30 ` [PATCH 4/4] ArmVirtPkg/HighMemDxe: move to FDT client protocol Ard Biesheuvel
2016-09-15 14:15   ` Laszlo Ersek
2016-09-15 14:18     ` Ard Biesheuvel
2016-09-15 13:34 ` [PATCH 0/4] ArmVirtPkg: FdtClientDxe & HighMemDxe updates Ard Biesheuvel
2016-09-15 14:40   ` Ard Biesheuvel

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=d719937f-c496-bc69-64ef-d3e13c03d543@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