You've already forked edk2-platforms
mirror of
https://github.com/Dasharo/edk2-platforms.git
synced 2026-03-06 14:51:43 -08:00
Because of its widespread availability and low price, we expect the Raspberry Pi source to be used by platform developers as a starting point to create their own platform implementation. As such, it makes a lot of sense to want to use the most up to date underlying standards, even if the pay off is limited in this case, or may even be seen as a liability in terms of ensuring greater compatibility with older OSes, as it may help others benefit from the latest improvements and features brought by modern ACPI. We also happen to already be using ACPI 6.3 constructs, such as PPTT (which was only introduced in ACPI 6.2 and further extended in 6.3), and have some reliance on 6.x GIC, as the original MADT binary blobs from Microsoft were 6.0 and abuse the GICR Base Address field in order for Windows to boot properly (for reasons that the proprietary nature of the Windows kernel makes difficult to determine). So in effect, we did apply a potential breaking change to Windows when we downgraded MADT to ACPI 5.1, though we did validate at the time that the downgrade in ACPI version didn't *seem* to break OS functionality. Still, because we are in the dark as to what the ACPI fields we removed when downgrading ACPI version were being used for, we obviously want to add them back. Therefore, since we do see a need for ACPI 6.x features, and effectively have a 6.3 table with PPTT, and also since we have tested that we are not seeing ill effects from doing so for the most common OSes we support, we bring all of the relevant ACPI tables to version 6.3. This is mostly accomplished by simply altering the version of ACPI being references in the macros, except for the new fields being initialized in the MADT table where we: * Use 1 for GICR Base Address in GICC_STRUCTURE_INIT because, even as this field is not supposed to apply to any of our platforms, this is what Microsoft used in the original Pi 3 hardcoded MADT blobs and Windows 10 doesn't boot on the Pi 3 if set to 0. * Use 2 for GIC version in GIC_DISTRIBUTOR_INIT, since the Pi 4 GIC is v2 only. Signed-off-by: Pete Batard <pete@akeo.ie> Reviewed-by: Ard Biesheuvel <ard.biesheuvel@arm.com>
169 lines
7.3 KiB
C
169 lines
7.3 KiB
C
/** @file
|
|
*
|
|
* RPi defines for constructing ACPI tables
|
|
*
|
|
* Copyright (c) 2020, Pete Batard <pete@akeo.ie>
|
|
* Copyright (c) 2019, ARM Ltd. All rights reserved.
|
|
* Copyright (c) 2018, Andrei Warkentin <andrey.warkentin@gmail.com>
|
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
*
|
|
**/
|
|
|
|
#ifndef __ACPITABLES_H__
|
|
#define __ACPITABLES_H__
|
|
|
|
#include <IndustryStandard/Acpi.h>
|
|
|
|
// The ASL compiler can't perform arithmetic on MEMORY32FIXED ()
|
|
// parameters so you can't pass a constant like BASE + OFFSET.
|
|
// We therefore define a macro that can perform arithmetic base
|
|
// address update with an offset.
|
|
#define MEMORY32SETBASE(BufName, MemName, VarName, Offset) \
|
|
CreateDwordField (^BufName, ^MemName._BAS, VarName) \
|
|
Add (BCM2836_SOC_REGISTERS, Offset, VarName)
|
|
|
|
#define EFI_ACPI_OEM_ID {'R','P','I','F','D','N'}
|
|
#if (RPI_MODEL == 3)
|
|
#define EFI_ACPI_OEM_TABLE_ID SIGNATURE_64 ('R','P','I','3',' ',' ',' ',' ')
|
|
#elif (RPI_MODEL == 4)
|
|
#define EFI_ACPI_OEM_TABLE_ID SIGNATURE_64 ('R','P','I','4',' ',' ',' ',' ')
|
|
#endif
|
|
#define EFI_ACPI_OEM_REVISION 0x00000200
|
|
#define EFI_ACPI_CREATOR_ID SIGNATURE_32 ('E','D','K','2')
|
|
#define EFI_ACPI_CREATOR_REVISION 0x00000300
|
|
|
|
#define EFI_ACPI_VENDOR_ID SIGNATURE_32 ('R','P','I','F')
|
|
|
|
// A macro to initialise the common header part of EFI ACPI tables as defined by
|
|
// EFI_ACPI_DESCRIPTION_HEADER structure.
|
|
#define ACPI_HEADER(Signature, Type, Revision) { \
|
|
Signature, /* UINT32 Signature */ \
|
|
sizeof (Type), /* UINT32 Length */ \
|
|
Revision, /* UINT8 Revision */ \
|
|
0, /* UINT8 Checksum */ \
|
|
EFI_ACPI_OEM_ID, /* UINT8 OemId[6] */ \
|
|
EFI_ACPI_OEM_TABLE_ID, /* UINT64 OemTableId */ \
|
|
EFI_ACPI_OEM_REVISION, /* UINT32 OemRevision */ \
|
|
EFI_ACPI_CREATOR_ID, /* UINT32 CreatorId */ \
|
|
EFI_ACPI_CREATOR_REVISION /* UINT32 CreatorRevision */ \
|
|
}
|
|
|
|
#define EFI_ACPI_CSRT_REVISION 0x00000005
|
|
#define EFI_ACPI_CSRT_DEVICE_ID_DMA 0x00000009 // Fixed id
|
|
#define EFI_ACPI_CSRT_RESOURCE_ID_IN_DMA_GRP 0x0 // Count up from 0
|
|
|
|
#define RPI_DMA_CHANNEL_COUNT 10 // All 10 DMA channels are listed, including the reserved ones
|
|
#define RPI_DMA_USED_CHANNEL_COUNT 5 // Use 5 DMA channels
|
|
|
|
#if (RPI_MODEL == 3)
|
|
#define RPI_SYSTEM_TIMER_BASE_ADDRESS 0x4000001C
|
|
#elif (RPI_MODEL == 4)
|
|
#define RPI_SYSTEM_TIMER_BASE_ADDRESS 0xFF80001C
|
|
#endif
|
|
|
|
#define EFI_ACPI_6_3_CSRT_REVISION 0x00000000
|
|
|
|
typedef enum
|
|
{
|
|
EFI_ACPI_CSRT_RESOURCE_TYPE_RESERVED, // 0
|
|
EFI_ACPI_CSRT_RESOURCE_TYPE_INTERRUPT, // 1
|
|
EFI_ACPI_CSRT_RESOURCE_TYPE_TIMER, // 2
|
|
EFI_ACPI_CSRT_RESOURCE_TYPE_DMA, // 3
|
|
EFI_ACPI_CSRT_RESOURCE_TYPE_CACHE, // 4
|
|
}
|
|
CSRT_RESOURCE_TYPE;
|
|
|
|
typedef enum
|
|
{
|
|
EFI_ACPI_CSRT_RESOURCE_SUBTYPE_DMA_CHANNEL, // 0
|
|
EFI_ACPI_CSRT_RESOURCE_SUBTYPE_DMA_CONTROLLER // 1
|
|
}
|
|
CSRT_DMA_SUBTYPE;
|
|
|
|
//------------------------------------------------------------------------
|
|
// CSRT Resource Group header 24 bytes long
|
|
//------------------------------------------------------------------------
|
|
typedef struct
|
|
{
|
|
UINT32 Length; // Length
|
|
UINT32 VendorID; // 4 bytes
|
|
UINT32 SubVendorId; // 4 bytes
|
|
UINT16 DeviceId; // 2 bytes
|
|
UINT16 SubdeviceId; // 2 bytes
|
|
UINT16 Revision; // 2 bytes
|
|
UINT16 Reserved; // 2 bytes
|
|
UINT32 SharedInfoLength; // 4 bytes
|
|
} EFI_ACPI_6_3_CSRT_RESOURCE_GROUP_HEADER;
|
|
|
|
//------------------------------------------------------------------------
|
|
// CSRT Resource Descriptor 12 bytes total
|
|
//------------------------------------------------------------------------
|
|
typedef struct
|
|
{
|
|
UINT32 Length; // 4 bytes
|
|
UINT16 ResourceType; // 2 bytes
|
|
UINT16 ResourceSubType; // 2 bytes
|
|
UINT32 UID; // 4 bytes
|
|
} EFI_ACPI_6_3_CSRT_RESOURCE_DESCRIPTOR_HEADER;
|
|
|
|
//------------------------------------------------------------------------
|
|
// Interrupts. These are specific to each platform
|
|
//------------------------------------------------------------------------
|
|
#if (RPI_MODEL == 3)
|
|
#define BCM2836_V3D_BUS_INTERRUPT 0x2A
|
|
#define BCM2836_DMA_INTERRUPT 0x3B
|
|
#define BCM2836_SPI1_INTERRUPT 0x3D
|
|
#define BCM2836_SPI2_INTERRUPT 0x3D
|
|
#define BCM2836_HVS_INTERRUPT 0x41
|
|
#define BCM2836_HDMI0_INTERRUPT 0x48
|
|
#define BCM2836_HDMI1_INTERRUPT 0x49
|
|
#define BCM2836_PV2_INTERRUPT 0x4A
|
|
#define BCM2836_PV0_INTERRUPT 0x4D
|
|
#define BCM2836_PV1_INTERRUPT 0x4E
|
|
#define BCM2836_MBOX_INTERRUPT 0x61
|
|
#define BCM2836_VCHIQ_INTERRUPT 0x62
|
|
#define BCM2386_GPIO_INTERRUPT0 0x51
|
|
#define BCM2386_GPIO_INTERRUPT1 0x52
|
|
#define BCM2386_GPIO_INTERRUPT2 0x53
|
|
#define BCM2386_GPIO_INTERRUPT3 0x54
|
|
#define BCM2836_I2C1_INTERRUPT 0x55
|
|
#define BCM2836_I2C2_INTERRUPT 0x55
|
|
#define BCM2836_SPI0_INTERRUPT 0x56
|
|
#define BCM2836_USB_INTERRUPT 0x29
|
|
#define BCM2836_SDHOST_INTERRUPT 0x58
|
|
#define BCM2836_MMCHS1_INTERRUPT 0x5E
|
|
#define BCM2836_MINI_UART_INTERRUPT 0x3D
|
|
#define BCM2836_PL011_UART_INTERRUPT 0x59
|
|
#elif (RPI_MODEL == 4)
|
|
#define BCM2836_V3D_BUS_INTERRUPT 0x2A
|
|
#define BCM2836_DMA_INTERRUPT 0x3B
|
|
#define BCM2836_SPI1_INTERRUPT 0x7D
|
|
#define BCM2836_SPI2_INTERRUPT 0x7D
|
|
#define BCM2836_HVS_INTERRUPT 0x41
|
|
#define BCM2836_HDMI0_INTERRUPT 0x48
|
|
#define BCM2836_HDMI1_INTERRUPT 0x49
|
|
#define BCM2836_PV2_INTERRUPT 0x4A
|
|
#define BCM2836_PV0_INTERRUPT 0x4D
|
|
#define BCM2836_PV1_INTERRUPT 0x4E
|
|
#define BCM2836_MBOX_INTERRUPT 0x41
|
|
#define BCM2836_VCHIQ_INTERRUPT 0x42
|
|
#define BCM2386_GPIO_INTERRUPT0 0x91
|
|
#define BCM2386_GPIO_INTERRUPT1 0x92
|
|
#define BCM2386_GPIO_INTERRUPT2 0x93
|
|
#define BCM2386_GPIO_INTERRUPT3 0x94
|
|
#define BCM2836_I2C1_INTERRUPT 0x95
|
|
#define BCM2836_I2C2_INTERRUPT 0x95
|
|
#define BCM2836_SPI0_INTERRUPT 0x96
|
|
#define BCM2836_USB_INTERRUPT 0x69
|
|
#define BCM2836_SDHOST_INTERRUPT 0x98
|
|
#define BCM2836_MMCHS1_INTERRUPT 0x9E
|
|
#define BCM2836_MINI_UART_INTERRUPT 0x7D
|
|
#define BCM2836_PL011_UART_INTERRUPT 0x99
|
|
#define GENET_INTERRUPT0 0xBD
|
|
#define GENET_INTERRUPT1 0xBE
|
|
#endif
|
|
|
|
#endif // __ACPITABLES_H__
|