Subversion Repositories HelenOS

Rev

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

Rev 2302 Rev 2692
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
# All rights reserved.
4
# All rights reserved.
5
#
5
#
6
# Redistribution and use in source and binary forms, with or without
6
# Redistribution and use in source and binary forms, with or without
Line 73... Line 73...
73
	movl %ebx, grub_ebx
73
	movl %ebx, grub_ebx
74
	
74
	
75
	# Protected 32-bit. We want to reuse the code-seg descriptor,
75
	# Protected 32-bit. We want to reuse the code-seg descriptor,
76
	# the Default operand size must not be 1 when entering long mode
76
	# the Default operand size must not be 1 when entering long mode
77
	
77
	
78
	movl $0x80000000, %eax  
78
	movl $(INTEL_CPUID_EXTENDED), %eax  
79
 	cpuid
79
 	cpuid
80
 	cmp $0x80000000, %eax						# any function > 80000000h?
80
 	cmp $(INTEL_CPUID_EXTENDED), %eax
81
	jbe long_mode_unsupported
81
	ja extended_cpuid_supported
-
 
82
		
-
 
83
		movl $extended_cpuid_msg, %esi
-
 
84
		jmp error_halt
-
 
85
	
-
 
86
	extended_cpuid_supported:
-
 
87
	
82
	movl $(AMD_CPUID_EXTENDED), %eax			# Extended function code 80000001
88
	movl $(AMD_CPUID_EXTENDED), %eax
83
	cpuid
89
	cpuid
84
	bt $29, %edx								# Test if long mode is supported.
90
	bt $(AMD_EXT_LONG_MODE), %edx
85
 	jc long_mode_supported
91
 	jc long_mode_supported
86
 
92
		
87
	long_mode_unsupported:
-
 
88
		movl $long_mode_msg, %esi
93
		movl $long_mode_msg, %esi
89
		jmp error_halt
94
		jmp error_halt
90
	
95
 
91
	long_mode_supported:
96
	long_mode_supported:
92
	
97
	
-
 
98
	bt $(AMD_EXT_NOEXECUTE), %edx
-
 
99
	jc noexecute_supported
-
 
100
	
-
 
101
		movl $noexecute_msg, %esi
-
 
102
		jmp error_halt
-
 
103
	
-
 
104
	noexecute_supported:
-
 
105
	
-
 
106
	movl $(INTEL_CPUID_STANDARD), %eax
-
 
107
	cpuid
-
 
108
	bt $(INTEL_FXSAVE), %edx
-
 
109
 	jc fx_supported
-
 
110
	
-
 
111
		movl $fx_msg, %esi
-
 
112
		jmp error_halt
-
 
113
	
-
 
114
	fx_supported:
-
 
115
	
-
 
116
	bt $(INTEL_SSE2), %edx
-
 
117
 	jc sse2_supported
-
 
118
	
-
 
119
		movl $sse2_msg, %esi
-
 
120
		jmp error_halt
-
 
121
	
-
 
122
	sse2_supported:
-
 
123
	
93
#ifdef CONFIG_FB
124
#ifdef CONFIG_FB
94
	mov $vesa_init, %esi
125
	mov $vesa_init, %esi
95
	mov $VESA_INIT_SEGMENT << 4, %edi
126
	mov $VESA_INIT_SEGMENT << 4, %edi
96
	mov $e_vesa_init - vesa_init, %ecx
127
	mov $e_vesa_init - vesa_init, %ecx
97
	cld
128
	cld
Line 109... Line 140...
109
	mov %bx, KA2PA(vesa_scanline)
140
	mov %bx, KA2PA(vesa_scanline)
110
	shr $16, %ebx
141
	shr $16, %ebx
111
	mov %bx, KA2PA(vesa_bpp)
142
	mov %bx, KA2PA(vesa_bpp)
112
#endif	
143
#endif	
113
	
144
	
114
	# Enable 64-bit page transaltion entries - CR4.PAE = 1.
145
	# Enable 64-bit page translation entries - CR4.PAE = 1.
115
	# Paging is not enabled until after long mode is enabled
146
	# Paging is not enabled until after long mode is enabled
116
	
147
	
117
	movl %cr4, %eax
148
	movl %cr4, %eax
118
	btsl $5, %eax
149
	btsl $5, %eax
119
	movl %eax, %cr4
150
	movl %eax, %cr4
Line 125... Line 156...
125
	
156
	
126
	# Enable long mode
157
	# Enable long mode
127
	
158
	
128
	movl $EFER_MSR_NUM, %ecx	# EFER MSR number
159
	movl $EFER_MSR_NUM, %ecx	# EFER MSR number
129
	rdmsr						# Read EFER
160
	rdmsr						# Read EFER
130
	btsl $AMD_LME_FLAG, %eax	# Set LME=1
161
	btsl $AMD_LME_FLAG, %eax	# Set LME = 1
131
	wrmsr						# Write EFER
162
	wrmsr						# Write EFER
132
	
163
	
133
	# Enable paging to activate long mode (set CR0.PG=1)
164
	# Enable paging to activate long mode (set CR0.PG = 1)
134
	
165
	
135
	movl %cr0, %eax
166
	movl %cr0, %eax
136
	btsl $31, %eax
167
	btsl $31, %eax
137
	movl %eax, %cr0
168
	movl %eax, %cr0
138
	
169
	
Line 633... Line 664...
633
	.long 0
664
	.long 0
634
 
665
 
635
grub_ebx:
666
grub_ebx:
636
	.long 0
667
	.long 0
637
 
668
 
-
 
669
extended_cpuid_msg:
-
 
670
	.asciz "Extended CPUID not supported. System halted."
638
long_mode_msg:
671
long_mode_msg:
639
	.asciz "64 bit long mode not supported. System halted."
672
	.asciz "64 bit long mode not supported. System halted."
-
 
673
noexecute_msg:
-
 
674
	.asciz "No-execute pages not supported. System halted."
-
 
675
fx_msg:
-
 
676
	.asciz "FXSAVE/FXRESTORE instructions not supported. System halted."
-
 
677
sse2_msg:
-
 
678
	.asciz "SSE2 instructions not supported. System halted."