Subversion Repositories HelenOS-historic

Rev

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

Rev 695 Rev 696
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
# All rights reserved.
4
# All rights reserved.
4
#
5
#
5
# Redistribution and use in source and binary forms, with or without
6
# Redistribution and use in source and binary forms, with or without
6
# modification, are permitted provided that the following conditions
7
# modification, are permitted provided that the following conditions
7
# are met:
8
# are met:
Line 35... Line 36...
35
#include <arch/cpuid.h>
36
#include <arch/cpuid.h>
36
 
37
 
37
#define START_STACK	(BOOT_OFFSET - BOOT_STACK_SIZE)
38
#define START_STACK	(BOOT_OFFSET - BOOT_STACK_SIZE)
38
	
39
	
39
.section K_TEXT_START, "ax"
40
.section K_TEXT_START, "ax"
40
# .code16
-
 
41
# .global kernel_image_start
-
 
42
# .global multiboot_image_start
-
 
43
# kernel_image_start:
-
 
44
 
41
 
45
# 	movl $0x80000000, %eax  
-
 
46
# 	cpuid
-
 
47
# 	cmp $0x80000000, %eax 	# any function > 80000000h?
-
 
48
# 	jbe no_long_mode
-
 
49
# 	movl $(AMD_CPUID_EXTENDED), %eax # Extended function code 80000001
-
 
50
# 	cpuid
-
 
51
# 	bt $29, %edx 		# Test if long mode is supported.
-
 
52
# 	jnc no_long_mode
-
 
53
# 
-
 
54
# 
-
 
55
# no_long_mode:
-
 
56
# 1:
-
 
57
# 	jmp 1b
-
 
58
# 	
-
 
59
.code32
42
.code32
60
.align 4
43
.align 4
61
.global multiboot_image_start
44
.global multiboot_image_start
62
multiboot_header:
45
multiboot_header:
63
	.long MULTIBOOT_HEADER_MAGIC
46
	.long MULTIBOOT_HEADER_MAGIC
Line 87... Line 70...
87
	movl %ebx, grub_ebx
70
	movl %ebx, grub_ebx
88
	
71
	
89
	# Protected 32-bit. We want to reuse the code-seg descriptor,
72
	# Protected 32-bit. We want to reuse the code-seg descriptor,
90
	# the Default operand size must not be 1 when entering long mode
73
	# the Default operand size must not be 1 when entering long mode
91
	
74
	
-
 
75
	movl $0x80000000, %eax  
-
 
76
 	cpuid
-
 
77
 	cmp $0x80000000, %eax						# any function > 80000000h?
-
 
78
	jbe long_mode_unsupported
-
 
79
	movl $(AMD_CPUID_EXTENDED), %eax			# Extended function code 80000001
-
 
80
	cpuid
-
 
81
	bt $29, %edx								# Test if long mode is supported.
-
 
82
 	jc long_mode_supported
-
 
83
 
-
 
84
	long_mode_unsupported:
-
 
85
		cli
-
 
86
		hlt
-
 
87
	
-
 
88
	long_mode_supported:
-
 
89
	
92
	# Enable 64-bit page transaltion entries - CR4.PAE = 1.
90
	# Enable 64-bit page transaltion entries - CR4.PAE = 1.
93
	# Paging is not enabled until after long mode is enabled
91
	# Paging is not enabled until after long mode is enabled
94
	
92
	
95
	movl %cr4, %eax
93
	movl %cr4, %eax
96
	btsl $5, %eax
94
	btsl $5, %eax
Line 216... Line 214...
216
		mmap_invalid:
214
		mmap_invalid:
217
		movl %edx, e820counter
215
		movl %edx, e820counter
218
		
216
		
219
	invalid_boot:
217
	invalid_boot:
220
	
218
	
-
 
219
#ifdef CONFIG_SMP
-
 
220
	
-
 
221
	# copy AP bootstrap routines below 1 MB
-
 
222
	
-
 
223
	movq $BOOT_OFFSET, %rsi
-
 
224
	movq $AP_BOOT_OFFSET, %rdi
-
 
225
	movq $_hardcoded_unmapped_size, %rcx
-
 
226
	cld
-
 
227
	rep movsb
-
 
228
	
-
 
229
#endif
-
 
230
	
221
	call main_bsp   # never returns
231
	call main_bsp   # never returns
222
	
232
	
223
	cli
233
	cli
224
	hlt
234
	hlt
225
				
235