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
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 */
81 /* set the PE bit of CR0 */
88 * make intrasegment jump to flush the processor pipeline and
98 * we are in USE32 mode now
99 * set up the protected mode segment registers : DS, SS, ES, FS
102 movw $0x20, %ax /* data segment */
103 mov %ax, %ds /* gas would waste a prefix byte for movw */
107 movw $0x10, %ax /* flat segment */
111 /* load idtr so we can debug */
120 * transfer from protected mode to real mode
126 /* Prepare %ax while we're still in a mode that gas understands. */
130 /* Change to use16 mode. */
141 /* clear the PE bit of CR0 */
143 and $CR0_PE_OFF, %eax
147 * make intersegment jmp to flush the processor pipeline
148 * and reload CS register
152 ljmp $BOOTSEG, $xreal
157 * we are in real mode now
158 * set up the real mode segment registers : DS, SS, ES, FS
167 /* load idtr so we can debug */
178 * start the program on protected mode where phyaddr is the entry point
180 * XXX This whole mess should go away and we should run the boot code in
181 * flat 32 bit mode with it linked -T BOOTSEG. See the netboot code for
189 movl %esp, %eax /* Use eax as the old stack pointer */
191 /* convert the current stack to a 32 bit flat model */
195 addl $(BOOTSEG<<4),%esp
197 /* copy the arguments from the old stack to the new stack */
198 pushl 0x14(%eax) /* &bootinfo */
199 pushl $0 /* was &nfsdiskless */
200 pushl $0 /* was esym */
201 pushl $0 /* was cyloffset */
202 pushl 0x10(%eax) /* bootdev */
203 pushl 0x0C(%eax) /* howto */
204 movl $(ourreturn),%ebx
205 addl $(BOOTSEG<<4),%ebx /* Fix it up for flat segments */
206 pushl %ebx /* our return address */
208 /* push on our entry address */
209 pushl $0x08 /* segment selector */
210 pushl 0x08(%eax) /* kernel entry address */
212 /* convert over the other data segs */
219 /* convert the PC (and code seg) */
222 /* For now there is not much we can do, just lock in a loop */
226 * pcpy(src, dst, cnt)
227 * where src is a virtual address and dst is a physical address
241 /* set %es to point at the flat segment */
245 mov 0x8(%ebp), %esi /* source */
246 mov 0xc(%ebp), %edi /* destination */
247 mov 0x10(%ebp), %ecx /* count */