Subversion Repositories HelenOS

Rev

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

Rev 3022 Rev 4055
Line 1... Line 1...
1
 
1
#
2
# Copyright (c) 2005 Ondrej Palkovsky
2
# Copyright (c) 2005 Ondrej Palkovsky
3
# Copyright (c) 2006 Martin Decky
3
# Copyright (c) 2006 Martin Decky
4
# Copyright (c) 2008 Jakub Jermar
4
# Copyright (c) 2008 Jakub Jermar
5
# All rights reserved.
5
# All rights reserved.
6
#
6
#
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 $16, %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
Line 425... Line 324...
425
		mov $VESA_SET_PALETTE, %ax
324
		mov $VESA_SET_PALETTE, %ax
426
		xor %bl, %bl
325
		xor %bl, %bl
427
		xor %dx, %dx
326
		xor %dx, %dx
428
		int $0x10
327
		int $0x10
429
		
328
		
-
 
329
		cmp $0x00, %ah
430
		jmp vga_not_compat
330
		je vga_not_compat
431
	
331
	
432
	vga_compat:
332
	vga_compat:
433
		
333
		
434
		# Try VGA registers to set palette
334
		# Try VGA registers to set palette
435
		
335