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:34:13 rpd
27 * $FreeBSD: src/sys/i386/boot/biosboot/asm.S,v 1.13 1999/08/28 00:43:11 peter Exp $
28 * $DragonFly: src/sys/i386/boot/biosboot/Attic/asm.S,v 1.2 2003/06/17 04:28:34 dillon Exp $
33 Copyright 1988, 1989, 1990, 1991, 1992
34 by Intel Corporation, Santa Clara, California.
38 Permission to use, copy, modify, and distribute this software and
39 its documentation for any purpose and without fee is hereby
40 granted, provided that the above copyright notice appears in all
41 copies and that both the copyright notice and this permission notice
42 appear in supporting documentation, and that the name of Intel
43 not be used in advertising or publicity pertaining to distribution
44 of the software without specific, written prior permission.
46 INTEL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE
47 INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
48 IN NO EVENT SHALL INTEL BE LIABLE FOR ANY SPECIAL, INDIRECT, OR
49 CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
50 LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT,
51 NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
52 WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
61 CR0_PE_OFF = 0xfffffffe
68 * transfer from real mode to protected mode.
72 /* guarantee that interrupt is disabled when in prot mode */
80 /* set the PE bit of CR0 */
88 * make intrasegment jump to flush the processor pipeline and
96 * we are in USE32 mode now
97 * set up the protected mode segment registers : DS, SS, ES, FS
99 movw $0x20, %ax /* data segment */
100 mov %ax, %ds /* gas would waste a prefix byte for movw */
103 movw $0x10, %ax /* flat segment */
107 /* load idtr so we can debug */
116 * transfer from protected mode to real mode
122 /* Prepare %ax while we're still in a mode that gas understands. */
125 /* Change to use16 mode. */
134 /* clear the PE bit of CR0 */
137 and $CR0_PE_OFF, %eax
141 * make intersegment jmp to flush the processor pipeline
142 * and reload CS register
145 ljmp $BOOTSEG, $xreal
149 * we are in real mode now
150 * set up the real mode segment registers : DS, SS, ES, FS
159 /* load idtr so we can debug */
170 * start the program on protected mode where phyaddr is the entry point
172 * XXX This whole mess should go away and we should run the boot code in
173 * flat 32 bit mode with it linked -T BOOTSEG. See the netboot code for
180 movl %esp, %eax /* Use eax as the old stack pointer */
182 /* convert the current stack to a 32 bit flat model */
185 addl $(BOOTSEG<<4),%esp
187 /* copy the arguments from the old stack to the new stack */
188 pushl 0x14(%eax) /* &bootinfo */
189 pushl $0 /* was &nfsdiskless */
190 pushl $0 /* was esym */
191 pushl $0 /* was cyloffset */
192 pushl 0x10(%eax) /* bootdev */
193 pushl 0x0C(%eax) /* howto */
194 movl $(ourreturn),%ebx
195 addl $(BOOTSEG<<4),%ebx /* Fix it up for flat segments */
196 pushl %ebx /* our return address */
198 /* push on our entry address */
199 pushl $0x08 /* segment selector */
200 pushl 0x08(%eax) /* kernel entry address */
202 /* convert over the other data segs */
207 /* convert the PC (and code seg) */
210 /* For now there is not much we can do, just lock in a loop */
214 * pcpy(src, dst, cnt)
215 * where src is a virtual address and dst is a physical address
228 /* set %es to point at the flat segment */
232 mov 0x8(%ebp), %esi /* source */
233 mov 0xc(%ebp), %edi /* destination */
234 mov 0x10(%ebp), %ecx /* count */