[edk2-devel] [PATCH v3 07/15] ArmVirtPkg: Early serial port initialisation

Sami Mujawar posted 15 patches 5 years, 7 months ago
There is a newer version of this series
[edk2-devel] [PATCH v3 07/15] ArmVirtPkg: Early serial port initialisation
Posted by Sami Mujawar 5 years, 7 months ago
Initialise serial port early so that the platform
memory map can be logged.

Signed-off-by: Sami Mujawar <sami.mujawar@arm.com>
---
 ArmVirtPkg/PrePi/PrePi.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/ArmVirtPkg/PrePi/PrePi.c b/ArmVirtPkg/PrePi/PrePi.c
index 4f0c3f98bad63d0682cccd76a0a062d1fd4f46ab..5e144f4bdefb810708238097a3373f11d150bfe5 100755
--- a/ArmVirtPkg/PrePi/PrePi.c
+++ b/ArmVirtPkg/PrePi/PrePi.c
@@ -1,6 +1,6 @@
 /** @file
 *
-*  Copyright (c) 2011-2014, ARM Limited. All rights reserved.
+*  Copyright (c) 2011-2020, ARM Limited. All rights reserved.
 *
 *  SPDX-License-Identifier: BSD-2-Clause-Patent
 *
@@ -60,16 +60,16 @@ PrePiMain (
   //
   InvalidateDataCacheRange((VOID *)(UINTN)PcdGet64 (PcdFdBaseAddress), PcdGet32 (PcdFdSize));
 
-  // Initialize MMU and Memory HOBs (Resource Descriptor HOBs)
-  Status = MemoryPeim (UefiMemoryBase, FixedPcdGet32 (PcdSystemMemoryUefiRegionSize));
-  ASSERT_EFI_ERROR (Status);
-
   // Initialize the Serial Port
   SerialPortInitialize ();
   CharCount = AsciiSPrint (Buffer,sizeof (Buffer),"UEFI firmware (version %s built at %a on %a)\n\r",
     (CHAR16*)PcdGetPtr(PcdFirmwareVersionString), __TIME__, __DATE__);
   SerialPortWrite ((UINT8 *) Buffer, CharCount);
 
+  // Initialize MMU and Memory HOBs (Resource Descriptor HOBs)
+  Status = MemoryPeim (UefiMemoryBase, FixedPcdGet32 (PcdSystemMemoryUefiRegionSize));
+  ASSERT_EFI_ERROR (Status);
+
   // Create the Stacks HOB (reserve the memory for all stacks)
   StacksSize = PcdGet32 (PcdCPUCorePrimaryStackSize);
   BuildStackHob (StacksBase, StacksSize);
-- 
'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#61667): https://edk2.groups.io/g/devel/message/61667
Mute This Topic: https://groups.io/mt/75081479/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-

Re: [edk2-devel] [PATCH v3 07/15] ArmVirtPkg: Early serial port initialisation
Posted by Ard Biesheuvel 5 years, 7 months ago
(+ Julien)

On 6/24/20 3:34 PM, Sami Mujawar wrote:
> Initialise serial port early so that the platform
> memory map can be logged.
> 
> Signed-off-by: Sami Mujawar <sami.mujawar@arm.com>
> ---
>   ArmVirtPkg/PrePi/PrePi.c | 10 +++++-----
>   1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/ArmVirtPkg/PrePi/PrePi.c b/ArmVirtPkg/PrePi/PrePi.c
> index 4f0c3f98bad63d0682cccd76a0a062d1fd4f46ab..5e144f4bdefb810708238097a3373f11d150bfe5 100755
> --- a/ArmVirtPkg/PrePi/PrePi.c
> +++ b/ArmVirtPkg/PrePi/PrePi.c
> @@ -1,6 +1,6 @@
>   /** @file
>   *
> -*  Copyright (c) 2011-2014, ARM Limited. All rights reserved.
> +*  Copyright (c) 2011-2020, ARM Limited. All rights reserved.
>   *
>   *  SPDX-License-Identifier: BSD-2-Clause-Patent
>   *
> @@ -60,16 +60,16 @@ PrePiMain (
>     //
>     InvalidateDataCacheRange((VOID *)(UINTN)PcdGet64 (PcdFdBaseAddress), PcdGet32 (PcdFdSize));
>   
> -  // Initialize MMU and Memory HOBs (Resource Descriptor HOBs)
> -  Status = MemoryPeim (UefiMemoryBase, FixedPcdGet32 (PcdSystemMemoryUefiRegionSize));
> -  ASSERT_EFI_ERROR (Status);
> -
>     // Initialize the Serial Port
>     SerialPortInitialize ();
>     CharCount = AsciiSPrint (Buffer,sizeof (Buffer),"UEFI firmware (version %s built at %a on %a)\n\r",
>       (CHAR16*)PcdGetPtr(PcdFirmwareVersionString), __TIME__, __DATE__);
>     SerialPortWrite ((UINT8 *) Buffer, CharCount);
>   
> +  // Initialize MMU and Memory HOBs (Resource Descriptor HOBs)
> +  Status = MemoryPeim (UefiMemoryBase, FixedPcdGet32 (PcdSystemMemoryUefiRegionSize));
> +  ASSERT_EFI_ERROR (Status);
> +
>     // Create the Stacks HOB (reserve the memory for all stacks)
>     StacksSize = PcdGet32 (PcdCPUCorePrimaryStackSize);
>     BuildStackHob (StacksBase, StacksSize);
> 

We need to check whether this works on Xen - I don't remember whether we 
use some kind of cache coherent shared memory ring there for the serial 
console that only works if the MMU and caches are enabled. Julien?


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#61717): https://edk2.groups.io/g/devel/message/61717
Mute This Topic: https://groups.io/mt/75081479/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-

Re: [edk2-devel] [PATCH v3 07/15] ArmVirtPkg: Early serial port initialisation
Posted by Julien Grall 5 years, 7 months ago
Hi,

On 25/06/2020 12:42, Ard Biesheuvel wrote:
> (+ Julien)

Thank you for the CC!

> On 6/24/20 3:34 PM, Sami Mujawar wrote:
>> Initialise serial port early so that the platform
>> memory map can be logged.
>>
>> Signed-off-by: Sami Mujawar <sami.mujawar@arm.com>
>> ---
>>   ArmVirtPkg/PrePi/PrePi.c | 10 +++++-----
>>   1 file changed, 5 insertions(+), 5 deletions(-)
>>
>> diff --git a/ArmVirtPkg/PrePi/PrePi.c b/ArmVirtPkg/PrePi/PrePi.c
>> index 
>> 4f0c3f98bad63d0682cccd76a0a062d1fd4f46ab..5e144f4bdefb810708238097a3373f11d150bfe5 
>> 100755
>> --- a/ArmVirtPkg/PrePi/PrePi.c
>> +++ b/ArmVirtPkg/PrePi/PrePi.c
>> @@ -1,6 +1,6 @@
>>   /** @file
>>   *
>> -*  Copyright (c) 2011-2014, ARM Limited. All rights reserved.
>> +*  Copyright (c) 2011-2020, ARM Limited. All rights reserved.
>>   *
>>   *  SPDX-License-Identifier: BSD-2-Clause-Patent
>>   *
>> @@ -60,16 +60,16 @@ PrePiMain (
>>     //
>>     InvalidateDataCacheRange((VOID *)(UINTN)PcdGet64 
>> (PcdFdBaseAddress), PcdGet32 (PcdFdSize));
>> -  // Initialize MMU and Memory HOBs (Resource Descriptor HOBs)
>> -  Status = MemoryPeim (UefiMemoryBase, FixedPcdGet32 
>> (PcdSystemMemoryUefiRegionSize));
>> -  ASSERT_EFI_ERROR (Status);
>> -
>>     // Initialize the Serial Port
>>     SerialPortInitialize ();
>>     CharCount = AsciiSPrint (Buffer,sizeof (Buffer),"UEFI firmware 
>> (version %s built at %a on %a)\n\r",
>>       (CHAR16*)PcdGetPtr(PcdFirmwareVersionString), __TIME__, __DATE__);
>>     SerialPortWrite ((UINT8 *) Buffer, CharCount);
>> +  // Initialize MMU and Memory HOBs (Resource Descriptor HOBs)
>> +  Status = MemoryPeim (UefiMemoryBase, FixedPcdGet32 
>> (PcdSystemMemoryUefiRegionSize));
>> +  ASSERT_EFI_ERROR (Status);
>> +
>>     // Create the Stacks HOB (reserve the memory for all stacks)
>>     StacksSize = PcdGet32 (PcdCPUCorePrimaryStackSize);
>>     BuildStackHob (StacksBase, StacksSize);
>>
> 
> We need to check whether this works on Xen - I don't remember whether we 
> use some kind of cache coherent shared memory ring there for the serial 
> console that only works if the MMU and caches are enabled. Julien?

Xen Console is using a shared memory ring that requires to be cache 
coherent. So you wouldn't be able to use the current driver before the 
MMU and caches are enabled.

It might be possible to make it work by issuing cache maintenance when 
sending the characters.

Cheers,

-- 
Julien Grall

-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#61755): https://edk2.groups.io/g/devel/message/61755
Mute This Topic: https://groups.io/mt/75081479/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-