From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f67.google.com (mail-wm1-f67.google.com [209.85.128.67]) by mx.groups.io with SMTP id smtpd.web12.8275.1570792085941770485 for ; Fri, 11 Oct 2019 04:08:06 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@akeo-ie.20150623.gappssmtp.com header.s=20150623 header.b=TiyicBnX; spf=none, err=permanent DNS error (domain: akeo.ie, ip: 209.85.128.67, mailfrom: pete@akeo.ie) Received: by mail-wm1-f67.google.com with SMTP id 3so9797508wmi.3 for ; Fri, 11 Oct 2019 04:08:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=akeo-ie.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=be29OQKpdBdiOHKNHURd6XWDJ/vaxAozE2+cmfOxG+Y=; b=TiyicBnXmGegQaDzM/zlW6A95bDd9cRmU72cMBSq6OqYfurnXy7TFZGAV/7TcE9NOp LJfLEfsiMojZ44qhHpR+vqTURbT3YdkbRPPEwUvHYFN7FP6d0LFnlCa16daMz4jiO/TL /jMeAmvkBZ9+/w/iyyrtnKs02Eb5stXmaDA+JMDAS1/oqlesR7bxNpWdOZRZ+2bO+Wrp xzpV3RsFpFVJyL6j2TGbiZOXschokL6eq7Ud+fOCSTuyz1UFZs70rrLX3/+NVxP4XT7H r8TNbYI6iO9nhnGAapLrB4+GGReefuKKgaBwZGf+hX8HYRDqhQEPSOmk1qk4EbSTmmYC HrFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=be29OQKpdBdiOHKNHURd6XWDJ/vaxAozE2+cmfOxG+Y=; b=Dp0Wmm8f7DhUW4iLf9NnY3jWsjGH839LzelVZrcWwimcJsVDshTNgyPpcGorHVxX24 OTm5OTtJ3iXVnfAwDvsp1KyAoN+JhYuBqXRvbbRmB1yMVm+eGjYbNh56X/y0zeX+2wTU UIILKk92aBJQTPx1aV1VVxv/BeCHxlrBVEMWpP9eJSn0HW6dyN4N6EEJE3kXuvs+JXfm x3goxhHRst3cISW1/j14HfsK816bogP/aDCOltfVNpS5Cu1k2/GVInbgw9Hb+bh4XV1f i+ljLg7OkaBO4hozlAfhEQKjS3HBzducdwvJY1qN6qLcE5/K12Oub+JJ7EwEEQEpQ7M7 l9Qw== X-Gm-Message-State: APjAAAVaIFyfOaPWH6s4OuUUJEp+ojITUVgqJnKmzOmOxJZns+8ZLUwA tJkNgMICvcHL1yhtUO7TyNx5BaFecec= X-Google-Smtp-Source: APXvYqyi68yjDJztgnvTZFoSvAEdLc1RiaCZ+88hNpELpmxgH39xQKxW9ukzMQwYirIc/jcAofZbWg== X-Received: by 2002:a1c:f709:: with SMTP id v9mr2933183wmh.62.1570792084174; Fri, 11 Oct 2019 04:08:04 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([84.203.40.122]) by smtp.gmail.com with ESMTPSA id r18sm12806044wme.48.2019.10.11.04.08.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 11 Oct 2019 04:08:03 -0700 (PDT) From: "Pete Batard" To: devel@edk2.groups.io Cc: ard.biesheuvel@linaro.org, leif.lindholm@linaro.org Subject: [edk2-platforms][PATCH v3 5/5] Platform/RPi3/PlatformSmbiosDxe: Derive RAM size from board revision Date: Fri, 11 Oct 2019 12:07:46 +0100 Message-Id: <20191011110746.1952-6-pete@akeo.ie> X-Mailer: git-send-email 2.21.0.windows.1 In-Reply-To: <20191011110746.1952-1-pete@akeo.ie> References: <20191011110746.1952-1-pete@akeo.ie> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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; + // 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