From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id DCB1D1A1EFC for ; Thu, 15 Sep 2016 06:57:25 -0700 (PDT) Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4ED8632B833; Thu, 15 Sep 2016 13:57:25 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-116-94.phx2.redhat.com [10.3.116.94]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u8FDvNMg030277; Thu, 15 Sep 2016 09:57:23 -0400 To: Ard Biesheuvel , edk2-devel@ml01.01.org References: <1473946233-10547-1-git-send-email-ard.biesheuvel@linaro.org> <1473946233-10547-4-git-send-email-ard.biesheuvel@linaro.org> From: Laszlo Ersek Message-ID: Date: Thu, 15 Sep 2016 15:57:22 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: <1473946233-10547-4-git-send-email-ard.biesheuvel@linaro.org> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 15 Sep 2016 13:57:25 +0000 (UTC) Subject: Re: [PATCH 3/4] ArmVirtPkg/FdtClient: add methods to iterate over memory nodes X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 15 Sep 2016 13:57:26 -0000 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit 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 > --- > 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