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 * boot2.S,v 1.6 1995/01/25 21:37:40 bde Exp
31 * Ported to PC-9801 by Yoshio Kimura
36 /* Conventional GDT indexes. */
37 #define BOOT_CS_INDEX 3
38 #define BOOT_CS16_INDEX 5
39 #define BOOT_DS_INDEX 4
42 #define DB_CS_INDEX 14
43 #define DB_CS16_INDEX 15
44 #define DB_DS_INDEX 16
49 #define BREAKPOINT_VECTOR 3
50 #define DEBUG_VECTOR 1
53 * boot2() -- second stage boot
54 * SP points to default string if found
64 /* fix up GDT entries for bootstrap */
65 #define FIXUP(gdt_index) \
68 movl %eax, EXT(Gdt)+(8*gdt_index)+2; /* actually movw %ax */ \
70 movb %bl, EXT(Gdt)+(8*gdt_index)+4; \
75 FIXUP(BOOT_CS16_INDEX)
78 /* fix up GDT pointer */
84 movl %eax, EXT(Gdtr)+2
88 /* fix up GDT entry for GDT */
93 /* fix up IDT pointer */
98 movl %ecx, EXT(Idtr_prot)+2
100 /* %es = vector table segment for a while */
106 /* fix up GDT entries for bdb */
108 movl $4*DEBUG_VECTOR, %esi
110 movl %es: 2(%esi), %eax /* actually movw to %ax */
119 /* Fetch entry points of bdb's protected mode trap handlers. These
120 * are stored at 2 before the corresponding entry points for real mode.
125 movl %es: (%esi), %ebx /* actually movw to %bx */
129 movl %es: 4*(BREAKPOINT_VECTOR-DEBUG_VECTOR)(%esi), %ecx
130 /* actually movw to %cx */
132 /* %es = bdb segment for a while */
137 /* fix up IDT entries for bdb */
139 subl $2, %ebx /* calculate EA to check it */
140 jb 1f /* give up if it would trap */
142 movl %es: (%ebx), %eax /* actually movw to %ax */
144 movl %eax, EXT(Idt)+8*DEBUG_VECTOR /* actually movw %ax */
150 movl %es: (%ecx), %eax /* actually movw to %ax */
152 movl %eax, EXT(Idt)+8*BREAKPOINT_VECTOR /* actually movw %ax */
155 /* finished with groping in real mode segments */
157 #endif /* BDE_DEBUGGER */
159 /* change to protected mode */
162 call EXT(real_to_prot)
165 movl $ EXT(edata), %edi /* no EXT(_edata) - krufty ld */
166 movl $ EXT(end), %ecx /* or EXT(_end) */
173 movl %esp, EXT(dflt_name)
176 movb 0xA1584 - BOOTSEG * 0x10, %dl
177 movzbl %dl, %edx /* discard head (%dh) and random high bits */