mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 18:28:12 +00:00
Kernel: Get rid of of some of the duplicate kernel base address macros
This commit is contained in:
parent
040fe0054b
commit
8c14488106
4 changed files with 34 additions and 32 deletions
|
@ -1,8 +1,8 @@
|
||||||
#define _BOOTLOADER
|
#define _BOOTLOADER
|
||||||
#include <AK/Platform.h>
|
#include <AK/Platform.h>
|
||||||
|
#include <Kernel/Sections.h>
|
||||||
|
|
||||||
.code32
|
.code32
|
||||||
.set KERNEL_VIRTUAL_BASE, 0xc0000000
|
|
||||||
|
|
||||||
.section .stack, "aw", @nobits
|
.section .stack, "aw", @nobits
|
||||||
stack_bottom:
|
stack_bottom:
|
||||||
|
@ -142,74 +142,74 @@ continue:
|
||||||
addl $16, %esi
|
addl $16, %esi
|
||||||
movl (%esi), %esi
|
movl (%esi), %esi
|
||||||
movl $1024, %ecx
|
movl $1024, %ecx
|
||||||
movl $(kernel_cmdline - KERNEL_VIRTUAL_BASE), %edi
|
movl $(kernel_cmdline - KERNEL_BASE), %edi
|
||||||
rep movsl
|
rep movsl
|
||||||
|
|
||||||
#if ARCH(X86_64)
|
#if ARCH(X86_64)
|
||||||
/* clear pml4t */
|
/* clear pml4t */
|
||||||
movl $(boot_pml4t - KERNEL_VIRTUAL_BASE), %edi
|
movl $(boot_pml4t - KERNEL_BASE), %edi
|
||||||
movl $1024, %ecx
|
movl $1024, %ecx
|
||||||
xorl %eax, %eax
|
xorl %eax, %eax
|
||||||
rep stosl
|
rep stosl
|
||||||
|
|
||||||
/* set up pml4t[0] */
|
/* set up pml4t[0] */
|
||||||
movl $(boot_pml4t - KERNEL_VIRTUAL_BASE), %edi
|
movl $(boot_pml4t - KERNEL_BASE), %edi
|
||||||
movl $(boot_pdpt - KERNEL_VIRTUAL_BASE), 0(%edi)
|
movl $(boot_pdpt - KERNEL_BASE), 0(%edi)
|
||||||
/* R/W + Present */
|
/* R/W + Present */
|
||||||
orl $0x3, 0(%edi)
|
orl $0x3, 0(%edi)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* clear pdpt */
|
/* clear pdpt */
|
||||||
movl $(boot_pdpt - KERNEL_VIRTUAL_BASE), %edi
|
movl $(boot_pdpt - KERNEL_BASE), %edi
|
||||||
movl $1024, %ecx
|
movl $1024, %ecx
|
||||||
xorl %eax, %eax
|
xorl %eax, %eax
|
||||||
rep stosl
|
rep stosl
|
||||||
|
|
||||||
/* set up pdpt[0] and pdpt[3] */
|
/* set up pdpt[0] and pdpt[3] */
|
||||||
movl $(boot_pdpt - KERNEL_VIRTUAL_BASE), %edi
|
movl $(boot_pdpt - KERNEL_BASE), %edi
|
||||||
#if ARCH(X86_64)
|
#if ARCH(X86_64)
|
||||||
movl $((boot_pd0 - KERNEL_VIRTUAL_BASE) + 3), 0(%edi)
|
movl $((boot_pd0 - KERNEL_BASE) + 3), 0(%edi)
|
||||||
movl $((boot_pd3 - KERNEL_VIRTUAL_BASE) + 3), 24(%edi)
|
movl $((boot_pd3 - KERNEL_BASE) + 3), 24(%edi)
|
||||||
#else
|
#else
|
||||||
movl $((boot_pd0 - KERNEL_VIRTUAL_BASE) + 1), 0(%edi)
|
movl $((boot_pd0 - KERNEL_BASE) + 1), 0(%edi)
|
||||||
movl $((boot_pd3 - KERNEL_VIRTUAL_BASE) + 1), 24(%edi)
|
movl $((boot_pd3 - KERNEL_BASE) + 1), 24(%edi)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* clear pd0 */
|
/* clear pd0 */
|
||||||
movl $(boot_pd0 - KERNEL_VIRTUAL_BASE), %edi
|
movl $(boot_pd0 - KERNEL_BASE), %edi
|
||||||
movl $1024, %ecx
|
movl $1024, %ecx
|
||||||
xorl %eax, %eax
|
xorl %eax, %eax
|
||||||
rep stosl
|
rep stosl
|
||||||
|
|
||||||
/* clear pd3 */
|
/* clear pd3 */
|
||||||
movl $(boot_pd3 - KERNEL_VIRTUAL_BASE), %edi
|
movl $(boot_pd3 - KERNEL_BASE), %edi
|
||||||
movl $1024, %ecx
|
movl $1024, %ecx
|
||||||
xorl %eax, %eax
|
xorl %eax, %eax
|
||||||
rep stosl
|
rep stosl
|
||||||
|
|
||||||
/* clear pd0's pt's */
|
/* clear pd0's pt's */
|
||||||
movl $(boot_pd0_pt0 - KERNEL_VIRTUAL_BASE), %edi
|
movl $(boot_pd0_pt0 - KERNEL_BASE), %edi
|
||||||
movl $(1024 * 4), %ecx
|
movl $(1024 * 4), %ecx
|
||||||
xorl %eax, %eax
|
xorl %eax, %eax
|
||||||
rep stosl
|
rep stosl
|
||||||
|
|
||||||
/* clear pd3's pt's */
|
/* clear pd3's pt's */
|
||||||
movl $(boot_pd3_pts - KERNEL_VIRTUAL_BASE), %edi
|
movl $(boot_pd3_pts - KERNEL_BASE), %edi
|
||||||
movl $(1024 * 17), %ecx
|
movl $(1024 * 17), %ecx
|
||||||
xorl %eax, %eax
|
xorl %eax, %eax
|
||||||
rep stosl
|
rep stosl
|
||||||
|
|
||||||
/* add boot_pd0_pt0 to boot_pd0 */
|
/* add boot_pd0_pt0 to boot_pd0 */
|
||||||
movl $(boot_pd0 - KERNEL_VIRTUAL_BASE), %edi
|
movl $(boot_pd0 - KERNEL_BASE), %edi
|
||||||
movl $(boot_pd0_pt0 - KERNEL_VIRTUAL_BASE), %eax
|
movl $(boot_pd0_pt0 - KERNEL_BASE), %eax
|
||||||
movl %eax, 0(%edi)
|
movl %eax, 0(%edi)
|
||||||
/* R/W + Present */
|
/* R/W + Present */
|
||||||
orl $0x3, 0(%edi)
|
orl $0x3, 0(%edi)
|
||||||
|
|
||||||
/* add boot_pd3_pts to boot_pd3 */
|
/* add boot_pd3_pts to boot_pd3 */
|
||||||
movl $16, %ecx
|
movl $16, %ecx
|
||||||
movl $(boot_pd3 - KERNEL_VIRTUAL_BASE), %edi
|
movl $(boot_pd3 - KERNEL_BASE), %edi
|
||||||
movl $(boot_pd3_pts - KERNEL_VIRTUAL_BASE), %eax
|
movl $(boot_pd3_pts - KERNEL_BASE), %eax
|
||||||
|
|
||||||
1:
|
1:
|
||||||
movl %eax, 0(%edi)
|
movl %eax, 0(%edi)
|
||||||
|
@ -221,7 +221,7 @@ continue:
|
||||||
|
|
||||||
/* identity map the 0 to 2MB range */
|
/* identity map the 0 to 2MB range */
|
||||||
movl $512, %ecx
|
movl $512, %ecx
|
||||||
movl $(boot_pd0_pt0 - KERNEL_VIRTUAL_BASE), %edi
|
movl $(boot_pd0_pt0 - KERNEL_BASE), %edi
|
||||||
xorl %eax, %eax
|
xorl %eax, %eax
|
||||||
|
|
||||||
1:
|
1:
|
||||||
|
@ -234,7 +234,7 @@ continue:
|
||||||
|
|
||||||
/* pseudo identity map the 3072-3102MB range */
|
/* pseudo identity map the 3072-3102MB range */
|
||||||
movl $(512 * 16), %ecx
|
movl $(512 * 16), %ecx
|
||||||
movl $(boot_pd3_pts - KERNEL_VIRTUAL_BASE), %edi
|
movl $(boot_pd3_pts - KERNEL_BASE), %edi
|
||||||
xorl %eax, %eax
|
xorl %eax, %eax
|
||||||
|
|
||||||
1:
|
1:
|
||||||
|
@ -246,17 +246,17 @@ continue:
|
||||||
loop 1b
|
loop 1b
|
||||||
|
|
||||||
/* create an empty page table for the top 2MB at the 4GB mark */
|
/* create an empty page table for the top 2MB at the 4GB mark */
|
||||||
movl $(boot_pd3 - KERNEL_VIRTUAL_BASE), %edi
|
movl $(boot_pd3 - KERNEL_BASE), %edi
|
||||||
movl $(boot_pd3_pt1023 - KERNEL_VIRTUAL_BASE), 4088(%edi)
|
movl $(boot_pd3_pt1023 - KERNEL_BASE), 4088(%edi)
|
||||||
orl $0x3, 4088(%edi)
|
orl $0x3, 4088(%edi)
|
||||||
movl $0, 4092(%edi)
|
movl $0, 4092(%edi)
|
||||||
|
|
||||||
#if ARCH(X86_64)
|
#if ARCH(X86_64)
|
||||||
/* point CR3 to PML4T */
|
/* point CR3 to PML4T */
|
||||||
movl $(boot_pml4t - KERNEL_VIRTUAL_BASE), %eax
|
movl $(boot_pml4t - KERNEL_BASE), %eax
|
||||||
#else
|
#else
|
||||||
/* point CR3 to PDPT */
|
/* point CR3 to PDPT */
|
||||||
movl $(boot_pdpt - KERNEL_VIRTUAL_BASE), %eax
|
movl $(boot_pdpt - KERNEL_BASE), %eax
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
movl %eax, %cr3
|
movl %eax, %cr3
|
||||||
|
@ -293,7 +293,7 @@ continue:
|
||||||
|
|
||||||
/* unmap the 0-1MB range, which isn't used after jmp-ing up here */
|
/* unmap the 0-1MB range, which isn't used after jmp-ing up here */
|
||||||
movl $256, %ecx
|
movl $256, %ecx
|
||||||
movl $(boot_pd0_pt0 - KERNEL_VIRTUAL_BASE), %edi
|
movl $(boot_pd0_pt0 - KERNEL_BASE), %edi
|
||||||
xorl %eax, %eax
|
xorl %eax, %eax
|
||||||
|
|
||||||
1:
|
1:
|
||||||
|
@ -302,7 +302,7 @@ continue:
|
||||||
loop 1b
|
loop 1b
|
||||||
|
|
||||||
/* jump into C++ land */
|
/* jump into C++ land */
|
||||||
addl $KERNEL_VIRTUAL_BASE, %ebx
|
addl $KERNEL_BASE, %ebx
|
||||||
movl %ebx, multiboot_info_ptr
|
movl %ebx, multiboot_info_ptr
|
||||||
|
|
||||||
#if ARCH(X86_64)
|
#if ARCH(X86_64)
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
.set KERNEL_VIRTUAL_BASE, 0xc0000000
|
#define _BOOTLOADER
|
||||||
|
#include <Kernel/Sections.h>
|
||||||
|
|
||||||
.extern init_ap
|
.extern init_ap
|
||||||
.type init_ap, @function
|
.type init_ap, @function
|
||||||
|
@ -109,7 +110,7 @@ apic_ap_start32_2:
|
||||||
|
|
||||||
/* push the Processor pointer this CPU is going to use */
|
/* push the Processor pointer this CPU is going to use */
|
||||||
movl (ap_cpu_init_processor_info_array - apic_ap_start)(%ebp), %eax
|
movl (ap_cpu_init_processor_info_array - apic_ap_start)(%ebp), %eax
|
||||||
addl $KERNEL_VIRTUAL_BASE, %eax
|
addl $KERNEL_BASE, %eax
|
||||||
movl 0(%eax, %esi, 4), %eax
|
movl 0(%eax, %esi, 4), %eax
|
||||||
push %eax
|
push %eax
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
.set KERNEL_VIRTUAL_BASE, 0xc0000000
|
#define _BOOTLOADER
|
||||||
|
#include <Kernel/Sections.h>
|
||||||
|
|
||||||
.extern init_ap
|
.extern init_ap
|
||||||
.type init_ap, @function
|
.type init_ap, @function
|
||||||
|
@ -124,7 +125,7 @@ apic_ap_start64:
|
||||||
|
|
||||||
/* push the Processor pointer this CPU is going to use */
|
/* push the Processor pointer this CPU is going to use */
|
||||||
movq (ap_cpu_init_processor_info_array - apic_ap_start)(%ebp), %rax
|
movq (ap_cpu_init_processor_info_array - apic_ap_start)(%ebp), %rax
|
||||||
movq $KERNEL_VIRTUAL_BASE, %r8
|
movq $KERNEL_BASE, %r8
|
||||||
addq %r8, %rax
|
addq %r8, %rax
|
||||||
movq 0(%rax, %rsi, 4), %rax
|
movq 0(%rax, %rsi, 4), %rax
|
||||||
push %rax
|
push %rax
|
||||||
|
|
|
@ -11,4 +11,4 @@
|
||||||
#define READONLY_AFTER_INIT __attribute__((section(".ro_after_init")))
|
#define READONLY_AFTER_INIT __attribute__((section(".ro_after_init")))
|
||||||
#define UNMAP_AFTER_INIT NEVER_INLINE __attribute__((section(".unmap_after_init")))
|
#define UNMAP_AFTER_INIT NEVER_INLINE __attribute__((section(".unmap_after_init")))
|
||||||
|
|
||||||
#define KERNEL_BASE 0xC000'0000
|
#define KERNEL_BASE 0xC0000000
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue