Subversion Repositories HelenOS

Rev

Rev 2302 | Rev 2703 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2302 Rev 2692
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
7
# modification, are permitted provided that the following conditions
7
# modification, are permitted provided that the following conditions
8
# are met:
8
# are met:
9
#
9
#
10
# - Redistributions of source code must retain the above copyright
10
# - Redistributions of source code must retain the above copyright
11
#   notice, this list of conditions and the following disclaimer.
11
#   notice, this list of conditions and the following disclaimer.
12
# - Redistributions in binary form must reproduce the above copyright
12
# - Redistributions in binary form must reproduce the above copyright
13
#   notice, this list of conditions and the following disclaimer in the
13
#   notice, this list of conditions and the following disclaimer in the
14
#   documentation and/or other materials provided with the distribution.
14
#   documentation and/or other materials provided with the distribution.
15
# - The name of the author may not be used to endorse or promote products
15
# - The name of the author may not be used to endorse or promote products
16
#   derived from this software without specific prior written permission.
16
#   derived from this software without specific prior written permission.
17
#
17
#
18
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
#
28
#
29
 
29
 
30
#include <arch/boot/boot.h>
30
#include <arch/boot/boot.h>
31
#include <arch/boot/memmap.h>
31
#include <arch/boot/memmap.h>
32
#include <arch/mm/page.h>	
32
#include <arch/mm/page.h>	
33
#include <arch/mm/ptl.h>
33
#include <arch/mm/ptl.h>
34
#include <arch/pm.h>
34
#include <arch/pm.h>
35
#include <arch/cpu.h>
35
#include <arch/cpu.h>
36
#include <arch/cpuid.h>
36
#include <arch/cpuid.h>
37
 
37
 
38
#define START_STACK	(BOOT_OFFSET - BOOT_STACK_SIZE)
38
#define START_STACK	(BOOT_OFFSET - BOOT_STACK_SIZE)
39
	
39
	
40
.section K_TEXT_START, "ax"
40
.section K_TEXT_START, "ax"
41
 
41
 
42
.code32
42
.code32
43
.align 4
43
.align 4
44
.global multiboot_image_start
44
.global multiboot_image_start
45
multiboot_header:
45
multiboot_header:
46
	.long MULTIBOOT_HEADER_MAGIC
46
	.long MULTIBOOT_HEADER_MAGIC
47
	.long MULTIBOOT_HEADER_FLAGS
47
	.long MULTIBOOT_HEADER_FLAGS
48
	.long -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS)	# checksum
48
	.long -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS)	# checksum
49
	.long multiboot_header
49
	.long multiboot_header
50
	.long unmapped_ktext_start
50
	.long unmapped_ktext_start
51
	.long 0
51
	.long 0
52
	.long 0
52
	.long 0
53
	.long multiboot_image_start
53
	.long multiboot_image_start
54
 
54
 
55
multiboot_image_start:
55
multiboot_image_start:
56
	movl $START_STACK, %esp			# initialize stack pointer
56
	movl $START_STACK, %esp			# initialize stack pointer
57
	lgdt bootstrap_gdtr				# initialize Global Descriptor Table register
57
	lgdt bootstrap_gdtr				# initialize Global Descriptor Table register
58
 
58
 
59
	movw $gdtselector(KDATA_DES), %cx
59
	movw $gdtselector(KDATA_DES), %cx
60
	movw %cx, %es
60
	movw %cx, %es
61
	movw %cx, %ds							# kernel data + stack
61
	movw %cx, %ds							# kernel data + stack
62
	movw %cx, %ss
62
	movw %cx, %ss
63
	# Simics seems to remove hidden part of GS on entering user mode
63
	# Simics seems to remove hidden part of GS on entering user mode
64
	#  when _visible_ part of GS does not point to user-mode segment
64
	#  when _visible_ part of GS does not point to user-mode segment
65
	movw $gdtselector(UDATA_DES), %cx
65
	movw $gdtselector(UDATA_DES), %cx
66
	movw %cx, %fs
66
	movw %cx, %fs
67
	movw %cx, %gs
67
	movw %cx, %gs
68
	
68
	
69
	jmpl $gdtselector(KTEXT32_DES), $multiboot_meeting_point
69
	jmpl $gdtselector(KTEXT32_DES), $multiboot_meeting_point
70
	multiboot_meeting_point:
70
	multiboot_meeting_point:
71
	
71
	
72
	movl %eax, grub_eax							# save parameters from GRUB
72
	movl %eax, grub_eax							# save parameters from GRUB
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
98
	rep movsb
129
	rep movsb
99
 
130
 
100
	mov $VESA_INIT_SEGMENT << 4, %edi
131
	mov $VESA_INIT_SEGMENT << 4, %edi
101
	jmpl *%edi
132
	jmpl *%edi
102
	
133
	
103
	vesa_meeting_point:
