Skip to content

Commit

Permalink
Prime: Windows boots!
Browse files Browse the repository at this point in the history
  • Loading branch information
Bingxing Wang committed Nov 20, 2019
1 parent 6da19fa commit 47a2642
Show file tree
Hide file tree
Showing 12 changed files with 179 additions and 51 deletions.
8 changes: 7 additions & 1 deletion AcpiTables/AcpiTables.inf
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
Fadt.aslc
Madt.asl
Facs.asl
Gtdt.aslc

[BuildOptions.ARM]
GCC:*_*_*_CC_FLAGS = -Wno-missing-braces -DCONFIG_L2CACHE_OFF
Expand All @@ -45,4 +46,9 @@
gArmPlatformTokenSpaceGuid.PcdCoreCount
gArmTokenSpaceGuid.PcdGicDistributorBase
gArmTokenSpaceGuid.PcdGicInterruptInterfaceBase
giMXPlatformTokenSpaceGuid.PcdKdUartInstance
giMXPlatformTokenSpaceGuid.PcdKdUartInstance

gArmTokenSpaceGuid.PcdArmArchTimerVirtIntrNum
gArmTokenSpaceGuid.PcdArmArchTimerHypIntrNum
gArmTokenSpaceGuid.PcdArmArchTimerSecIntrNum
gArmTokenSpaceGuid.PcdArmArchTimerIntrNum
4 changes: 2 additions & 2 deletions AcpiTables/Dsdt/Dsdt-Platform.asl
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Device (EPIT)
}

// Platform Extension Plugin
Device (PEP0)
/*Device (PEP0)
{
Name (_HID, "NXP0102")
Name (_UID, 0x0)
Expand All @@ -70,4 +70,4 @@ Device (PEP0)
// UART1
Interrupt (ResourceConsumer, Level, ActiveHigh, Shared) { 58 }
})
}
}*/
77 changes: 77 additions & 0 deletions AcpiTables/Gtdt.aslc
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/** @file
* Generic Timer Description Table (GTDT)
*
* Copyright (c) 2012 - 2017, ARM Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-2-Clause-Patent
*
**/

#include "Platform.h"

#include <Library/AcpiLib.h>
#include <Library/PcdLib.h>
#include <IndustryStandard/Acpi.h>

#define GTDT_GLOBAL_FLAGS_MAPPED EFI_ACPI_5_0_GTDT_GLOBAL_FLAG_MEMORY_MAPPED_BLOCK_PRESENT
#define GTDT_GLOBAL_FLAGS_NOT_MAPPED 0
#define GTDT_GLOBAL_FLAGS_EDGE EFI_ACPI_5_0_GTDT_GLOBAL_FLAG_INTERRUPT_MODE
#define GTDT_GLOBAL_FLAGS_LEVEL 0

// Note: We could have a build flag that switches between memory mapped/non-memory mapped timer
#ifdef SYSTEM_TIMER_BASE_ADDRESS
#define GTDT_GLOBAL_FLAGS (GTDT_GLOBAL_FLAGS_MAPPED | GTDT_GLOBAL_FLAGS_LEVEL)
#else
#define GTDT_GLOBAL_FLAGS (GTDT_GLOBAL_FLAGS_NOT_MAPPED | GTDT_GLOBAL_FLAGS_LEVEL)
#define SYSTEM_TIMER_BASE_ADDRESS 0xFFFFFFFFFFFFFFFF
#endif

#define GTDT_TIMER_EDGE_TRIGGERED EFI_ACPI_5_0_GTDT_TIMER_FLAG_TIMER_INTERRUPT_MODE
#define GTDT_TIMER_LEVEL_TRIGGERED 0
#define GTDT_TIMER_ACTIVE_LOW EFI_ACPI_5_0_GTDT_TIMER_FLAG_TIMER_INTERRUPT_POLARITY
#define GTDT_TIMER_ACTIVE_HIGH 0

#define GTDT_GTIMER_FLAGS (GTDT_TIMER_ACTIVE_LOW | GTDT_TIMER_LEVEL_TRIGGERED)

#pragma pack (1)

typedef struct {
EFI_ACPI_5_1_GENERIC_TIMER_DESCRIPTION_TABLE Gtdt;
} GENERIC_TIMER_DESCRIPTION_TABLE;

#pragma pack ()

