From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=pass header.i=@akeo-ie.20150623.gappssmtp.com header.s=20150623 header.b=AhWMFK9j; spf=none, err=permanent DNS error (domain: akeo.ie, ip: 209.85.128.67, mailfrom: pete@akeo.ie) Received: from mail-wm1-f67.google.com (mail-wm1-f67.google.com [209.85.128.67]) by groups.io with SMTP; Tue, 08 Oct 2019 05:39:02 -0700 Received: by mail-wm1-f67.google.com with SMTP id m18so2974148wmc.1 for ; Tue, 08 Oct 2019 05:39:01 -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=Lr0HWAFM0hgMlA9Pd47DvBGo6y+Tl5JTqDCuSiGqBaY=; b=AhWMFK9j0Vbu/Cx9yLzu8epHtXq3GqA9fqckIXczzEyE9hdYVxmO4qx7k7vrMqXe9L kBDcfyzpo4DZmgDMXr4qd24/fOBXNpgCw/xf/YtknOGNLdMyyeUjlrt+PlmNOxTX+VWJ xgQ0m9cSAIQyDCqemJy2QjNLI3F3LeussNbyVCAC3k3qTgXFrMGsFRHrbQnfC9WVKcqe whbph7u36Fm54+r8nZ1YDkJugXstDfUhswuExsoULggdfk/fUeeeyFt3+dcEjMmYnb9o hMzRnSNbY0q1Zi712forw7yLsS8BQF7cETqKd1V/Hn5FGtTGmvcHTxZ8niQCreaUGXJY U3EA== 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=Lr0HWAFM0hgMlA9Pd47DvBGo6y+Tl5JTqDCuSiGqBaY=; b=iRY5AV97ei+xKg69TKSfs1gX7IFmpTMJXXgZ4i5UJoUE5Mz0XoFcfU2Rm0W6z/Jqoj 1J+o3lKHHZZOJPdgkI+UA3ExVComqVqPrZ2uTJgZPemh3J3aK4tcSJ7LvZfpPWIDOJkM V+vbHt0dj9FjOKLKFEp/eh+ylwo0pCrVhQdpSyALHSDJcoEROUPcG4LscS8BBljyDIDO /L1RbN8TFj2mW/cx2neY3qiWSK18a+gDgmPGNCTNLU5LUKhMIYq6dWouh5VbAHt5cGwy hwwJoqqGLuOOeQ6urrTuhxzN0Ggl5d31y3WPTPT9nzKKkm17iOA3mjiL17x8krCrwSFv uNrA== X-Gm-Message-State: APjAAAWOrQdZ4SHoXBsbxrEPTmxSQlmfsqMTEO+89qr1C9H1yvKoG0SX omwmP54n/ooMSo3KLRvxGpPcMELlFDg= X-Google-Smtp-Source: APXvYqxBhxLXna/iq1OeEhqEyb0DPMkSNQwl4QbiNVmhu+kUIzSXxGnDi7ZPwxkauNRTea2X64AgoA== X-Received: by 2002:a7b:c631:: with SMTP id p17mr3645548wmk.5.1570538339820; Tue, 08 Oct 2019 05:38:59 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([84.203.40.122]) by smtp.gmail.com with ESMTPSA id r6sm3203087wmh.38.2019.10.08.05.38.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 08 Oct 2019 05:38:59 -0700 (PDT) From: "Pete Batard" To: devel@edk2.groups.io Cc: ard.biesheuvel@linaro.org, leif.lindholm@linaro.org Subject: [edk2-platforms][PATCH v2 5/5] Platform/RPi3/PlatformSmbiosDxe: Derive RAM size from board revision Date: Tue, 8 Oct 2019 13:38:41 +0100 Message-Id: <20191008123841.12952-6-pete@akeo.ie> X-Mailer: git-send-email 2.21.0.windows.1 In-Reply-To: <20191008123841.12952-1-pete@akeo.ie> References: <20191008123841.12952-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 --- 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