Subversion Repositories HelenOS-historic

Rev

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

Rev 695 Rev 696
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:
8
#
9
#
9
# - Redistributions of source code must retain the above copyright
10
# - Redistributions of source code must retain the above copyright
10
#   notice, this list of conditions and the following disclaimer.
11
#   notice, this list of conditions and the following disclaimer.
11
# - Redistributions in binary form must reproduce the above copyright
12
# - Redistributions in binary form must reproduce the above copyright
12
#   notice, this list of conditions and the following disclaimer in the
13
#   notice, this list of conditions and the following disclaimer in the
13
#   documentation and/or other materials provided with the distribution.
14
#   documentation and/or other materials provided with the distribution.
14
# - 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
15
#   derived from this software without specific prior written permission.
16
#   derived from this software without specific prior written permission.
16
#
17
#
17
# 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
18
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20
# 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,
21
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22
# 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,
23
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
# (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
26
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
#
28
#
28
 
29
 
29
#include <arch/boot/boot.h>
30
#include <arch/boot/boot.h>
30
#include <arch/boot/memmap.h>
31
#include <arch/boot/memmap.h>
31
#include <arch/mm/page.h>	
32
#include <arch/mm/page.h>	
32
#include <arch/mm/ptl.h>
33
#include <arch/mm/ptl.h>
33
#include <arch/pm.h>
34
#include <arch/pm.h>
34
#include <arch/cpu.h>
35
#include <arch/cpu.h>
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
64
	.long MULTIBOOT_HEADER_FLAGS
47
	.long MULTIBOOT_HEADER_FLAGS
65
	.long -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS)	# checksum
48
	.long -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS)	# checksum
66
	.long multiboot_header
49
	.long multiboot_header
67
	.long unmapped_ktext_start
50
	.long unmapped_ktext_start
68
	.long 0
51
	.long 0
69
	.long 0
52
	.long 0
70
	.long multiboot_image_start
53
	.long multiboot_image_start
71
 
54
 
72
multiboot_image_start:
55
multiboot_image_start:
73
	movl $START_STACK, %esp			# initialize stack pointer
56
	movl $START_STACK, %esp			# initialize stack pointer
74
	lgdt bootstrap_gdtr				# initialize Global Descriptor Table register
57
	lgdt bootstrap_gdtr				# initialize Global Descriptor Table register
75
 
58
 
76
	movw $gdtselector(KDATA_DES), %cx
59
	movw $gdtselector(KDATA_DES), %cx
77
	movw %cx, %es
60
	movw %cx, %es
78
	movw %cx, %gs
61
	movw %cx, %gs
79
	movw %cx, %fs
62
	movw %cx, %fs
80
	movw %cx, %ds							# kernel data + stack
63
	movw %cx, %ds							# kernel data + stack
81
	movw %cx, %ss
64
	movw %cx, %ss
82
	
65
	
83
	jmpl $gdtselector(KTEXT32_DES), $multiboot_meeting_point
66
	jmpl $gdtselector(KTEXT32_DES), $multiboot_meeting_point
84
	multiboot_meeting_point:
67
	multiboot_meeting_point:
85
	
68
	
86
	movl %eax, grub_eax							# save parameters from GRUB
69
	movl %eax, grub_eax							# save parameters from GRUB
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
97
	movl %eax, %cr4
95
	movl %eax, %cr4
98
 
96
 
99
	# Set up paging tables
97
	# Set up paging tables
100
	
98
	
101
	leal ptl_0, %eax
99
	leal ptl_0, %eax
102
	movl %eax, %cr3
100
	movl %eax, %cr3
103
	
101
	
104
	# Enable long mode
102
	# Enable long mode
105
	
103
	
106
	movl $EFER_MSR_NUM, %ecx	# EFER MSR number
104
	movl $EFER_MSR_NUM, %ecx	# EFER MSR number
107
	rdmsr						# Read EFER
105
	rdmsr						# Read EFER
108
	btsl $AMD_LME_FLAG, %eax	# Set LME=1
106
	btsl $AMD_LME_FLAG, %eax	# Set LME=1
