Nucleus
Barry ACPI + APIC 232d0f9 (3 years, 3 months ago)diff --git a/kernel/acpi/trampoline.S b/kernel/acpi/trampoline.S new file mode 100644 index 0000000..5438967 --- /dev/null +++ b/kernel/acpi/trampoline.S @@ -0,0 +1,79 @@ +/* + * This file contains the AP trampoline code to bounce it back into protected + * mode and run the kernel on them. The location of the stack is set by the + * calling code. This code runs initially in real mode, at 0x1000 in physical + * memory. + */ + +.extern ap_startup +.type ap_startup, @function + +.global ap_trampoline +.type ap_trampoline, @function +.align 4 +ap_trampoline: +.code16 + cli + jmp $0x100, $(1f - ap_trampoline) +1: + mov %cs, %ax + mov %ax, %ds + + xor %ax, %ax + mov %ax, %sp + + /* Load the GDT */ + lgdt (ap_gdt_desc - ap_trampoline) + + /* Enable PM */ + movl %cr0, %eax + orl $1, %eax + movl %eax, %cr0 + + ljmpl $8, $(ap_pm - ap_trampoline + 0x1000) + +ap_pm: +.code32 + mov $0x10, %ax + mov %ax, %ss + mov %ax, %ds + mov %ax, %es + mov %ax, %fs + mov %ax, %gs + + movl $0x1000, %ebp + movl %ebp, %esp + + movl ap_id, %eax + incl %eax + movl %eax, ap_id + + movl $0x1F00, %esi + movl (%esi,%eax), %ebx + movl %ebx, %esp + movl %esp, %ebp + + sti + jmp $8, $(ap_startup) + + cli +1: + hlt + jmp 1b + +.align 4 +ap_gdt_start: + /* Null */ + .4byte 0x00000000 + .4byte 0x00000000 + /* Code */ + .4byte 0x0000FFFF + .4byte 0x00CF9A00 + /* Data */ + .4byte 0x0000FFFF + .4byte 0x00CF9200 +ap_gdt_desc: + .2byte ap_gdt_desc - ap_gdt_start - 1 + .4byte (ap_gdt_start - ap_trampoline) + 0x1000 +ap_id: + .4byte 0