134
	vesa_meeting_point:
104
	
135
	
105
	mov %esi, KA2PA(vesa_ph_addr)
136
	mov %esi, KA2PA(vesa_ph_addr)
106
	mov %di, KA2PA(vesa_height)
137
	mov %di, KA2PA(vesa_height)
107
	shr $16, %edi
138
	shr $16, %edi
108
	mov %di, KA2PA(vesa_width)
139
	mov %di, KA2PA(vesa_width)
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
120
 
151
 
121
	# Set up paging tables
152
	# Set up paging tables
122
	
153
	
123
	leal ptl_0, %eax
154
	leal ptl_0, %eax
124
	movl %eax, %cr3
155
	movl %eax, %cr3
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
	
139
	# At this point we are in compatibility mode
170
	# At this point we are in compatibility mode
140
	
171
	
141
	jmpl $gdtselector(KTEXT_DES), $start64
172
	jmpl $gdtselector(KTEXT_DES), $start64
142
 
173
 
143
.code64
174
.code64
144
start64:
175
start64:
145
	movq $(PA2KA(START_STACK)), %rsp
176
	movq $(PA2KA(START_STACK)), %rsp
146
	movl grub_eax, %eax
177
	movl grub_eax, %eax
147
	movl grub_ebx, %ebx
178
	movl grub_ebx, %ebx
148
	
179
	
149
	cmpl $MULTIBOOT_LOADER_MAGIC, %eax				# compare GRUB signature
180
	cmpl $MULTIBOOT_LOADER_MAGIC, %eax				# compare GRUB signature
150
	je valid_boot
181
	je valid_boot
151
		
182
		
152
		xorl %ecx, %ecx							# no memory size or map available
183
		xorl %ecx, %ecx							# no memory size or map available
153
		movl %ecx, e801memorysize
184
		movl %ecx, e801memorysize
154
		movl %ecx, e820counter
185
		movl %ecx, e820counter
155
		
186
		
156
		jmp invalid_boot
187
		jmp invalid_boot
157
		
188
		
158
	valid_boot:
189
	valid_boot:
159
		
190
		
160
		movl (%ebx), %eax						# ebx = physical address of struct multiboot_info
191
		movl (%ebx), %eax						# ebx = physical address of struct multiboot_info
161
		
192
		
162
		bt $0, %eax								# mbi->flags[0] (mem_lower, mem_upper valid)
193
		bt $0, %eax								# mbi->flags[0] (mem_lower, mem_upper valid)
163
		jc mem_valid
194
		jc mem_valid
164
			
195
			
165
			xorl %ecx, %ecx
196
			xorl %ecx, %ecx
166
			jmp mem_invalid
197
			jmp mem_invalid
167
			
198
			
168
		mem_valid:
199
		mem_valid:
169
		movl 4(%ebx), %ecx						# mbi->mem_lower
200
		movl 4(%ebx), %ecx						# mbi->mem_lower
170
		addl 8(%ebx), %ecx						# mbi->mem_upper
201
		addl 8(%ebx), %ecx						# mbi->mem_upper
171
		
202
		
172
		mem_invalid:
203
		mem_invalid:
173
		movl %ecx, e801memorysize
204
		movl %ecx, e801memorysize
174
		
205
		
175
		bt $3, %eax								# mbi->flags[3] (mods_count, mods_addr valid)
206
		bt $3, %eax								# mbi->flags[3] (mods_count, mods_addr valid)
176
		jc mods_valid
207
		jc mods_valid
177
			
208
			
178
			xorq %rcx, %rcx
209
			xorq %rcx, %rcx
179
			movq %rcx, init
210
			movq %rcx, init
180
			jmp mods_end
211
			jmp mods_end
181
		
212
		
182
		mods_valid:
213
		mods_valid:
183
		
214
		
184
		xorq %rcx, %rcx
215
		xorq %rcx, %rcx
185
		movl 20(%ebx), %ecx						# mbi->mods_count
216
		movl 20(%ebx), %ecx						# mbi->mods_count
186
		movq %rcx, init
217
		movq %rcx, init
187
		
218
		
188
		cmpl $0, %ecx
219
		cmpl $0, %ecx
189
		je mods_end
220
		je mods_end
190
		
221
		
191
		movl 24(%ebx), %esi						# mbi->mods_addr
222
		movl 24(%ebx), %esi						# mbi->mods_addr
192
		movq $init, %rdi
223
		movq $init, %rdi
193
		
224
		
194
		mods_loop:
225
		mods_loop:
195
			
226
			
196
			xorq %rdx, %rdx
227
			xorq %rdx, %rdx
197
			movl 0(%esi), %edx					# mods->mod_start
228
			movl 0(%esi), %edx					# mods->mod_start
198
			movq $0xffff800000000000, %r10
229
			movq $0xffff800000000000, %r10
199
			addq %r10, %rdx
