2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_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. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
33 * Mach Operating System
34 * Copyright (c) 1991,1990 Carnegie Mellon University
35 * All Rights Reserved.
37 * Permission to use, copy, modify and distribute this software and its
38 * documentation is hereby granted, provided that both the copyright
39 * notice and this permission notice appear in all copies of the
40 * software, derivative works or modified versions, and any portions
41 * thereof, and that both notices appear in supporting documentation.
43 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
44 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
45 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
47 * Carnegie Mellon requests users of this software to return to
49 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
50 * School of Computer Science
51 * Carnegie Mellon University
52 * Pittsburgh PA 15213-3890
54 * any improvements or extensions that they make and grant Carnegie Mellon
55 * the rights to redistribute these changes.
59 #include <i386/mp_slave_boot.h>
60 #include <i386/postcode.h>
63 #define CR0_PE_OFF 0xfffffffe
68 .align 12 // Page align for single bcopy_phys()
70 #define operand_size_prefix .byte 0x66
71 #define address_size_prefix .byte 0x67
73 #define LJMP(segment,address) \
74 operand_size_prefix ;\
76 .long address-EXT(slave_boot_base) ;\
79 #define LGDT(address) \
80 address_size_prefix ;\
81 operand_size_prefix ;\
84 .long address-EXT(slave_boot_base)
86 Entry(slave_boot_base)
87 /* code is loaded at 0x0:0x1000 */
88 /* ljmp to the next instruction to set up %cs */
89 LJMP(MP_BOOTSEG, EXT(slave_rstart))
96 POSTCODE(SLAVE_RSTART_ENTRY);
98 /* set up %ss and %esp */
101 mov $(MP_BOOTSTACK), %esp
106 /* change to protected mode */
108 call EXT(slave_real_to_prot)
111 call EXT(slave_startprog)
115 transfer from real mode to protected mode.
118 Entry(slave_real_to_prot)
119 /* guarantee that interrupt is disabled when in prot mode */
122 POSTCODE(SLAVE_REAL_TO_PROT_ENTRY);
128 /* set the PE bit of CR0 */
130 or $(CR0_PE_ON), %eax
133 /* make intrasegment jump to flush the processor pipeline and */
134 /* reload CS register */
138 /* we are in USE32 mode now */
139 /* set up the protective mode segment registers : DS, SS, ES */
145 POSTCODE(SLAVE_REAL_TO_PROT_EXIT);
150 slave_startprog(phyaddr)
151 start the program on protected mode where phyaddr is the entry point
154 Entry(slave_startprog)
158 POSTCODE(SLAVE_STARTPROG_ENTRY);
160 movl 0x8(%ebp), %ecx /* entry offset */
161 movl $0x28, %ebx /* segment */
165 /* set up %ds and %es */
170 POSTCODE(SLAVE_STARTPROG_EXIT);
175 . = MP_BOOTGDT-MP_BOOT /* GDT location */
178 /* Segment Descriptor
181 * ------------------------------------------------------------
182 * | | |B| |A| | | |1|0|E|W|A| |
183 * | BASE 31..24 |G|/|0|V| LIMIT |P|DPL| TYPE | BASE 23:16 |
184 * | | |D| |L| 19..16| | |1|1|C|R|A| |
185 * ------------------------------------------------------------
187 * | BASE 15..0 | LIMIT 15..0 |
189 * ------------------------------------------------------------
191 .word 0,0 /* 0x0 : null */
194 .word 0xffff,MP_BOOT /* 0x8 : boot code */
197 .word 0xffff,MP_BOOT /* 0x10 : boot data */
200 .word 0xffff,MP_BOOT /* 0x18 : boot code, 16 bits */
203 .word 0xffff,0 /* 0x20 : init data */
206 .word 0xffff,0 /* 0x28 : init code */
210 .short 48 /* limit (8*6 segs) */
211 .short MP_BOOTGDT /* base low */
212 .short 0 /* base high */
214 Entry(slave_boot_end)