GENERIC_TIMER_DESCRIPTION_TABLE Gtdt = {
{
{
EFI_ACPI_5_1_GENERIC_TIMER_DESCRIPTION_TABLE_SIGNATURE,
sizeof (EFI_ACPI_5_1_GENERIC_TIMER_DESCRIPTION_TABLE),
EFI_ACPI_5_1_GENERIC_TIMER_DESCRIPTION_TABLE_REVISION,
0,
EFI_ACPI_OEM_ID,
EFI_ACPI_OEM_TABLE_ID,
EFI_ACPI_OEM_REVISION,
EFI_ACPI_CREATOR_ID,
EFI_ACPI_CREATOR_REVISION
},
SYSTEM_TIMER_BASE_ADDRESS, // UINT64 PhysicalAddress
0, // UINT32 Reserved
FixedPcdGet32 (PcdArmArchTimerSecIntrNum), // UINT32 SecurePL1TimerGSIV
GTDT_GTIMER_FLAGS, // UINT32 SecurePL1TimerFlags
FixedPcdGet32 (PcdArmArchTimerIntrNum), // UINT32 NonSecurePL1TimerGSIV
GTDT_GTIMER_FLAGS, // UINT32 NonSecurePL1TimerFlags
FixedPcdGet32 (PcdArmArchTimerVirtIntrNum), // UINT32 VirtualTimerGSIV
GTDT_GTIMER_FLAGS, // UINT32 VirtualTimerFlags
FixedPcdGet32 (PcdArmArchTimerHypIntrNum), // UINT32 NonSecurePL2TimerGSIV
GTDT_GTIMER_FLAGS, // UINT32 NonSecurePL2TimerFlags
0xFFFFFFFFFFFFFFFF, // UINT64 CntReadBasePhysicalAddress
0, // UINT32 PlatformTimerCount
0
},
};

//
// Reference the table being generated to prevent the optimizer from removing the
// data structure from the executable
//
VOID* CONST ReferenceAcpiTable = &Gtdt;
2 changes: 1 addition & 1 deletion AcpiTables/Madt.asl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
Virtual GIC Interrupt Trigger Mode : 0
[03Ch 0060 4] Parking Protocol Version : 00000001
[040h 0064 4] Performance Interrupt : 0000007e
[044h 0068 8] Parked Address : 000000008fe00000
[044h 0068 8] Parked Address : 0000000080100000
[04Ch 0076 8] Base Address : 0000000000a02000
[054h 0084 8] Virtual GIC Base Address : 0000000000000000
[05Ch 0092 8] Hypervisor GIC Base Address : 0000000000000000
Expand Down
6 changes: 3 additions & 3 deletions Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.c
Original file line number Diff line number Diff line change
Expand Up @@ -387,10 +387,10 @@ SMBIOS_TABLE_TYPE16 mPhyMemArrayInfoType16 = {
MemoryErrorCorrectionUnknown, // MemoryErrorCorrection; ///< The
// enumeration value from
// MEMORY_ERROR_CORRECTION.
0x10000000, // MaximumCapacity;
0x0fc00000, // MaximumCapacity;
0xFFFE, // MemoryErrorInformationHandle;
1, // NumberOfMemoryDevices;
0x10000000ULL, // ExtendedMaximumCapacity;
0x0fb00000ULL, // ExtendedMaximumCapacity;
};
CHAR8 *mPhyMemArrayInfoType16Strings[] = {NULL};