230
			addq %r10, %rdx
200
			movq %rdx, 8(%rdi)
231
			movq %rdx, 8(%rdi)
201
			
232
			
202
			xorq %rdx, %rdx
233
			xorq %rdx, %rdx
203
			movl 4(%esi), %edx
234
			movl 4(%esi), %edx
204
			subl 0(%esi), %edx					# mods->mod_end - mods->mod_start
235
			subl 0(%esi), %edx					# mods->mod_end - mods->mod_start
205
			movq %rdx, 16(%rdi)
236
			movq %rdx, 16(%rdi)
206
			
237
			
207
			addl $16, %esi
238
			addl $16, %esi
208
			addq $16, %rdi
239
			addq $16, %rdi
209
			
240
			
210
			loop mods_loop
241
			loop mods_loop
211
			
242
			
212
		mods_end:
243
		mods_end:
213
		
244
		
214
		bt $6, %eax								# mbi->flags[6] (mmap_length, mmap_addr valid)	
245
		bt $6, %eax								# mbi->flags[6] (mmap_length, mmap_addr valid)	
215
		jc mmap_valid
246
		jc mmap_valid
216
			
247
			
217
			xorl %edx, %edx
248
			xorl %edx, %edx
218
			jmp mmap_invalid
249
			jmp mmap_invalid
219
			
250
			
220
		mmap_valid:
251
		mmap_valid:
221
		movl 44(%ebx), %ecx						# mbi->mmap_length
252
		movl 44(%ebx), %ecx						# mbi->mmap_length
222
		movl 48(%ebx), %esi						# mbi->mmap_addr
253
		movl 48(%ebx), %esi						# mbi->mmap_addr
223
		movq $e820table, %rdi
254
		movq $e820table, %rdi
224
		xorl %edx, %edx
255
		xorl %edx, %edx
225
		
256
		
226
		mmap_loop:
257
		mmap_loop:
227
			cmpl $0, %ecx
258
			cmpl $0, %ecx
228
			jle mmap_end
259
			jle mmap_end
229
			
260
			
230
			movl 4(%esi), %eax					# mmap->base_addr_low
261
			movl 4(%esi), %eax					# mmap->base_addr_low
231
			movl %eax, (%rdi)
262
			movl %eax, (%rdi)
232
			
263
			
233
			movl 8(%esi), %eax					# mmap->base_addr_high
264
			movl 8(%esi), %eax					# mmap->base_addr_high
234
			movl %eax, 4(%rdi)
265
			movl %eax, 4(%rdi)
235
			
266
			
236
			movl 12(%esi), %eax					# mmap->length_low
267
			movl 12(%esi), %eax					# mmap->length_low
237
			movl %eax, 8(%rdi)
268
			movl %eax, 8(%rdi)
238
			
269
			
239
			movl 16(%esi), %eax					# mmap->length_high
270
			movl 16(%esi), %eax					# mmap->length_high
240
			movl %eax, 12(%rdi)
271
			movl %eax, 12(%rdi)
241
			
272
			
242
			movl 20(%esi), %eax					# mmap->type
273
			movl 20(%esi), %eax					# mmap->type
243
			movl %eax, 16(%rdi)
274
			movl %eax, 16(%rdi)
244
			
275
			
245
			movl (%esi), %eax					# mmap->size
276
			movl (%esi), %eax					# mmap->size
246
			addl $0x4, %eax
277
			addl $0x4, %eax
247
			addl %eax, %esi
278
			addl %eax, %esi
248
			subl %eax, %ecx
279
			subl %eax, %ecx
249
			addq $MEMMAP_E820_RECORD_SIZE, %rdi
280
			addq $MEMMAP_E820_RECORD_SIZE, %rdi
250
			incl %edx
281
			incl %edx
251
			jmp mmap_loop
282
			jmp mmap_loop
252
		
283
		
253
		mmap_end:
284
		mmap_end:
254
		
285
		
255
		mmap_invalid:
286
		mmap_invalid:
256
		movl %edx, e820counter
287
		movl %edx, e820counter
257
		
288
		
258
	invalid_boot:
289
	invalid_boot:
259
	
290
	
260
#ifdef CONFIG_SMP
291
#ifdef CONFIG_SMP
261
	
292
	
262
	# copy AP bootstrap routines below 1 MB
293
	# copy AP bootstrap routines below 1 MB
263
	
294
	
264
	movq $BOOT_OFFSET, %rsi
295
	movq $BOOT_OFFSET, %rsi
265
	movq $AP_BOOT_OFFSET, %rdi
296
	movq $AP_BOOT_OFFSET, %rdi
266
	movq $_hardcoded_unmapped_size, %rcx
297
	movq $_hardcoded_unmapped_size, %rcx
267
	cld
298
	cld
268
	rep movsb
299
	rep movsb
269
	
300
	
270
#endif
301
#endif
271
	
