Subversion Repositories HelenOS

Rev

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

Rev 798 Rev 807
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, %gs
-
 
62
	movw %cx, %fs
-
 
63
	movw %cx, %ds							# kernel data + stack
61
	movw %cx, %ds							# kernel data + stack
64
	movw %cx, %ss
62
	movw %cx, %ss
-
 
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
-
 
65
	movw $gdtselector(UDATA_DES), %cx
-
 
66
	movw %cx, %fs
-
 
67
	movw %cx, %gs
65
	
68
	
66
	jmpl $gdtselector(KTEXT32_DES), $multiboot_meeting_point
69
	jmpl $gdtselector(KTEXT32_DES), $multiboot_meeting_point
67
	multiboot_meeting_point:
70
	multiboot_meeting_point:
68
	
71
	
69
	movl %eax, grub_eax							# save parameters from GRUB
72
	movl %eax, grub_eax							# save parameters from GRUB
70
	movl %ebx, grub_ebx
73
	movl %ebx, grub_ebx
71
	
74
	
72
	# Protected 32-bit. We want to reuse the code-seg descriptor,
75
	# Protected 32-bit. We want to reuse the code-seg descriptor,
73
	# 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
74
	
77
	
75
	movl $0x80000000, %eax  
78
	movl $0x80000000, %eax  
76
 	cpuid
79
 	cpuid
77
 	cmp $0x80000000, %eax						# any function > 80000000h?
80
 	cmp $0x80000000, %eax						# any function > 80000000h?
78
	jbe long_mode_unsupported
81
	jbe long_mode_unsupported
79
	movl $(AMD_CPUID_EXTENDED), %eax			# Extended function code 80000001
82
	movl $(AMD_CPUID_EXTENDED), %eax			# Extended function code 80000001
80
	cpuid
83
	cpuid
81
	bt $29, %edx								# Test if long mode is supported.
84
	bt $29, %edx								# Test if long mode is supported.
82
 	jc long_mode_supported
85
 	jc long_mode_supported
83
 
86
 
84
	long_mode_unsupported:
87
	long_mode_unsupported:
85
		cli
88
		cli
86
		hlt
89
		hlt
87
	
90
	
88
	long_mode_supported:
91
	long_mode_supported:
89
	
92
	
90
	# Enable 64-bit page transaltion entries - CR4.PAE = 1.
93
	# Enable 64-bit page transaltion entries - CR4.PAE = 1.
91
	# Paging is not enabled until after long mode is enabled
94
	# Paging is not enabled until after long mode is enabled
92
	
95
	
93
	movl %cr4, %eax
96
	movl %cr4, %eax
94
	btsl $5, %eax
97
	btsl $5, %eax
95
	movl %eax, %cr4
98
	movl %eax, %cr4
96
 
99
 
97
	# Set up paging tables
100
	# Set up paging tables
98
	
101
	
99
	leal ptl_0, %eax
102
	leal ptl_0, %eax
100
	movl %eax, %cr3
103
	movl %eax, %cr3
101
	
104
	
102
	# Enable long mode
105
	# Enable long mode
103
	
106
	
104
	movl $EFER_MSR_NUM, %ecx	# EFER MSR number
107
	movl $EFER_MSR_NUM, %ecx	# EFER MSR number
105
	rdmsr						# Read EFER
108
	rdmsr						# Read EFER
106
	btsl $AMD_LME_FLAG, %eax	# Set LME=1
109
	btsl $AMD_LME_FLAG, %eax	# Set LME=1
107
	wrmsr						# Write EFER
110
	wrmsr						# Write EFER
108
	
111
	
109
	# Enable paging to activate long mode (set CR0.PG=1)
112
	# Enable paging to activate long mode (set CR0.PG=1)
110
	
113
	
111
	movl %cr0, %eax
114
	movl %cr0, %eax
112
	btsl $31, %eax
115
	btsl $31, %eax
113
	movl %eax, %cr0
116
	movl %eax, %cr0
114
	
117
	
115
	# At this point we are in compatibility mode
118
	# At this point we are in compatibility mode
116
	
119
	
117
	jmpl $gdtselector(KTEXT_DES), $start64
120
	jmpl $gdtselector(KTEXT_DES), $start64
118
 
