From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by mx.groups.io with SMTP id smtpd.web11.2372.1571053450838940940 for ; Mon, 14 Oct 2019 04:44:11 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@akeo-ie.20150623.gappssmtp.com header.s=20150623 header.b=onHfKC8D; spf=none, err=permanent DNS error (domain: akeo.ie, ip: 209.85.221.65, mailfrom: pete@akeo.ie) Received: by mail-wr1-f65.google.com with SMTP id y18so9876788wrn.5 for ; Mon, 14 Oct 2019 04:44:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=akeo-ie.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=QbwUckumB1/kS6CFKKHJ0l4IPNrMatrkhjqMdHfcdYg=; b=onHfKC8DFE9FTJAvgiNwtySOQNVaxSpwC//Upsldq5KWzQs+SgQyVAzn8pBDczcKqt 63u+EtX1Jw+GNsfh66CMWrWzYDlaU3BMQ9amOpJEDp3KKJKvfA7AhVySzeJmj9rPZy+h EEbjLKIVj8og7CI5CtMZDy5bWNJiQCQBpxoLd+Z27SG4NNuqKfQOVCal7V8RJWcurayE OnWlUX4mJeHFtaxqrcnde5D2V6eJj89KXJH58ZwN/fT7mN5vKe7oWNYofAYy4M508Tti CBrhM5S5EeOerOFeqV8aafyU//gZzyCwLS7yRZpZlBm4YlBZgsrDaANLBGBDxYI6YJgD I96A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=QbwUckumB1/kS6CFKKHJ0l4IPNrMatrkhjqMdHfcdYg=; b=SbFJMAK8fsPeAcIT2BrpbxHWacgQfDjMfdozyITD8/nRT2DBKLMP13KdTfsZl6gYjm 0EBSg5hMkWkjwREIVn4A5UbMa2M0WJ7dzDVsuz90M5q/ad3wERaPlZP2RruPQmtHZQxq rd6ua/epD0oDDPlYWzSi5iGRPNhhDUgRahMYxsoI+rAnvJg2sXq89J1xTHleKJXkFId/ Fv1SwAuy4Z0LedsIsfEmL962jEDmhqZuHrFn24udz+2S5FKFbtso+I0GDbQbAWQBNJsQ EUztLnjGGu5nJUgmTGTO0m1116AVkEzlKzHa0uCCruZvxvfJggGyFiyvuXdYRLLvay5Z K49Q== X-Gm-Message-State: APjAAAX8byKulZjlKFsGQUUYaHgXWNlbnI/7GrjWKc67+8RUOJJDGXAJ DttdhIbaAZlR1BinShu3xtGemA== X-Google-Smtp-Source: APXvYqzA9sGUcM5bmzHsasWVBHF7SdfMlU1BgT+lLXFbtSOB4Y8AGj2tRQnNg7RnxAdFh9ItTDsauw== X-Received: by 2002:adf:ee82:: with SMTP id b2mr25046733wro.285.1571053449231; Mon, 14 Oct 2019 04:44:09 -0700 (PDT) Return-Path: Received: from [10.0.0.122] ([84.203.40.122]) by smtp.googlemail.com with ESMTPSA id g13sm15232498wrm.42.2019.10.14.04.44.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Oct 2019 04:44:08 -0700 (PDT) Subject: Re: [edk2-devel] [edk2-platforms][PATCH v3 5/5] Platform/RPi3/PlatformSmbiosDxe: Derive RAM size from board revision To: =?UTF-8?Q?Philippe_Mathieu-Daud=c3=a9?= , devel@edk2.groups.io Cc: ard.biesheuvel@linaro.org, leif.lindholm@linaro.org References: <20191011110746.1952-1-pete@akeo.ie> <20191011110746.1952-6-pete@akeo.ie> From: "Pete Batard" Message-ID: Date: Mon, 14 Oct 2019 12:44:06 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 8bit Hi Philippe, On 2019.10.14 11:01, Philippe Mathieu-Daudé wrote: > Hi Pete, > > On 10/11/19 1:07 PM, Pete Batard wrote: >> The board revision is the proper channel to use to detect the amount of >> RAM available as bits [20-22] report the effective RAM size for the board >> starting with 256 MB (000b) and doubling in size for each value. >> >> Signed-off-by: Pete Batard >> Reviewed-by: Leif Lindholm >> --- >> >> Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.c | >> 18 ++++++++++++------ >>   1 file changed, 12 insertions(+), 6 deletions(-) >> >> diff --git >> a/Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.c >> b/Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.c >> index b5dcff897a59..5abc82b8d363 100644 >> --- >> a/Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.c >> +++ >> b/Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.c >> @@ -866,16 +866,22 @@ MemArrMapInfoUpdateSmbiosType19 ( >>     ) >>   { >>     EFI_STATUS Status; >> -  UINT32 Base; >> -  UINT32 Size; >> +  UINT32 BoardRevision = 0; >> -  Status = mFwProtocol->GetArmMem (&Base, &Size); >> +  // Note: Type 19 addresses are expressed in KB, not bytes >> +  mMemArrMapInfoType19.StartingAddress = 0; > > Now you assume the ARM base RAM address is always 0, why? Because, in the case that is of interest to us here (Broadcom SoCs used for the various Raspberry Pi platforms), this is what the documentation says. If you look at something like https://www.raspberrypi.org/app/uploads/2012/02/BCM2835-ARM-Peripherals.pdf (which, as per the Pi Foundation, also applies to the later models) and especially the memory layout graphic that you see early in the document, you can find that the ARM base RAM address is indeed set to 0 always. At this stage, we have no reason to think that we are going to contend with a model where the RAM base address isn't 0. Regards, /Pete >> +  // The minimum RAM size used on any Raspberry Pi model is 256 MB >> +  mMemArrMapInfoType19.EndingAddress = 256 * 1024; >> +  Status = mFwProtocol->GetModelRevision (&BoardRevision); >>     if (Status != EFI_SUCCESS) { >> -    DEBUG ((DEBUG_ERROR, "Couldn't get the ARM memory size: %r\n", >> Status)); >> +    DEBUG ((DEBUG_WARNING, "Couldn't get the board memory size - >> defaulting to 256 MB: %r\n", Status)); >>     } else { >> -    mMemArrMapInfoType19.StartingAddress = Base / 1024; >> -    mMemArrMapInfoType19.EndingAddress = (Base + Size - 1) / 1024; >> +    // >> www.raspberrypi.org/documentation/hardware/raspberrypi/revision-codes/README.md >> >> +    // Bits [20-22] indicate the amount of memory starting with 256MB >> (000b) >> +    // and doubling in size for each value (001b = 512 MB, 010b = >> 1GB, etc.) >> +    mMemArrMapInfoType19.EndingAddress <<= (BoardRevision >> 20) & 0x07; >>     } >> +  mMemArrMapInfoType19.EndingAddress -= 1; >>     LogSmbiosData ((EFI_SMBIOS_TABLE_HEADER*)&mMemArrMapInfoType19, >> mMemArrMapInfoType19Strings, NULL); >>   } >> >