302
	
272
	call main_bsp   # never returns
303
	call main_bsp   # never returns
273
	
304
	
274
	cli
305
	cli
275
	hlt
306
	hlt
276
 
307
 
277
#ifdef CONFIG_FB
308
#ifdef CONFIG_FB
278
.code32
309
.code32
279
vesa_init:
310
vesa_init:
280
	jmp $gdtselector(VESA_INIT_DES), $vesa_init_real - vesa_init
311
	jmp $gdtselector(VESA_INIT_DES), $vesa_init_real - vesa_init
281
	
312
	
282
.code16
313
.code16
283
vesa_init_real:
314
vesa_init_real:
284
	
315
	
285
	mov %cr0, %eax
316
	mov %cr0, %eax
286
	and $~1, %eax
317
	and $~1, %eax
287
	mov %eax, %cr0
318
	mov %eax, %cr0
288
	
319
	
289
	jmp $VESA_INIT_SEGMENT, $vesa_init_real2 - vesa_init
320
	jmp $VESA_INIT_SEGMENT, $vesa_init_real2 - vesa_init
290
	
321
	
291
vesa_init_real2:
322
vesa_init_real2:
292
	
323
	
293
	mov $VESA_INIT_SEGMENT, %bx
324
	mov $VESA_INIT_SEGMENT, %bx
294
	
325
	
295
	mov %bx, %es
326
	mov %bx, %es
296
	mov %bx, %fs
327
	mov %bx, %fs
297
	mov %bx, %gs
328
	mov %bx, %gs
298
	mov %bx, %ds
329
	mov %bx, %ds
299
	mov %bx, %ss
330
	mov %bx, %ss
300
	
331
	
301
	movl $0x0000fffc, %esp
332
	movl $0x0000fffc, %esp
302
    movl $0x0000fffc, %ebp
333
    movl $0x0000fffc, %ebp
303
	
334
	
304
#define VESA_INFO_SIZE 1024
335
#define VESA_INFO_SIZE 1024
305
 
336
 
306
#define VESA_MODE_ATTRIBUTES_OFFSET 0
337
#define VESA_MODE_ATTRIBUTES_OFFSET 0
307
#define VESA_MODE_LIST_PTR_OFFSET 14
338
#define VESA_MODE_LIST_PTR_OFFSET 14
308
#define VESA_MODE_SCANLINE_OFFSET 16
339
#define VESA_MODE_SCANLINE_OFFSET 16
309
#define VESA_MODE_WIDTH_OFFSET 18
340
#define VESA_MODE_WIDTH_OFFSET 18
310
#define VESA_MODE_HEIGHT_OFFSET 20
341
#define VESA_MODE_HEIGHT_OFFSET 20
311
#define VESA_MODE_BPP_OFFSET 25
342
#define VESA_MODE_BPP_OFFSET 25
312
#define VESA_MODE_PHADDR_OFFSET 40
343
#define VESA_MODE_PHADDR_OFFSET 40
313
 
344
 
314
#define VESA_END_OF_MODES 0xffff
345
#define VESA_END_OF_MODES 0xffff
315
 
346
 
316
#define VESA_OK 0x4f
347
#define VESA_OK 0x4f
317
 
348
 
318
#define VESA_GET_INFO 0x4f00
349
#define VESA_GET_INFO 0x4f00
319
#define VESA_GET_MODE_INFO 0x4f01
350
#define VESA_GET_MODE_INFO 0x4f01
320
#define VESA_SET_MODE 0x4f02
351
#define VESA_SET_MODE 0x4f02
321
#define VESA_SET_PALETTE 0x4f09
352
#define VESA_SET_PALETTE 0x4f09
322
 
353
 
323
#define CONFIG_VESA_BPP_a 255
354
#define CONFIG_VESA_BPP_a 255
324
 
355
 
325
#if CONFIG_VESA_BPP == 24
356
#if CONFIG_VESA_BPP == 24
326
#define CONFIG_VESA_BPP_VARIANT 32
357
#define CONFIG_VESA_BPP_VARIANT 32
327
#endif
358
#endif
328
 
359
 
329
	mov $VESA_GET_INFO, %ax
360
	mov $VESA_GET_INFO, %ax
330
	mov $e_vesa_init - vesa_init, %di
361
	mov $e_vesa_init - vesa_init, %di
331
	push %di
362
	push %di
332
	int $0x10
363
	int $0x10
333
	
364
	
334
	pop %di
365
	pop %di
335
	cmp $VESA_OK, %al
366
	cmp $VESA_OK, %al
336
	jnz 0f
367
	jnz 0f
337
	
368
	
338
	mov 2 + VESA_MODE_LIST_PTR_OFFSET(%di), %si
369
	mov 2 + VESA_MODE_LIST_PTR_OFFSET(%di), %si
339
	mov %si, %gs
370
	mov %si, %gs