121
 
119
.code64
122
.code64
120
start64:
123
start64:
121
	movq $(PA2KA(START_STACK)), %rsp
124
	movq $(PA2KA(START_STACK)), %rsp
122
	movl grub_eax, %eax
125
	movl grub_eax, %eax
123
	movl grub_ebx, %ebx
126
	movl grub_ebx, %ebx
124
	
127
	
125
	cmpl $MULTIBOOT_LOADER_MAGIC, %eax				# compare GRUB signature
128
	cmpl $MULTIBOOT_LOADER_MAGIC, %eax				# compare GRUB signature
126
	je valid_boot
129
	je valid_boot
127
		
130
		
128
		xorl %ecx, %ecx							# no memory size or map available
131
		xorl %ecx, %ecx							# no memory size or map available
129
		movl %ecx, e801memorysize
132
		movl %ecx, e801memorysize
130
		movl %ecx, e820counter
133
		movl %ecx, e820counter
131
		
134
		
132
		jmp invalid_boot
135
		jmp invalid_boot
133
		
136
		
134
	valid_boot:
137
	valid_boot:
135
		
138
		
136
		movl (%ebx), %eax						# ebx = physical address of struct multiboot_info
139
		movl (%ebx), %eax						# ebx = physical address of struct multiboot_info
137
		
140
		
138
		bt $0, %eax								# mbi->flags[0] (mem_lower, mem_upper valid)
141
		bt $0, %eax								# mbi->flags[0] (mem_lower, mem_upper valid)
139
		jc mem_valid
142
		jc mem_valid
140
			
143
			
141
			xorl %ecx, %ecx
144
			xorl %ecx, %ecx
142
			jmp mem_invalid
145
			jmp mem_invalid
143
			
146
			
144
		mem_valid:
147
		mem_valid:
145
		movl 4(%ebx), %ecx						# mbi->mem_lower
148
		movl 4(%ebx), %ecx						# mbi->mem_lower
146
		addl 8(%ebx), %ecx						# mbi->mem_upper
149
		addl 8(%ebx), %ecx						# mbi->mem_upper
147
		
150
		
148
		mem_invalid:
151
		mem_invalid:
149
		movl %ecx, e801memorysize
152
		movl %ecx, e801memorysize
150
		
153
		
151
		bt $3, %eax								# mbi->flags[3] (mods_count, mods_addr valid)	
154
		bt $3, %eax								# mbi->flags[3] (mods_count, mods_addr valid)	
152
		jc mods_valid
155
		jc mods_valid
153
			
156
			
154
			xorl %ecx, %ecx
157
			xorl %ecx, %ecx
155
			xorl %edx, %edx
158
			xorl %edx, %edx
156
			jmp mods_invalid
159
			jmp mods_invalid
157
		
160
		
158
		mods_valid:
161
		mods_valid:
159
		movl 20(%ebx), %ecx						# mbi->mods_count
162
		movl 20(%ebx), %ecx						# mbi->mods_count
160
		cmpl $0, %ecx
163
		cmpl $0, %ecx
161
		je mods_invalid
164
		je mods_invalid
162
		
165
		
163
		xorq %rdx, %rdx
166
		xorq %rdx, %rdx
164
		movl 24(%ebx), %esi						# mbi->mods_addr
167
		movl 24(%ebx), %esi						# mbi->mods_addr
165
		movl 0(%esi), %edx						# mods->mod_start
168
		movl 0(%esi), %edx						# mods->mod_start
166
		movl 4(%esi), %ecx						# mods->mod_end
169
		movl 4(%esi), %ecx						# mods->mod_end
167
		subl %edx, %ecx
170
		subl %edx, %ecx
168
		addq $0xffffffff80000000, %rdx
171
		addq $0xffffffff80000000, %rdx
169
		
172
		
170
		mods_invalid:
173
		mods_invalid:
171
		movl %ecx, init_size
174
		movl %ecx, init_size
172
		movq %rdx, init_addr
175
		movq %rdx, init_addr
173
		
176
		
174
		bt $6, %eax								# mbi->flags[6] (mmap_length, mmap_addr valid)	
177
		bt $6, %eax								# mbi->flags[6] (mmap_length, mmap_addr valid)	
175
		jc mmap_valid