109
	wrmsr						# Write EFER
107
	wrmsr						# Write EFER
110
	
108
	
111
	# Enable paging to activate long mode (set CR0.PG=1)
109
	# Enable paging to activate long mode (set CR0.PG=1)
112
	
110
	
113
	movl %cr0, %eax
111
	movl %cr0, %eax
114
	btsl $31, %eax
112
	btsl $31, %eax
115
	movl %eax, %cr0
113
	movl %eax, %cr0
116
	
114
	
117
	# At this point we are in compatibility mode
115
	# At this point we are in compatibility mode
118
	
116
	
119
	jmpl $gdtselector(KTEXT_DES), $start64
117
	jmpl $gdtselector(KTEXT_DES), $start64
120
 
118
 
121
.code64
119
.code64
122
start64:
120
start64:
123
	movq $(PA2KA(START_STACK)), %rsp
121
	movq $(PA2KA(START_STACK)), %rsp
124
	movl grub_eax, %eax
122
	movl grub_eax, %eax
125
	movl grub_ebx, %ebx
123
	movl grub_ebx, %ebx
126
	
124
	
127
	cmpl $MULTIBOOT_LOADER_MAGIC, %eax				# compare GRUB signature
125
	cmpl $MULTIBOOT_LOADER_MAGIC, %eax				# compare GRUB signature
128
	je valid_boot
126
	je valid_boot
129
		
127
		
130
		xorl %ecx, %ecx							# no memory size or map available
128
		xorl %ecx, %ecx							# no memory size or map available
131
		movl %ecx, e801memorysize
129
		movl %ecx, e801memorysize
132
		movl %ecx, e820counter
130
		movl %ecx, e820counter
133
		
131
		
134
		jmp invalid_boot
132
		jmp invalid_boot
135
		
133
		
136
	valid_boot:
134
	valid_boot:
137
		
135
		
138
		movl (%ebx), %eax						# ebx = physical address of struct multiboot_info
136
		movl (%ebx), %eax						# ebx = physical address of struct multiboot_info
139
		
137
		
140
		bt $0, %eax								# mbi->flags[0] (mem_lower, mem_upper valid)
138
		bt $0, %eax								# mbi->flags[0] (mem_lower, mem_upper valid)
141
		jc mem_valid
139
		jc mem_valid
142
			
140
			
143
			xorl %ecx, %ecx
141
			xorl %ecx, %ecx
144
			jmp mem_invalid
142
			jmp mem_invalid
145
			
143
			
146
		mem_valid:
144
		mem_valid:
147
		movl 4(%ebx), %ecx						# mbi->mem_lower
145
		movl 4(%ebx), %ecx						# mbi->mem_lower
148
		addl 8(%ebx), %ecx						# mbi->mem_upper
146
		addl 8(%ebx), %ecx						# mbi->mem_upper
149
		
147
		
150
		mem_invalid:
148
		mem_invalid:
151
		movl %ecx, e801memorysize
149
		movl %ecx, e801memorysize
152
		
150
		
153
		bt $3, %eax								# mbi->flags[3] (mods_count, mods_addr valid)	
151
		bt $3, %eax								# mbi->flags[3] (mods_count, mods_addr valid)	
154
		jc mods_valid
152
		jc mods_valid
155
			
153
			
156
			xorl %ecx, %ecx
154
			xorl %ecx, %ecx
157
			xorl %edx, %edx
155
			xorl %edx, %edx
158
			jmp mods_invalid
156
			jmp mods_invalid
159
		
157
		
160
		mods_valid:
158
		mods_valid:
161
		movl 20(%ebx), %ecx						# mbi->mods_count
159
		movl 20(%ebx), %ecx						# mbi->mods_count
162
		cmpl $0, %ecx
160
		cmpl $0, %ecx
163
		je mods_invalid
161
		je mods_invalid
164
		
162
		
165
		movl 24(%ebx), %esi						# mbi->mods_addr
163
		movl 24(%ebx), %esi						# mbi->mods_addr
166
		movl 0(%esi), %edx						# mods->mod_start