Expand All @@ -404,7 +404,7 @@ SMBIOS_TABLE_TYPE17 mMemDevInfoType17 = {
0xFFFE, // MemoryErrorInformationHandle;
0xFFFF, // TotalWidth;
0xFFFF, // DataWidth;
0x00F5, // Size; // When bit 15 is 0: Size in MB
0x00Fc, // Size; // When bit 15 is 0: Size in MB
// When bit 15 is 1: Size in KB, and continues in ExtendedSize
MemoryFormFactorTsop, // FormFactor; ///< The
// enumeration value from MEMORY_FORM_FACTOR.
Expand Down
40 changes: 25 additions & 15 deletions Library/MemoryInitPeiLib/MemoryInitPeiLib.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,36 +113,46 @@ MemoryPeim (
EfiMemoryMappedIO
);

// Free memory
Add(&MemoryTable[1], EFI_RESOURCE_SYSTEM_MEMORY,
SYSTEM_MEMORY_RESOURCE_ATTR_CAPABILITIES,
EfiConventionalMemory
Add(&MemoryTable[1], EFI_RESOURCE_MEMORY_MAPPED_IO,
EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE,
EfiMemoryMappedIO
);

// MPPark mailbox
Add(&MemoryTable[2], EFI_RESOURCE_MEMORY_RESERVED,
EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE,
EfiRuntimeServicesCode
Add(&MemoryTable[2], EFI_RESOURCE_MEMORY_MAPPED_IO,
EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE,
EfiMemoryMappedIO
);

// Framebuffer
Add(&MemoryTable[3], EFI_RESOURCE_MEMORY_RESERVED,
EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE,
EfiReservedMemoryType
// Free memory
Add(&MemoryTable[3], EFI_RESOURCE_SYSTEM_MEMORY,
SYSTEM_MEMORY_RESOURCE_ATTR_CAPABILITIES,
EfiConventionalMemory
);

// FD region
// FD
Add(&MemoryTable[4], EFI_RESOURCE_SYSTEM_MEMORY,
SYSTEM_MEMORY_RESOURCE_ATTR_CAPABILITIES,
EfiBootServicesData
EfiBootServicesCode
);

// Usable memory.
// Free memory
Add(&MemoryTable[5], EFI_RESOURCE_SYSTEM_MEMORY,
SYSTEM_MEMORY_RESOURCE_ATTR_CAPABILITIES,
EfiConventionalMemory
);

// MPPark mailbox
Add(&MemoryTable[6], EFI_RESOURCE_MEMORY_RESERVED,
EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE,
EfiRuntimeServicesCode
);

// Framebuffer
Add(&MemoryTable[7], EFI_RESOURCE_MEMORY_RESERVED,
EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE,
EfiReservedMemoryType
);

// Build Memory Allocation Hob
InitMmu (MemoryTable);

Expand Down
46 changes: 31 additions & 15 deletions Library/PlatformLib/ArmPlatformLibMem.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,28 +56,44 @@ ArmPlatformGetVirtualMemoryMap (
// SOC registers region, DMA registers region and GIC-400 registers region
// I doubt if it is really a GIC-400 anyway, but it should be something
// compliant with GICv2
VirtualMemoryTable[Index].PhysicalBase = 0x00000000;
VirtualMemoryTable[Index].VirtualBase = 0x00000000;
VirtualMemoryTable[Index].Length = 0x80000000;
VirtualMemoryTable[Index].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;

// Free memory
VirtualMemoryTable[Index].PhysicalBase = SOC_REGISTERS_PHYSICAL_BASE1;
VirtualMemoryTable[Index].VirtualBase = SOC_REGISTERS_PHYSICAL_BASE1;
VirtualMemoryTable[Index].Length = SOC_REGISTERS_PHYSICAL_LENGTH1;
VirtualMemoryTable[Index].Attributes = SOC_REGISTERS_ATTRIBUTES;

VirtualMemoryTable[++Index].PhysicalBase = APBH_DMA_REGISTERS_PHYSICAL_BASE;
VirtualMemoryTable[Index].VirtualBase = APBH_DMA_REGISTERS_PHYSICAL_BASE;
VirtualMemoryTable[Index].Length = APBH_DMA_REGISTERS_PHYSICAL_LENGTH;
VirtualMemoryTable[Index].Attributes = SOC_REGISTERS_ATTRIBUTES;

VirtualMemoryTable[++Index].PhysicalBase = GIC_REGISTERS_PHYSICAL_BASE;
VirtualMemoryTable[Index].VirtualBase = GIC_REGISTERS_PHYSICAL_BASE;
VirtualMemoryTable[Index].Length = GIC_REGISTERS_PHYSICAL_LENGTH;
VirtualMemoryTable[Index].Attributes = SOC_REGISTERS_ATTRIBUTES;

// Rearranged system memory regions
VirtualMemoryTable[++Index].PhysicalBase = 0x80000000;
VirtualMemoryTable[Index].VirtualBase = 0x80000000;
VirtualMemoryTable[Index].Length = 0x0fe00000;
VirtualMemoryTable[Index].Attributes = CacheAttributes;
VirtualMemoryTable[Index].Length = 0x00100000;
VirtualMemoryTable[Index].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_WRITE_THROUGH;

// MPPark mailbox
VirtualMemoryTable[++Index].PhysicalBase = 0x8fe00000;
VirtualMemoryTable[Index].VirtualBase = 0x8fe00000;
// MpPark
VirtualMemoryTable[++Index].PhysicalBase = 0x80100000;
VirtualMemoryTable[Index].VirtualBase = 0x80100000;
VirtualMemoryTable[Index].Length = 0x00100000;
VirtualMemoryTable[Index].Attributes = DDR_ATTRIBUTES_UNCACHED;

// Framebuffer
VirtualMemoryTable[++Index].PhysicalBase = 0x8ff00000;
VirtualMemoryTable[Index].VirtualBase = 0x8ff00000;
// FD
VirtualMemoryTable[++Index].PhysicalBase = 0x80200000;
VirtualMemoryTable[Index].VirtualBase = 0x80200000;
VirtualMemoryTable[Index].Length = 0x00100000;
VirtualMemoryTable[Index].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_WRITE_THROUGH;
VirtualMemoryTable[Index].Attributes = CacheAttributes;

// Free memory
VirtualMemoryTable[++Index].PhysicalBase = 0x80300000;
VirtualMemoryTable[Index].VirtualBase = 0x80300000;
VirtualMemoryTable[Index].Length = 0x0fb00000;
VirtualMemoryTable[Index].Attributes = CacheAttributes;

// End of Table
VirtualMemoryTable[++Index].PhysicalBase = 0;
Expand Down
1 change: 0 additions & 1 deletion PrePi/PeiUniCore.inf
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@

gArmPlatformTokenSpaceGuid.PcdCoreCount

gEmbeddedTokenSpaceGuid.PcdPrePiCpuMemorySize
gEmbeddedTokenSpaceGuid.PcdPrePiCpuIoSize

gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiACPIReclaimMemory
Expand Down
2 changes: 1 addition & 1 deletion PrePi/PrePi.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ PrePiMain (
BuildStackHob (StacksBase, StacksSize);

//TODO: Call CpuPei as a library
BuildCpuHob (PcdGet8 (PcdPrePiCpuMemorySize), PcdGet8 (PcdPrePiCpuIoSize));
BuildCpuHob (ArmGetPhysicalAddressBits (), PcdGet8 (PcdPrePiCpuIoSize));

if (ArmIsMpCore ()) {
// Only MP Core platform need to produce gArmMpCoreInfoPpiGuid
Expand Down
25 changes: 20 additions & 5 deletions PrimeG2.dsc
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@

[PcdsFixedAtBuild.common]
gArmPlatformTokenSpaceGuid.PcdCPUCorePrimaryStackSize|0x4000
gArmTokenSpaceGuid.PcdSystemMemorySize|0x0fe00000
gArmTokenSpaceGuid.PcdSystemMemoryBase|0x80000000
gArmTokenSpaceGuid.PcdSystemMemoryBase|0x80200000
gArmTokenSpaceGuid.PcdSystemMemorySize|0x0fc00000
gArmPlatformTokenSpaceGuid.PcdSystemMemoryUefiRegionSize|0x01000000
gArmPlatformTokenSpaceGuid.PcdCoreCount|1
!if $(TARGET) == RELEASE
Expand All @@ -47,6 +47,8 @@
gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|$(DEBUG_PRINT_ERROR_LEVEL)
gEfiMdePkgTokenSpaceGuid.PcdReportStatusCodePropertyMask|0x07

giMXPlatformTokenSpaceGuid.MpParkMailboxBase|0x80100000

gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiACPIReclaimMemory|0
gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiACPIMemoryNVS|0
gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiReservedMemoryType|0
Expand All @@ -57,6 +59,8 @@
gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiLoaderCode|10
gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiLoaderData|0

gEmbeddedTokenSpaceGuid.PcdPrePiCpuIoSize|0

gEmbeddedTokenSpaceGuid.PcdInterruptBaseAddress|0x00a01000
gArmTokenSpaceGuid.PcdGicDistributorBase|0x00a01000
gArmTokenSpaceGuid.PcdGicInterruptInterfaceBase|0x00a02000
Expand Down Expand Up @@ -97,7 +101,9 @@
gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiExposedTableVersions|0x20

# Variable Services
!if $(UDK2019) == 1
gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvModeEnable|TRUE
!endif

[PcdsFeatureFlag.common]
gArmTokenSpaceGuid.PcdRelocateVectorTable|FALSE
Expand Down Expand Up @@ -153,7 +159,11 @@

UefiUsbLib|MdePkg/Library/UefiUsbLib/UefiUsbLib.inf
PciLib|MdePkg/Library/BasePciLibCf8/BasePciLibCf8.inf
NetLib|NetworkPkg/Library/DxeNetLib/DxeNetLib.inf
!if $(UDK2019) == 1
NetLib|MdeModulePkg/Library/DxeNetLib/DxeNetLib.inf
!else
NetLib|MdeModulePkg/Library/DxeNetLib/DxeNetLib.inf
!endif

PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
UefiLib|MdePkg/Library/UefiLib/UefiLib.inf
Expand Down Expand Up @@ -285,7 +295,7 @@
PerformanceLib|MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.inf

[Components.common]
ArmPlatformPkg/PrePi/PeiUniCore.inf
PrimeG2Pkg/PrePi/PeiUniCore.inf

MdeModulePkg/Core/Dxe/DxeMain.inf {
<LibraryClasses>
Expand Down Expand Up @@ -352,9 +362,14 @@
MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf
MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf
MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf
EmbeddedPkg/ResetRuntimeDxe/ResetRuntimeDxe.inf

!if $(UDK2019) == 1
MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf
!else
MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariableRuntimeDxe.inf
!endif

PrimeG2Pkg/Drivers/LcdFbDxe/LcdFbDxe.inf
PrimeG2Pkg/Drivers/LogoDxe/LogoDxe.inf
PrimeG2Pkg/Drivers/LedHeartbeatDxe/LedHeartbeatDxe.inf
Expand Down
Loading

0 comments on commit 47a2642

Please sign in to comment.