2 * (c) 2009 Adam Lackorzynski <adam@os.inf.tu-dresden.de>,
3 * Frank Mehnert <fm3@os.inf.tu-dresden.de>
4 * economic rights: Technische Universität Dresden (Germany)
6 * This file is part of TUD:OS and distributed under the terms of the
7 * GNU General Public License 2.
8 * Please see the COPYING-GPL-2 file for details.
10 #include <l4/sys/compiler.h>
14 #define X86_CR0_PE 0x00000001
15 #define X86_CR0_WP 0x00010000
16 #define X86_CR0_PG 0x80000000
18 #define X86_CR4_PSE 0x00000010
20 #define MSR_MTRR_DEF_TYPE 0x000002ff
21 #define MTRR_ENABLE 0x00000800
24 .section ".jh.boot", "ax"
30 .section ".jh.startup", "ax"
39 ljmpl $INMATE_CS32,$_start
46 .quad 0x00cf9b000000ffff
47 .quad 0x00af9b000000ffff
48 .quad 0x00cf93000000ffff
51 .short gdt_ptr - loader_gdt - 1
52 .long loader_gdt + FSEGMENT_BASE
66 #ifdef REALMODE_LOADING
72 mov $loader_pdpt + FSEGMENT_BASE,%eax
75 mov $(X86_CR0_PG | X86_CR0_WP | X86_CR0_PE),%eax
79 movl $MSR_MTRR_DEF_TYPE,%ecx
97 pushl $0 /* No Xen start_info pointer */
102 /* initialize vector for exception 6 */
103 movl $trap6_entry,%eax
104 movw %ax, _idt_offset_low
106 movw %ax, _idt_offset_high
108 movw %ax, _idt_selector
110 /* load tiny interrupt descriptor table to catch exception 6 */
117 /* Show an error message and wait for keypress to reboot. */
125 * edx: value to print
126 * eax: location on screen
130 98: mov $numbers,%ebx
134 movzbl (%ebx,%ecx,1),%ecx
143 /* print out warning */
144 movl $trap6_warning, %esi
145 movl $(0xb8000 + (24*80*2)), %edi
148 1: /* read next character from string */
151 /* check for end-of-string */
155 /* Check for hex number */
159 mov (32 + 32)(%esp),%edx
166 4: /* check for newline */
173 /* move screen upwards 1 line */
174 movl $((24*80*2)/4), %ecx
175 movl $(0xb8000 + 1*80*2), %esi
179 /* clear last line of screen */
180 movl $((1*80*2)/4), %ecx
181 movl $0x07200720, %eax
187 /* jump to new line */
188 movl $(0xb8000 + (24*80*2)), %edi
191 2: /* print character */
195 3: /* wait for keypress */
202 /* empty keyboard buffer */
205 /* ignore PS/2 mouse events */
212 /* the warning text */
215 .ascii "Bootstrap: Invalid opcode at detected!\n"
216 .ascii "Be sure that you don't use any CPU optimization flags like\n"
217 .ascii " -march=i686\n"
218 .ascii "when compiling Bootstrap and the depending libraries.\n"
220 .asciz " Press any key to reboot..."
223 .ascii "0123456789abcdef"
225 /* MultiBoot header - see multiboot.h. */
228 #define MULTIBOOT_MEMORY_INFO 0x00000002
230 .long 0x1BADB002 /* magic */
231 .long MULTIBOOT_MEMORY_INFO /* flags: AOUT_KLUDGE */
232 .long 0 - 0x1BADB002 - MULTIBOOT_MEMORY_INFO
241 .word 0,0,0,0 /* trap 0 */
242 .word 0,0,0,0 /* trap 1 */
243 .word 0,0,0,0 /* trap 2 */
244 .word 0,0,0,0 /* trap 3 */
245 .word 0,0,0,0 /* trap 4 */
246 .word 0,0,0,0 /* trap 5 */
258 #ifdef REALMODE_LOADING