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 $
32 Copyright 1988, 1989, 1990, 1991, 1992
33 by Intel Corporation, Santa Clara, California.
37 Permission to use, copy, modify, and distribute this software and
38 its documentation for any purpose and without fee is hereby
39 granted, provided that the above copyright notice appears in all
40 copies and that both the copyright notice and this permission notice
41 appear in supporting documentation, and that the name of Intel
42 not be used in advertising or publicity pertaining to distribution
43 of the software without specific, written prior permission.
45 INTEL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE
46 INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
47 IN NO EVENT SHALL INTEL BE LIABLE FOR ANY SPECIAL, INDIRECT, OR
48 CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
49 LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT,
50 NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
51 WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
60 CR0_PE_OFF = 0xfffffffe
67 * transfer from real mode to protected mode.
71 /* guarantee that interrupt is disabled when in prot mode */
79 /* set the PE bit of CR0 */
87 * make intrasegment jump to flush the processor pipeline and
95 * we are in USE32 mode now
96 * set up the protected mode segment registers : DS, SS, ES, FS
98 movw $0x20, %ax /* data segment */
99 mov %ax, %ds /* gas would waste a prefix byte for movw */
102 movw $0x10, %ax /* flat segment */
106 /* load idtr so we can debug */
115 * transfer from protected mode to real mode
121 /* Prepare %ax while we're still in a mode that gas understands. */
124 /* Change to use16 mode. */
133 /* clear the PE bit of CR0 */
136 and $CR0_PE_OFF, %eax
140 * make intersegment jmp to flush the processor pipeline
141 * and reload CS register
144 ljmp $BOOTSEG, $xreal
148 * we are in real mode now
149 * set up the real mode segment registers : DS, SS, ES, FS
158 /* load idtr so we can debug */
169 * start the program on protected mode where phyaddr is the entry point
171 * XXX This whole mess should go away and we should run the boot code in
172 * flat 32 bit mode with it linked -T BOOTSEG. See the netboot code for
179 movl %esp, %eax /* Use eax as the old stack pointer */
181 /* convert the current stack to a 32 bit flat model */
184 addl $(BOOTSEG<<4),%esp
186 /* copy the arguments from the old stack to the new stack */
187 pushl 0x14(%eax) /* &bootinfo */
188 pushl $0 /* was &nfsdiskless */
189 pushl $0 /* was esym */
190 pushl $0 /* was cyloffset */
191 pushl 0x10(%eax) /* bootdev */
192 pushl 0x0C(%eax) /* howto */
193 movl $(ourreturn),%ebx
194 addl $(BOOTSEG<<4),%ebx /* Fix it up for flat segments */
195 pushl %ebx /* our return address */
197 /* push on our entry address */
198 pushl $0x08 /* segment selector */
199 pushl 0x08(%eax) /* kernel entry address */
201 /* convert over the other data segs */
206 /* convert the PC (and code seg) */
209 /* For now there is not much we can do, just lock in a loop */
213 * pcpy(src, dst, cnt)
214 * where src is a virtual address and dst is a physical address
227 /* set %es to point at the flat segment */
231 mov 0x8(%ebp), %esi /* source */
232 mov 0xc(%ebp), %edi /* destination */
233 mov 0x10(%ebp), %ecx /* count */