forked from KolibriOS/kolibrios
uefi4kos: Make sure 32bit trampoline is below 4GiB
This fixes booting via uefi64kos on some systems. git-svn-id: svn://kolibrios.org@8656 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
9d6221ab7a
commit
af53d12ef9
@ -23,6 +23,7 @@ GOP_BUFFER_SIZE = 0x100
|
|||||||
LIP_BUFFER_SIZE = 0x100
|
LIP_BUFFER_SIZE = 0x100
|
||||||
FILE_BUFFER_SIZE = 0x1000
|
FILE_BUFFER_SIZE = 0x1000
|
||||||
|
|
||||||
|
KERNEL_TRAMPOLINE = 0x8f80 ; just before BOOT_LO
|
||||||
KERNEL_BASE = 0x10000
|
KERNEL_BASE = 0x10000
|
||||||
RAMDISK_BASE = 0x100000
|
RAMDISK_BASE = 0x100000
|
||||||
MAX_FILE_SIZE = 0x10000000
|
MAX_FILE_SIZE = 0x10000000
|
||||||
@ -818,7 +819,14 @@ main:
|
|||||||
mov ecx, 0x17
|
mov ecx, 0x17
|
||||||
rep movsb
|
rep movsb
|
||||||
|
|
||||||
lgdt [cs:GDTR]
|
; kernel trampoline
|
||||||
|
mov rsi, kernel_trampoline
|
||||||
|
mov rdi, KERNEL_TRAMPOLINE
|
||||||
|
mov ecx, kernel_trampoline.size
|
||||||
|
rep movsb
|
||||||
|
|
||||||
|
mov rax, GDTR
|
||||||
|
lgdt [cs:rax]
|
||||||
|
|
||||||
mov ax, DATA_32_SELECTOR
|
mov ax, DATA_32_SELECTOR
|
||||||
mov ds, ax
|
mov ds, ax
|
||||||
@ -828,29 +836,10 @@ main:
|
|||||||
mov ss, ax
|
mov ss, ax
|
||||||
|
|
||||||
push CODE_32_SELECTOR
|
push CODE_32_SELECTOR
|
||||||
lea rax, [.next]
|
mov rax, KERNEL_TRAMPOLINE
|
||||||
push rax
|
push rax
|
||||||
retf
|
retf
|
||||||
use32
|
|
||||||
align 16
|
|
||||||
.next:
|
|
||||||
mov eax, cr0
|
|
||||||
and eax, not CR0_PG
|
|
||||||
mov cr0, eax
|
|
||||||
|
|
||||||
mov ecx, MSR_AMD_EFER
|
|
||||||
rdmsr
|
|
||||||
btr eax, 8 ; LME
|
|
||||||
wrmsr
|
|
||||||
|
|
||||||
mov eax, cr4
|
|
||||||
and eax, not CR4_PAE
|
|
||||||
mov cr4, eax
|
|
||||||
|
|
||||||
push KERNEL_BASE
|
|
||||||
retn
|
|
||||||
|
|
||||||
use64
|
|
||||||
.error:
|
.error:
|
||||||
mov rbx, [efi_table]
|
mov rbx, [efi_table]
|
||||||
mov rbx, [rbx+EFI_SYSTEM_TABLE.ConOut]
|
mov rbx, [rbx+EFI_SYSTEM_TABLE.ConOut]
|
||||||
@ -1086,7 +1075,25 @@ clearbuf:
|
|||||||
pop rdi rsi rdx rcx rbx rax
|
pop rdi rsi rdx rcx rbx rax
|
||||||
ret
|
ret
|
||||||
|
|
||||||
section '.rodata' data readable
|
use32
|
||||||
|
kernel_trampoline:
|
||||||
|
org KERNEL_TRAMPOLINE
|
||||||
|
mov eax, cr0
|
||||||
|
and eax, not CR0_PG
|
||||||
|
mov cr0, eax
|
||||||
|
|
||||||
|
mov ecx, MSR_AMD_EFER
|
||||||
|
rdmsr
|
||||||
|
btr eax, 8 ; LME
|
||||||
|
wrmsr
|
||||||
|
|
||||||
|
mov eax, cr4
|
||||||
|
and eax, not CR4_PAE
|
||||||
|
mov cr4, eax
|
||||||
|
|
||||||
|
push KERNEL_BASE
|
||||||
|
retn
|
||||||
|
|
||||||
align 16
|
align 16
|
||||||
GDTR:
|
GDTR:
|
||||||
dw 4*8-1
|
dw 4*8-1
|
||||||
@ -1097,7 +1104,10 @@ GDT:
|
|||||||
dw 0FFFFh,0,9A00h,0CFh ; 32-bit code
|
dw 0FFFFh,0,9A00h,0CFh ; 32-bit code
|
||||||
dw 0FFFFh,0,9200h,0CFh ; flat data
|
dw 0FFFFh,0,9200h,0CFh ; flat data
|
||||||
dw 0FFFFh,0,9A00h,0AFh ; 64-bit code
|
dw 0FFFFh,0,9A00h,0AFh ; 64-bit code
|
||||||
|
assert $ < BOOT_LO
|
||||||
|
kernel_trampoline.size = $ - KERNEL_TRAMPOLINE
|
||||||
|
|
||||||
|
section '.rodata' data readable
|
||||||
gopuuid db EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID
|
gopuuid db EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID
|
||||||
lipuuid db EFI_LOADED_IMAGE_PROTOCOL_GUID
|
lipuuid db EFI_LOADED_IMAGE_PROTOCOL_GUID
|
||||||
sfspguid db EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID
|
sfspguid db EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID
|
||||||
|
Loading…
Reference in New Issue
Block a user