Subversion Repositories HelenOS

Rev

Rev 4344 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4344 Rev 4345
Line 173... Line 173...
173
	jmpl $gdtselector(KTEXT_DES), $start64
173
	jmpl $gdtselector(KTEXT_DES), $start64
174
 
174
 
175
.code64
175
.code64
176
start64:
176
start64:
177
	movq $(PA2KA(START_STACK)), %rsp
177
	movq $(PA2KA(START_STACK)), %rsp
178
	movl grub_eax, %eax
-
 
179
	movl grub_ebx, %ebx
-
 
180
	
178
 
181
	cmpl $MULTIBOOT_LOADER_MAGIC, %eax			# compare GRUB signature
-
 
182
	je valid_boot
-
 
183
		
-
 
184
		xorl %ecx, %ecx					# no memory size or map available
-
 
185
		movl %ecx, e820counter
-
 
186
		
-
 
187
		jmp invalid_boot
-
 
188
		
-
 
189
	valid_boot:
-
 
190
		
-
 
191
		movl (%ebx), %eax				# ebx = physical address of struct multiboot_info
-
 
192
		
-
 
193
		bt $3, %eax					# mbi->flags[3] (mods_count, mods_addr valid)
-
 
194
		jc mods_valid
-
 
195
			
-
 
196
			xorq %rcx, %rcx
-
 
197
			movq %rcx, init
-
 
198
			jmp mods_end
-
 
199
		
-
 
200
		mods_valid:
-
 
201
		
-
 
202
		xorq %rcx, %rcx
-
 
203
		movl 20(%ebx), %ecx				# mbi->mods_count
-
 
204
		movq %rcx, init
-
 
205
		
-
 
206
		cmpl $0, %ecx
-
 
207
		je mods_end
-
 
208
		
-
 
209
		movl 24(%ebx), %esi				# mbi->mods_addr
179
	# arch_pre_main(grub_eax, grub_ebx)
210
		movq $init, %rdi
-
 
211
		
-
 
212
		mods_loop:
-
 
213
			
-
 
214
			xorq %rdx, %rdx
180
	xorq %rdi, %rdi
215
			movl 0(%esi), %edx			# mods->mod_start
-
 
216
			movq $0xffff800000000000, %r10
-
 
217
			addq %r10, %rdx
-
 
218
			movq %rdx, 8(%rdi)
181
	movl grub_eax, %edi
219
			
-
 
220
			xorq %rdx, %rdx
182
	xorq %rsi, %rsi
221
			movl 4(%esi), %edx
183
	movl grub_ebx, %esi
222
			subl 0(%esi), %edx			# mods->mod_end - mods->mod_start
-
 
223
			movq %rdx, 16(%rdi)
-
 
224
			
-
 
225
			addl $16, %esi
-
 
226
			addq $48, %rdi
-
 
227
			
-
 
228
			loop mods_loop
-
 
229
			
-
 
230
		mods_end:
-
 
231
		
-
 
232
		bt $6, %eax					# mbi->flags[6] (mmap_length, mmap_addr valid)	
-
 
233
		jc mmap_valid
-
 
234
			
-
 
235
			xorl %edx, %edx
-
 
236
			jmp mmap_invalid
-
 
237
			
-
 
238
		mmap_valid:
-
 
239
		movl 44(%ebx), %ecx				# mbi->mmap_length
-
 
240
		movl 48(%ebx), %esi				# mbi->mmap_addr
-
 
241
		movq $e820table, %rdi
-
 
242
		xorl %edx, %edx
-
 
243
		
-
 
244
		mmap_loop:
-
 
245
			cmpl $0, %ecx
-
 
246
			jle mmap_end
-
 
247
			
-
 
248
			movl 4(%esi), %eax			# mmap->base_addr_low
-
 
249
			movl %eax, (%rdi)
-
 
250
			
-
 
251
			movl 8(%esi), %eax			# mmap->base_addr_high
-
 
252
			movl %eax, 4(%rdi)
-
 
253
			
-
 
254
			movl 12(%esi), %eax			# mmap->length_low
-
 
255
			movl %eax, 8(%rdi)
-
 
256
			
-
 
257
			movl 16(%esi), %eax			# mmap->length_high
-
 
258
			movl %eax, 12(%rdi)
-
 
259
			
-
 
260
			movl 20(%esi), %eax			# mmap->type
-
 
261
			movl %eax, 16(%rdi)
-
 
262
			
-
 
263
			movl (%esi), %eax			# mmap->size
-
 
264
			addl $0x4, %eax
-
 
265
			addl %eax, %esi
184
	call arch_pre_main
266
			subl %eax, %ecx
-
 
267
			addq $MEMMAP_E820_RECORD_SIZE, %rdi
-
 
268
			incl %edx
-
 
269
			jmp mmap_loop
-
 
270
		
-
 
271
		mmap_end:
-
 
272
		
-
 
273
		mmap_invalid:
-
 
274
		movl %edx, e820counter
-
 
275
		
-
 
276
	invalid_boot:
-
 
277
	
185
 
278
#ifdef CONFIG_SMP
186
	call main_bsp  
279
	
187
 
280
	# copy AP bootstrap routines below 1 MB
-
 
281
	
-
 
282
	movq $BOOT_OFFSET, %rsi
-
 
283
	movq $AP_BOOT_OFFSET, %rdi
-
 
284
	movq $_hardcoded_unmapped_size, %rcx
-
 
285
	rep movsb
188
	# Not reached.
286
	
-
 
287
#endif
-
 
288
	
-
 
289
	call main_bsp   # never returns
-
 
290
	
189
	
291
	cli
190
	cli
292
	hlt
191
	hlt
293
 
192
 
294
#ifdef CONFIG_FB
193
#ifdef CONFIG_FB