|
|
1.1 root 1:
2: #include <mach/machine/asm.h>
3:
1.1.1.2 ! root 4: #include <i386/i386asm.h>
1.1 root 5:
1.1.1.2 ! root 6: /*
! 7: * This section will be put first into .text. See also i386/ldscript.
! 8: */
! 9: .section .text.start,"ax"
! 10:
1.1 root 11: /* We should never be entered this way. */
12: .globl start,_start
13: start:
14: _start:
15: jmp boot_entry
16:
17: /* MultiBoot header - see multiboot.h. */
18: #define MULTIBOOT_MAGIC 0x1BADB002
19: #ifdef __ELF__
20: #define MULTIBOOT_FLAGS 0x00000002
21: #else /* __ELF__ */
22: #define MULTIBOOT_FLAGS 0x00010002
23: #endif /* __ELF__ */
24: P2ALIGN(2)
25: boot_hdr:
26: .long MULTIBOOT_MAGIC
27: .long MULTIBOOT_FLAGS
28: /*
29: * The next item here is the checksum.
30: * XX this works OK until we need at least the 30th bit.
31: */
32: .long - (MULTIBOOT_MAGIC+MULTIBOOT_FLAGS)
33: #ifndef __ELF__ /* a.out kludge */
34: .long boot_hdr /* header_addr */
35: .long _start /* load_addr */
36: .long _edata /* load_end_addr */
37: .long _end /* bss_end_addr */
38: .long boot_entry /* entry */
39: #endif /* __ELF__ */
40:
41: boot_entry:
1.1.1.2 ! root 42: /* use segmentation to offset ourself. */
! 43: lgdt boot_gdt_descr - KERNELBASE
! 44: ljmp $8,$0f
! 45: 0:
! 46: movw $0,%ax
! 47: movw %ax,%ds
! 48: movw %ax,%es
! 49: movw %ax,%fs
! 50: movw %ax,%gs
! 51: movw $16,%ax
! 52: movw %ax,%ds
! 53: movw %ax,%es
! 54: movw %ax,%ss
1.1 root 55:
56: /* Switch to our own interrupt stack. */
57: movl $_intstack+INTSTACK_SIZE,%esp
58:
59: /* Reset EFLAGS to a known state. */
60: pushl $0
61: popf
62:
63: /* Clear uninitialized data. */
64: lea _edata,%edi
65: lea _end,%ecx
66: subl %edi,%ecx
67: xorl %eax,%eax
68: rep
69: stosb
70:
71: /* Push the boot_info pointer to be the second argument. */
72: pushl %ebx
73:
1.1.1.2 ! root 74: /* Fix ifunc entries */
! 75: movl $__rel_iplt_start,%esi
! 76: movl $__rel_iplt_end,%edi
! 77: iplt_cont:
! 78: cmpl %edi,%esi
! 79: jae iplt_done
! 80: movl (%esi),%ebx /* r_offset */
! 81: movb 4(%esi),%al /* info */
! 82: cmpb $42,%al /* IRELATIVE */
! 83: jnz iplt_next
! 84: call *(%ebx) /* call ifunc */
! 85: movl %eax,(%ebx) /* fixed address */
! 86: iplt_next:
! 87: addl $8,%esi
! 88: jmp iplt_cont
! 89: iplt_done:
! 90:
1.1 root 91: /* Jump into C code. */
92: call EXT(c_boot_entry)
93:
94: .comm _intstack,INTSTACK_SIZE
95:
1.1.1.2 ! root 96: .align 16
! 97: .word 0
! 98: boot_gdt_descr:
! 99: .word 3*8+7
! 100: .long boot_gdt - KERNELBASE
! 101: .align 16
! 102: boot_gdt:
! 103: /* 0 */
! 104: .quad 0
! 105: /* boot CS = 8 */
! 106: .word 0xffff
! 107: .word (-KERNELBASE) & 0xffff
! 108: .byte ((-KERNELBASE) >> 16) & 0xff
! 109: .byte 0x9a
! 110: .byte 0xcf
! 111: .byte ((-KERNELBASE) >> 24) & 0xff
! 112: /* boot DS = 8 */
! 113: .word 0xffff
! 114: .word (-KERNELBASE) & 0xffff
! 115: .byte ((-KERNELBASE) >> 16) & 0xff
! 116: .byte 0x92
! 117: .byte 0xcf
! 118: .byte ((-KERNELBASE) >> 24) & 0xff
! 119:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.