178
		jc mmap_valid
176
			
179
			
177
			xorl %edx, %edx
180
			xorl %edx, %edx
178
			jmp mmap_invalid
181
			jmp mmap_invalid
179
			
182
			
180
		mmap_valid:
183
		mmap_valid:
181
		movl 44(%ebx), %ecx						# mbi->mmap_length
184
		movl 44(%ebx), %ecx						# mbi->mmap_length
182
		movl 48(%ebx), %esi						# mbi->mmap_addr
185
		movl 48(%ebx), %esi						# mbi->mmap_addr
183
		movq $e820table, %rdi
186
		movq $e820table, %rdi
184
		xorl %edx, %edx
187
		xorl %edx, %edx
185
		
188
		
186
		mmap_loop:
189
		mmap_loop:
187
			cmpl $0, %ecx
190
			cmpl $0, %ecx
188
			jle mmap_end
191
			jle mmap_end
189
			
192
			
190
			movl 4(%esi), %eax					# mmap->base_addr_low
193
			movl 4(%esi), %eax					# mmap->base_addr_low
191
			movl %eax, (%rdi)
194
			movl %eax, (%rdi)
192
			
195
			
193
			movl 8(%esi), %eax					# mmap->base_addr_high
196
			movl 8(%esi), %eax					# mmap->base_addr_high
194
			movl %eax, 4(%rdi)
197
			movl %eax, 4(%rdi)
195
			
198
			
196
			movl 12(%esi), %eax					# mmap->length_low
199
			movl 12(%esi), %eax					# mmap->length_low
197
			movl %eax, 8(%rdi)
200
			movl %eax, 8(%rdi)
198
			
201
			
199
			movl 16(%esi), %eax					# mmap->length_high
202
			movl 16(%esi), %eax					# mmap->length_high
200
			movl %eax, 12(%rdi)
203
			movl %eax, 12(%rdi)
201
			
204
			
202
			movl 20(%esi), %eax					# mmap->type
205
			movl 20(%esi), %eax					# mmap->type
203
			movl %eax, 16(%rdi)
206
			movl %eax, 16(%rdi)
204
			
207
			
205
			movl (%esi), %eax					# mmap->size
208
			movl (%esi), %eax					# mmap->size
206
			addl $0x4, %eax
209
			addl $0x4, %eax
207
			addl %eax, %esi
210
			addl %eax, %esi
208
			subl %eax, %ecx
211
			subl %eax, %ecx
209
			addq $MEMMAP_E820_RECORD_SIZE, %rdi
212
			addq $MEMMAP_E820_RECORD_SIZE, %rdi
210
			incl %edx
213
			incl %edx
211
			jmp mmap_loop
214
			jmp mmap_loop
212
		
215
		
213
		mmap_end:
216
		mmap_end:
214
		
217
		
215
		mmap_invalid:
218
		mmap_invalid:
216
		movl %edx, e820counter
219
		movl %edx, e820counter
217
		
220
		
218
	invalid_boot:
221
	invalid_boot:
219
	
222
	
220
#ifdef CONFIG_SMP
223
#ifdef CONFIG_SMP
221
	
224
	
222
	# copy AP bootstrap routines below 1 MB
225
	# copy AP bootstrap routines below 1 MB
223
	
226
	
224
	movq $BOOT_OFFSET, %rsi
227
	movq $BOOT_OFFSET, %rsi
225
	movq $AP_BOOT_OFFSET, %rdi
228
	movq $AP_BOOT_OFFSET, %rdi
226
	movq $_hardcoded_unmapped_size, %rcx
229
	movq $_hardcoded_unmapped_size, %rcx
227
	cld
230
	cld
228
	rep movsb
231
	rep movsb
229
	
232
	
230
#endif
233
#endif
231
	
234
	
232
	call main_bsp   # never returns
235
	call main_bsp   # never returns
233
	
236
	
234
	cli
237
	cli
235
	hlt
238
	hlt
236
				
239
				
237
.section K_DATA_START, "aw", @progbits
240
.section K_DATA_START, "aw", @progbits
238
.align 4096
241
.align 4096
239
 
242
 