164
		movl 0(%esi), %edx						# mods->mod_start
167
		movl 4(%esi), %ecx						# mods->mod_end
165
		movl 4(%esi), %ecx						# mods->mod_end
168
		subl %edx, %ecx
166
		subl %edx, %ecx
169
		addl $0x80000000, %edx
167
		addl $0x80000000, %edx
170
		
168
		
171
		mods_invalid:
169
		mods_invalid:
172
		movl %ecx, init_size
170
		movl %ecx, init_size
173
		movl %edx, init_addr
171
		movl %edx, init_addr
174
		
172
		
175
		bt $6, %eax								# mbi->flags[6] (mmap_length, mmap_addr valid)	
173
		bt $6, %eax								# mbi->flags[6] (mmap_length, mmap_addr valid)	
176
		jc mmap_valid
174
		jc mmap_valid
177
			
175
			
178
			xorl %edx, %edx
176
			xorl %edx, %edx
179
			jmp mmap_invalid
177
			jmp mmap_invalid
180
			
178
			
181
		mmap_valid:
179
		mmap_valid:
182
		movl 44(%ebx), %ecx						# mbi->mmap_length
180
		movl 44(%ebx), %ecx						# mbi->mmap_length
183
		movl 48(%ebx), %esi						# mbi->mmap_addr
181
		movl 48(%ebx), %esi						# mbi->mmap_addr
184
		movq $e820table, %rdi
182
		movq $e820table, %rdi
185
		xorl %edx, %edx
183
		xorl %edx, %edx
186
		
184
		
187
		mmap_loop:
185
		mmap_loop:
188
			cmpl $0, %ecx
186
			cmpl $0, %ecx
189
			jle mmap_end
187
			jle mmap_end
190
			
188
			
191
			movl 4(%esi), %eax					# mmap->base_addr_low
189
			movl 4(%esi), %eax					# mmap->base_addr_low
192
			movl %eax, (%rdi)
190
			movl %eax, (%rdi)
193
			
191
			
194
			movl 8(%esi), %eax					# mmap->base_addr_high
192
			movl 8(%esi), %eax					# mmap->base_addr_high
195
			movl %eax, 4(%rdi)
193
			movl %eax, 4(%rdi)
196
			
194
			
197
			movl 12(%esi), %eax					# mmap->length_low
195
			movl 12(%esi), %eax					# mmap->length_low
198
			movl %eax, 8(%rdi)
196
			movl %eax, 8(%rdi)
199
			
197
			
200
			movl 16(%esi), %eax					# mmap->length_high
198
			movl 16(%esi), %eax					# mmap->length_high
201
			movl %eax, 12(%rdi)
199
			movl %eax, 12(%rdi)
202
			
200
			
203
			movl 20(%esi), %eax					# mmap->type
201
			movl 20(%esi), %eax					# mmap->type
204
			movl %eax, 16(%rdi)
202
			movl %eax, 16(%rdi)
205
			
203
			
206
			movl (%esi), %eax					# mmap->size
204
			movl (%esi), %eax					# mmap->size
207
			addl $0x4, %eax
205
			addl $0x4, %eax
208
			addl %eax, %esi
206
			addl %eax, %esi
209
			subl %eax, %ecx
207
			subl %eax, %ecx
210
			addq $MEMMAP_E820_RECORD_SIZE, %rdi
208
			addq $MEMMAP_E820_RECORD_SIZE, %rdi
211
			incl %edx
209
			incl %edx
212
			jmp mmap_loop
210
			jmp mmap_loop
213
		
211
		
214
		mmap_end:
212
		mmap_end:
215
		
213
		
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
				
226
.section K_DATA_START, "aw", @progbits
236
.section K_DATA_START, "aw", @progbits
227
.align 4096
237
.align 4096
228
 
238
 
229
# Identical mapping of first 64MB and the same of -2GB -> 0	
239
# Identical mapping of first 64MB and the same of -2GB -> 0	
230
.global ptl_2
240
.global ptl_2
231
ptl_2:	
241
ptl_2:	
232
	.quad 0x0 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