340
	mov VESA_MODE_LIST_PTR_OFFSET(%di), %si
371
	mov VESA_MODE_LIST_PTR_OFFSET(%di), %si
341
	
372
	
342
	add $VESA_INFO_SIZE, %di
373
	add $VESA_INFO_SIZE, %di
343
 
374
 
344
1:# Try next mode
375
1:# Try next mode
345
	mov %gs:(%si), %cx
376
	mov %gs:(%si), %cx
346
	cmp $VESA_END_OF_MODES, %cx
377
	cmp $VESA_END_OF_MODES, %cx
347
	jz 0f
378
	jz 0f
348
	
379
	
349
	inc %si
380
	inc %si
350
	inc %si
381
	inc %si
351
	push %cx
382
	push %cx
352
	push %di
383
	push %di
353
	push %si
384
	push %si
354
	mov $VESA_GET_MODE_INFO, %ax
385
	mov $VESA_GET_MODE_INFO, %ax
355
	int $0x10
386
	int $0x10
356
	
387
	
357
	pop %si
388
	pop %si
358
	pop %di
389
	pop %di
359
	pop %cx
390
	pop %cx
360
	cmp $VESA_OK, %al
391
	cmp $VESA_OK, %al
361
	jnz 0f
392
	jnz 0f
362
	
393
	
363
	mov $CONFIG_VESA_WIDTH, %ax
394
	mov $CONFIG_VESA_WIDTH, %ax
364
	cmp VESA_MODE_WIDTH_OFFSET(%di), %ax
395
	cmp VESA_MODE_WIDTH_OFFSET(%di), %ax
365
	jnz 1b
396
	jnz 1b
366
	
397
	
367
	mov $CONFIG_VESA_HEIGHT, %ax
398
	mov $CONFIG_VESA_HEIGHT, %ax
368
	cmp VESA_MODE_HEIGHT_OFFSET(%di), %ax
399
	cmp VESA_MODE_HEIGHT_OFFSET(%di), %ax
369
	jnz 1b
400
	jnz 1b
370
	
401
	
371
	mov $CONFIG_VESA_BPP, %al
402
	mov $CONFIG_VESA_BPP, %al
372
	cmp VESA_MODE_BPP_OFFSET(%di), %al
403
	cmp VESA_MODE_BPP_OFFSET(%di), %al
373
 
404
 
374
#ifdef CONFIG_VESA_BPP_VARIANT
405
#ifdef CONFIG_VESA_BPP_VARIANT
375
	jz 2f
406
	jz 2f
376
	
407
	
377
	mov $CONFIG_VESA_BPP_VARIANT, %al
408
	mov $CONFIG_VESA_BPP_VARIANT, %al
378
	cmp VESA_MODE_BPP_OFFSET(%di), %al
409
	cmp VESA_MODE_BPP_OFFSET(%di), %al
379
#endif
410
#endif
380
	jnz 1b
411
	jnz 1b
381
	
412
	
382
2:
413
2:
383
	
414
	
384
	mov %cx, %bx
415
	mov %cx, %bx
385
	or $0xc000, %bx
416
	or $0xc000, %bx
386
	push %di
417
	push %di
387
	mov $VESA_SET_MODE, %ax
418
	mov $VESA_SET_MODE, %ax
388
	int $0x10
419
	int $0x10
389
	
420
	
390
	pop %di
421
	pop %di
391
	cmp $VESA_OK, %al
422
	cmp $VESA_OK, %al
392
	jnz 0f
423
	jnz 0f
393
 
424
 
394
#if CONFIG_VESA_BPP == 8
425
#if CONFIG_VESA_BPP == 8
395
	
426
	
396
	# Set 3:2:3 VGA palette
427
	# Set 3:2:3 VGA palette
397
	
428
	
398
	mov VESA_MODE_ATTRIBUTES_OFFSET(%di), %ax
429
	mov VESA_MODE_ATTRIBUTES_OFFSET(%di), %ax
399
	push %di
430
	push %di
400
	mov $vga323 - vesa_init, %di
431
	mov $vga323 - vesa_init, %di
401
	mov $0x100, %ecx
432
	mov $0x100, %ecx
402
	
433
	
403
	bt $5, %ax							# Test if VGA compatible registers are present
434
	bt $5, %ax							# Test if VGA compatible registers are present
404
	jnc vga_compat
435
	jnc vga_compat
405
		
436
		
406
		# Try VESA routine to set palette
437
		# Try VESA routine to set palette
407
		
438
		
408
		mov $VESA_SET_PALETTE, %ax
439
		mov $VESA_SET_PALETTE, %ax
409
		xor %bl, %bl
440
		xor %bl, %bl
410
		xor %dx, %dx
441
		xor %dx, %dx
411
		int $0x10
442
		int $0x10
412
		
443
		
413
		jmp vga_not_compat
444
		jmp vga_not_compat
