From nobody Sat Apr 27 11:37:57 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+58540+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+58540+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1588590964; cv=none; d=zohomail.com; s=zohoarc; b=c6zJ7eEO1WKPlbHD9nNmmtgs/n0P0yQx8NU4HLjyWHJpEvLAPnxfAeZYmBMM7bJVEvIl8jL25F/2vbYWMvwwctXVJShlrWaFqxVT8dZoQcR26HWsbBT8QmV9PRk4Bgu4W48q6yrRrY87GQT5xOdDm1kJictML5q6wud2n36EOQg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588590964; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=r7CdRU+YoDyj0ub34ol1m9stL4fL4X/ynpWCUAu54NY=; b=K45mGYdcr92nA8Y5kNOQ0Md67vij2YnP+V8soep/W1vqwGqM492TrzLtVEyNJh1DvstIJ4jzKAQKYphMmm/JuIJ3cd5OvkldYHF/5o4JmRDE+aKtLElXcQdaOThDayPkSx5ieizGBH2kbupilbZDIwTrbkNz81ygINqGDIWOaj0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+58540+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1588590964484698.895580897629; Mon, 4 May 2020 04:16:04 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id r2IlYY1788612xxKsAffF6wc; Mon, 04 May 2020 04:16:04 -0700 X-Received: from mail-ej1-f53.google.com (mail-ej1-f53.google.com [209.85.218.53]) by mx.groups.io with SMTP id smtpd.web11.3953.1588590963368187498 for ; Mon, 04 May 2020 04:16:03 -0700 X-Received: by mail-ej1-f53.google.com with SMTP id a2so13541111ejx.5 for ; Mon, 04 May 2020 04:16:03 -0700 (PDT) X-Gm-Message-State: t5NmVpaRDTxxSewz6ggVlnIKx1787277AA= X-Google-Smtp-Source: APiQypIhtL98+LWoSvr58UQxfxLEP/eDAoQjInIg15BMvAYhM2AgNPhKg2p3KoTYg+Hj63/jHl5vew== X-Received: by 2002:a17:906:3da:: with SMTP id c26mr14622111eja.290.1588590961568; Mon, 04 May 2020 04:16:01 -0700 (PDT) X-Received: from localhost.localdomain ([84.203.75.87]) by smtp.gmail.com with ESMTPSA id gf12sm1470894ejb.62.2020.05.04.04.16.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 04 May 2020 04:16:01 -0700 (PDT) From: "Pete Batard" To: devel@edk2.groups.io Cc: ard.biesheuvel@arm.com, leif@nuviainc.com, awarkentin@vmware.com, Andrei Warkentin Subject: [edk2-devel] [edk2-platforms][PATCH 1/3] Platform/RPi: Fortify mailbox code Date: Mon, 4 May 2020 12:15:46 +0100 Message-Id: <20200504111548.11112-2-pete@akeo.ie> In-Reply-To: <20200504111548.11112-1-pete@akeo.ie> References: <20200504111548.11112-1-pete@akeo.ie> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,pete@akeo.ie Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1588590964; bh=KMZd1O3mqDWJ3tmGjGVq9RuYlql5wGT0KxKcx2+Zh1k=; h=Cc:Date:From:Reply-To:Subject:To; b=WlOGmUNFJ3DUsBzyXuNvWdTKqiCCYBzkz6EQMbQv13NV6bvjP9jcy+1W++rI3is8MCK RPgzDyjFhPFI9slVqKrX3KyYmlEiFdRYchj+IrIKzDzHc8lXqNjhIwiPSkiWy/Sgma/LD RajjifjVDsbv40ukr1UnYZwACybXQqLhtCc= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" From: Andrei Warkentin As part of the analysis done in: https://github.com/raspberrypi/firmware/issues/1376: * Bump up max tries, to avoid command time-outs. * Macro-ify RaspberryPiHelper.S some more to make code more maintainable. * Add ".align 4" before every command buffer. Co-authored-by: Pete Batard Co-authored-by: Andrei Warkentin Signed-off-by: Pete Batard Reviewed-by: Ard Biesheuvel --- Platform/RaspberryPi/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c | 11 = +--- Platform/RaspberryPi/Include/IndustryStandard/RpiMbox.h | 11 = +++- Platform/RaspberryPi/Library/PlatformLib/AArch64/RaspberryPiHelper.S | 60 = ++++++++------------ 3 files changed, 37 insertions(+), 45 deletions(-) diff --git a/Platform/RaspberryPi/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c b= /Platform/RaspberryPi/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c index 40c78b5d57cf..6c45cf47f082 100644 --- a/Platform/RaspberryPi/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c +++ b/Platform/RaspberryPi/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c @@ -1,5 +1,6 @@ /** @file * + * Copyright (c) 2020, Pete Batard * Copyright (c) 2019, ARM Limited. All rights reserved. * Copyright (c) 2017-2018, Andrei Warkentin * Copyright (c) 2016, Linaro, Ltd. All rights reserved. @@ -30,12 +31,6 @@ // #define NUM_PAGES 1 =20 -// -// The number of iterations to perform when waiting for the mailbox -// status to change -// -#define MAX_TRIES 0x100000 - STATIC VOID *mDmaBuffer; STATIC VOID *mDmaBufferMapping; STATIC UINTN mDmaBufferBusAddress; @@ -62,7 +57,7 @@ DrainMailbox ( } ArmDataSynchronizationBarrier (); MmioRead32 (BCM2836_MBOX_BASE_ADDRESS + BCM2836_MBOX_READ_OFFSET); - } while (++Tries < MAX_TRIES); + } while (++Tries < RPI_MBOX_MAX_TRIES); =20 return FALSE; } @@ -86,7 +81,7 @@ MailboxWaitForStatusCleared ( return TRUE; } ArmDataSynchronizationBarrier (); - } while (++Tries < MAX_TRIES); + } while (++Tries < RPI_MBOX_MAX_TRIES); =20 return FALSE; } diff --git a/Platform/RaspberryPi/Include/IndustryStandard/RpiMbox.h b/Plat= form/RaspberryPi/Include/IndustryStandard/RpiMbox.h index 584786a61dfd..3328be582df1 100644 --- a/Platform/RaspberryPi/Include/IndustryStandard/RpiMbox.h +++ b/Platform/RaspberryPi/Include/IndustryStandard/RpiMbox.h @@ -1,6 +1,6 @@ /** @file * - * Copyright (c) 2019, Pete Batard + * Copyright (c) 2019-2020, Pete Batard * Copyright (c) 2016, Linaro Limited. All rights reserved. * * SPDX-License-Identifier: BSD-2-Clause-Patent @@ -10,6 +10,15 @@ #ifndef __RASPBERRY_PI_MAILBOX_H__ #define __RASPBERRY_PI_MAILBOX_H__ =20 +/* + * Number of iterations to perform when waiting for the mailbox. + * + * This number was arrived at empirically, following discussion + * at https://github.com/raspberrypi/firmware/issues/1376, to + * avoid mailbox time-outs on some commands. + */ +#define RPI_MBOX_MAX_TRIES 0x8000000 + /* Mailbox channels */ #define RPI_MBOX_PM_CHANNEL 0 #define RPI_MBOX_FB_CHANNEL 1 diff --git a/Platform/RaspberryPi/Library/PlatformLib/AArch64/RaspberryPiHe= lper.S b/Platform/RaspberryPi/Library/PlatformLib/AArch64/RaspberryPiHelper= .S index cc58406e1bfc..91dfe1bb981e 100644 --- a/Platform/RaspberryPi/Library/PlatformLib/AArch64/RaspberryPiHelper.S +++ b/Platform/RaspberryPi/Library/PlatformLib/AArch64/RaspberryPiHelper.S @@ -1,6 +1,7 @@ /** @file * - * Copyright (c) 2019, Pete Batard + * Copyright (c) 2020, Andrei Warkentin + * Copyright (c) 2019-2020, Pete Batard * Copyright (c) 2016, Linaro Limited. All rights reserved. * Copyright (c) 2011-2013, ARM Limited. All rights reserved. * @@ -13,10 +14,8 @@ #include #include =20 -#define MAX_TRIES 0x100000 - .macro drain - mov x5, #MAX_TRIES + mov x5, #RPI_MBOX_MAX_TRIES 0: ldr w6, [x4, #BCM2836_MBOX_STATUS_OFFSET] tbnz w6, #BCM2836_MBOX_STATUS_EMPTY, 1f dmb ld @@ -27,7 +26,7 @@ .endm =20 .macro poll, status - mov x5, #MAX_TRIES + mov x5, #RPI_MBOX_MAX_TRIES 0: ldr w6, [x4, #BCM2836_MBOX_STATUS_OFFSET] tbz w6, #\status, 1f dmb ld @@ -36,23 +35,30 @@ 1: .endm =20 + .macro run, command_buffer + adr x0, \command_buffer + orr x0, x0, #RPI_MBOX_VC_CHANNEL + add x0, x0, x1 + + poll BCM2836_MBOX_STATUS_FULL + str w0, [x4, #BCM2836_MBOX_WRITE_OFFSET] + dmb sy + poll BCM2836_MBOX_STATUS_EMPTY + dmb sy + ldr wzr, [x4, #BCM2836_MBOX_READ_OFFSET] + dmb ld + .endm + ASM_FUNC (ArmPlatformPeiBootAction) - adr x0, .Lmeminfo_buffer mov x1, #FixedPcdGet64 (PcdDmaDeviceOffset) orr x0, x0, #RPI_MBOX_VC_CHANNEL // x1 holds the value of PcdDmaDeviceOffset throughout this function - add x0, x0, x1 =20 MOV32 (x4, BCM2836_MBOX_BASE_ADDRESS) =20 drain - poll BCM2836_MBOX_STATUS_FULL - str w0, [x4, #BCM2836_MBOX_WRITE_OFFSET] - dmb sy - poll BCM2836_MBOX_STATUS_EMPTY - dmb sy - ldr wzr, [x4, #BCM2836_MBOX_READ_OFFSET] - dmb ld + + run .Lmeminfo_buffer =20 ldr w0, .Lmembase adr x2, mSystemMemoryBase @@ -63,17 +69,7 @@ ASM_FUNC (ArmPlatformPeiBootAction) adr x2, mSystemMemoryEnd str x0, [x2] =20 - adr x0, .Lvcinfo_buffer - orr x0, x0, #RPI_MBOX_VC_CHANNEL - add x0, x0, x1 - - poll BCM2836_MBOX_STATUS_FULL - str w0, [x4, #BCM2836_MBOX_WRITE_OFFSET] - dmb sy - poll BCM2836_MBOX_STATUS_EMPTY - dmb sy - ldr wzr, [x4, #BCM2836_MBOX_READ_OFFSET] - dmb ld + run .Lvcinfo_buffer =20 ldr w0, .Lvcbase adr x2, mVideoCoreBase @@ -83,17 +79,7 @@ ASM_FUNC (ArmPlatformPeiBootAction) adr x2, mVideoCoreSize str x0, [x2] =20 - adr x0, .Lrevinfo_buffer - orr x0, x0, #RPI_MBOX_VC_CHANNEL - add x0, x0, x1 - - poll BCM2836_MBOX_STATUS_FULL - str w0, [x4, #BCM2836_MBOX_WRITE_OFFSET] - dmb sy - poll BCM2836_MBOX_STATUS_EMPTY - dmb sy - ldr wzr, [x4, #BCM2836_MBOX_READ_OFFSET] - dmb ld + run .Lrevinfo_buffer =20 ldr w0, .Lrevision adr x2, mBoardRevision @@ -115,6 +101,7 @@ ASM_FUNC (ArmPlatformPeiBootAction) .long 0 // end tag .set .Lmeminfo_size, . - .Lmeminfo_buffer =20 + .align 4 .Lvcinfo_buffer: .long .Lvcinfo_size .long 0x0 @@ -128,6 +115,7 @@ ASM_FUNC (ArmPlatformPeiBootAction) .long 0 // end tag .set .Lvcinfo_size, . - .Lvcinfo_buffer =20 + .align 4 .Lrevinfo_buffer: .long .Lrevinfo_size .long 0x0 --=20 2.21.0.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#58540): https://edk2.groups.io/g/devel/message/58540 Mute This Topic: https://groups.io/mt/73972539/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Sat Apr 27 11:37:57 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+58541+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+58541+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1588590967; cv=none; d=zohomail.com; s=zohoarc; b=krItfVj4KY36bypazLvxVRB0WvH3HMeZyT/ok2KtvX/8B1BYtD/uEqg4lw6Zzc5ttRGSF+RI+Vs/kLxRAoGm/TcDpDBHOmMnOifbDQAc8zbbZzNYW49lvlCCGX07zjt5CvMzAgV7KHRL2UtTpLcG6HdZrN9TNWc1axD2907ciqo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588590967; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=DU2AGYf3tjHp/S/aReivQFqLGCx/HAVbCn7z8fJm1Ec=; b=cVA+v4oZmGPtz/1dysL6TD3kwhPEKzb/pJA6HAtwyztTuYZPIcrRaK93klAOFTX/M/PFMTnWL9X4m+9oo6qxJHRiEEG5cwvXtAyiUedAj3b1ltuekOMbtO7elec+nsF4TeSdfNOGp8sS3+IwQioJte02qcS5oxGg1bznhRopNos= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+58541+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1588590967808244.3072117452192; Mon, 4 May 2020 04:16:07 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id lV36YY1788612xl64HA6hqYI; Mon, 04 May 2020 04:16:07 -0700 X-Received: from mail-ej1-f65.google.com (mail-ej1-f65.google.com [209.85.218.65]) by mx.groups.io with SMTP id smtpd.web11.3955.1588590966535940880 for ; Mon, 04 May 2020 04:16:07 -0700 X-Received: by mail-ej1-f65.google.com with SMTP id b20so1834223ejg.11 for ; Mon, 04 May 2020 04:16:06 -0700 (PDT) X-Gm-Message-State: wxemljiTzSgOHKu9HDovCYERx1787277AA= X-Google-Smtp-Source: APiQypIs/Z61879SRdQ+s2fn+VTXWrNQ5cJPTBjPHeEQTtAacWWaSbjT5naJo8Yl7UZql6xsmeFukg== X-Received: by 2002:a17:906:310e:: with SMTP id 14mr14750741ejx.177.1588590964268; Mon, 04 May 2020 04:16:04 -0700 (PDT) X-Received: from localhost.localdomain ([84.203.75.87]) by smtp.gmail.com with ESMTPSA id gf12sm1470894ejb.62.2020.05.04.04.16.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 04 May 2020 04:16:03 -0700 (PDT) From: "Pete Batard" To: devel@edk2.groups.io Cc: ard.biesheuvel@arm.com, leif@nuviainc.com, awarkentin@vmware.com, Andrei Warkentin Subject: [edk2-devel] [edk2-platforms][PATCH 2/3] Platform/RPi/DualSerialPortLib: Fix miniUART serial divisor computation Date: Mon, 4 May 2020 12:15:47 +0100 Message-Id: <20200504111548.11112-3-pete@akeo.ie> In-Reply-To: <20200504111548.11112-1-pete@akeo.ie> References: <20200504111548.11112-1-pete@akeo.ie> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,pete@akeo.ie Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1588590967; bh=N+BzGsvkbI4Woq3dVsYGgGEMOBirmwJxE8ftvVpIynM=; h=Cc:Date:From:Reply-To:Subject:To; b=Sm0YVGDjnQVxn9OvfxsKWZZdew6lEUV+jYspKnLANLnMVJKK3ODDu6N9g1oNIuVn0tn r/jcRYG4zLTe+wsYMGIKN559vTt6a2nuIRaUBicTKdTUXThynfmXBSKzs+OSFkvsB91zB fBKgcU1db5MLCJfsIvOYO+KXLL+RyS5pa2I= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" From: Andrei Warkentin Fix for https://github.com/raspberrypi/firmware/issues/1376. For the Pi 3, to properly configure miniUART, we need the core clock, which can be vary between VideoCore firmare release or config.txt options. Unfortunately, it's painful to get - it's only available via the mailbox interface. Additionally, SerialLib is a very limited environment, even when linked in a DXE-mode component, because as part of a DebugLib implementation it ends being the base prerequisite of everything. That means a "normal" mailbox implementation like the one from RpiFirmwareDxe (with dependencies on DmaLib) is out of the question. Using a basic implementation such as the one in PlatformLib doesn't work either because it operates in both environments with MMU on (DXE phase) and MMU off (SEC/PrePi). Ideally, we read the value via mbox exactly once at boot (PlatformLib), and then somehow stash it. A GUID Hob sounds appropriate, yet when SerialPortLib operates in DXE components, we can't use the HobLib to *locate* the Hob list itself (remember, SerialPortLib initializes before any of HobLib's dependencies, like UeflLib...). FORTUNATELY, there is a way out - we can use PrePeiGetHobList to cut through to the HOB list pointer stashed by PrePi without dealing with any of the libraries meant for DXE. Once we have the Hob list pointer, we can use the regular DXE HobLib routines safely (so long as they are the ones taking a HobList pointer as a parameter). So we can link DualSerialPortLib with whatever HobLib that is appropriate for the environment - just need to also link in PrePiHobListPointerLib. gSerialLibCoreClockFreq is always externally set when DualSerialPortLib run as part of PrePi. So - if gSerialLibCoreClockFreq is not set, then we must be in the DXE phase and can fetch the Hob list via PrePeiGetHobList. The GUID Hob is registered as part of a Pi-customized PlatformPeiLib. For the Pi 4, the situation is a bit different, as the system clock used to compute the baud rate is not derived directly from the core clock, but instead from a fixed clock (current 1 GHz) to which a 12.12 fixed point divisor is applied. But even though we don't use it, we still initialize gSerialLibCoreClockFreq a.k.a. the VPU core frequency, as this can be useful to have. As a result of the above, the PcdSerialClockRate values in the .dsc are also updated, so that it can be used as a fallback to the default core frequency in case of the Pi 3, and as the fixed frequency to which the fixed point divisor is applied in case of the Pi 4. Co-authored-by: Pete Batard Co-authored-by: Andrei Warkentin Signed-off-by: Pete Batard --- Platform/RaspberryPi/Include/Guid/DualSerialPortLibHobGuid.h | 22= ++++ Platform/RaspberryPi/Library/DualSerialPortLib/DualSerialPortLib.c | 106= +++++++++++++++++--- Platform/RaspberryPi/Library/DualSerialPortLib/DualSerialPortLib.inf | 6= ++ Platform/RaspberryPi/Library/PlatformLib/AArch64/RaspberryPiHelper.S | 23= +++++ Platform/RaspberryPi/Library/PlatformPeiLib/PlatformPeiLib.c | 33= ++++++ Platform/RaspberryPi/Library/PlatformPeiLib/PlatformPeiLib.inf | 47= +++++++++ Platform/RaspberryPi/RPi3/RPi3.dsc | 8= +- Platform/RaspberryPi/RPi4/RPi4.dsc | 9= +- Platform/RaspberryPi/RaspberryPi.dec | 1= + 9 files changed, 234 insertions(+), 21 deletions(-) diff --git a/Platform/RaspberryPi/Include/Guid/DualSerialPortLibHobGuid.h b= /Platform/RaspberryPi/Include/Guid/DualSerialPortLibHobGuid.h new file mode 100644 index 000000000000..82864eb33268 --- /dev/null +++ b/Platform/RaspberryPi/Include/Guid/DualSerialPortLibHobGuid.h @@ -0,0 +1,22 @@ +/** @file +* +* Copyright (c) 2020, Pete Batard +* Copyright (c) 2020, Andrei Warkentin +* +* SPDX-License-Identifier: BSD-2-Clause-Patent +* +**/ + +#ifndef _DUAL_SERIAL_PORT_LIB_HOB_GUID_H_ +#define _DUAL_SERIAL_PORT_LIB_HOB_GUID_H_ + +#define DUAL_SERIAL_PORT_LIB_HOB_GUID \ + { 0x1CB0EB5B, 0x4F73, 0x4308, { 0xA3, 0x33, 0x1D, 0x95, 0xBE, 0x5F, 0x30= , 0xB5 } } + +extern GUID gDualSerialPortLibHobGuid; + +typedef struct { + UINT32 CoreClockFreq; +} DUAL_SERIAL_PORT_LIB_VARS; + +#endif /* _DUAL_SERIAL_PORT_LIB_HOB_GUID_H_ */ diff --git a/Platform/RaspberryPi/Library/DualSerialPortLib/DualSerialPortL= ib.c b/Platform/RaspberryPi/Library/DualSerialPortLib/DualSerialPortLib.c index 05e12f383785..77b5f586b6c5 100644 --- a/Platform/RaspberryPi/Library/DualSerialPortLib/DualSerialPortLib.c +++ b/Platform/RaspberryPi/Library/DualSerialPortLib/DualSerialPortLib.c @@ -1,6 +1,7 @@ /** @file 16550 and PL011 Serial Port library functions for Raspberry Pi =20 + Copyright (c) 2020, Andrei Warkentin Copyright (c) 2020, Pete Batard Copyright (c) 2018, AMD Incorporated. All rights reserved.
Copyright (c) 2014, Hewlett-Packard Development Company, L.P.
@@ -12,7 +13,8 @@ =20 **/ =20 -#include +#include +#include #include #include #include @@ -21,9 +23,21 @@ #include #include #include +// +// The order of the following includes should not be altered +// +#include +#include +#include =20 -BOOLEAN UsePl011Uart =3D FALSE; -BOOLEAN UsePl011UartSet =3D FALSE; +STATIC BOOLEAN UsePl011Uart =3D FALSE; +STATIC BOOLEAN UsePl011UartSet =3D FALSE; +UINT32 gSerialLibCoreClockFreq =3D 0; +// +// Set by ArmPlatformPeiBootAction to skip PrePeiGetHobList, +// as it won't be initialized and could return garbage. +// +UINT32 gSerialLibCoreSkipHob =3D 0; =20 #define PL011_UART_REGISTER_BASE BCM2836_PL011_UART_BASE_ADDRESS #define MINI_UART_REGISTER_BASE (BCM2836_MINI_UART_BASE_ADDRESS + 0x= 40) @@ -152,26 +166,86 @@ SerialPortGetDivisor ( UINT32 SerialBaudRate ) { - UINT64 BaseClockRate; - UINT32 Divisor; + UINT64 BaseSerialClockFreq; + UINT32 Divisor; + +#if (RPI_MODEL =3D=3D 3) + VOID *HobList; + EFI_HOB_GUID_TYPE *GuidHob; + DUAL_SERIAL_PORT_LIB_VARS *Vars; + + // + // For the Pi 3, the base serial clock is the VPU core clock. + // + // Unfortunately, it's painful to get - it's only available via + // the mailbox interface. Additionally, SerialLib is a very + // limited environment, even when linked in a DXE-mode component, because + // as part of a DebugLib implementation it ends being the base prerequis= ite + // of /everything/. That means a "normal" mailbox implementation like + // the one im RpiFirmwareDxe (with dependencies on DmaLib) is out + // of the question. Using a basic implementation such as the one + // in PlatformLib doesn't work either because operate in both + // environments with MMU on (DXE phase) and MMU off (SEC/PrePi). + // + // Ideally, we read the value via mbox exactly once (PlatformLib), + // then somehow stash it. A GUID Hob sounds pretty nice, but + // we can't use the DXE HobLib to *locate* the Hob list itself + // (remember, SerialPortLib initializes before any of HobLib's + // dependencies, like UeflLib). + // + // FORTUNATELY, there is a way out - we can use PrePeiGetHobList + // to cut through to the HOB list pointer stashed by PrePi without. + // Once we have the Hob list pointer, we can use the DXE HobLib routines + // safely (so long as they are the ones taking a HobList pointer + // as a parameter). + // + // gSerialLibCoreClockFreq is always externally set when we run + // as part of PrePi. So - if gSerialLibCoreClockFreq is not set, + // then we must be in the DXE phase and can fetch the Hob list + // via our little hack. + // + if (gSerialLibCoreClockFreq =3D=3D 0 && !gSerialLibCoreSkipHob) { + HobList =3D PrePeiGetHobList (); + if (HobList !=3D NULL) { + GuidHob =3D (EFI_HOB_GUID_TYPE *) GetNextGuidHob (&gDualSerialPortLi= bHobGuid, + HobList); + if (GuidHob !=3D NULL) { + Vars =3D (DUAL_SERIAL_PORT_LIB_VARS *) GET_GUID_HOB_DATA (GuidHob); + gSerialLibCoreClockFreq =3D Vars->CoreClockFreq; + gSerialLibCoreSkipHob =3D 1; + } + } + } =20 // - // On the Raspberry Pi, the clock to use for the 16650-compatible UART - // is the base clock divided by the 12.12 fixed point VPU clock divisor. + // Fall back to PCD if we have a nonsensical value. + // + if (gSerialLibCoreClockFreq < 10000000) { + gSerialLibCoreClockFreq =3D PcdGet32 (PcdSerialClockRate); + } + BaseSerialClockFreq =3D (UINT64) gSerialLibCoreClockFreq; +#else // - BaseClockRate =3D (UINT64)PcdGet32 (PcdSerialClockRate) * 4; - Divisor =3D MmioRead32(BCM2836_CM_BASE + BCM2836_CM_VPU_CLOCK_DIVISOR) &= 0xFFFFFF; - if (Divisor !=3D 0) - BaseClockRate =3D (BaseClockRate << 12) / Divisor; + // For the Pi 4, the base serial clock is not derived from the VPU + // core clock, but from a fixed clock (currently 1 GHz) to which a + // variable 12.12 fixed point clock divisor is applied. + // + BaseSerialClockFreq =3D (UINT64) PcdGet32 (PcdSerialClockRate); + Divisor =3D MmioRead32 (BCM2836_CM_BASE + BCM2836_CM_VPU_CLOCK_DIVISOR) = & 0xFFFFFF; + if (Divisor !=3D 0) { + BaseSerialClockFreq =3D (BaseSerialClockFreq << 12) / Divisor; + } +#endif =20 // - // Now calculate divisor for baud generator - // Ref_Clk_Rate / Baud_Rate / 16 + // As per the BCM2xxx datasheets: + // baudrate =3D system_clock_freq / (8 * (divisor + 1)). // - Divisor =3D (UINT32)BaseClockRate / (SerialBaudRate * 16); - if (((UINT32)BaseClockRate % (SerialBaudRate * 16)) >=3D SerialBaudRate = * 8) { - Divisor++; + Divisor =3D (UINT32)BaseSerialClockFreq / (SerialBaudRate * 8); + if (Divisor !=3D 0) { + Divisor--; } + return Divisor; } =20 diff --git a/Platform/RaspberryPi/Library/DualSerialPortLib/DualSerialPortL= ib.inf b/Platform/RaspberryPi/Library/DualSerialPortLib/DualSerialPortLib.i= nf index af1e6b026fe6..7430eede18db 100644 --- a/Platform/RaspberryPi/Library/DualSerialPortLib/DualSerialPortLib.inf +++ b/Platform/RaspberryPi/Library/DualSerialPortLib/DualSerialPortLib.inf @@ -22,17 +22,23 @@ [Packages] EmbeddedPkg/EmbeddedPkg.dec MdePkg/MdePkg.dec MdeModulePkg/MdeModulePkg.dec + Platform/RaspberryPi/RaspberryPi.dec Silicon/Broadcom/Bcm283x/Bcm283x.dec =20 [LibraryClasses] IoLib + HobLib PcdLib PL011UartClockLib PL011UartLib + PrePiHobListPointerLib =20 [Sources] DualSerialPortLib.c =20 +[Guids] + gDualSerialPortLibHobGuid + [Pcd] gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterAccessWidth ## SOMET= IMES_CONSUMES gEfiMdeModulePkgTokenSpaceGuid.PcdSerialUseMmio ## CONSU= MES diff --git a/Platform/RaspberryPi/Library/PlatformLib/AArch64/RaspberryPiHe= lper.S b/Platform/RaspberryPi/Library/PlatformLib/AArch64/RaspberryPiHelper= .S index 91dfe1bb981e..83a3511d3507 100644 --- a/Platform/RaspberryPi/Library/PlatformLib/AArch64/RaspberryPiHelper.S +++ b/Platform/RaspberryPi/Library/PlatformLib/AArch64/RaspberryPiHelper.S @@ -85,6 +85,16 @@ ASM_FUNC (ArmPlatformPeiBootAction) adr x2, mBoardRevision str w0, [x2] =20 + run .Lclkinfo_buffer + + ldr w0, .Lfrequency + adr x2, gSerialLibCoreClockFreq + str w0, [x2] + adr x2, gSerialLibCoreSkipHob + // + // Any non-zero value will do. + // + str w0, [x2] ret =20 .align 4 @@ -127,6 +137,19 @@ ASM_FUNC (ArmPlatformPeiBootAction) .long 0 // end tag .set .Lrevinfo_size, . - .Lrevinfo_buffer =20 + .align 4 +.Lclkinfo_buffer: + .long .Lclkinfo_size + .long 0x0 + .long RPI_MBOX_GET_CLOCK_RATE + .long 8 // buf size + .long 4 // input len + .long 4 // clock id: 0x04 =3D Core/VPU +.Lfrequency: + .long 0 // frequency + .long 0 // end tag + .set .Lclkinfo_size, . - .Lclkinfo_buffer + //UINTN //ArmPlatformGetPrimaryCoreMpId ( // VOID diff --git a/Platform/RaspberryPi/Library/PlatformPeiLib/PlatformPeiLib.c b= /Platform/RaspberryPi/Library/PlatformPeiLib/PlatformPeiLib.c new file mode 100644 index 000000000000..367a32bd4ca7 --- /dev/null +++ b/Platform/RaspberryPi/Library/PlatformPeiLib/PlatformPeiLib.c @@ -0,0 +1,33 @@ +/** @file +* +* Copyright (c) 2011-2014, ARM Limited. All rights reserved. +* +* SPDX-License-Identifier: BSD-2-Clause-Patent +* +**/ + +#include + +#include +#include +#include +#include +#include + +extern UINT32 gSerialLibCoreClockFreq, gSerialLibCoreSkipHob; + +static DUAL_SERIAL_PORT_LIB_VARS mUartLibVars; + +EFI_STATUS +EFIAPI +PlatformPeim ( + VOID + ) +{ + BuildFvHob (PcdGet64 (PcdFvBaseAddress), PcdGet32 (PcdFvSize)); + + mUartLibVars.CoreClockFreq =3D gSerialLibCoreClockFreq; + BuildGuidDataHob (&gDualSerialPortLibHobGuid, &mUartLibVars, sizeof(mUar= tLibVars)); + + return EFI_SUCCESS; +} diff --git a/Platform/RaspberryPi/Library/PlatformPeiLib/PlatformPeiLib.inf= b/Platform/RaspberryPi/Library/PlatformPeiLib/PlatformPeiLib.inf new file mode 100644 index 000000000000..8e2bab14a89a --- /dev/null +++ b/Platform/RaspberryPi/Library/PlatformPeiLib/PlatformPeiLib.inf @@ -0,0 +1,47 @@ +#/** @file +# +# Copyright (c) 2011-2012, ARM Limited. All rights reserved. +# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +#**/ + +[Defines] + INF_VERSION =3D 0x0001001A + BASE_NAME =3D ArmPlatformPeiLib + FILE_GUID =3D 49d37060-70b5-11e0-aa2d-0002a5d5c51b + MODULE_TYPE =3D SEC + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D PlatformPeiLib + +[Sources] + PlatformPeiLib.c + +[Packages] + ArmPkg/ArmPkg.dec + ArmPlatformPkg/ArmPlatformPkg.dec + MdePkg/MdePkg.dec + EmbeddedPkg/EmbeddedPkg.dec + MdeModulePkg/MdeModulePkg.dec + Platform/RaspberryPi/RaspberryPi.dec + +[LibraryClasses] + ArmPlatformLib + DebugLib + HobLib + +[Guids] + gDualSerialPortLibHobGuid + +[Ppis] + gEfiPeiMasterBootModePpiGuid # PPI ALWAYS_PRODUCED + gEfiPeiBootInRecoveryModePpiGuid # PPI SOMETIMES_PRODUCED + +[FixedPcd] + gArmTokenSpaceGuid.PcdFdBaseAddress + gArmTokenSpaceGuid.PcdFdSize + gArmTokenSpaceGuid.PcdFvBaseAddress + gArmTokenSpaceGuid.PcdFvSize + +[Depex] + TRUE diff --git a/Platform/RaspberryPi/RPi3/RPi3.dsc b/Platform/RaspberryPi/RPi3= /RPi3.dsc index 563fb891b841..efebf1f823b3 100644 --- a/Platform/RaspberryPi/RPi3/RPi3.dsc +++ b/Platform/RaspberryPi/RPi3/RPi3.dsc @@ -77,6 +77,10 @@ [LibraryClasses.common] =20 UefiLib|MdePkg/Library/UefiLib/UefiLib.inf HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf + # + # PrePiHobListPointerLib is necessary for DualSerialPortLib. + # + PrePiHobListPointerLib|ArmPlatformPkg/Library/PrePiHobListPointerLib/Pre= PiHobListPointerLib.inf UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeServicesTableLib/U= efiRuntimeServicesTableLib.inf DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf UefiBootServicesTableLib|MdePkg/Library/UefiBootServicesTableLib/UefiBoo= tServicesTableLib.inf @@ -174,7 +178,7 @@ [LibraryClasses.common.SEC] PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf MemoryInitPeiLib|Platform/RaspberryPi/Library/MemoryInitPeiLib/MemoryIni= tPeiLib.inf - PlatformPeiLib|ArmPlatformPkg/PlatformPei/PlatformPeiLib.inf + PlatformPeiLib|Platform/RaspberryPi/Library/PlatformPeiLib/PlatformPeiLi= b.inf ExtractGuidedSectionLib|EmbeddedPkg/Library/PrePiExtractGuidedSectionLib= /PrePiExtractGuidedSectionLib.inf LzmaDecompressLib|MdeModulePkg/Library/LzmaCustomDecompressLib/LzmaCusto= mDecompressLib.inf PrePiLib|EmbeddedPkg/Library/PrePiLib/PrePiLib.inf @@ -409,7 +413,7 @@ [PcdsFixedAtBuild.common] gArmPlatformTokenSpaceGuid.PL011UartClkInHz|48000000 gEfiMdeModulePkgTokenSpaceGuid.PcdSerialUseMmio|TRUE gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterStride|4 - gEfiMdeModulePkgTokenSpaceGuid.PcdSerialClockRate|500000000 + gEfiMdeModulePkgTokenSpaceGuid.PcdSerialClockRate|250000000 gEfiMdeModulePkgTokenSpaceGuid.PcdSerialFifoControl|0x27 gEfiMdeModulePkgTokenSpaceGuid.PcdSerialExtendedTxFifoSize|8 gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate|115200 diff --git a/Platform/RaspberryPi/RPi4/RPi4.dsc b/Platform/RaspberryPi/RPi4= /RPi4.dsc index 4deccd9d3ecc..4dc9b493cf79 100644 --- a/Platform/RaspberryPi/RPi4/RPi4.dsc +++ b/Platform/RaspberryPi/RPi4/RPi4.dsc @@ -75,6 +75,10 @@ [LibraryClasses.common] =20 UefiLib|MdePkg/Library/UefiLib/UefiLib.inf HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf + # + # PrePiHobListPointerLib is necessary for DualSerialPortLib. + # + PrePiHobListPointerLib|ArmPlatformPkg/Library/PrePiHobListPointerLib/Pre= PiHobListPointerLib.inf UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeServicesTableLib/U= efiRuntimeServicesTableLib.inf DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf UefiBootServicesTableLib|MdePkg/Library/UefiBootServicesTableLib/UefiBoo= tServicesTableLib.inf @@ -182,12 +186,11 @@ [LibraryClasses.common.SEC] PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf MemoryInitPeiLib|Platform/RaspberryPi/Library/MemoryInitPeiLib/MemoryIni= tPeiLib.inf - PlatformPeiLib|ArmPlatformPkg/PlatformPei/PlatformPeiLib.inf + PlatformPeiLib|Platform/RaspberryPi/Library/PlatformPeiLib/PlatformPeiLi= b.inf ExtractGuidedSectionLib|EmbeddedPkg/Library/PrePiExtractGuidedSectionLib= /PrePiExtractGuidedSectionLib.inf LzmaDecompressLib|MdeModulePkg/Library/LzmaCustomDecompressLib/LzmaCusto= mDecompressLib.inf PrePiLib|EmbeddedPkg/Library/PrePiLib/PrePiLib.inf HobLib|EmbeddedPkg/Library/PrePiHobLib/PrePiHobLib.inf - PrePiHobListPointerLib|ArmPlatformPkg/Library/PrePiHobListPointerLib/Pre= PiHobListPointerLib.inf MemoryAllocationLib|EmbeddedPkg/Library/PrePiMemoryAllocationLib/PrePiMe= moryAllocationLib.inf =20 [LibraryClasses.common.DXE_CORE] @@ -420,7 +423,7 @@ [PcdsFixedAtBuild.common] gArmPlatformTokenSpaceGuid.PL011UartClkInHz|48000000 gEfiMdeModulePkgTokenSpaceGuid.PcdSerialUseMmio|TRUE gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterStride|4 - gEfiMdeModulePkgTokenSpaceGuid.PcdSerialClockRate|500000000 + gEfiMdeModulePkgTokenSpaceGuid.PcdSerialClockRate|1000000000 gEfiMdeModulePkgTokenSpaceGuid.PcdSerialFifoControl|0x27 gEfiMdeModulePkgTokenSpaceGuid.PcdSerialExtendedTxFifoSize|8 gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate|115200 diff --git a/Platform/RaspberryPi/RaspberryPi.dec b/Platform/RaspberryPi/Ra= spberryPi.dec index 66ef6186644b..a915387fc822 100644 --- a/Platform/RaspberryPi/RaspberryPi.dec +++ b/Platform/RaspberryPi/RaspberryPi.dec @@ -26,6 +26,7 @@ [Guids] gRaspberryPiTokenSpaceGuid =3D {0xCD7CC258, 0x31DB, 0x11E6, {0x9F, 0xD3,= 0x63, 0xB0, 0xB8, 0xEE, 0xD6, 0xB5}} gRaspberryPiEventResetGuid =3D {0xCD7CC258, 0x31DB, 0x11E6, {0x9F, 0xD3,= 0x63, 0xB4, 0xB4, 0xE4, 0xD4, 0xB4}} gConfigDxeFormSetGuid =3D {0xCD7CC258, 0x31DB, 0x22E6, {0x9F, 0x22, 0x63= , 0xB0, 0xB8, 0xEE, 0xD6, 0xB5}} + gDualSerialPortLibHobGuid =3D { 0x1CB0EB5B, 0x4F73, 0x4308, { 0xA3, 0x33= , 0x1D, 0x95, 0xBE, 0x5F, 0x30, 0xB5 } } =20 [PcdsFixedAtBuild.common] # --=20 2.21.0.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#58541): https://edk2.groups.io/g/devel/message/58541 Mute This Topic: https://groups.io/mt/73972541/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Sat Apr 27 11:37:57 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+58542+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+58542+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1588590968; cv=none; d=zohomail.com; s=zohoarc; b=LZKHs9s5YvD6VTeq1AjE0vJHsZpRWDMKQ3icubzwLF9ANCRoMalhl2RReAzemjkuh9IpMptdrbpYGBjV1pykkR5G96mVaryPkXiqqb6TGI/tSBcz1mnGP0HqWrDMn3o/XYMcwffAtDYZhZO+cDaVsVCpEcIqAPhDJwM+c6495Ds= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588590968; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=GlONueo8pZhahruVl6gQ8+Aao7tvweJXSiozhoOUcpk=; b=nijHXWkjtKiBWCMXzG0O/QeML9IfTsjcrPann6bpeyq7lIVb3WVrOG9xdUiqpGKnGpI0K8p95GQ8+lLgvarM3xlGXQHfuwr8LR/0qOmcZrijifsLOJPBUxcAwm2+mmbPi/kXqgdpKuUnlcoSw3gPAoBjYJ1CLsnzoCmWL05kVNs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+58542+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1588590968347761.0097889381242; Mon, 4 May 2020 04:16:08 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id EUeAYY1788612xD8ZzChAGho; Mon, 04 May 2020 04:16:07 -0700 X-Received: from mail-ed1-f65.google.com (mail-ed1-f65.google.com [209.85.208.65]) by mx.groups.io with SMTP id smtpd.web10.3921.1588590967178886414 for ; Mon, 04 May 2020 04:16:07 -0700 X-Received: by mail-ed1-f65.google.com with SMTP id s10so13149213edy.9 for ; Mon, 04 May 2020 04:16:06 -0700 (PDT) X-Gm-Message-State: d9WfGsRa8w4dqdburcm9LX9Lx1787277AA= X-Google-Smtp-Source: APiQypIDGNyFxwISe9qNVinFitYwAjxnygUvGNVvBE/5K9rjM7gJbBnsKal6yuy/HAoygJ8BjkGX+w== X-Received: by 2002:a50:8e4b:: with SMTP id 11mr13791213edx.329.1588590965278; Mon, 04 May 2020 04:16:05 -0700 (PDT) X-Received: from localhost.localdomain ([84.203.75.87]) by smtp.gmail.com with ESMTPSA id gf12sm1470894ejb.62.2020.05.04.04.16.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 04 May 2020 04:16:04 -0700 (PDT) From: "Pete Batard" To: devel@edk2.groups.io Cc: ard.biesheuvel@arm.com, leif@nuviainc.com, awarkentin@vmware.com Subject: [edk2-devel] [edk2-platforms][PATCH 3/3] Platform/RPi: Report core clock frequency during early init Date: Mon, 4 May 2020 12:15:48 +0100 Message-Id: <20200504111548.11112-4-pete@akeo.ie> In-Reply-To: <20200504111548.11112-1-pete@akeo.ie> References: <20200504111548.11112-1-pete@akeo.ie> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,pete@akeo.ie Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1588590967; bh=w8UHkJpo5YiaxPkK9slp4WRU4ibomOi5EQAEBQnLLVc=; h=Cc:Date:From:Reply-To:Subject:To; b=fKQtA5nSeLKcp1GcIWSK8RGoD/txC6RT+nvw6IVpp4Pa2r4MOAUkjYuQ2Qka68yRO2E aYSa56XU7WCLaQRo+ztR2eFq2cSvcgCBnP04SmUkDQN7oWJwqZNZ1rIW8CGvIiOiFlxfu 3W06adVNzeKJcNZDdwfeXlRXNwN1CsrL5bU= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" The previous commit ensures that gSerialLibCoreClockFreq contains the VPU core frequency by the time we execute ArmPlatformGetVirtualMemoryMap (). This value can prove useful for troubleshooting, so report it. Signed-off-by: Pete Batard Reviewed-by: Andrei Warkentin Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- Platform/RaspberryPi/Library/PlatformLib/RaspberryPiMem.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Platform/RaspberryPi/Library/PlatformLib/RaspberryPiMem.c b/Pl= atform/RaspberryPi/Library/PlatformLib/RaspberryPiMem.c index aae189ec8136..015d3dccc27c 100644 --- a/Platform/RaspberryPi/Library/PlatformLib/RaspberryPiMem.c +++ b/Platform/RaspberryPi/Library/PlatformLib/RaspberryPiMem.c @@ -22,7 +22,12 @@ extern UINT64 mSystemMemoryEnd; UINT64 mVideoCoreBase; UINT64 mVideoCoreSize; UINT32 mBoardRevision; - +// +// gSerialLibCoreClockFreq, which resides in DualSerialLib is set +// to the VPU Core Clock frequency by ArmPlatformPeiBootAction (). +// We use it to report the core frequency during early boot. +// +extern UINT32 gSerialLibCoreClockFreq; =20 // The total number of descriptors, including the final "end-of-table" des= criptor. #define MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS 11 @@ -66,6 +71,7 @@ ArmPlatformGetVirtualMemoryMap ( DEBUG ((DEBUG_INFO, "Board Rev: 0x%lX\n", mBoardRevision)); DEBUG ((DEBUG_INFO, "Base RAM : 0x%ll08X (Size 0x%ll08X)\n", mSystemMemo= ryBase, mSystemMemoryEnd + 1)); DEBUG ((DEBUG_INFO, "VideoCore: 0x%ll08X (Size 0x%ll08X)\n", mVideoCoreB= ase, mVideoCoreSize)); + DEBUG ((DEBUG_INFO, "Core Freq: %d MHz\n", gSerialLibCoreClockFreq / 100= 0000)); =20 ASSERT (mSystemMemoryBase =3D=3D 0); ASSERT (VirtualMemoryMap !=3D NULL); --=20 2.21.0.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#58542): https://edk2.groups.io/g/devel/message/58542 Mute This Topic: https://groups.io/mt/73972542/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-