2 * Mach Operating System
3 * Copyright (c) 1992, 1991 Carnegie Mellon University
6 * Permission to use, copy, modify and distribute this software and its
7 * documentation is hereby granted, provided that both the copyright
8 * notice and this permission notice appear in all copies of the
9 * software, derivative works or modified versions, and any portions
10 * thereof, and that both notices appear in supporting documentation.
12 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
13 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
14 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
16 * Carnegie Mellon requests users of this software to return to
18 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
19 * School of Computer Science
20 * Carnegie Mellon University
21 * Pittsburgh PA 15213-3890
23 * any improvements or extensions that they make and grant Carnegie Mellon
24 * the rights to redistribute these changes.
26 * from: Mach, Revision 2.2 92/04/04 11:35:26 rpd
27 * $FreeBSD: src/sys/i386/boot/biosboot/boot2.S,v 1.12 1999/08/28 00:43:13 peter Exp $
28 * $DragonFly: src/sys/i386/boot/biosboot/Attic/boot2.S,v 1.2 2003/06/17 04:28:34 dillon Exp $
33 /* Conventional GDT indexes. */
34 #define BOOT_CS_INDEX 3
35 #define BOOT_CS16_INDEX 5
36 #define BOOT_DS_INDEX 4
39 #define DB_CS_INDEX 14
40 #define DB_CS16_INDEX 15
41 #define DB_DS_INDEX 16
46 #define BREAKPOINT_VECTOR 3
47 #define DEBUG_VECTOR 1
50 * boot2() -- second stage boot
51 * SP points to default string if found
63 /* fix up GDT entries for bootstrap */
64 #define FIXUP(gdt_index) \
66 movl %eax, EXT(Gdt)+(8*gdt_index)+2; /* actually movw %ax */ \
68 movb %bl, EXT(Gdt)+(8*gdt_index)+4
73 FIXUP(BOOT_CS16_INDEX)
76 /* fix up GDT pointer */
83 movl %eax, EXT(Gdtr)+2
86 /* fix up GDT entry for GDT */
91 /* fix up IDT pointer */
96 movl %ecx, EXT(Idtr_prot)+2
98 /* %es = vector table segment for a while */
104 /* fix up GDT entries for bdb */
106 movl $4*DEBUG_VECTOR, %esi
108 movl %es: 2(%esi), %eax /* actually movw to %ax */
117 /* Fetch entry points of bdb's protected mode trap handlers. These
118 * are stored at 2 before the corresponding entry points for real mode.
123 movl %es: (%esi), %ebx /* actually movw to %bx */
127 movl %es: 4*(BREAKPOINT_VECTOR-DEBUG_VECTOR)(%esi), %ecx
128 /* actually movw to %cx */
130 /* %es = bdb segment for a while */
135 /* fix up IDT entries for bdb */
137 subl $2, %ebx /* calculate EA to check it */
138 jb 1f /* give up if it would trap */
140 movl %es: (%ebx), %eax /* actually movw to %ax */
142 movl %eax, EXT(Idt)+8*DEBUG_VECTOR /* actually movw %ax */
148 movl %es: (%ecx), %eax /* actually movw to %ax */
150 movl %eax, EXT(Idt)+8*BREAKPOINT_VECTOR /* actually movw %ax */
153 /* finished with groping in real mode segments */
155 #endif /* BDE_DEBUGGER */
157 /* change to protected mode */
159 call EXT(real_to_prot)
162 movl $ EXT(edata), %edi /* no EXT(_edata) - krufty ld */
163 movl $ EXT(end), %ecx /* or EXT(_end) */
170 movl %esp, EXT(dflt_name)
173 movzbl %dl, %edx /* discard head (%dh) and random high bits */