update AP bootstrap code
This commit is contained in:
parent
d7a1b01b63
commit
5670398077
@ -12,17 +12,74 @@
|
||||
.text
|
||||
|
||||
|
||||
.global ArBootstrapPageMap
|
||||
|
||||
.global ArStartApplicationProcessor
|
||||
ArStartApplicationProcessor:
|
||||
/* 16-bit code (real mode) */
|
||||
.code16
|
||||
|
||||
/* Turn off interrupts and clear direction flag */
|
||||
cli
|
||||
cld
|
||||
hlt
|
||||
|
||||
/* Load temporary GDT */
|
||||
lgdt (ArpApTemporaryGdtSize - ArStartApplicationProcessor + 0x1000)
|
||||
|
||||
/* Enable bit 0 in CR0 to enable Protected Mode */
|
||||
movl %cr0, %eax
|
||||
orl $0x1, %eax
|
||||
movl %eax, %cr0
|
||||
|
||||
/* Long jump into 32bits */
|
||||
ljmpl $0x8, $(ApplicationProcessor32 - ArStartApplicationProcessor + 0x1000)
|
||||
|
||||
/* 32-bit code (protected mode) */
|
||||
.code32
|
||||
ApplicationProcessor32:
|
||||
|
||||
/* Fix segment registers */
|
||||
mov $0x10, %ax
|
||||
mov %ax, %ds
|
||||
mov %ax, %es
|
||||
mov %ax, %fs
|
||||
mov %ax, %gs
|
||||
mov %ax, %ss
|
||||
|
||||
/* Enable LM and NX in the EFER. */
|
||||
mov $0xC0000080, %ecx
|
||||
rdmsr
|
||||
or $0x900, %eax
|
||||
wrmsr
|
||||
|
||||
/* Enable PAE and PSE */
|
||||
mov %cr4, %eax
|
||||
or $0x668, %eax
|
||||
mov %eax, %cr4
|
||||
|
||||
/* Install page map in CR3 */
|
||||
mov (ArBootstrapPageMap - ArStartApplicationProcessor + 0x1000), %eax
|
||||
mov %eax, %cr3
|
||||
|
||||
/* Enable paging */
|
||||
mov %cr0, %eax
|
||||
or $0x80010000, %eax
|
||||
mov %eax, %cr0
|
||||
|
||||
/* Long jump into 64bits */
|
||||
ljmpl $0x8, $(ApplicationProcessor64 - ArStartApplicationProcessor + 0x1000)
|
||||
|
||||
/* 64-bit code (long mode) */
|
||||
.code64
|
||||
ApplicationProcessor64:
|
||||
|
||||
/* HALT CPU in long mode */
|
||||
hlt
|
||||
|
||||
.align 8
|
||||
ArpApTemporaryGdtDesc: .quad 0x0000000000000000, 0x00CF9A000000FFFF, 0x00CF92000000FFFF, 0x00AF9A000000FFFF
|
||||
ArpApTemporaryGdtSize: .short ArpApTemporaryGdtSize - ArpApTemporaryGdtDesc - 1
|
||||
ArpApTemporaryGdtBase: .long ArpApTemporaryGdtDesc - ArStartApplicationProcessor + 0x1000
|
||||
ArBootstrapPageMap: .quad 0x0000000000000000
|
||||
|
||||
ArStartApplicationProcessorEnd:
|
||||
|
@ -79,6 +79,8 @@ HlStartProcessor(IN ULONG CpuId,
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
extern ULONG_PTR ArBootstrapPageMap;
|
||||
|
||||
XTAPI
|
||||
XTSTATUS
|
||||
HlStartAllProcessors(VOID)
|
||||
@ -95,6 +97,9 @@ HlStartAllProcessors(VOID)
|
||||
/* Check if at least one AP is present */
|
||||
if(HlpSystemInfo.CpuCount > 1)
|
||||
{
|
||||
/* Save page map address in the bootstrap code */
|
||||
ArBootstrapPageMap = ArReadControlRegister(3);
|
||||
|
||||
/* Allocate 5 pages for AP bootstrap code and ensure it is low memory */
|
||||
Status = MmAllocateHardwareMemory(AP_SPINUP_PAGE_COUNT, FALSE, &ApPhysicalAddress);
|
||||
if(Status != STATUS_SUCCESS || ApPhysicalAddress.QuadPart > (0x100000 - AP_SPINUP_PAGE_COUNT * MM_PAGE_SIZE))
|
||||
|
Loading…
Reference in New Issue
Block a user