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
28 * $FreeBSD: src/sys/boot/pc98/boot2/boot2.S,v 1.3 2001/05/24 11:18:32 nyan Exp $
29 * $DragonFly: src/sys/boot/pc98/boot2/Attic/boot2.S,v 1.3 2003/11/10 06:08:38 dillon Exp $
32 * Ported to PC-9801 by Yoshio Kimura
37 /* Conventional GDT indexes. */
38 #define BOOT_CS_INDEX 3
39 #define BOOT_CS16_INDEX 5
40 #define BOOT_DS_INDEX 4
43 #define DB_CS_INDEX 14
44 #define DB_CS16_INDEX 15
45 #define DB_DS_INDEX 16
50 #define BREAKPOINT_VECTOR 3
51 #define DEBUG_VECTOR 1
54 * boot2() -- second stage boot
55 * SP points to default string if found
65 /* fix up GDT entries for bootstrap */
66 #define FIXUP(gdt_index) \
69 movl %eax, EXT(Gdt)+(8*gdt_index)+2; /* actually movw %ax */ \
71 movb %bl, EXT(Gdt)+(8*gdt_index)+4; \
76 FIXUP(BOOT_CS16_INDEX)
79 /* fix up GDT pointer */
85 movl %eax, EXT(Gdtr)+2
89 /* fix up GDT entry for GDT */
94 /* fix up IDT pointer */
99 movl %ecx, EXT(Idtr_prot)+2
101 /* %es = vector table segment for a while */
107 /* fix up GDT entries for bdb */
109 movl $4*DEBUG_VECTOR, %esi
111 movl %es: 2(%esi), %eax /* actually movw to %ax */
120 /* Fetch entry points of bdb's protected mode trap handlers. These
121 * are stored at 2 before the corresponding entry points for real mode.
126 movl %es: (%esi), %ebx /* actually movw to %bx */
130 movl %es: 4*(BREAKPOINT_VECTOR-DEBUG_VECTOR)(%esi), %ecx
131 /* actually movw to %cx */
133 /* %es = bdb segment for a while */
138 /* fix up IDT entries for bdb */
140 subl $2, %ebx /* calculate EA to check it */
141 jb 1f /* give up if it would trap */
143 movl %es: (%ebx), %eax /* actually movw to %ax */
145 movl %eax, EXT(Idt)+8*DEBUG_VECTOR /* actually movw %ax */
151 movl %es: (%ecx), %eax /* actually movw to %ax */
153 movl %eax, EXT(Idt)+8*BREAKPOINT_VECTOR /* actually movw %ax */
156 /* finished with groping in real mode segments */
158 #endif /* BDE_DEBUGGER */
160 /* change to protected mode */
163 call EXT(real_to_prot)
166 movl $ EXT(edata), %edi /* no EXT(_edata) - krufty ld */
167 movl $ EXT(end), %ecx /* or EXT(_end) */
174 movl %esp, EXT(dflt_name)
178 movb 0xA1584 - BOOTSEG * 0x10, %dl
180 movzbl %dl, %edx /* discard head (%dh) and random high bits */