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 $
32 /* Conventional GDT indexes. */
33 #define BOOT_CS_INDEX 3
34 #define BOOT_CS16_INDEX 5
35 #define BOOT_DS_INDEX 4
38 #define DB_CS_INDEX 14
39 #define DB_CS16_INDEX 15
40 #define DB_DS_INDEX 16
45 #define BREAKPOINT_VECTOR 3
46 #define DEBUG_VECTOR 1
49 * boot2() -- second stage boot
50 * SP points to default string if found
62 /* fix up GDT entries for bootstrap */
63 #define FIXUP(gdt_index) \
65 movl %eax, EXT(Gdt)+(8*gdt_index)+2; /* actually movw %ax */ \
67 movb %bl, EXT(Gdt)+(8*gdt_index)+4
72 FIXUP(BOOT_CS16_INDEX)
75 /* fix up GDT pointer */
82 movl %eax, EXT(Gdtr)+2
85 /* fix up GDT entry for GDT */
90 /* fix up IDT pointer */
95 movl %ecx, EXT(Idtr_prot)+2
97 /* %es = vector table segment for a while */
103 /* fix up GDT entries for bdb */
105 movl $4*DEBUG_VECTOR, %esi
107 movl %es: 2(%esi), %eax /* actually movw to %ax */
116 /* Fetch entry points of bdb's protected mode trap handlers. These
117 * are stored at 2 before the corresponding entry points for real mode.
122 movl %es: (%esi), %ebx /* actually movw to %bx */
126 movl %es: 4*(BREAKPOINT_VECTOR-DEBUG_VECTOR)(%esi), %ecx
127 /* actually movw to %cx */
129 /* %es = bdb segment for a while */
134 /* fix up IDT entries for bdb */
136 subl $2, %ebx /* calculate EA to check it */
137 jb 1f /* give up if it would trap */
139 movl %es: (%ebx), %eax /* actually movw to %ax */
141 movl %eax, EXT(Idt)+8*DEBUG_VECTOR /* actually movw %ax */
147 movl %es: (%ecx), %eax /* actually movw to %ax */
149 movl %eax, EXT(Idt)+8*BREAKPOINT_VECTOR /* actually movw %ax */
152 /* finished with groping in real mode segments */
154 #endif /* BDE_DEBUGGER */
156 /* change to protected mode */
158 call EXT(real_to_prot)
161 movl $ EXT(edata), %edi /* no EXT(_edata) - krufty ld */
162 movl $ EXT(end), %ecx /* or EXT(_end) */
169 movl %esp, EXT(dflt_name)
172 movzbl %dl, %edx /* discard head (%dh) and random high bits */