240
# Identical mapping of first 64MB and the same of -2GB -> 0	
243
# Identical mapping of first 64MB and the same of -2GB -> 0	
241
.global ptl_2
244
.global ptl_2
242
ptl_2:	
245
ptl_2:	
243
	.quad 0x0 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
246
	.quad 0x0 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
244
	.quad 0x200000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
247
	.quad 0x200000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
245
	.quad 0x400000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
248
	.quad 0x400000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
246
	.quad 0x600000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
249
	.quad 0x600000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
247
	.quad 0x800000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
250
	.quad 0x800000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
248
	.quad 0xa00000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
251
	.quad 0xa00000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
249
	.quad 0xc00000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
252
	.quad 0xc00000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
250
	.quad 0xe00000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
253
	.quad 0xe00000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
251
	.quad 0x1000000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
254
	.quad 0x1000000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
252
	.quad 0x1200000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
255
	.quad 0x1200000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
253
	.quad 0x1400000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
256
	.quad 0x1400000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
254
	.quad 0x1600000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
257
	.quad 0x1600000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
255
	.quad 0x1800000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
258
	.quad 0x1800000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
256
	.quad 0x1a00000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
259
	.quad 0x1a00000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
257
	.quad 0x1c00000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
260
	.quad 0x1c00000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
258
	.quad 0x1e00000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
261
	.quad 0x1e00000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
259
	.quad 0x2000000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
262
	.quad 0x2000000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
260
	.quad 0x2200000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
263
	.quad 0x2200000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
261
	.quad 0x2400000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
264
	.quad 0x2400000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
262
	.quad 0x2600000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
265
	.quad 0x2600000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
263
	.quad 0x2800000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
266
	.quad 0x2800000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
264
	.quad 0x2a00000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
267
	.quad 0x2a00000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
265
	.quad 0x2c00000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
268
	.quad 0x2c00000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
266
	.quad 0x2e00000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
269
	.quad 0x2e00000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
267
	.quad 0x3000000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
270
	.quad 0x3000000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
268
	.quad 0x3200000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
271
	.quad 0x3200000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
269
	.quad 0x3400000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
272
	.quad 0x3400000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
270
	.quad 0x3600000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
273
	.quad 0x3600000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
271
	.quad 0x3800000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
274
	.quad 0x3800000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
272
	.quad 0x3a00000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
275
	.quad 0x3a00000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
273
	.quad 0x3c00000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
276
	.quad 0x3c00000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
274
	.quad 0x3e00000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
277
	.quad 0x3e00000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
275
	
278
	
276
.align 4096
279
.align 4096
277
.global ptl_1
280
.global ptl_1
278
ptl_1:
281
ptl_1:
279
	.quad ptl_2 + (PTL_WRITABLE | PTL_PRESENT)
282
	.quad ptl_2 + (PTL_WRITABLE | PTL_PRESENT)
280
	.fill 509,8,0
283
	.fill 509,8,0
281
	.quad ptl_2 + (PTL_WRITABLE | PTL_PRESENT)
284
	.quad ptl_2 + (PTL_WRITABLE | PTL_PRESENT)
282
	.fill 1,8,0
285
	.fill 1,8,0
283
	
286
	
284
.align 4096
287
.align 4096
285
.global ptl_0
288
.global ptl_0
286
ptl_0:
289
ptl_0:
287
	.quad ptl_1 + (PTL_WRITABLE | PTL_PRESENT)
290
	.quad ptl_1 + (PTL_WRITABLE | PTL_PRESENT)
288
	.fill 510,8,0
291
	.fill 510,8,0
289
	.quad ptl_1 + (PTL_WRITABLE | PTL_PRESENT)
292
	.quad ptl_1 + (PTL_WRITABLE | PTL_PRESENT)
290
 
293
 
291
.global bootstrap_gdtr
294
.global bootstrap_gdtr
292
bootstrap_gdtr:
295
bootstrap_gdtr:
293
	.word gdtselector(GDT_ITEMS)
296
	.word gdtselector(GDT_ITEMS)
294
	.long KA2PA(gdt)
297
	.long KA2PA(gdt)
295
 
298
 
296
grub_eax:
299
grub_eax:
297
	.long 0
300
	.long 0
298
 
301
 
299
grub_ebx:
302
grub_ebx:
300
	.long 0
303
	.long 0
301
 
304