242
	.quad 0x0 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
233
	.quad 0x200000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
243
	.quad 0x200000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
234
	.quad 0x400000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
244
	.quad 0x400000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
235
	.quad 0x600000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
245
	.quad 0x600000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
236
	.quad 0x800000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
246
	.quad 0x800000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
237
	.quad 0xa00000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
247
	.quad 0xa00000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
238
	.quad 0xc00000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
248
	.quad 0xc00000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
239
	.quad 0xe00000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
249
	.quad 0xe00000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
240
	.quad 0x1000000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
250
	.quad 0x1000000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
241
	.quad 0x1200000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
251
	.quad 0x1200000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
242
	.quad 0x1400000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
252
	.quad 0x1400000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
243
	.quad 0x1600000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
253
	.quad 0x1600000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
244
	.quad 0x1800000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
254
	.quad 0x1800000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
245
	.quad 0x1a00000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
255
	.quad 0x1a00000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
246
	.quad 0x1c00000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
256
	.quad 0x1c00000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
247
	.quad 0x1e00000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
257
	.quad 0x1e00000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
248
	.quad 0x2000000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
258
	.quad 0x2000000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
249
	.quad 0x2200000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
259
	.quad 0x2200000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
250
	.quad 0x2400000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
260
	.quad 0x2400000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
251
	.quad 0x2600000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
261
	.quad 0x2600000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
252
	.quad 0x2800000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
262
	.quad 0x2800000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
253
	.quad 0x2a00000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
263
	.quad 0x2a00000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
254
	.quad 0x2c00000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
264
	.quad 0x2c00000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
255
	.quad 0x2e00000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
265
	.quad 0x2e00000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
256
	.quad 0x3000000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
266
	.quad 0x3000000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
257
	.quad 0x3200000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
267
	.quad 0x3200000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
258
	.quad 0x3400000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
268
	.quad 0x3400000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
259
	.quad 0x3600000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
269
	.quad 0x3600000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
260
	.quad 0x3800000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
270
	.quad 0x3800000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
261
	.quad 0x3a00000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
271
	.quad 0x3a00000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
262
	.quad 0x3c00000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
272
	.quad 0x3c00000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
263
	.quad 0x3e00000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
273
	.quad 0x3e00000 | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
264
	
274
	
265
.align 4096
275
.align 4096
266
.global ptl_1
276
.global ptl_1
267
ptl_1:
277
ptl_1:
268
	.quad ptl_2 + (PTL_WRITABLE | PTL_PRESENT)
278
	.quad ptl_2 + (PTL_WRITABLE | PTL_PRESENT)
269
	.fill 509,8,0
279
	.fill 509,8,0
270
	.quad ptl_2 + (PTL_WRITABLE | PTL_PRESENT)
280
	.quad ptl_2 + (PTL_WRITABLE | PTL_PRESENT)
271
	.fill 1,8,0
281
	.fill 1,8,0
272
	
282
	
273
.align 4096
283
.align 4096
274
.global ptl_0
284
.global ptl_0
275
ptl_0:
285
ptl_0:
276
	.quad ptl_1 + (PTL_WRITABLE | PTL_PRESENT)
286
	.quad ptl_1 + (PTL_WRITABLE | PTL_PRESENT)
277
	.fill 510,8,0
287
	.fill 510,8,0
278
	.quad ptl_1 + (PTL_WRITABLE | PTL_PRESENT)
288
	.quad ptl_1 + (PTL_WRITABLE | PTL_PRESENT)
279
 
289
 
280
.global bootstrap_gdtr
290
.global bootstrap_gdtr
281
bootstrap_gdtr:
291
bootstrap_gdtr:
282
	.word gdtselector(GDT_ITEMS)
292
	.word gdtselector(GDT_ITEMS)
283
	.long KA2PA(gdt)
293
	.long KA2PA(gdt)
284
 
294
 
285
grub_eax:
295
grub_eax:
286
	.long 0
296
	.long 0
287
 
297
 
288
grub_ebx:
298
grub_ebx:
289
	.long 0
299
	.long 0
290
 
300