2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
27 * Mach Operating System
28 * Copyright (c) 1991,1990 Carnegie Mellon University
29 * All Rights Reserved.
31 * Permission to use, copy, modify and distribute this software and its
32 * documentation is hereby granted, provided that both the copyright
33 * notice and this permission notice appear in all copies of the
34 * software, derivative works or modified versions, and any portions
35 * thereof, and that both notices appear in supporting documentation.
37 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
38 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
39 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
41 * Carnegie Mellon requests users of this software to return to
43 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
44 * School of Computer Science
45 * Carnegie Mellon University
46 * Pittsburgh PA 15213-3890
48 * any improvements or extensions that they make and grant Carnegie Mellon
49 * the rights to redistribute these changes.
53 #include <i386/mp_slave_boot.h>
54 #include <i386/postcode.h>
57 #define CR0_PE_OFF 0xfffffffe
62 .align 12 // Page align for single bcopy_phys()
64 #define LJMP(segment,address) \
66 .long address-EXT(slave_boot_base) ;\
69 #define LGDT(address) \
72 .long address-EXT(slave_boot_base)
74 Entry(slave_boot_base)
75 /* code is loaded at 0x0:0x1000 */
76 /* ljmp to the next instruction to set up %cs */
78 LJMP(MP_BOOTSEG, EXT(slave_pstart))
85 POSTCODE(SLAVE_PSTART_ENTRY);
87 /* set up %ss and %esp */
89 mov $(MP_BOOTSEG), %eax
92 mov $(MP_BOOTSTACK), %esp
97 /* change to protected mode */
99 call EXT(real_to_prot)
106 transfer from real mode to protected mode.
110 /* guarantee that interrupt is disabled when in prot mode */
113 POSTCODE(REAL_TO_PROT_ENTRY);
121 /* set the PE bit of CR0 */
125 or $(CR0_PE_ON), %eax
128 /* make intrasegment jump to flush the processor pipeline and */
129 /* reload CS register */
135 /* we are in USE32 mode now */
136 /* set up the protective mode segment registers : DS, SS, ES */
142 POSTCODE(REAL_TO_PROT_EXIT);
148 start the program on protected mode where phyaddr is the entry point
155 POSTCODE(STARTPROG_ENTRY);
157 movl 0x8(%ebp), %ecx /* entry offset */
158 movl $0x28, %ebx /* segment */
162 /* set up %ds and %es */
167 POSTCODE(STARTPROG_EXIT);
172 . = MP_BOOTGDT-MP_BOOT /* GDT location */
175 /* Segment Descriptor
178 * ------------------------------------------------------------
179 * | | |B| |A| | | |1|0|E|W|A| |
180 * | BASE 31..24 |G|/|0|V| LIMIT |P|DPL| TYPE | BASE 23:16 |
181 * | | |D| |L| 19..16| | |1|1|C|R|A| |
182 * ------------------------------------------------------------
184 * | BASE 15..0 | LIMIT 15..0 |
186 * ------------------------------------------------------------
188 .word 0,0 /* 0x0 : null */
191 .word 0xffff,MP_BOOT /* 0x8 : boot code */
194 .word 0xffff,MP_BOOT /* 0x10 : boot data */
197 .word 0xffff,MP_BOOT /* 0x18 : boot code, 16 bits */
200 .word 0xffff,0 /* 0x20 : init data */
203 .word 0xffff,0 /* 0x28 : init code */
207 .short 48 /* limit (8*6 segs) */
208 .short MP_BOOTGDT /* base low */
209 .short 0 /* base high */
211 Entry(slave_boot_end)