414
	
445
	
415
	vga_compat:
446
	vga_compat:
416
		
447
		
417
		# Try VGA registers to set palette
448
		# Try VGA registers to set palette
418
		
449
		
419
		movw $0x3c6, %dx						# Set palette mask
450
		movw $0x3c6, %dx						# Set palette mask
420
		movb $0xff, %al
451
		movb $0xff, %al
421
		outb %al, %dx
452
		outb %al, %dx
422
		
453
		
423
		movw $0x3c8, %dx						# First index to set
454
		movw $0x3c8, %dx						# First index to set
424
		xor %al, %al
455
		xor %al, %al
425
		outb %al, %dx
456
		outb %al, %dx
426
		
457
		
427
		movw $0x3c9, %dx						# Data port
458
		movw $0x3c9, %dx						# Data port
428
		vga_loop:
459
		vga_loop:
429
			movb %es:2(%di), %al
460
			movb %es:2(%di), %al
430
			outb %al, %dx
461
			outb %al, %dx
431
			
462
			
432
			movb %es:1(%di), %al
463
			movb %es:1(%di), %al
433
			outb %al, %dx
464
			outb %al, %dx
434
			
465
			
435
			movb %es:(%di), %al
466
			movb %es:(%di), %al
436
			outb %al, %dx
467
			outb %al, %dx
437
			
468
			
438
			addw $4, %di
469
			addw $4, %di
439
			loop vga_loop
470
			loop vga_loop
440
		
471
		
441
	vga_not_compat:
472
	vga_not_compat:
442
	
473
	
443
	pop %di
474
	pop %di
444
	
475
	
445
#endif
476
#endif
446
	
477
	
447
	mov VESA_MODE_PHADDR_OFFSET(%di), %esi
478
	mov VESA_MODE_PHADDR_OFFSET(%di), %esi
448
	mov VESA_MODE_WIDTH_OFFSET(%di), %ax
479
	mov VESA_MODE_WIDTH_OFFSET(%di), %ax
449
	shl $16, %eax
480
	shl $16, %eax
450
	mov VESA_MODE_HEIGHT_OFFSET(%di), %ax
481
	mov VESA_MODE_HEIGHT_OFFSET(%di), %ax
451
	mov VESA_MODE_BPP_OFFSET(%di), %bl
482
	mov VESA_MODE_BPP_OFFSET(%di), %bl
452
	xor %bh, %bh
483
	xor %bh, %bh
453
	shl $16, %ebx
484
	shl $16, %ebx
454
	mov VESA_MODE_SCANLINE_OFFSET(%di), %bx
485
	mov VESA_MODE_SCANLINE_OFFSET(%di), %bx
455
	mov %eax, %edi
486
	mov %eax, %edi
456
	
487
	
457
8:
488
8:
458
	
489
	
459
	mov %cr0, %eax
490
	mov %cr0, %eax
460
	or $1, %eax
491
	or $1, %eax
461
	mov %eax, %cr0
492
	mov %eax, %cr0
462
	
493
	
463
	jmp 9f
494
	jmp 9f
464
9:
495
9:
465
	
496
	
466
	ljmpl $gdtselector(KTEXT32_DES), $(vesa_init_protect - vesa_init + VESA_INIT_SEGMENT << 4)
497
	ljmpl $gdtselector(KTEXT32_DES), $(vesa_init_protect - vesa_init + VESA_INIT_SEGMENT << 4)
467
	
498
	
468
0:# No prefered mode found
499
0:# No prefered mode found
469
	mov $0x111, %cx
500
	mov $0x111, %cx
470
	push %di
501
	push %di
471
	push %cx
502
	push %cx
472
	mov $VESA_GET_MODE_INFO, %ax
503
	mov $VESA_GET_MODE_INFO, %ax
473
	int $0x10
504
	int $0x10
474
	
505
	
475
	pop %cx
506
	pop %cx
476
	pop %di
507
	pop %di
477
	cmp $VESA_OK, %al
508
	cmp $VESA_OK, %al
478
	jnz 1f
509
	jnz 1f
479
	jz 2b						# Force relative jump
510
	jz 2b						# Force relative jump
480
 
511
 
481
1:
512
1:
482
	mov $0x0003, %ax
513
	mov $0x0003, %ax
483
	int $0x10
514
	int $0x10
484
	mov $0xffffffff, %edi		# EGA text mode used, because of problems with VESA
515
	mov $0xffffffff, %edi		# EGA text mode used, because of problems with VESA
485
	xor %ax, %ax
516
	xor %ax, %ax
486
	jz 8b						# Force relative jump
517
	jz 8b						# Force relative jump
487
 
518
 
488
vga323:
519
vga323:
489
#include "vga323.pal"	
520
#include "vga323.pal"	
490
	
521
	
