]>
git.saurik.com Git - apple/xnu.git/blob - osfmk/i386/AT386/asm_startup.h
4bc3ef0270bca8a4c090798b978db6e8f715f54b
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
23 * @APPLE_LICENSE_HEADER_END@
29 * Mach Operating System
30 * Copyright (c) 1991,1990 Carnegie Mellon University
31 * All Rights Reserved.
33 * Permission to use, copy, modify and distribute this software and its
34 * documentation is hereby granted, provided that both the copyright
35 * notice and this permission notice appear in all copies of the
36 * software, derivative works or modified versions, and any portions
37 * thereof, and that both notices appear in supporting documentation.
39 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
40 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
41 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
43 * Carnegie Mellon requests users of this software to return to
45 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
46 * School of Computer Science
47 * Carnegie Mellon University
48 * Pittsburgh PA 15213-3890
50 * any improvements or extensions that they make and grant Carnegie Mellon
51 * the rights to redistribute these changes.
56 * Startup code for an i386 on an AT.
57 * Kernel is loaded starting at 1MB.
58 * Protected mode, paging disabled.
62 cmpl $
-1,%eax
/* new calling convention */
66 * Old calling convention
68 * %esp -> boottype (deprecated)
69 * size of extended memory (K)
70 * size of conventional memory (K)
71 * boothowto (deprecated)
72 * esym (if KDB set up)
74 #define SYS_REBOOT_COMPAT 1
76 movl %eax
,PA(EXT(boottype
))
78 popl
PA(EXT(extmem
)) /* extended memory, in K */
79 popl
PA(EXT(cnvmem
)) /* conventional memory, in K */
80 popl %edx
/* old boothowto */
84 #define RB_ALTBOOT 0x40
85 testb $
(RB_SINGLE
),%edx
/* old RB_SINGLE flag ? */
87 incl
PA(EXT(startup_single_user
))
88 2: testb $
(RB_HALT
),%edx
/* old RB_HALT flag ? */
90 incl
PA(EXT(halt_in_debugger
))
91 2: testb $
(RB_ALTBOOT
),%edx
/* old RB_ALTBOOT flag ? */
93 incl
PA(EXT(cons_is_com1
))
97 movb %edx
,PA(EXT(wncpu
)) /* old want ncpus flag */
101 popl %eax
/* get boot_string & esym */
102 #if SYS_REBOOT_COMPAT
104 lea
PA(EXT(boot_string_store
)), %edi
105 movl
PA(EXT(boot_string_sz
)), %ecx
112 * Move symbol table out of the way of BSS.
114 * When kernel is loaded, at the start of BSS we have:
116 * .long kern_sym_size
117 * .long boot_image_size
118 * .long load_info_size
126 * bootstrap load information
128 * all of which must be moved somewhere else, since it
129 * is sitting in the kernel BSS. In addition, the bootstrap
130 * image must be moved to a machine page boundary, so that we get:
134 * _end: <- kern_sym_start (VA)
135 * kernel symbols . (kern_sym_size)
136 * <next page boundary>: <- boot_start (VA)
138 * <- load_info_start (VA)
143 lea
PA(EXT(edata
))+4-1,%esi
/* point to symbol size word */
145 movl (%esi
),%edx
/* get symbol size */
147 lea
PA(EXT(end
))+NBPG
-1(%edx
),%edi
148 /* point after BSS, add symbol */
149 /* size, and round up to */
150 andl $
-NBPG
,%edi
/* machine page boundary */
152 lea
-KVTOPHYS(%edi
),%eax
/* save virtual address */
153 movl %eax
,PA(EXT(boot_start
)) /* of start of bootstrap */
154 movl
4(%esi
),%ecx
/* get size of bootstrap */
155 movl %ecx
,PA(EXT(boot_size
)) /* save size of bootstrap */
156 lea
-KVTOPHYS(%edi
,%ecx
),%eax
157 movl %eax
,PA(EXT(load_info_start
))
158 /* save virtual address */
159 /* of start of loader info */
160 movl
8(%esi
),%eax
/* get size of loader info */
161 movl %eax
,PA(EXT(load_info_size
))
162 /* save size of loader info */
163 addl %eax
,%ecx
/* get total size to move */
165 leal
12(%esi
,%edx
),%esi
/* point to start of boot image - source */
167 leal (%edi
,%ecx
),%ebx
/* point to new location of */
168 /* end of bootstrap - next */
169 /* available physical address */
171 lea
-4(%esi
,%ecx
),%esi
/* point to end of src - 4 */
172 lea
-4(%edi
,%ecx
),%edi
/* point to end of dst - 4 */
173 shrl $
2,%ecx
/* move by longs */
174 std
/* move backwards */
176 movsl
/* move bootstrap and loader_info */
177 cld
/* reset direction flag */
179 movl $
EXT(end
),PA(EXT(kern_sym_start
))
180 /* save virtual address */
181 /* of start of symbols */
182 movl %edx
,PA(EXT(kern_sym_size
)) /* save symbol table size */
183 testl %edx
,%edx
/* any symbols? */
186 /* %esi points to start of boot-4 */
187 /* == end of symbol table (source) - 4 */
188 leal
PA(EXT(end
))-4(%edx
),%edi
/* point to end of dst - 4 */
189 movl %edx
,%ecx
/* copy size */
190 shrl $
2,%ecx
/* move by longs */
191 std
/* move backwards */
193 movsl
/* move symbols */
194 cld
/* reset direction flag */
199 * New calling convention
202 * size of extended memory (K)
203 * size of conventional memory (K)
216 * boot_thread_state_flavor
218 * boot_thread_state_count
221 * top of loaded memory
226 #define BOOT_TO_VIRT (MEM_BASE-(KVTOPHYS))
227 .globl
EXT(boot_start
)
230 popl
PA(EXT(extmem
)) /* extended memory, in K */
231 popl
PA(EXT(cnvmem
)) /* conventional memory, in K */
233 addl $BOOT_TO_VIRT
,%eax
/* convert to virtual address */
234 movl %eax
,PA(EXT(kern_sym_start
))
235 popl
PA(EXT(kern_sym_size
))
237 addl $BOOT_TO_VIRT
,%eax
/* convert to virtual address */
238 movl %eax
,PA(EXT(kern_args_start
))
239 popl
PA(EXT(kern_args_size
))
241 addl $BOOT_TO_VIRT
,%eax
/* convert to virtual address */
242 movl %eax
,PA(EXT(boot_sym_start
))
243 popl
PA(EXT(boot_sym_size
))
245 addl $BOOT_TO_VIRT
,%eax
/* convert to virtual address */
246 movl %eax
,PA(EXT(boot_args_start
))
247 popl
PA(EXT(boot_args_size
))
249 addl $BOOT_TO_VIRT
,%eax
/* convert to virtual address */
250 movl %eax
,PA(EXT(boot_start
))
251 popl
PA(EXT(boot_size
))
253 addl $BOOT_TO_VIRT
,%eax
/* convert to virtual address */
254 movl %eax
,PA(EXT(boot_region_desc
))
255 popl
PA(EXT(boot_region_count
))
256 popl
PA(EXT(boot_thread_state_flavor
))
258 addl $BOOT_TO_VIRT
,%eax
/* convert to virtual address */
259 movl %eax
,PA(EXT(boot_thread_state
))
260 popl
PA(EXT(boot_thread_state_count
))
262 addl $BOOT_TO_VIRT
,%eax
/* convert to virtual address */
263 movl %eax
,PA(EXT(env_start
))
264 popl
PA(EXT(env_size
))
265 popl %ebx
/* mem top */
266 addl $MEM_BASE
,%ebx
/* translate */
270 call
PA(EXT(i386_preinit
))