]>
Commit | Line | Data |
---|---|---|
1c79356b A |
1 | /* |
2 | * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
43866e37 | 6 | * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. |
1c79356b | 7 | * |
43866e37 A |
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 | |
13 | * file. | |
14 | * | |
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 | |
1c79356b A |
17 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
18 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
43866e37 A |
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. | |
1c79356b A |
22 | * |
23 | * @APPLE_LICENSE_HEADER_END@ | |
24 | */ | |
25 | /* | |
26 | * @OSF_COPYRIGHT@ | |
27 | */ | |
28 | /* | |
29 | * Mach Operating System | |
30 | * Copyright (c) 1991,1990 Carnegie Mellon University | |
31 | * All Rights Reserved. | |
32 | * | |
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. | |
38 | * | |
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. | |
42 | * | |
43 | * Carnegie Mellon requests users of this software to return to | |
44 | * | |
45 | * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU | |
46 | * School of Computer Science | |
47 | * Carnegie Mellon University | |
48 | * Pittsburgh PA 15213-3890 | |
49 | * | |
50 | * any improvements or extensions that they make and grant Carnegie Mellon | |
51 | * the rights to redistribute these changes. | |
52 | */ | |
53 | ||
54 | #ifndef __MACHO__ | |
55 | /* | |
56 | * Startup code for an i386 on an AT. | |
57 | * Kernel is loaded starting at 1MB. | |
58 | * Protected mode, paging disabled. | |
59 | */ | |
60 | ||
61 | popl %eax | |
62 | cmpl $-1,%eax /* new calling convention */ | |
63 | je 0f | |
64 | ||
65 | /* | |
66 | * Old calling convention | |
67 | * | |
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) | |
73 | */ | |
74 | #define SYS_REBOOT_COMPAT 1 | |
75 | #if SYS_REBOOT_COMPAT | |
76 | movl %eax,PA(EXT(boottype)) | |
77 | #endif | |
78 | popl PA(EXT(extmem)) /* extended memory, in K */ | |
79 | popl PA(EXT(cnvmem)) /* conventional memory, in K */ | |
80 | popl %edx /* old boothowto */ | |
81 | #if SYS_REBOOT_COMPAT | |
82 | #define RB_SINGLE 0x2 | |
83 | #define RB_HALT 0x8 | |
84 | #define RB_ALTBOOT 0x40 | |
85 | testb $(RB_SINGLE),%edx /* old RB_SINGLE flag ? */ | |
86 | je 2f | |
87 | incl PA(EXT(startup_single_user)) | |
88 | 2: testb $(RB_HALT),%edx /* old RB_HALT flag ? */ | |
89 | je 2f | |
90 | incl PA(EXT(halt_in_debugger)) | |
91 | 2: testb $(RB_ALTBOOT),%edx /* old RB_ALTBOOT flag ? */ | |
92 | je 2f | |
93 | incl PA(EXT(cons_is_com1)) | |
94 | 2: | |
95 | #if NCPUS > 1 | |
96 | shrl $0x8,%edx | |
97 | movb %edx,PA(EXT(wncpu)) /* old want ncpus flag */ | |
98 | #endif | |
99 | #endif | |
100 | ||
101 | popl %eax /* get boot_string & esym */ | |
102 | #if SYS_REBOOT_COMPAT | |
103 | movl %eax, %esi | |
104 | lea PA(EXT(boot_string_store)), %edi | |
105 | movl PA(EXT(boot_string_sz)), %ecx | |
106 | cld | |
107 | rep | |
108 | movsb | |
109 | #endif | |
110 | ||
111 | /* | |
112 | * Move symbol table out of the way of BSS. | |
113 | * | |
114 | * When kernel is loaded, at the start of BSS we have: | |
115 | * _edata: | |
116 | * .long kern_sym_size | |
117 | * .long boot_image_size | |
118 | * .long load_info_size | |
119 | * sym_start: | |
120 | * kernel symbols | |
121 | * .align ALIGN | |
122 | * boot_start: | |
123 | * bootstrap image | |
124 | * .align ALIGN | |
125 | * load_info_start: | |
126 | * bootstrap load information | |
127 | * | |
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: | |
131 | * | |
132 | * _edata: | |
133 | * BSS | |
134 | * _end: <- kern_sym_start (VA) | |
135 | * kernel symbols . (kern_sym_size) | |
136 | * <next page boundary>: <- boot_start (VA) | |
137 | * bootstrap image | |
138 | * <- load_info_start (VA) | |
139 | * load information | |
140 | * <- %ebx (PA) | |
141 | * | |
142 | */ | |
143 | lea PA(EXT(edata))+4-1,%esi /* point to symbol size word */ | |
144 | andl $~0x3,%esi | |
145 | movl (%esi),%edx /* get symbol size */ | |
146 | ||
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 */ | |
151 | ||
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 */ | |
164 | ||
165 | leal 12(%esi,%edx),%esi /* point to start of boot image - source */ | |
166 | ||
167 | leal (%edi,%ecx),%ebx /* point to new location of */ | |
168 | /* end of bootstrap - next */ | |
169 | /* available physical address */ | |
170 | ||
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 */ | |
175 | rep | |
176 | movsl /* move bootstrap and loader_info */ | |
177 | cld /* reset direction flag */ | |
178 | ||
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? */ | |
184 | jz 1f /* if so: */ | |
185 | ||
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 */ | |
192 | rep | |
193 | movsl /* move symbols */ | |
194 | cld /* reset direction flag */ | |
195 | ||
196 | jmp 1f | |
197 | ||
198 | /* | |
199 | * New calling convention | |
200 | * | |
201 | * %esp -> -1 | |
202 | * size of extended memory (K) | |
203 | * size of conventional memory (K) | |
204 | * kern_sym_start | |
205 | * kern_sym_size | |
206 | * kern_args_start | |
207 | * kern_args_size | |
208 | * boot_sym_start | |
209 | * boot_sym_size | |
210 | * boot_args_start | |
211 | * boot_args_size | |
212 | * boot_start | |
213 | * boot_size | |
214 | * boot_region_desc | |
215 | * boot_region_count | |
216 | * boot_thread_state_flavor | |
217 | * boot_thread_state | |
218 | * boot_thread_state_count | |
219 | * env_start | |
220 | * env_size | |
221 | * top of loaded memory | |
222 | */ | |
223 | ||
224 | #define MEM_BASE 0 | |
225 | ||
226 | #define BOOT_TO_VIRT (MEM_BASE-(KVTOPHYS)) | |
227 | .globl EXT(boot_start) | |
228 | ||
229 | 0: | |
230 | popl PA(EXT(extmem)) /* extended memory, in K */ | |
231 | popl PA(EXT(cnvmem)) /* conventional memory, in K */ | |
232 | popl %eax | |
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)) | |
236 | popl %eax | |
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)) | |
240 | popl %eax | |
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)) | |
244 | popl %eax | |
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)) | |
248 | popl %eax | |
249 | addl $BOOT_TO_VIRT,%eax /* convert to virtual address */ | |
250 | movl %eax,PA(EXT(boot_start)) | |
251 | popl PA(EXT(boot_size)) | |
252 | popl %eax | |
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)) | |
257 | popl %eax | |
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)) | |
261 | popl %eax | |
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 */ | |
267 | 1: | |
268 | #else | |
269 | cld | |
270 | call PA(EXT(i386_preinit)) | |
271 | movl %eax,%ebx | |
272 | #endif |