]>
Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /* |
2 | * linux/arch/i386/kernel/head.S -- the 32-bit startup code. | |
3 | * | |
4 | * Copyright (C) 1991, 1992 Linus Torvalds | |
5 | * | |
6 | * Enhanced CPU detection and feature setting code by Mike Jagdis | |
7 | * and Martin Mares, November 1997. | |
8 | */ | |
9 | ||
10 | .text | |
1da177e4 LT |
11 | #include <linux/threads.h> |
12 | #include <linux/linkage.h> | |
13 | #include <asm/segment.h> | |
14 | #include <asm/page.h> | |
15 | #include <asm/pgtable.h> | |
16 | #include <asm/desc.h> | |
17 | #include <asm/cache.h> | |
18 | #include <asm/thread_info.h> | |
86feeaa8 | 19 | #include <asm/asm-offsets.h> |
1da177e4 LT |
20 | #include <asm/setup.h> |
21 | ||
22 | /* | |
23 | * References to members of the new_cpu_data structure. | |
24 | */ | |
25 | ||
26 | #define X86 new_cpu_data+CPUINFO_x86 | |
27 | #define X86_VENDOR new_cpu_data+CPUINFO_x86_vendor | |
28 | #define X86_MODEL new_cpu_data+CPUINFO_x86_model | |
29 | #define X86_MASK new_cpu_data+CPUINFO_x86_mask | |
30 | #define X86_HARD_MATH new_cpu_data+CPUINFO_hard_math | |
31 | #define X86_CPUID new_cpu_data+CPUINFO_cpuid_level | |
32 | #define X86_CAPABILITY new_cpu_data+CPUINFO_x86_capability | |
33 | #define X86_VENDOR_ID new_cpu_data+CPUINFO_x86_vendor_id | |
34 | ||
35 | /* | |
36 | * This is how much memory *in addition to the memory covered up to | |
9ce8c2ed JF |
37 | * and including _end* we need mapped initially. |
38 | * We need: | |
39 | * - one bit for each possible page, but only in low memory, which means | |
40 | * 2^32/4096/8 = 128K worst case (4G/4G split.) | |
41 | * - enough space to map all low memory, which means | |
42 | * (2^32/4096) / 1024 pages (worst case, non PAE) | |
43 | * (2^32/4096) / 512 + 4 pages (worst case for PAE) | |
44 | * - a few pages for allocator use before the kernel pagetable has | |
45 | * been set up | |
1da177e4 LT |
46 | * |
47 | * Modulo rounding, each megabyte assigned here requires a kilobyte of | |
48 | * memory, which is currently unreclaimed. | |
49 | * | |
50 | * This should be a multiple of a page. | |
51 | */ | |
9ce8c2ed | 52 | LOW_PAGES = 1<<(32-PAGE_SHIFT_asm) |
1da177e4 | 53 | |
9ce8c2ed JF |
54 | #if PTRS_PER_PMD > 1 |
55 | PAGE_TABLE_SIZE = (LOW_PAGES / PTRS_PER_PMD) + PTRS_PER_PGD | |
56 | #else | |
57 | PAGE_TABLE_SIZE = (LOW_PAGES / PTRS_PER_PGD) | |
58 | #endif | |
59 | BOOTBITMAP_SIZE = LOW_PAGES / 8 | |
60 | ALLOCATOR_SLOP = 4 | |
61 | ||
62 | INIT_MAP_BEYOND_END = BOOTBITMAP_SIZE + (PAGE_TABLE_SIZE + ALLOCATOR_SLOP)*PAGE_SIZE_asm | |
1da177e4 LT |
63 | |
64 | /* | |
65 | * 32-bit kernel entrypoint; only used by the boot CPU. On entry, | |
66 | * %esi points to the real-mode code as a 32-bit pointer. | |
67 | * CS and DS must be 4 GB flat segments, but we don't depend on | |
68 | * any particular GDT layout, because we load our own as soon as we | |
69 | * can. | |
70 | */ | |
f8657e1b | 71 | .section .text.head,"ax",@progbits |
1da177e4 LT |
72 | ENTRY(startup_32) |
73 | ||
74 | /* | |
75 | * Set segments to known values. | |
76 | */ | |
77 | cld | |
78 | lgdt boot_gdt_descr - __PAGE_OFFSET | |
79 | movl $(__BOOT_DS),%eax | |
80 | movl %eax,%ds | |
81 | movl %eax,%es | |
82 | movl %eax,%fs | |
83 | movl %eax,%gs | |
84 | ||
85 | /* | |
86 | * Clear BSS first so that there are no surprises... | |
87 | * No need to cld as DF is already clear from cld above... | |
88 | */ | |
89 | xorl %eax,%eax | |
90 | movl $__bss_start - __PAGE_OFFSET,%edi | |
91 | movl $__bss_stop - __PAGE_OFFSET,%ecx | |
92 | subl %edi,%ecx | |
93 | shrl $2,%ecx | |
94 | rep ; stosl | |
484b90c4 VG |
95 | /* |
96 | * Copy bootup parameters out of the way. | |
97 | * Note: %esi still has the pointer to the real-mode data. | |
98 | * With the kexec as boot loader, parameter segment might be loaded beyond | |
99 | * kernel image and might not even be addressable by early boot page tables. | |
100 | * (kexec on panic case). Hence copy out the parameters before initializing | |
101 | * page tables. | |
102 | */ | |
103 | movl $(boot_params - __PAGE_OFFSET),%edi | |
104 | movl $(PARAM_SIZE/4),%ecx | |
105 | cld | |
106 | rep | |
107 | movsl | |
108 | movl boot_params - __PAGE_OFFSET + NEW_CL_POINTER,%esi | |
109 | andl %esi,%esi | |
110 | jnz 2f # New command line protocol | |
111 | cmpw $(OLD_CL_MAGIC),OLD_CL_MAGIC_ADDR | |
112 | jne 1f | |
113 | movzwl OLD_CL_OFFSET,%esi | |
114 | addl $(OLD_CL_BASE_ADDR),%esi | |
115 | 2: | |
4e498b66 | 116 | movl $(boot_command_line - __PAGE_OFFSET),%edi |
484b90c4 VG |
117 | movl $(COMMAND_LINE_SIZE/4),%ecx |
118 | rep | |
119 | movsl | |
120 | 1: | |
1da177e4 LT |
121 | |
122 | /* | |
123 | * Initialize page tables. This creates a PDE and a set of page | |
124 | * tables, which are located immediately beyond _end. The variable | |
125 | * init_pg_tables_end is set up to point to the first "safe" location. | |
126 | * Mappings are created both at virtual address 0 (identity mapping) | |
127 | * and PAGE_OFFSET for up to _end+sizeof(page tables)+INIT_MAP_BEYOND_END. | |
128 | * | |
129 | * Warning: don't use %esi or the stack in this code. However, %esp | |
130 | * can be used as a GPR if you really need it... | |
131 | */ | |
132 | page_pde_offset = (__PAGE_OFFSET >> 20); | |
133 | ||
134 | movl $(pg0 - __PAGE_OFFSET), %edi | |
135 | movl $(swapper_pg_dir - __PAGE_OFFSET), %edx | |
136 | movl $0x007, %eax /* 0x007 = PRESENT+RW+USER */ | |
137 | 10: | |
138 | leal 0x007(%edi),%ecx /* Create PDE entry */ | |
139 | movl %ecx,(%edx) /* Store identity PDE entry */ | |
140 | movl %ecx,page_pde_offset(%edx) /* Store kernel PDE entry */ | |
141 | addl $4,%edx | |
142 | movl $1024, %ecx | |
143 | 11: | |
144 | stosl | |
145 | addl $0x1000,%eax | |
146 | loop 11b | |
147 | /* End condition: we must map up to and including INIT_MAP_BEYOND_END */ | |
148 | /* bytes beyond the end of our own page tables; the +0x007 is the attribute bits */ | |
149 | leal (INIT_MAP_BEYOND_END+0x007)(%edi),%ebp | |
150 | cmpl %ebp,%eax | |
151 | jb 10b | |
152 | movl %edi,(init_pg_tables_end - __PAGE_OFFSET) | |
153 | ||
1da177e4 LT |
154 | xorl %ebx,%ebx /* This is the boot CPU (BSP) */ |
155 | jmp 3f | |
1da177e4 LT |
156 | /* |
157 | * Non-boot CPU entry point; entered from trampoline.S | |
158 | * We can't lgdt here, because lgdt itself uses a data segment, but | |
52de74dd | 159 | * we know the trampoline has already loaded the boot_gdt for us. |
f8657e1b VG |
160 | * |
161 | * If cpu hotplug is not supported then this code can go in init section | |
162 | * which will be freed later | |
1da177e4 | 163 | */ |
f8657e1b VG |
164 | |
165 | #ifdef CONFIG_HOTPLUG_CPU | |
166 | .section .text,"ax",@progbits | |
167 | #else | |
168 | .section .init.text,"ax",@progbits | |
169 | #endif | |
170 | ||
b1c931e3 EB |
171 | /* Do an early initialization of the fixmap area */ |
172 | movl $(swapper_pg_dir - __PAGE_OFFSET), %edx | |
173 | movl $(swapper_pg_pmd - __PAGE_OFFSET), %eax | |
174 | addl $0x007, %eax /* 0x007 = PRESENT+RW+USER */ | |
175 | movl %eax, 4092(%edx) | |
176 | ||
f8657e1b | 177 | #ifdef CONFIG_SMP |
1da177e4 LT |
178 | ENTRY(startup_32_smp) |
179 | cld | |
180 | movl $(__BOOT_DS),%eax | |
181 | movl %eax,%ds | |
182 | movl %eax,%es | |
183 | movl %eax,%fs | |
184 | movl %eax,%gs | |
185 | ||
186 | /* | |
187 | * New page tables may be in 4Mbyte page mode and may | |
188 | * be using the global pages. | |
189 | * | |
190 | * NOTE! If we are on a 486 we may have no cr4 at all! | |
191 | * So we do not try to touch it unless we really have | |
192 | * some bits in it to set. This won't work if the BSP | |
193 | * implements cr4 but this AP does not -- very unlikely | |
194 | * but be warned! The same applies to the pse feature | |
195 | * if not equally supported. --macro | |
196 | * | |
197 | * NOTE! We have to correct for the fact that we're | |
198 | * not yet offset PAGE_OFFSET.. | |
199 | */ | |
200 | #define cr4_bits mmu_cr4_features-__PAGE_OFFSET | |
201 | movl cr4_bits,%edx | |
202 | andl %edx,%edx | |
203 | jz 6f | |
204 | movl %cr4,%eax # Turn on paging options (PSE,PAE,..) | |
205 | orl %edx,%eax | |
206 | movl %eax,%cr4 | |
207 | ||
208 | btl $5, %eax # check if PAE is enabled | |
209 | jnc 6f | |
210 | ||
211 | /* Check if extended functions are implemented */ | |
212 | movl $0x80000000, %eax | |
213 | cpuid | |
214 | cmpl $0x80000000, %eax | |
215 | jbe 6f | |
216 | mov $0x80000001, %eax | |
217 | cpuid | |
218 | /* Execute Disable bit supported? */ | |
219 | btl $20, %edx | |
220 | jnc 6f | |
221 | ||
222 | /* Setup EFER (Extended Feature Enable Register) */ | |
223 | movl $0xc0000080, %ecx | |
224 | rdmsr | |
225 | ||
226 | btsl $11, %eax | |
227 | /* Make changes effective */ | |
228 | wrmsr | |
229 | ||
230 | 6: | |
231 | /* This is a secondary processor (AP) */ | |
232 | xorl %ebx,%ebx | |
233 | incl %ebx | |
234 | ||
1da177e4 | 235 | #endif /* CONFIG_SMP */ |
f8657e1b | 236 | 3: |
1da177e4 LT |
237 | |
238 | /* | |
239 | * Enable paging | |
240 | */ | |
241 | movl $swapper_pg_dir-__PAGE_OFFSET,%eax | |
242 | movl %eax,%cr3 /* set the page table pointer.. */ | |
243 | movl %cr0,%eax | |
244 | orl $0x80000000,%eax | |
245 | movl %eax,%cr0 /* ..and set paging (PG) bit */ | |
246 | ljmp $__BOOT_CS,$1f /* Clear prefetch and normalize %eip */ | |
247 | 1: | |
248 | /* Set up the stack pointer */ | |
249 | lss stack_start,%esp | |
250 | ||
251 | /* | |
252 | * Initialize eflags. Some BIOS's leave bits like NT set. This would | |
253 | * confuse the debugger if this code is traced. | |
254 | * XXX - best to initialize before switching to protected mode. | |
255 | */ | |
256 | pushl $0 | |
257 | popfl | |
258 | ||
259 | #ifdef CONFIG_SMP | |
260 | andl %ebx,%ebx | |
261 | jz 1f /* Initial CPU cleans BSS */ | |
262 | jmp checkCPUtype | |
263 | 1: | |
264 | #endif /* CONFIG_SMP */ | |
265 | ||
266 | /* | |
267 | * start system 32-bit setup. We need to re-do some of the things done | |
268 | * in 16-bit mode for the "real" operations. | |
269 | */ | |
270 | call setup_idt | |
271 | ||
1da177e4 LT |
272 | checkCPUtype: |
273 | ||
274 | movl $-1,X86_CPUID # -1 for no CPUID initially | |
275 | ||
276 | /* check if it is 486 or 386. */ | |
277 | /* | |
278 | * XXX - this does a lot of unnecessary setup. Alignment checks don't | |
279 | * apply at our cpl of 0 and the stack ought to be aligned already, and | |
280 | * we don't need to preserve eflags. | |
281 | */ | |
282 | ||
283 | movb $3,X86 # at least 386 | |
284 | pushfl # push EFLAGS | |
285 | popl %eax # get EFLAGS | |
286 | movl %eax,%ecx # save original EFLAGS | |
287 | xorl $0x240000,%eax # flip AC and ID bits in EFLAGS | |
288 | pushl %eax # copy to EFLAGS | |
289 | popfl # set EFLAGS | |
290 | pushfl # get new EFLAGS | |
291 | popl %eax # put it in eax | |
292 | xorl %ecx,%eax # change in flags | |
293 | pushl %ecx # restore original EFLAGS | |
294 | popfl | |
295 | testl $0x40000,%eax # check if AC bit changed | |
296 | je is386 | |
297 | ||
298 | movb $4,X86 # at least 486 | |
299 | testl $0x200000,%eax # check if ID bit changed | |
300 | je is486 | |
301 | ||
302 | /* get vendor info */ | |
303 | xorl %eax,%eax # call CPUID with 0 -> return vendor ID | |
304 | cpuid | |
305 | movl %eax,X86_CPUID # save CPUID level | |
306 | movl %ebx,X86_VENDOR_ID # lo 4 chars | |
307 | movl %edx,X86_VENDOR_ID+4 # next 4 chars | |
308 | movl %ecx,X86_VENDOR_ID+8 # last 4 chars | |
309 | ||
310 | orl %eax,%eax # do we have processor info as well? | |
311 | je is486 | |
312 | ||
313 | movl $1,%eax # Use the CPUID instruction to get CPU type | |
314 | cpuid | |
315 | movb %al,%cl # save reg for future use | |
316 | andb $0x0f,%ah # mask processor family | |
317 | movb %ah,X86 | |
318 | andb $0xf0,%al # mask model | |
319 | shrb $4,%al | |
320 | movb %al,X86_MODEL | |
321 | andb $0x0f,%cl # mask mask revision | |
322 | movb %cl,X86_MASK | |
323 | movl %edx,X86_CAPABILITY | |
324 | ||
325 | is486: movl $0x50022,%ecx # set AM, WP, NE and MP | |
326 | jmp 2f | |
327 | ||
328 | is386: movl $2,%ecx # set MP | |
329 | 2: movl %cr0,%eax | |
330 | andl $0x80000011,%eax # Save PG,PE,ET | |
331 | orl %ecx,%eax | |
332 | movl %eax,%cr0 | |
333 | ||
334 | call check_x87 | |
2a57ff1a | 335 | lgdt early_gdt_descr |
1da177e4 LT |
336 | lidt idt_descr |
337 | ljmp $(__KERNEL_CS),$1f | |
338 | 1: movl $(__KERNEL_DS),%eax # reload all the segment registers | |
339 | movl %eax,%ss # after changing gdt. | |
7c3576d2 | 340 | movl %eax,%fs # gets reset once there's real percpu |
1da177e4 LT |
341 | |
342 | movl $(__USER_DS),%eax # DS/ES contains default USER segment | |
343 | movl %eax,%ds | |
344 | movl %eax,%es | |
345 | ||
464d1a78 JF |
346 | xorl %eax,%eax # Clear GS and LDT |
347 | movl %eax,%gs | |
1da177e4 | 348 | lldt %ax |
f95d47ca | 349 | |
1da177e4 | 350 | cld # gcc2 wants the direction flag cleared at all times |
26fd5e08 | 351 | pushl $0 # fake return address for unwinder |
1da177e4 | 352 | #ifdef CONFIG_SMP |
d92de65c SL |
353 | movb ready, %cl |
354 | movb $1, ready | |
29fe5f3b | 355 | cmpb $0,%cl # the first CPU calls start_kernel |
7c3576d2 JF |
356 | je 1f |
357 | movl $(__KERNEL_PERCPU), %eax | |
358 | movl %eax,%fs # set this cpu's percpu | |
359 | jmp initialize_secondary # all other CPUs call initialize_secondary | |
360 | 1: | |
1da177e4 | 361 | #endif /* CONFIG_SMP */ |
29fe5f3b | 362 | jmp start_kernel |
1da177e4 LT |
363 | |
364 | /* | |
365 | * We depend on ET to be correct. This checks for 287/387. | |
366 | */ | |
367 | check_x87: | |
368 | movb $0,X86_HARD_MATH | |
369 | clts | |
370 | fninit | |
371 | fstsw %ax | |
372 | cmpb $0,%al | |
373 | je 1f | |
374 | movl %cr0,%eax /* no coprocessor: have to set bits */ | |
375 | xorl $4,%eax /* set EM */ | |
376 | movl %eax,%cr0 | |
377 | ret | |
378 | ALIGN | |
379 | 1: movb $1,X86_HARD_MATH | |
380 | .byte 0xDB,0xE4 /* fsetpm for 287, ignored by 387 */ | |
381 | ret | |
382 | ||
383 | /* | |
384 | * setup_idt | |
385 | * | |
386 | * sets up a idt with 256 entries pointing to | |
387 | * ignore_int, interrupt gates. It doesn't actually load | |
388 | * idt - that can be done only after paging has been enabled | |
389 | * and the kernel moved to PAGE_OFFSET. Interrupts | |
390 | * are enabled elsewhere, when we can be relatively | |
391 | * sure everything is ok. | |
392 | * | |
393 | * Warning: %esi is live across this function. | |
394 | */ | |
395 | setup_idt: | |
396 | lea ignore_int,%edx | |
397 | movl $(__KERNEL_CS << 16),%eax | |
398 | movw %dx,%ax /* selector = 0x0010 = cs */ | |
399 | movw $0x8E00,%dx /* interrupt gate - dpl=0, present */ | |
400 | ||
401 | lea idt_table,%edi | |
402 | mov $256,%ecx | |
403 | rp_sidt: | |
404 | movl %eax,(%edi) | |
405 | movl %edx,4(%edi) | |
406 | addl $8,%edi | |
407 | dec %ecx | |
408 | jne rp_sidt | |
ec5c0926 CE |
409 | |
410 | .macro set_early_handler handler,trapno | |
411 | lea \handler,%edx | |
412 | movl $(__KERNEL_CS << 16),%eax | |
413 | movw %dx,%ax | |
414 | movw $0x8E00,%dx /* interrupt gate - dpl=0, present */ | |
415 | lea idt_table,%edi | |
416 | movl %eax,8*\trapno(%edi) | |
417 | movl %edx,8*\trapno+4(%edi) | |
418 | .endm | |
419 | ||
420 | set_early_handler handler=early_divide_err,trapno=0 | |
421 | set_early_handler handler=early_illegal_opcode,trapno=6 | |
422 | set_early_handler handler=early_protection_fault,trapno=13 | |
423 | set_early_handler handler=early_page_fault,trapno=14 | |
424 | ||
1da177e4 LT |
425 | ret |
426 | ||
ec5c0926 CE |
427 | early_divide_err: |
428 | xor %edx,%edx | |
429 | pushl $0 /* fake errcode */ | |
430 | jmp early_fault | |
431 | ||
432 | early_illegal_opcode: | |
433 | movl $6,%edx | |
434 | pushl $0 /* fake errcode */ | |
435 | jmp early_fault | |
436 | ||
437 | early_protection_fault: | |
438 | movl $13,%edx | |
439 | jmp early_fault | |
440 | ||
441 | early_page_fault: | |
442 | movl $14,%edx | |
443 | jmp early_fault | |
444 | ||
445 | early_fault: | |
446 | cld | |
447 | #ifdef CONFIG_PRINTK | |
448 | movl $(__KERNEL_DS),%eax | |
449 | movl %eax,%ds | |
450 | movl %eax,%es | |
451 | cmpl $2,early_recursion_flag | |
452 | je hlt_loop | |
453 | incl early_recursion_flag | |
454 | movl %cr2,%eax | |
455 | pushl %eax | |
456 | pushl %edx /* trapno */ | |
457 | pushl $fault_msg | |
458 | #ifdef CONFIG_EARLY_PRINTK | |
459 | call early_printk | |
460 | #else | |
461 | call printk | |
462 | #endif | |
463 | #endif | |
464 | hlt_loop: | |
465 | hlt | |
466 | jmp hlt_loop | |
467 | ||
1da177e4 LT |
468 | /* This is the default interrupt "handler" :-) */ |
469 | ALIGN | |
470 | ignore_int: | |
471 | cld | |
d59745ce | 472 | #ifdef CONFIG_PRINTK |
1da177e4 LT |
473 | pushl %eax |
474 | pushl %ecx | |
475 | pushl %edx | |
476 | pushl %es | |
477 | pushl %ds | |
478 | movl $(__KERNEL_DS),%eax | |
479 | movl %eax,%ds | |
480 | movl %eax,%es | |
ec5c0926 CE |
481 | cmpl $2,early_recursion_flag |
482 | je hlt_loop | |
483 | incl early_recursion_flag | |
1da177e4 LT |
484 | pushl 16(%esp) |
485 | pushl 24(%esp) | |
486 | pushl 32(%esp) | |
487 | pushl 40(%esp) | |
488 | pushl $int_msg | |
c0cdf193 IM |
489 | #ifdef CONFIG_EARLY_PRINTK |
490 | call early_printk | |
491 | #else | |
1da177e4 | 492 | call printk |
c0cdf193 | 493 | #endif |
1da177e4 LT |
494 | addl $(5*4),%esp |
495 | popl %ds | |
496 | popl %es | |
497 | popl %edx | |
498 | popl %ecx | |
499 | popl %eax | |
d59745ce | 500 | #endif |
1da177e4 LT |
501 | iret |
502 | ||
f8657e1b | 503 | .section .text |
1da177e4 LT |
504 | /* |
505 | * Real beginning of normal "text" segment | |
506 | */ | |
507 | ENTRY(stext) | |
508 | ENTRY(_stext) | |
509 | ||
510 | /* | |
511 | * BSS section | |
512 | */ | |
5ead97c8 JF |
513 | .section ".bss.page_aligned","wa" |
514 | .align PAGE_SIZE_asm | |
1da177e4 LT |
515 | ENTRY(swapper_pg_dir) |
516 | .fill 1024,4,0 | |
b1c931e3 EB |
517 | ENTRY(swapper_pg_pmd) |
518 | .fill 1024,4,0 | |
1da177e4 LT |
519 | ENTRY(empty_zero_page) |
520 | .fill 4096,1,0 | |
521 | ||
522 | /* | |
523 | * This starts the data section. | |
524 | */ | |
525 | .data | |
1da177e4 LT |
526 | ENTRY(stack_start) |
527 | .long init_thread_union+THREAD_SIZE | |
528 | .long __BOOT_DS | |
529 | ||
530 | ready: .byte 0 | |
531 | ||
ec5c0926 CE |
532 | early_recursion_flag: |
533 | .long 0 | |
534 | ||
1da177e4 LT |
535 | int_msg: |
536 | .asciz "Unknown interrupt or fault at EIP %p %p %p\n" | |
537 | ||
ec5c0926 CE |
538 | fault_msg: |
539 | .ascii "Int %d: CR2 %p err %p EIP %p CS %p flags %p\n" | |
540 | .asciz "Stack: %p %p %p %p %p %p %p %p\n" | |
541 | ||
5ead97c8 JF |
542 | #include "../xen/xen-head.S" |
543 | ||
1da177e4 LT |
544 | /* |
545 | * The IDT and GDT 'descriptors' are a strange 48-bit object | |
546 | * only used by the lidt and lgdt instructions. They are not | |
547 | * like usual segment descriptors - they consist of a 16-bit | |
548 | * segment size, and 32-bit linear address value: | |
549 | */ | |
550 | ||
551 | .globl boot_gdt_descr | |
552 | .globl idt_descr | |
1da177e4 LT |
553 | |
554 | ALIGN | |
555 | # early boot GDT descriptor (must use 1:1 address mapping) | |
556 | .word 0 # 32 bit align gdt_desc.address | |
557 | boot_gdt_descr: | |
558 | .word __BOOT_DS+7 | |
52de74dd | 559 | .long boot_gdt - __PAGE_OFFSET |
1da177e4 LT |
560 | |
561 | .word 0 # 32-bit align idt_desc.address | |
562 | idt_descr: | |
563 | .word IDT_ENTRIES*8-1 # idt contains 256 entries | |
564 | .long idt_table | |
565 | ||
566 | # boot GDT descriptor (later on used by CPU#0): | |
567 | .word 0 # 32 bit align gdt_desc.address | |
2a57ff1a | 568 | ENTRY(early_gdt_descr) |
1da177e4 | 569 | .word GDT_ENTRIES*8-1 |
7a61d35d | 570 | .long per_cpu__gdt_page /* Overwritten for secondary CPUs */ |
1da177e4 | 571 | |
1da177e4 | 572 | /* |
52de74dd | 573 | * The boot_gdt must mirror the equivalent in setup.S and is |
1da177e4 LT |
574 | * used only for booting. |
575 | */ | |
576 | .align L1_CACHE_BYTES | |
52de74dd | 577 | ENTRY(boot_gdt) |
1da177e4 LT |
578 | .fill GDT_ENTRY_BOOT_CS,8,0 |
579 | .quad 0x00cf9a000000ffff /* kernel 4GB code at 0x00000000 */ | |
580 | .quad 0x00cf92000000ffff /* kernel 4GB data at 0x00000000 */ |