2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_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. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
28 * Mach Operating System
29 * Copyright (c) 1991,1990 Carnegie Mellon University
30 * All Rights Reserved.
32 * Permission to use, copy, modify and distribute this software and its
33 * documentation is hereby granted, provided that both the copyright
34 * notice and this permission notice appear in all copies of the
35 * software, derivative works or modified versions, and any portions
36 * thereof, and that both notices appear in supporting documentation.
38 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
39 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
40 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
42 * Carnegie Mellon requests users of this software to return to
44 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
45 * School of Computer Science
46 * Carnegie Mellon University
47 * Pittsburgh PA 15213-3890
49 * any improvements or extensions that they make and grant Carnegie Mellon
50 * the rights to redistribute these changes.
54 #include <i386/mp_slave_boot.h>
55 #include <i386/postcode.h>
58 #define CR0_PE_OFF 0xfffffffe
63 .align 12 // Page align for single bcopy_phys()
65 #define LJMP(segment,address) \
67 .long address-EXT(slave_boot_base) ;\
70 #define LGDT(address) \
73 .long address-EXT(slave_boot_base)
75 Entry(slave_boot_base)
76 /* code is loaded at 0x0:0x1000 */
77 /* ljmp to the next instruction to set up %cs */
79 LJMP(MP_BOOTSEG, EXT(slave_pstart))
86 POSTCODE(SLAVE_PSTART_ENTRY);
88 /* set up %ss and %esp */
90 mov $(MP_BOOTSEG), %eax
93 mov $(MP_BOOTSTACK), %esp
98 /* change to protected mode */
100 call EXT(real_to_prot)
107 transfer from real mode to protected mode.
111 /* guarantee that interrupt is disabled when in prot mode */
114 POSTCODE(REAL_TO_PROT_ENTRY);
122 /* set the PE bit of CR0 */
126 or $(CR0_PE_ON), %eax
129 /* make intrasegment jump to flush the processor pipeline and */
130 /* reload CS register */
136 /* we are in USE32 mode now */
137 /* set up the protective mode segment registers : DS, SS, ES */
143 POSTCODE(REAL_TO_PROT_EXIT);
149 start the program on protected mode where phyaddr is the entry point
156 POSTCODE(STARTPROG_ENTRY);
158 movl 0x8(%ebp), %ecx /* entry offset */
159 movl $0x28, %ebx /* segment */
163 /* set up %ds and %es */
168 POSTCODE(STARTPROG_EXIT);
173 . = MP_BOOTGDT-MP_BOOT /* GDT location */
176 /* Segment Descriptor
179 * ------------------------------------------------------------
180 * | | |B| |A| | | |1|0|E|W|A| |
181 * | BASE 31..24 |G|/|0|V| LIMIT |P|DPL| TYPE | BASE 23:16 |
182 * | | |D| |L| 19..16| | |1|1|C|R|A| |
183 * ------------------------------------------------------------
185 * | BASE 15..0 | LIMIT 15..0 |
187 * ------------------------------------------------------------
189 .word 0,0 /* 0x0 : null */
192 .word 0xffff,MP_BOOT /* 0x8 : boot code */
195 .word 0xffff,MP_BOOT /* 0x10 : boot data */
198 .word 0xffff,MP_BOOT /* 0x18 : boot code, 16 bits */
201 .word 0xffff,0 /* 0x20 : init data */
204 .word 0xffff,0 /* 0x28 : init code */
208 .short 48 /* limit (8*6 segs) */
209 .short MP_BOOTGDT /* base low */
210 .short 0 /* base high */
212 Entry(slave_boot_end)