2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_OSREFERENCE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the
10 * License may not be used to create, or enable the creation or
11 * redistribution of, unlawful or unlicensed copies of an Apple operating
12 * system, or to circumvent, violate, or enable the circumvention or
13 * violation of, any terms of an Apple operating system software license
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
20 * The Original Code and all software distributed under the License are
21 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
22 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
23 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
25 * Please see the License for the specific language governing rights and
26 * limitations under the License.
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
35 * Mach Operating System
36 * Copyright (c) 1991,1990 Carnegie Mellon University
37 * All Rights Reserved.
39 * Permission to use, copy, modify and distribute this software and its
40 * documentation is hereby granted, provided that both the copyright
41 * notice and this permission notice appear in all copies of the
42 * software, derivative works or modified versions, and any portions
43 * thereof, and that both notices appear in supporting documentation.
45 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
46 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
47 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
49 * Carnegie Mellon requests users of this software to return to
51 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
52 * School of Computer Science
53 * Carnegie Mellon University
54 * Pittsburgh PA 15213-3890
56 * any improvements or extensions that they make and grant Carnegie Mellon
57 * the rights to redistribute these changes.
61 #include <i386/mp_slave_boot.h>
62 #include <i386/postcode.h>
65 #define CR0_PE_OFF 0xfffffffe
70 .align 12 // Page align for single bcopy_phys()
72 #define LJMP(segment,address) \
74 .long address-EXT(slave_boot_base) ;\
77 #define LGDT(address) \
80 .long address-EXT(slave_boot_base)
82 Entry(slave_boot_base)
83 /* code is loaded at 0x0:0x1000 */
84 /* ljmp to the next instruction to set up %cs */
86 LJMP(MP_BOOTSEG, EXT(slave_pstart))
93 POSTCODE(SLAVE_PSTART_ENTRY);
95 /* set up %ss and %esp */
97 mov $(MP_BOOTSEG), %eax
100 mov $(MP_BOOTSTACK), %esp
105 /* change to protected mode */
107 call EXT(real_to_prot)
114 transfer from real mode to protected mode.
118 /* guarantee that interrupt is disabled when in prot mode */
121 POSTCODE(REAL_TO_PROT_ENTRY);
129 /* set the PE bit of CR0 */
133 or $(CR0_PE_ON), %eax
136 /* make intrasegment jump to flush the processor pipeline and */
137 /* reload CS register */
143 /* we are in USE32 mode now */
144 /* set up the protective mode segment registers : DS, SS, ES */
150 POSTCODE(REAL_TO_PROT_EXIT);
156 start the program on protected mode where phyaddr is the entry point
163 POSTCODE(STARTPROG_ENTRY);
165 movl 0x8(%ebp), %ecx /* entry offset */
166 movl $0x28, %ebx /* segment */
170 /* set up %ds and %es */
175 POSTCODE(STARTPROG_EXIT);
180 . = MP_BOOTGDT-MP_BOOT /* GDT location */
183 /* Segment Descriptor
186 * ------------------------------------------------------------
187 * | | |B| |A| | | |1|0|E|W|A| |
188 * | BASE 31..24 |G|/|0|V| LIMIT |P|DPL| TYPE | BASE 23:16 |
189 * | | |D| |L| 19..16| | |1|1|C|R|A| |
190 * ------------------------------------------------------------
192 * | BASE 15..0 | LIMIT 15..0 |
194 * ------------------------------------------------------------
196 .word 0,0 /* 0x0 : null */
199 .word 0xffff,MP_BOOT /* 0x8 : boot code */
202 .word 0xffff,MP_BOOT /* 0x10 : boot data */
205 .word 0xffff,MP_BOOT /* 0x18 : boot code, 16 bits */
208 .word 0xffff,0 /* 0x20 : init data */
211 .word 0xffff,0 /* 0x28 : init code */
215 .short 48 /* limit (8*6 segs) */
216 .short MP_BOOTGDT /* base low */
217 .short 0 /* base high */
219 Entry(slave_boot_end)