]>
git.saurik.com Git - apple/xnu.git/blob - osfmk/i386/AT386/asm_startup.h
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@
26 * Mach Operating System
27 * Copyright (c) 1991,1990 Carnegie Mellon University
28 * All Rights Reserved.
30 * Permission to use, copy, modify and distribute this software and its
31 * documentation is hereby granted, provided that both the copyright
32 * notice and this permission notice appear in all copies of the
33 * software, derivative works or modified versions, and any portions
34 * thereof, and that both notices appear in supporting documentation.
36 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
37 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
38 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
40 * Carnegie Mellon requests users of this software to return to
42 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
43 * School of Computer Science
44 * Carnegie Mellon University
45 * Pittsburgh PA 15213-3890
47 * any improvements or extensions that they make and grant Carnegie Mellon
48 * the rights to redistribute these changes.
53 * Startup code for an i386 on an AT.
54 * Kernel is loaded starting at 1MB.
55 * Protected mode, paging disabled.
59 cmpl $
-1,%eax
/* new calling convention */
63 * Old calling convention
65 * %esp -> boottype (deprecated)
66 * size of extended memory (K)
67 * size of conventional memory (K)
68 * boothowto (deprecated)
69 * esym (if KDB set up)
71 #define SYS_REBOOT_COMPAT 1
73 movl %eax
,PA(EXT(boottype
))
75 popl
PA(EXT(extmem
)) /* extended memory, in K */
76 popl
PA(EXT(cnvmem
)) /* conventional memory, in K */
77 popl %edx
/* old boothowto */
81 #define RB_ALTBOOT 0x40
82 testb $
(RB_SINGLE
),%edx
/* old RB_SINGLE flag ? */
84 incl
PA(EXT(startup_single_user
))
85 2: testb $
(RB_HALT
),%edx
/* old RB_HALT flag ? */
87 incl
PA(EXT(halt_in_debugger
))
88 2: testb $
(RB_ALTBOOT
),%edx
/* old RB_ALTBOOT flag ? */
90 incl
PA(EXT(cons_is_com1
))
94 movb %edx
,PA(EXT(wncpu
)) /* old want ncpus flag */
98 popl %eax
/* get boot_string & esym */
101 lea
PA(EXT(boot_string_store
)), %edi
102 movl
PA(EXT(boot_string_sz
)), %ecx
109 * Move symbol table out of the way of BSS.
111 * When kernel is loaded, at the start of BSS we have:
113 * .long kern_sym_size
114 * .long boot_image_size
115 * .long load_info_size
123 * bootstrap load information
125 * all of which must be moved somewhere else, since it
126 * is sitting in the kernel BSS. In addition, the bootstrap
127 * image must be moved to a machine page boundary, so that we get:
131 * _end: <- kern_sym_start (VA)
132 * kernel symbols . (kern_sym_size)
133 * <next page boundary>: <- boot_start (VA)
135 * <- load_info_start (VA)
140 lea
PA(EXT(edata
))+4-1,%esi
/* point to symbol size word */
142 movl (%esi
),%edx
/* get symbol size */
144 lea
PA(EXT(end
))+NBPG
-1(%edx
),%edi
145 /* point after BSS, add symbol */
146 /* size, and round up to */
147 andl $
-NBPG
,%edi
/* machine page boundary */
149 lea
-KVTOPHYS(%edi
),%eax
/* save virtual address */
150 movl %eax
,PA(EXT(boot_start
)) /* of start of bootstrap */
151 movl
4(%esi
),%ecx
/* get size of bootstrap */
152 movl %ecx
,PA(EXT(boot_size
)) /* save size of bootstrap */
153 lea
-KVTOPHYS(%edi
,%ecx
),%eax
154 movl %eax
,PA(EXT(load_info_start
))
155 /* save virtual address */
156 /* of start of loader info */
157 movl
8(%esi
),%eax
/* get size of loader info */
158 movl %eax
,PA(EXT(load_info_size
))
159 /* save size of loader info */
160 addl %eax
,%ecx
/* get total size to move */
162 leal
12(%esi
,%edx
),%esi
/* point to start of boot image - source */
164 leal (%edi
,%ecx
),%ebx
/* point to new location of */
165 /* end of bootstrap - next */
166 /* available physical address */
168 lea
-4(%esi
,%ecx
),%esi
/* point to end of src - 4 */
169 lea
-4(%edi
,%ecx
),%edi
/* point to end of dst - 4 */
170 shrl $
2,%ecx
/* move by longs */
171 std
/* move backwards */
173 movsl
/* move bootstrap and loader_info */
174 cld
/* reset direction flag */
176 movl $
EXT(end
),PA(EXT(kern_sym_start
))
177 /* save virtual address */
178 /* of start of symbols */
179 movl %edx
,PA(EXT(kern_sym_size
)) /* save symbol table size */
180 testl %edx
,%edx
/* any symbols? */
183 /* %esi points to start of boot-4 */
184 /* == end of symbol table (source) - 4 */
185 leal
PA(EXT(end
))-4(%edx
),%edi
/* point to end of dst - 4 */
186 movl %edx
,%ecx
/* copy size */
187 shrl $
2,%ecx
/* move by longs */
188 std
/* move backwards */
190 movsl
/* move symbols */
191 cld
/* reset direction flag */
196 * New calling convention
199 * size of extended memory (K)
200 * size of conventional memory (K)
213 * boot_thread_state_flavor
215 * boot_thread_state_count
218 * top of loaded memory
223 #define BOOT_TO_VIRT (MEM_BASE-(KVTOPHYS))
224 .globl
EXT(boot_start
)
227 popl
PA(EXT(extmem
)) /* extended memory, in K */
228 popl
PA(EXT(cnvmem
)) /* conventional memory, in K */
230 addl $BOOT_TO_VIRT
,%eax
/* convert to virtual address */
231 movl %eax
,PA(EXT(kern_sym_start
))
232 popl
PA(EXT(kern_sym_size
))
234 addl $BOOT_TO_VIRT
,%eax
/* convert to virtual address */
235 movl %eax
,PA(EXT(kern_args_start
))
236 popl
PA(EXT(kern_args_size
))
238 addl $BOOT_TO_VIRT
,%eax
/* convert to virtual address */
239 movl %eax
,PA(EXT(boot_sym_start
))
240 popl
PA(EXT(boot_sym_size
))
242 addl $BOOT_TO_VIRT
,%eax
/* convert to virtual address */
243 movl %eax
,PA(EXT(boot_args_start
))
244 popl
PA(EXT(boot_args_size
))
246 addl $BOOT_TO_VIRT
,%eax
/* convert to virtual address */
247 movl %eax
,PA(EXT(boot_start
))
248 popl
PA(EXT(boot_size
))
250 addl $BOOT_TO_VIRT
,%eax
/* convert to virtual address */
251 movl %eax
,PA(EXT(boot_region_desc
))
252 popl
PA(EXT(boot_region_count
))
253 popl
PA(EXT(boot_thread_state_flavor
))
255 addl $BOOT_TO_VIRT
,%eax
/* convert to virtual address */
256 movl %eax
,PA(EXT(boot_thread_state
))
257 popl
PA(EXT(boot_thread_state_count
))
259 addl $BOOT_TO_VIRT
,%eax
/* convert to virtual address */
260 movl %eax
,PA(EXT(env_start
))
261 popl
PA(EXT(env_size
))
262 popl %ebx
/* mem top */
263 addl $MEM_BASE
,%ebx
/* translate */
267 call
PA(EXT(i386_preinit
))