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 operand_size_prefix .byte 0x66
73 #define address_size_prefix .byte 0x67
75 #define LJMP(segment,address) \
76 operand_size_prefix ;\
78 .long address-EXT(slave_boot_base) ;\
81 #define LGDT(address) \
82 address_size_prefix ;\
83 operand_size_prefix ;\
86 .long address-EXT(slave_boot_base)
88 Entry(slave_boot_base)
89 /* code is loaded at 0x0:0x1000 */
90 /* ljmp to the next instruction to set up %cs */
91 LJMP(MP_BOOTSEG, EXT(slave_rstart))
98 POSTCODE(SLAVE_RSTART_ENTRY);
100 /* set up %ss and %esp */
103 mov $(MP_BOOTSTACK), %esp
108 /* change to protected mode */
110 call EXT(slave_real_to_prot)
113 call EXT(slave_startprog)
117 transfer from real mode to protected mode.
120 Entry(slave_real_to_prot)
121 /* guarantee that interrupt is disabled when in prot mode */
124 POSTCODE(SLAVE_REAL_TO_PROT_ENTRY);
130 /* set the PE bit of CR0 */
132 or $(CR0_PE_ON), %eax
135 /* make intrasegment jump to flush the processor pipeline and */
136 /* reload CS register */
140 /* we are in USE32 mode now */
141 /* set up the protective mode segment registers : DS, SS, ES */
147 POSTCODE(SLAVE_REAL_TO_PROT_EXIT);
152 slave_startprog(phyaddr)
153 start the program on protected mode where phyaddr is the entry point
156 Entry(slave_startprog)
160 POSTCODE(SLAVE_STARTPROG_ENTRY);
162 movl 0x8(%ebp), %ecx /* entry offset */
163 movl $0x28, %ebx /* segment */
167 /* set up %ds and %es */
172 POSTCODE(SLAVE_STARTPROG_EXIT);
177 . = MP_BOOTGDT-MP_BOOT /* GDT location */
180 /* Segment Descriptor
183 * ------------------------------------------------------------
184 * | | |B| |A| | | |1|0|E|W|A| |
185 * | BASE 31..24 |G|/|0|V| LIMIT |P|DPL| TYPE | BASE 23:16 |
186 * | | |D| |L| 19..16| | |1|1|C|R|A| |
187 * ------------------------------------------------------------
189 * | BASE 15..0 | LIMIT 15..0 |
191 * ------------------------------------------------------------
193 .word 0,0 /* 0x0 : null */
196 .word 0xffff,MP_BOOT /* 0x8 : boot code */
199 .word 0xffff,MP_BOOT /* 0x10 : boot data */
202 .word 0xffff,MP_BOOT /* 0x18 : boot code, 16 bits */
205 .word 0xffff,0 /* 0x20 : init data */
208 .word 0xffff,0 /* 0x28 : init code */
212 .short 48 /* limit (8*6 segs) */
213 .short MP_BOOTGDT /* base low */
214 .short 0 /* base high */
216 Entry(slave_boot_end)