Changeset View
Changeset View
Standalone View
Standalone View
sys/amd64/amd64/locore.S
Show First 20 Lines • Show All 48 Lines • ▼ Show 20 Lines | |||||
* | * | ||||
* We are called with the stack looking like this: | * We are called with the stack looking like this: | ||||
* 0(%rsp) = 32 bit return address (cannot be used) | * 0(%rsp) = 32 bit return address (cannot be used) | ||||
* 4(%rsp) = 32 bit modulep | * 4(%rsp) = 32 bit modulep | ||||
* 8(%rsp) = 32 bit kernend | * 8(%rsp) = 32 bit kernend | ||||
* | * | ||||
* We are already in long mode, on a 64 bit %cs and running at KERNBASE. | * We are already in long mode, on a 64 bit %cs and running at KERNBASE. | ||||
*/ | */ | ||||
NON_GPROF_ENTRY(btext) | ENTRY(btext) | ||||
/* Tell the bios to warmboot next time */ | /* Tell the bios to warmboot next time */ | ||||
movw $0x1234,0x472 | movw $0x1234,0x472 | ||||
/* Don't trust what the loader gives for rflags. */ | /* Don't trust what the loader gives for rflags. */ | ||||
pushq $PSL_KERNEL | pushq $PSL_KERNEL | ||||
popfq | popfq | ||||
/* Find the metadata pointers before we lose them */ | /* Find the metadata pointers before we lose them */ | ||||
movq %rsp, %rbp | movq %rsp, %rbp | ||||
movl 4(%rbp),%edi /* modulep (arg 1) */ | movl 4(%rbp),%edi /* modulep (arg 1) */ | ||||
movl 8(%rbp),%esi /* kernend (arg 2) */ | movl 8(%rbp),%esi /* kernend (arg 2) */ | ||||
/* Get onto a stack that we can trust - there is no going back now. */ | /* Get onto a stack that we can trust - there is no going back now. */ | ||||
movq $bootstack,%rsp | movq $bootstack,%rsp | ||||
xorl %ebp, %ebp | xorl %ebp, %ebp | ||||
call hammer_time /* set up cpu for unix operation */ | call hammer_time /* set up cpu for unix operation */ | ||||
movq %rax,%rsp /* set up kstack for mi_startup() */ | movq %rax,%rsp /* set up kstack for mi_startup() */ | ||||
call mi_startup /* autoconfiguration, mountroot etc */ | call mi_startup /* autoconfiguration, mountroot etc */ | ||||
0: hlt | 0: hlt | ||||
jmp 0b | jmp 0b | ||||
/* la57_trampoline(%rdi pml5) */ | /* la57_trampoline(%rdi pml5) */ | ||||
NON_GPROF_ENTRY(la57_trampoline) | ENTRY(la57_trampoline) | ||||
movq %rsp,%r11 | movq %rsp,%r11 | ||||
movq %rbx,%r10 | movq %rbx,%r10 | ||||
leaq la57_trampoline_end(%rip),%rsp | leaq la57_trampoline_end(%rip),%rsp | ||||
movq %cr0,%rdx | movq %cr0,%rdx | ||||
lgdtq la57_trampoline_gdt_desc(%rip) | lgdtq la57_trampoline_gdt_desc(%rip) | ||||
pushq $(2<<3) | pushq $(2<<3) | ||||
Show All 22 Lines | l1: movl $(3<<3),%eax | ||||
pushl %ebx | pushl %ebx | ||||
lretl | lretl | ||||
.code64 | .code64 | ||||
l2: movq %r11,%rsp | l2: movq %r11,%rsp | ||||
movq %r10,%rbx | movq %r10,%rbx | ||||
retq | retq | ||||
.p2align 4,0 | .p2align 4,0 | ||||
NON_GPROF_ENTRY(la57_trampoline_gdt_desc) | ENTRY(la57_trampoline_gdt_desc) | ||||
.word la57_trampoline_end - la57_trampoline_gdt | .word la57_trampoline_end - la57_trampoline_gdt | ||||
.long 0 /* filled by pmap_bootstrap_la57 */ | .long 0 /* filled by pmap_bootstrap_la57 */ | ||||
.p2align 4,0 | .p2align 4,0 | ||||
NON_GPROF_ENTRY(la57_trampoline_gdt) | ENTRY(la57_trampoline_gdt) | ||||
.long 0x00000000 /* null desc */ | .long 0x00000000 /* null desc */ | ||||
.long 0x00000000 | .long 0x00000000 | ||||
.long 0x00000000 /* 64bit code */ | .long 0x00000000 /* 64bit code */ | ||||
.long 0x00209800 | .long 0x00209800 | ||||
.long 0x0000ffff /* 32bit code */ | .long 0x0000ffff /* 32bit code */ | ||||
.long 0x00cf9b00 | .long 0x00cf9b00 | ||||
.long 0x0000ffff /* universal data */ | .long 0x0000ffff /* universal data */ | ||||
.long 0x00cf9300 | .long 0x00cf9300 | ||||
.dcb.l 16,0 | .dcb.l 16,0 | ||||
NON_GPROF_ENTRY(la57_trampoline_end) | ENTRY(la57_trampoline_end) | ||||
.bss | .bss | ||||
ALIGN_DATA /* just to be sure */ | ALIGN_DATA /* just to be sure */ | ||||
.globl bootstack | .globl bootstack | ||||
.space 0x1000 /* space for bootstack - temporary stack */ | .space 0x1000 /* space for bootstack - temporary stack */ | ||||
bootstack: | bootstack: |