491
.code32
522
.code32
492
vesa_init_protect:
523
vesa_init_protect:
493
	movw $gdtselector(KDATA_DES), %cx
524
	movw $gdtselector(KDATA_DES), %cx
494
	movw %cx, %es
525
	movw %cx, %es
495
	movw %cx, %ds							# kernel data + stack
526
	movw %cx, %ds							# kernel data + stack
496
	movw %cx, %ss
527
	movw %cx, %ss
497
	# Simics seems to remove hidden part of GS on entering user mode
528
	# Simics seems to remove hidden part of GS on entering user mode
498
	#  when _visible_ part of GS does not point to user-mode segment
529
	#  when _visible_ part of GS does not point to user-mode segment
499
	movw $gdtselector(UDATA_DES), %cx
530
	movw $gdtselector(UDATA_DES), %cx
500
	movw %cx, %fs
531
	movw %cx, %fs
501
	movw %cx, %gs
532
	movw %cx, %gs
502
	
533
	
503
	movl $START_STACK, %esp			# initialize stack pointer
534
	movl $START_STACK, %esp			# initialize stack pointer
504
	
535
	
505
	jmpl $gdtselector(KTEXT32_DES), $vesa_meeting_point
536
	jmpl $gdtselector(KTEXT32_DES), $vesa_meeting_point
506
	
537
	
507
.align 4
538
.align 4
508
e_vesa_init:
539
e_vesa_init:
509
#endif
540
#endif
510
 
541
 
511
# Print string from %esi to EGA display (in red) and halt
542
# Print string from %esi to EGA display (in red) and halt
512
error_halt:
543
error_halt:
513
	movl $0xb8000, %edi						# base of EGA text mode memory
544
	movl $0xb8000, %edi						# base of EGA text mode memory
514
	xorl %eax, %eax
545
	xorl %eax, %eax
515
	
546
	
516
	movw $0x3d4, %dx						# read bits 8 - 15 of the cursor address
547
	movw $0x3d4, %dx						# read bits 8 - 15 of the cursor address
517
	movb $0xe, %al
548
	movb $0xe, %al
518
	outb %al, %dx
549
	outb %al, %dx
519
	
550
	
520
	movw $0x3d5, %dx
551
	movw $0x3d5, %dx
521
	inb %dx, %al
552
	inb %dx, %al
522
	shl $8, %ax
553
	shl $8, %ax
523
	
554
	
524
	movw $0x3d4, %dx						# read bits 0 - 7 of the cursor address
555
	movw $0x3d4, %dx						# read bits 0 - 7 of the cursor address
525
	movb $0xf, %al
556
	movb $0xf, %al
526
	outb %al, %dx
557
	outb %al, %dx
527
	
558
	
528
	movw $0x3d5, %dx
559
	movw $0x3d5, %dx
529
	inb %dx, %al
560
	inb %dx, %al
530
	
561
	
531
	cmp $1920, %ax
562
	cmp $1920, %ax
532
	jbe cursor_ok
563
	jbe cursor_ok
533
		movw $1920, %ax						# sanity check for the cursor on the last line
564
		movw $1920, %ax						# sanity check for the cursor on the last line
534
	cursor_ok:
565
	cursor_ok:
535
	
566
	
536
	movw %ax, %bx
567
	movw %ax, %bx
537
	shl $1, %eax
568
	shl $1, %eax
538
	addl %eax, %edi
569
	addl %eax, %edi
539
	
570
	
540
	movw $0x0c00, %ax						# black background, light red foreground
571
	movw $0x0c00, %ax						# black background, light red foreground
541
	cld
572
	cld
542
	
573
	
543
	ploop:
574
	ploop:
544
		lodsb
575
		lodsb
545
		cmp $0, %al
576
		cmp $0, %al
546
		je ploop_end
577
		je ploop_end
547
		stosw
578
		stosw
548
		inc %bx	
579
		inc %bx	
549
		jmp ploop
580
		jmp ploop
550
	ploop_end:
581
	ploop_end:
551
	
582
	
552
	movw $0x3d4, %dx						# write bits 8 - 15 of the cursor address
583
	movw $0x3d4, %dx						# write bits 8 - 15 of the cursor address
553
	movb $0xe, %al
584
	movb $0xe, %al
554
	outb %al, %dx
585
	outb %al, %dx
555
	
586
	
556
	movw $0x3d5, %dx
587
	movw $0x3d5, %dx
557
	movb %bh, %al
588
	movb %bh, %al
558
	outb %al, %dx
589
	outb %al, %dx
559
	
590
	
560
	movw $0x3d4, %dx						# write bits 0 - 7 of the cursor address
591
	movw $0x3d4, %dx						# write bits 0 - 7 of the cursor address
561
	movb $0xf, %al
592
	movb $0xf, %al
562
	outb %al, %dx
593
	outb %al, %dx
563
	
594
	
564
	movw $0x3d5, %dx
