From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) by mx.groups.io with SMTP id smtpd.web10.3734.1570698189998503396 for ; Thu, 10 Oct 2019 02:03:10 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@linaro.org header.s=google header.b=hCrzMMSD; spf=pass (domain: linaro.org, ip: 209.85.221.68, mailfrom: leif.lindholm@linaro.org) Received: by mail-wr1-f68.google.com with SMTP id r3so6855833wrj.6 for ; Thu, 10 Oct 2019 02:03:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=iNYJWZXnRDO1T1ERu9oFmHMsIf6da9SbtbQyz0dMQPw=; b=hCrzMMSDUtaJ75AohfZesjBF1Zd2boAC3DYGMnI/URHd7UVAM65AkPWWGQ/VeZ/zJZ SL0BdsmJNVMWEKJn4E6WEdaU4bbmFtOJA7qoMQzUuVsDI2DgOhdqg/YBlbqV+RI6guMy DLj4VwklfVs8DwpJzxjzXS6nP1KuNLK89d3JHXrA6il+egLMYEYUL7ZqgTbdkbciPUfe 5rI0SixzpggDY2ZHOrMfSH31FWgxuAWiIm8wV7GhLxu2RwAbd48lrTeaOAOjQKW2WBxT QTRDK+MG0a+O8zGxrQKXtmrjZhDLXM50n6owDXDHG+kP5WRRnFRpNoZlIwfOyRQemNX6 Ucjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=iNYJWZXnRDO1T1ERu9oFmHMsIf6da9SbtbQyz0dMQPw=; b=mnEpMoAplfkOQWeu2vqVx2LdVgz5rz8BWqFRsb0OLBEYhIPUnbjJP79Y+aW9HuuSEd f8GHz/+FXYTTbNxZhjQmXpQvAoPIoTNoyj81l8dunwZq65lsWgGQj2fM4EJXHnoRsu7S smfh5u6cfTxSH1EepooGaeqx4bIFmJj2CrRk2Pnv4Ntw4QzgNgYpcqwOS5cIZftMKLoQ qxz2jVPkRS1CJUNKpjGvOxgeVUZo++B3HlFLNc/srsYr+bT7eVQ3whG6woFdjCbk3gKc VxTUuiS65fO8tz3CnE8jLhrPGTPrY79SARbW74vq9qW6NuIW6wUAUGgocRm/7eLDEERn pjog== X-Gm-Message-State: APjAAAX58rWLyCQi/PX9a4J5PxCj6WIEm8x5l3AkLt2OCqjmqjL/4OPj dZfVCkJY6bvn9Jm3THD0JJpshA== X-Google-Smtp-Source: APXvYqyQSObSVueIk/flZeJYy/6lkkmZQN0hb7tOSmoEdtBilF3LmTteFHT34kkF8bcKwBK1XIfRDg== X-Received: by 2002:adf:9283:: with SMTP id 3mr7226110wrn.331.1570698188456; Thu, 10 Oct 2019 02:03:08 -0700 (PDT) Return-Path: Received: from bivouac.eciton.net (bivouac.eciton.net. [2a00:1098:0:86:1000:23:0:2]) by smtp.gmail.com with ESMTPSA id x2sm5629261wrn.81.2019.10.10.02.03.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Oct 2019 02:03:07 -0700 (PDT) Date: Thu, 10 Oct 2019 10:03:06 +0100 From: "Leif Lindholm" To: Pete Batard Cc: devel@edk2.groups.io, ard.biesheuvel@linaro.org Subject: Re: [edk2-platforms][PATCH v2 5/5] Platform/RPi3/PlatformSmbiosDxe: Derive RAM size from board revision Message-ID: <20191010090306.GW25504@bivouac.eciton.net> References: <20191008123841.12952-1-pete@akeo.ie> <20191008123841.12952-6-pete@akeo.ie> MIME-Version: 1.0 In-Reply-To: <20191008123841.12952-6-pete@akeo.ie> User-Agent: Mutt/1.10.1 (2018-07-13) Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Tue, Oct 08, 2019 at 01:38:41PM +0100, 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 66ffadd0cade..540e3fd61f25 100644 > --- a/Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.c > +++ b/Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.c > @@ -863,16 +863,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; > + // 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); > } > -- > 2.21.0.windows.1 >