Initial XTLDR APIC support, finds and maps base APIC address for kernel
This commit is contained in:
parent
3d0a48df26
commit
a3c28cee73
@ -32,6 +32,10 @@ XTCDECL
|
|||||||
ULONG_PTR
|
ULONG_PTR
|
||||||
ArReadControlRegister(IN USHORT ControlRegister);
|
ArReadControlRegister(IN USHORT ControlRegister);
|
||||||
|
|
||||||
|
XTCDECL
|
||||||
|
ULONGLONG
|
||||||
|
ArReadModelSpecificRegister(IN ULONG Register);
|
||||||
|
|
||||||
XTCDECL
|
XTCDECL
|
||||||
VOID
|
VOID
|
||||||
ArWriteControlRegister(IN USHORT ControlRegister,
|
ArWriteControlRegister(IN USHORT ControlRegister,
|
||||||
|
@ -14,6 +14,9 @@
|
|||||||
#include <xttypes.h>
|
#include <xttypes.h>
|
||||||
|
|
||||||
|
|
||||||
|
/* APIC base address */
|
||||||
|
#define APIC_BASE 0xFFFFFFFFFFFE0000ULL
|
||||||
|
|
||||||
/* Serial port I/O addresses */
|
/* Serial port I/O addresses */
|
||||||
#define COMPORT_ADDRESSES {0x000, 0x3F8, 0x2F8, 0x3E8, 0x2E8, 0x5F8, 0x4F8, 0x5E8, 0x4E8}
|
#define COMPORT_ADDRESSES {0x000, 0x3F8, 0x2F8, 0x3E8, 0x2E8, 0x5F8, 0x4F8, 0x5E8, 0x4E8}
|
||||||
|
|
||||||
|
@ -32,6 +32,10 @@ XTCDECL
|
|||||||
ULONG_PTR
|
ULONG_PTR
|
||||||
ArReadControlRegister(IN USHORT ControlRegister);
|
ArReadControlRegister(IN USHORT ControlRegister);
|
||||||
|
|
||||||
|
XTCDECL
|
||||||
|
ULONGLONG
|
||||||
|
ArReadModelSpecificRegister(IN ULONG Register);
|
||||||
|
|
||||||
XTCDECL
|
XTCDECL
|
||||||
VOID
|
VOID
|
||||||
ArWriteControlRegister(IN USHORT ControlRegister,
|
ArWriteControlRegister(IN USHORT ControlRegister,
|
||||||
|
@ -14,6 +14,9 @@
|
|||||||
#include <xttypes.h>
|
#include <xttypes.h>
|
||||||
|
|
||||||
|
|
||||||
|
/* APIC base address */
|
||||||
|
#define APIC_BASE 0xFFFE0000
|
||||||
|
|
||||||
/* Serial port I/O addresses */
|
/* Serial port I/O addresses */
|
||||||
#define COMPORT_ADDRESSES {0x000, 0x3F8, 0x2F8, 0x3E8, 0x2E8, 0x5F8, 0x4F8, 0x5E8, 0x4E8}
|
#define COMPORT_ADDRESSES {0x000, 0x3F8, 0x2F8, 0x3E8, 0x2E8, 0x5F8, 0x4F8, 0x5E8, 0x4E8}
|
||||||
|
|
||||||
|
@ -29,6 +29,10 @@ XtpBootSequence(IN PEFI_FILE_HANDLE BootDir,
|
|||||||
IN PXT_BOOT_PROTOCOL_PARAMETERS Parameters);
|
IN PXT_BOOT_PROTOCOL_PARAMETERS Parameters);
|
||||||
|
|
||||||
|
|
||||||
|
XTCDECL
|
||||||
|
EFI_STATUS
|
||||||
|
XtpInitializeApicBase(IN PLIST_ENTRY MemoryMappings);
|
||||||
|
|
||||||
XTCDECL
|
XTCDECL
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
XtpInitializeLoaderBlock(IN PLIST_ENTRY MemoryMappings,
|
XtpInitializeLoaderBlock(IN PLIST_ENTRY MemoryMappings,
|
||||||
|
@ -229,6 +229,21 @@ XtpBootSequence(IN PEFI_FILE_HANDLE BootDir,
|
|||||||
|
|
||||||
/* Setup and map kernel initialization block */
|
/* Setup and map kernel initialization block */
|
||||||
Status = XtpInitializeLoaderBlock(&MemoryMappings, &VirtualAddress);
|
Status = XtpInitializeLoaderBlock(&MemoryMappings, &VirtualAddress);
|
||||||
|
if(Status != STATUS_EFI_SUCCESS)
|
||||||
|
{
|
||||||
|
/* Failed to setup kernel initialization block */
|
||||||
|
XtLdrProtocol->DbgPrint(L"Failed to setup kernel initialization block (Status Code: %lx)\n", Status);
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Find and map APIC base address */
|
||||||
|
Status = XtpInitializeApicBase(&MemoryMappings);
|
||||||
|
if(Status != STATUS_EFI_SUCCESS)
|
||||||
|
{
|
||||||
|
/* Failed to setup kernel initialization block */
|
||||||
|
XtLdrProtocol->DbgPrint(L"Failed to initialize APIC (Status Code: %lx)\n", Status);
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
/* Get kernel entry point */
|
/* Get kernel entry point */
|
||||||
XtPeCoffProtocol->GetEntryPoint(ImageContext, (PVOID)&KernelEntryPoint);
|
XtPeCoffProtocol->GetEntryPoint(ImageContext, (PVOID)&KernelEntryPoint);
|
||||||
@ -254,6 +269,47 @@ XtpBootSequence(IN PEFI_FILE_HANDLE BootDir,
|
|||||||
return STATUS_EFI_SUCCESS;
|
return STATUS_EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if APIC is present in the system and finds its base address.
|
||||||
|
*
|
||||||
|
* @param MemoryMappings
|
||||||
|
* Supplies a pointer to linked list containing all memory mappings.
|
||||||
|
*
|
||||||
|
* @return This routine returns an EFI status code.
|
||||||
|
*
|
||||||
|
* @since XT 1.0
|
||||||
|
*/
|
||||||
|
XTCDECL
|
||||||
|
EFI_STATUS
|
||||||
|
XtpInitializeApicBase(IN PLIST_ENTRY MemoryMappings)
|
||||||
|
{
|
||||||
|
PCPUID_REGISTERS CpuRegisters = NULL;
|
||||||
|
PVOID ApicBaseAddress;
|
||||||
|
|
||||||
|
/* Get CPU features list */
|
||||||
|
CpuRegisters->Leaf = CPUID_GET_CPU_FEATURES;
|
||||||
|
CpuRegisters->SubLeaf = 0;
|
||||||
|
CpuRegisters->Eax = 0;
|
||||||
|
CpuRegisters->Ebx = 0;
|
||||||
|
CpuRegisters->Ecx = 0;
|
||||||
|
CpuRegisters->Edx = 0;
|
||||||
|
ArCpuId(CpuRegisters);
|
||||||
|
|
||||||
|
/* Check if APIC is present */
|
||||||
|
if((CpuRegisters->Edx & CPUID_FEATURES_EDX_APIC) == 0)
|
||||||
|
{
|
||||||
|
/* APIC is not supported by the CPU */
|
||||||
|
return STATUS_EFI_UNSUPPORTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Get APIC base address */
|
||||||
|
ApicBaseAddress = (PVOID)((UINT_PTR)ArReadModelSpecificRegister(0x1B) & 0xFFFFF000);
|
||||||
|
|
||||||
|
/* Map APIC base address */
|
||||||
|
XtLdrProtocol->AddVirtualMemoryMapping(MemoryMappings, (PVOID)APIC_BASE, ApicBaseAddress, 1, LoaderFirmwarePermanent);
|
||||||
|
return STATUS_EFI_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes and maps the kernel initialization block.
|
* Initializes and maps the kernel initialization block.
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user