595
	movw $0x3d5, %dx
565
	movb %bl, %al
596
	movb %bl, %al
566
	outb %al, %dx
597
	outb %al, %dx
567
		
598
		
568
	cli
599
	cli
569
	hlt
600
	hlt
570
				
601
				
571
.section K_DATA_START, "aw", @progbits
602
.section K_DATA_START, "aw", @progbits
572
.align 4096
603
.align 4096
573
 
604
 
574
# Identical mapping of first 64MB and the same of -2GB -> 0	
605
# Identical mapping of first 64MB and the same of -2GB -> 0	
575
.global ptl_2
606
.global ptl_2
576
ptl_2:	
607
ptl_2:	
577
	.quad 0x0 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
608
	.quad 0x0 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
578
	.quad 0x200000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
609
	.quad 0x200000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
579
	.quad 0x400000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
610
	.quad 0x400000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
580
	.quad 0x600000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
611
	.quad 0x600000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
581
	.quad 0x800000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
612
	.quad 0x800000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
582
	.quad 0xa00000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
613
	.quad 0xa00000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
583
	.quad 0xc00000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
614
	.quad 0xc00000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
584
	.quad 0xe00000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
615
	.quad 0xe00000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
585
	.quad 0x1000000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
616
	.quad 0x1000000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
586
	.quad 0x1200000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
617
	.quad 0x1200000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
587
	.quad 0x1400000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
618
	.quad 0x1400000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
588
	.quad 0x1600000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
619
	.quad 0x1600000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
589
	.quad 0x1800000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
620
	.quad 0x1800000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
590
	.quad 0x1a00000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
621
	.quad 0x1a00000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
591
	.quad 0x1c00000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
622
	.quad 0x1c00000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
592
	.quad 0x1e00000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
623
	.quad 0x1e00000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
593
	.quad 0x2000000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
624
	.quad 0x2000000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
594
	.quad 0x2200000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
625
	.quad 0x2200000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
595
	.quad 0x2400000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
626
	.quad 0x2400000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
596
	.quad 0x2600000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
627
	.quad 0x2600000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
597
	.quad 0x2800000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
628
	.quad 0x2800000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
598
	.quad 0x2a00000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
629
	.quad 0x2a00000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
599
	.quad 0x2c00000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
630
	.quad 0x2c00000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
600
	.quad 0x2e00000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
631
	.quad 0x2e00000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
601
	.quad 0x3000000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
632
	.quad 0x3000000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
602
	.quad 0x3200000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
633
	.quad 0x3200000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
603
	.quad 0x3400000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
634
	.quad 0x3400000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
604
	.quad 0x3600000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
635
	.quad 0x3600000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
605
	.quad 0x3800000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
636
	.quad 0x3800000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
606
	.quad 0x3a00000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
637
	.quad 0x3a00000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
607
	.quad 0x3c00000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
638
	.quad 0x3c00000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
608
	.quad 0x3e00000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
639
	.quad 0x3e00000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
609
	
640
	
610
.align 4096
641
.align 4096
611
.global ptl_1
642
.global ptl_1
612
ptl_1:
643
ptl_1:
613
	.quad ptl_2 + (PTL_WRITABLE | PTL_PRESENT)
644
	.quad ptl_2 + (PTL_WRITABLE | PTL_PRESENT)
614
	.fill 509,8,0
645
	.fill 509,8,0
615
	.quad ptl_2 + (PTL_WRITABLE | PTL_PRESENT)
646
	.quad ptl_2 + (PTL_WRITABLE | PTL_PRESENT)
616
	.fill 1,8,0
647
	.fill 1,8,0
617
	
648
	
618
.align 4096
649
.align 4096
619
.global ptl_0
650
.global ptl_0
620
ptl_0:
651
ptl_0:
621
	.quad ptl_1 + (PTL_WRITABLE | PTL_PRESENT)
652
	.quad ptl_1 + (PTL_WRITABLE | PTL_PRESENT)
622
	.fill 255,8,0
653
	.fill 255,8,0
623
	.quad ptl_1 + (PTL_WRITABLE | PTL_PRESENT)
654
	.quad ptl_1 + (PTL_WRITABLE | PTL_PRESENT)
624
	.fill 254,8,0
655
	.fill 254,8,0
625
	.quad ptl_1 + (PTL_WRITABLE | PTL_PRESENT)
656
	.quad ptl_1 + (PTL_WRITABLE | PTL_PRESENT)
626
 
657
 
627
.global bootstrap_gdtr
658
.global bootstrap_gdtr
628
bootstrap_gdtr:
659
bootstrap_gdtr:
629
	.word gdtselector(GDT_ITEMS)
660
	.word gdtselector(GDT_ITEMS)
630
	.long KA2PA(gdt)
661
	.long KA2PA(gdt)
631
 
662
 
632
grub_eax:
663
grub_eax:
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."
640
 
679