public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@redhat.com>
To: Pete Batard <pete@akeo.ie>, devel@edk2.groups.io
Cc: ard.biesheuvel@linaro.org, leif.lindholm@linaro.org
Subject: Re: [edk2-platforms][PATCH 3/6] Platform/RPi4: Improve SPCR and DBG2 ACPI table generation
Date: Wed, 18 Dec 2019 18:00:07 +0100	[thread overview]
Message-ID: <d153a9e6-49aa-e5c0-11d5-fbb0781951c1@redhat.com> (raw)
In-Reply-To: <ddf0a41b-f55a-a2f0-9f26-f4860363e2ad@akeo.ie>

On 12/18/19 5:36 PM, Pete Batard wrote:
> Hi Philippe,
> 
> On 2019.12.18 15:57, Philippe Mathieu-Daudé wrote:
>> On 12/18/19 12:41 PM, Pete Batard wrote:
>>> Use code derived from JunoPkg to generate our serial tables and
>>> also use PCDs where possible.
>>>
>>> Signed-off-by: Pete Batard <pete@akeo.ie>
>>> ---
>>>   Platform/RaspberryPi/RPi4/AcpiTables/AcpiTables.inf |   4 +-
>>>   Platform/RaspberryPi/RPi4/AcpiTables/Dbg2.aslc      | 100 
>>> +++++++++++++++++---
>>>   Platform/RaspberryPi/RPi4/AcpiTables/Spcr.asl       |  48 ----------
>>>   Platform/RaspberryPi/RPi4/AcpiTables/Spcr.aslc      |  94 
>>> ++++++++++++++++++
>>>   4 files changed, 183 insertions(+), 63 deletions(-)
>>>
>>> diff --git a/Platform/RaspberryPi/RPi4/AcpiTables/AcpiTables.inf 
>>> b/Platform/RaspberryPi/RPi4/AcpiTables/AcpiTables.inf
>>> index 50c9f7694d84..6b1155d66444 100644
>>> --- a/Platform/RaspberryPi/RPi4/AcpiTables/AcpiTables.inf
>>> +++ b/Platform/RaspberryPi/RPi4/AcpiTables/AcpiTables.inf
>>> @@ -31,7 +31,7 @@ [Sources]
>>>     Gtdt.aslc
>>>     Dsdt.asl
>>>     Csrt.aslc
>>> -  Spcr.asl
>>> +  Spcr.aslc
>>>   [Packages]
>>>     ArmPkg/ArmPkg.dec
>>> @@ -47,4 +47,6 @@ [FixedPcd]
>>>     gArmTokenSpaceGuid.PcdArmArchTimerVirtIntrNum
>>>     gArmTokenSpaceGuid.PcdGicInterruptInterfaceBase
>>>     gArmTokenSpaceGuid.PcdGicDistributorBase
>>> +  gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterBase
>>> +  gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate
>>>     gEmbeddedTokenSpaceGuid.PcdInterruptBaseAddress
>>> diff --git a/Platform/RaspberryPi/RPi4/AcpiTables/Dbg2.aslc 
>>> b/Platform/RaspberryPi/RPi4/AcpiTables/Dbg2.aslc
>>> index 849cf5134793..589a5c2cbd71 100644
>>> --- a/Platform/RaspberryPi/RPi4/AcpiTables/Dbg2.aslc
>>> +++ b/Platform/RaspberryPi/RPi4/AcpiTables/Dbg2.aslc
>>> @@ -2,27 +2,99 @@
>>>    *
>>>    *  Debug Port Table (DBG2)
>>>    *
>>> - *  Copyright (c) Microsoft Corporation. All rights reserved.
>>> + *  Copyright (c) 2019, Pete Batard <pete@akeo.ie>
>>> + *  Copyright (c) 2012-2016, ARM Limited. All rights reserved.
>>>    *
>>>    *  SPDX-License-Identifier: BSD-2-Clause-Patent
>>>    *
>>>    **/
>>> -UINT8 Dbg2[92] = {
>>> -  0x44, 0x42, 0x47, 0x32, 0x5C, 0x00, 0x00, 0x00, 0x00, 0x00,
>>> -  0x4D, 0x53, 0x46, 0x54, 0x20, 0x20, 0x45, 0x44, 0x4B, 0x32,
>>> -  0x20, 0x20, 0x20, 0x20, 0x01, 0x00, 0x00, 0x00, 0x4D, 0x53,
>>> -  0x46, 0x54, 0x01, 0x00, 0x00, 0x00, 0x2C, 0x00, 0x00, 0x00,
>>> -  0x01, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x01, 0x0A, 0x00,
>>> -  0x26, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x80, 0x10, 0x00,
>>> -  0x00, 0x00, 0x16, 0x00, 0x22, 0x00, 0x00, 0x20, 0x00, 0x10,
>>> -  0x00, 0x50, 0x21, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x6C, 0x00,
>>> -  0x00, 0x00, '\\',  '_',  'S',  'B',  '.',  'U',  'R',  'T',
>>> -  'M', 0x00,
>>> +#include <IndustryStandard/Acpi.h>
>>> +#include <IndustryStandard/DebugPort2Table.h>
>>> +#include <Library/AcpiLib.h>
>>> +#include <Library/PcdLib.h>
>>> +
>>> +#include "AcpiTables.h"
>>> +
>>> +#pragma pack(1)
>>> +
>>> +#define RPI_DBG2_NUM_DEBUG_PORTS                        1
>>> +#define RPI_DBG2_NUMBER_OF_GENERIC_ADDRESS_REGISTERS    1
>>> +#define RPI_DBG2_NAMESPACESTRING_FIELD_SIZE             10
>>> +
>>> +//
>>> +// When using the miniUART, PcdSerialRegisterBase points to the 8250 
>>> base address,
>>> +// which is offset by 0x40 from the actual Bcm2835 base address
>>
>> Actually this is the other way around, the 8250 is at AUX + 0x40.
>>
>> Can we clean that up or is it too late?
> 
> Yeah, re-reading this I admit the comment is not too clear.
> 
> Let me try to rephrase this better in v2.

Actually my comment is about the code... Do you think we can clean the 
RPi3/RPi4 codebase by changing 
gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterBase?

If you don't have time for this, maybe you can add a /* TODO FIXME */?

>>
>>> +//
>>> +#define RPI_UART_BASE_ADDRESS (FixedPcdGet64 (PcdSerialRegisterBase) 
>>> - 0x40)
>>> +#define RPI_UART_LENGTH                                 0x70
>>> +//
>>> +// RPI_UART_STR should match the value used Uart.asl
>>> +//
>>> +#define RPI_UART_STR                                    { '\\', '_', 
>>> 'S', 'B', '.', 'U', 'R', 'T', 'M', 0x00 }
>>> +
>>> +typedef struct {
>>> +  EFI_ACPI_DBG2_DEBUG_DEVICE_INFORMATION_STRUCT         Dbg2Device;
>>> +  EFI_ACPI_5_1_GENERIC_ADDRESS_STRUCTURE BaseAddressRegister;
>>> +  UINT32                                                AddressSize;
>>> +  UINT8 NameSpaceString[RPI_DBG2_NAMESPACESTRING_FIELD_SIZE];
>>> +} DBG2_DEBUG_DEVICE_INFORMATION;
>>> +
>>> +typedef struct {
>>> +  EFI_ACPI_DEBUG_PORT_2_DESCRIPTION_TABLE               Description;
>>> +  DBG2_DEBUG_DEVICE_INFORMATION 
>>> Dbg2DeviceInfo[RPI_DBG2_NUM_DEBUG_PORTS];
>>> +} DBG2_TABLE;
>>> +
>>> +
>>> +#define DBG2_DEBUG_PORT_DDI(NumReg, SubType, UartBase, UartAddrLen, 
>>> UartNameStr) {                                    \
>>> + { \
>>> +      EFI_ACPI_DBG2_DEBUG_DEVICE_INFORMATION_STRUCT_REVISION, /* 
>>> UINT8     Revision */                        \
>>> +      sizeof (DBG2_DEBUG_DEVICE_INFORMATION), /* UINT16    Length 
>>> */                          \
>>> +      NumReg, /* UINT8     NumberofGenericAddressRegisters */ \
>>> +      RPI_DBG2_NAMESPACESTRING_FIELD_SIZE, /* UINT16    
>>> NameSpaceStringLength */           \
>>> +      OFFSET_OF (DBG2_DEBUG_DEVICE_INFORMATION, NameSpaceString), /* 
>>> UINT16    NameSpaceStringOffset */           \
>>> +      0, /* UINT16    OemDataLength */                   \
>>> +      0, /* UINT16    OemDataOffset */                   \
>>> +      EFI_ACPI_DBG2_PORT_TYPE_SERIAL, /* UINT16    Port Type 
>>> */                       \
>>> +      SubType, /* UINT16    Port Subtype */                    \
>>> +      {EFI_ACPI_RESERVED_BYTE, EFI_ACPI_RESERVED_BYTE}, /* UINT8     
>>> Reserved[2] */                     \
>>> +      OFFSET_OF (DBG2_DEBUG_DEVICE_INFORMATION, 
>>> BaseAddressRegister), /* UINT16    BaseAddressRegister Offset */      \
>>> +      OFFSET_OF (DBG2_DEBUG_DEVICE_INFORMATION, AddressSize) /* 
>>> UINT16    AddressSize Offset */              \
>>> + }, \
>>> +    ARM_GAS32 (UartBase),                            /* 
>>> EFI_ACPI_5_1_GENERIC_ADDRESS_STRUCTURE BaseAddressRegister */ \
>>> +    UartAddrLen,                                     /* UINT32 
>>> AddressSize */                                        \
>>> +    UartNameStr                                      /* UINT8 
>>> NameSpaceString[MAX_DBG2_NAME_LEN] */                 \
>>> +  }
>>> +
>>> +
>>> +STATIC DBG2_TABLE Dbg2 = {
>>> +  {
>>> +    ACPI_HEADER (
>>> +      EFI_ACPI_5_1_DEBUG_PORT_2_TABLE_SIGNATURE,
>>> +      DBG2_TABLE,
>>> +      EFI_ACPI_DBG2_DEBUG_DEVICE_INFORMATION_STRUCT_REVISION
>>> +    ),
>>> +    OFFSET_OF (DBG2_TABLE, Dbg2DeviceInfo),
>>> +    RPI_DBG2_NUM_DEBUG_PORTS /* UINT32  NumberDbgDeviceInfo */
>>> +  },
>>> +  {
>>> +    /*
>>> +     * Kernel Debug Port
>>> +     */
>>> +    DBG2_DEBUG_PORT_DDI (
>>> +      RPI_DBG2_NUMBER_OF_GENERIC_ADDRESS_REGISTERS,
>>> +      EFI_ACPI_DBG2_PORT_SUBTYPE_SERIAL_BCM2835_UART,
>>> +      RPI_UART_BASE_ADDRESS,
>>> +      RPI_UART_LENGTH,
>>> +      RPI_UART_STR
>>> +    ),
>>> +  }
>>>   };
>> [...]
>>
> 


  reply	other threads:[~2019-12-18 17:00 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-18 11:41 [edk2-platforms][PATCH 0/6] Platform/RPi4: ACPI improvements Pete Batard
2019-12-18 11:41 ` [edk2-platforms][PATCH 1/6] Platform/RPi4: Clean up ACPI definitions Pete Batard
2019-12-18 11:41 ` [edk2-platforms][PATCH 2/6] Platform/RPi4: Improve FADT ACPI table generation Pete Batard
2019-12-18 14:46   ` Ard Biesheuvel
2019-12-18 16:31     ` Pete Batard
2019-12-18 11:41 ` [edk2-platforms][PATCH 3/6] Platform/RPi4: Improve SPCR and DBG2 " Pete Batard
2019-12-18 15:57   ` Philippe Mathieu-Daudé
2019-12-18 16:36     ` Pete Batard
2019-12-18 17:00       ` Philippe Mathieu-Daudé [this message]
2019-12-18 17:10         ` Pete Batard
2019-12-18 11:41 ` [edk2-platforms][PATCH 4/6] Platform/RPi4: Add switch to select between PL011 and miniUART Pete Batard
2019-12-18 16:05   ` Philippe Mathieu-Daudé
2019-12-18 16:59     ` [edk2-devel] " Pete Batard
2019-12-18 17:05       ` Philippe Mathieu-Daudé
2019-12-18 11:41 ` [edk2-platforms][PATCH 5/6] Platform/RPi4: Add XHCI and MCFG ACPI tables Pete Batard
2019-12-18 14:55   ` Ard Biesheuvel
2019-12-18 16:31     ` Pete Batard
2019-12-18 11:41 ` [edk2-platforms][PATCH 6/6] Platform/RPi4: Add ACPI basic mode build option Pete Batard
2019-12-18 12:10   ` Leif Lindholm

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d153a9e6-49aa-e5c0-11d5-fbb0781951c1@redhat.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox