source: mainline/kernel/arch/amd64/src/boot/multiboot.S@ 08f1a6d

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 08f1a6d was 8781e9d, checked in by Jiří Zárevúcky <zarevucky.jiri@…>, 7 years ago

Remove realmode VESA code

This simply enables framebuffer setup via multiboot1
(multiboot2 already did it), and removes the obsolete code.

  • Property mode set to 100644
File size: 15.0 KB
RevLine 
[873c681]1/*
2 * Copyright (c) 2005 Ondrej Palkovsky
3 * Copyright (c) 2006 Martin Decky
4 * Copyright (c) 2008 Jakub Jermar
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * - Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * - Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * - The name of the author may not be used to endorse or promote products
17 * derived from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
[1141c1a]30
[3b0f1b9a]31#include <abi/asmtool.h>
[46d26ee]32#include <arch/boot/boot.h>
[a1f60f3]33#include <arch/mm/page.h>
[6f878b7]34#include <arch/mm/ptl.h>
[8fc0d455]35#include <arch/pm.h>
[1f5c9c96]36#include <genarch/multiboot/multiboot.h>
[c4b3e3e]37#include <arch/cpuid.h>
[1f5c9c96]38#include <arch/cpu.h>
[1141c1a]39
[8781e9d]40// TODO: most of this file can be rewritten in C
41
[873c681]42#define START_STACK (BOOT_OFFSET - BOOT_STACK_SIZE)
[421c833]43
[874e312a]44.section K_TEXT_START, "ax"
[46d26ee]45
[8ccec3c1]46.code32
[873c681]47
48.macro pm_error msg
49 movl \msg, %esi
50 jmp pm_error_halt
51.endm
52
53.macro pm_status msg
[8781e9d]54#if defined(CONFIG_EGA) && !defined(CONFIG_FB)
[873c681]55 pushl %esi
56 movl \msg, %esi
57 call pm_early_puts
58 popl %esi
59#endif
60.endm
61
62.macro pm2_status msg
63#ifndef CONFIG_FB
64 pm_status \msg
65#endif
66.endm
67
[8ccec3c1]68.align 4
69multiboot_header:
70 .long MULTIBOOT_HEADER_MAGIC
[8781e9d]71#ifdef CONFIG_FB
[8ccec3c1]72 .long MULTIBOOT_HEADER_FLAGS
[873c681]73 .long -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS) /* checksum */
[8781e9d]74#else
75 .long MULTIBOOT_HEADER_FLAGS_NOFB
76 .long -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS_NOFB) /* checksum */
77#endif
[8725fb4]78 .long multiboot_header
[bae43dc]79 .long unmapped_start
[8ccec3c1]80 .long 0
81 .long 0
[8725fb4]82 .long multiboot_image_start
[8781e9d]83#ifdef CONFIG_FB
84 .long 0
85 .long CONFIG_BFB_WIDTH
86 .long CONFIG_BFB_HEIGHT
87 .long CONFIG_BFB_BPP
88#endif
[8ccec3c1]89
[3b0f1b9a]90SYMBOL(multiboot_image_start)
[f66c203d]91 cli
[e13daa5d]92 cld
[a35b458]93
[873c681]94 /* Initialize stack pointer */
95 movl $START_STACK, %esp
[a35b458]96
[f66c203d]97 /*
98 * Initialize Global Descriptor Table and
99 * Interrupt Descriptor Table registers
100 */
[873c681]101 lgdtl bootstrap_gdtr
[f66c203d]102 lidtl bootstrap_idtr
[a35b458]103
[873c681]104 /* Kernel data + stack */
[1d3d2cf]105 movw $GDT_SELECTOR(KDATA_DES), %cx
[1a67595]106 movw %cx, %es
[873c681]107 movw %cx, %ds
[1a67595]108 movw %cx, %ss
[a35b458]109
[873c681]110 /*
111 * Simics seems to remove hidden part of GS on entering user mode
112 * when _visible_ part of GS does not point to user-mode segment.
113 */
[1d3d2cf]114 movw $GDT_SELECTOR(UDATA_DES), %cx
[65640fef]115 movw %cx, %fs
116 movw %cx, %gs
[a35b458]117
[1d3d2cf]118 jmpl $GDT_SELECTOR(KTEXT32_DES), $multiboot_meeting_point
[1a67595]119 multiboot_meeting_point:
[a35b458]120
[1f5c9c96]121 /*
122 * Protected 32-bit. We want to reuse the code-seg descriptor,
123 * the Default operand size must not be 1 when entering long mode.
124 */
[a35b458]125
[1f5c9c96]126 /* Save multiboot arguments */
127 movl %eax, multiboot_eax
128 movl %ebx, multiboot_ebx
[a35b458]129
[873c681]130 pm_status $status_prot
[a35b458]131
[421c833]132 movl $(INTEL_CPUID_EXTENDED), %eax
133 cpuid
134 cmp $(INTEL_CPUID_EXTENDED), %eax
[4fb6bf36]135 ja extended_cpuid_supported
[a35b458]136
[873c681]137 pm_error $err_extended_cpuid
[a35b458]138
[4fb6bf36]139 extended_cpuid_supported:
[a35b458]140
[4fb6bf36]141 movl $(AMD_CPUID_EXTENDED), %eax
[ac88c93]142 cpuid
[4fb6bf36]143 bt $(AMD_EXT_LONG_MODE), %edx
[421c833]144 jc long_mode_supported
[a35b458]145
[873c681]146 pm_error $err_long_mode
[a35b458]147
[ac88c93]148 long_mode_supported:
[a35b458]149
[4fb6bf36]150 bt $(AMD_EXT_NOEXECUTE), %edx
151 jc noexecute_supported
[a35b458]152
[873c681]153 pm_error $err_noexecute
[a35b458]154
[4fb6bf36]155 noexecute_supported:
[a35b458]156
[4fb6bf36]157 movl $(INTEL_CPUID_STANDARD), %eax
158 cpuid
159 bt $(INTEL_FXSAVE), %edx
[421c833]160 jc fx_supported
[a35b458]161
[873c681]162 pm_error $err_fx
[a35b458]163
[4fb6bf36]164 fx_supported:
[a35b458]165
[4fb6bf36]166 bt $(INTEL_SSE2), %edx
[421c833]167 jc sse2_supported
[a35b458]168
[873c681]169 pm_error $err_sse2
[a35b458]170
[4fb6bf36]171 sse2_supported:
[a35b458]172
[873c681]173 pm2_status $status_prot2
[a35b458]174
[873c681]175 /*
176 * Enable 64-bit page translation entries - CR4.PAE = 1.
177 * Paging is not enabled until after long mode is enabled.
178 */
[a35b458]179
[6f878b7]180 movl %cr4, %eax
[811770c]181 orl $CR4_PAE, %eax
[6f878b7]182 movl %eax, %cr4
[a35b458]183
[873c681]184 /* Set up paging tables */
[6f878b7]185 leal ptl_0, %eax
186 movl %eax, %cr3
[a35b458]187
[873c681]188 /* Enable long mode */
[811770c]189 movl $AMD_MSR_EFER, %ecx
[873c681]190 rdmsr /* read EFER */
[811770c]191 orl $AMD_LME, %eax /* set LME = 1 */
[873c681]192 wrmsr
[a35b458]193
[873c681]194 /* Enable paging to activate long mode (set CR0.PG = 1) */
[6f878b7]195 movl %cr0, %eax
[811770c]196 orl $CR0_PG, %eax
[6f878b7]197 movl %eax, %cr0
[a35b458]198
[873c681]199 /* At this point we are in compatibility mode */
[1d3d2cf]200 jmpl $GDT_SELECTOR(KTEXT_DES), $start64
[c245372b]201
[873c681]202/** Print string to EGA display (in light red) and halt.
203 *
204 * Should be executed from 32 bit protected mode with paging
205 * turned off. Stack is not required. This routine is used even
206 * if CONFIG_EGA is not enabled. Since we are going to halt the
207 * CPU anyway, it is always better to at least try to print
208 * some hints.
209 *
[da52547]210 * @param %esi Pointer to the NULL-terminated string
211 * to be print.
[873c681]212 *
213 */
214pm_error_halt:
215 movl $0xb8000, %edi /* base of EGA text mode memory */
216 xorl %eax, %eax
[a35b458]217
[873c681]218 /* Read bits 8 - 15 of the cursor address */
219 movw $0x3d4, %dx
220 movb $0xe, %al
221 outb %al, %dx
[a35b458]222
[873c681]223 movw $0x3d5, %dx
224 inb %dx, %al
225 shl $8, %ax
[a35b458]226
[873c681]227 /* Read bits 0 - 7 of the cursor address */
228 movw $0x3d4, %dx
229 movb $0xf, %al
230 outb %al, %dx
[a35b458]231
[873c681]232 movw $0x3d5, %dx
233 inb %dx, %al
[a35b458]234
[873c681]235 /* Sanity check for the cursor on screen */
236 cmp $2000, %ax
237 jb err_cursor_ok
[a35b458]238
[873c681]239 movw $1998, %ax
[a35b458]240
[873c681]241 err_cursor_ok:
[a35b458]242
[873c681]243 movw %ax, %bx
244 shl $1, %eax
245 addl %eax, %edi
[a35b458]246
[873c681]247 err_ploop:
248 lodsb
[a35b458]249
[873c681]250 cmp $0, %al
251 je err_ploop_end
[a35b458]252
[873c681]253 movb $0x0c, %ah /* black background, light red foreground */
254 stosw
[a35b458]255
[873c681]256 /* Sanity check for the cursor on the last line */
257 inc %bx
258 cmp $2000, %bx
259 jb err_ploop
[a35b458]260
[873c681]261 /* Scroll the screen (24 rows) */
262 movl %esi, %edx
263 movl $0xb80a0, %esi
264 movl $0xb8000, %edi
[22c3444]265 movl $960, %ecx
266 rep movsl
[a35b458]267
[873c681]268 /* Clear the 24th row */
269 xorl %eax, %eax
[22c3444]270 movl $40, %ecx
271 rep stosl
[a35b458]272
[873c681]273 /* Go to row 24 */
274 movl %edx, %esi
275 movl $0xb8f00, %edi
276 movw $1920, %bx
[a35b458]277
[873c681]278 jmp err_ploop
279 err_ploop_end:
[a35b458]280
[873c681]281 /* Write bits 8 - 15 of the cursor address */
282 movw $0x3d4, %dx
283 movb $0xe, %al
284 outb %al, %dx
[a35b458]285
[873c681]286 movw $0x3d5, %dx
287 movb %bh, %al
288 outb %al, %dx
[a35b458]289
[873c681]290 /* Write bits 0 - 7 of the cursor address */
291 movw $0x3d4, %dx
292 movb $0xf, %al
293 outb %al, %dx
[a35b458]294
[873c681]295 movw $0x3d5, %dx
296 movb %bl, %al
297 outb %al, %dx
[a35b458]298
[873c681]299 cli
300 hlt1:
301 hlt
302 jmp hlt1
303
304/** Print string to EGA display (in light green).
305 *
306 * Should be called from 32 bit protected mode with paging
307 * turned off. A stack space of at least 24 bytes is required,
308 * but the function does not establish a stack frame.
309 *
310 * Macros such as pm_status and pm2_status take care that
311 * this function is used only when CONFIG_EGA is enabled
312 * and CONFIG_FB is disabled.
313 *
[da52547]314 * @param %esi Pointer to the NULL-terminated string
315 * to be print.
[873c681]316 *
317 */
318pm_early_puts:
319 pushl %eax
320 pushl %ebx
321 pushl %ecx
322 pushl %edx
323 pushl %edi
[a35b458]324
[873c681]325 movl $0xb8000, %edi /* base of EGA text mode memory */
326 xorl %eax, %eax
[a35b458]327
[873c681]328 /* Read bits 8 - 15 of the cursor address */
329 movw $0x3d4, %dx
330 movb $0xe, %al
331 outb %al, %dx
[a35b458]332
[873c681]333 movw $0x3d5, %dx
334 inb %dx, %al
335 shl $8, %ax
[a35b458]336
[873c681]337 /* Read bits 0 - 7 of the cursor address */
338 movw $0x3d4, %dx
339 movb $0xf, %al
340 outb %al, %dx
[a35b458]341
[873c681]342 movw $0x3d5, %dx
343 inb %dx, %al
[a35b458]344
[873c681]345 /* Sanity check for the cursor on screen */
346 cmp $2000, %ax
347 jb pm_puts_cursor_ok
[a35b458]348
[873c681]349 movw $1998, %ax
[a35b458]350
[873c681]351 pm_puts_cursor_ok:
[a35b458]352
[873c681]353 movw %ax, %bx
354 shl $1, %eax
355 addl %eax, %edi
[a35b458]356
[873c681]357 pm_puts_ploop:
358 lodsb
[a35b458]359
[873c681]360 cmp $0, %al
361 je pm_puts_ploop_end
[a35b458]362
[873c681]363 movb $0x0a, %ah /* black background, light green foreground */
364 stosw
[a35b458]365
[873c681]366 /* Sanity check for the cursor on the last line */
367 inc %bx
368 cmp $2000, %bx
369 jb pm_puts_ploop
[a35b458]370
[873c681]371 /* Scroll the screen (24 rows) */
372 movl %esi, %edx
373 movl $0xb80a0, %esi
374 movl $0xb8000, %edi
[22c3444]375 movl $960, %ecx
376 rep movsl
[a35b458]377
[873c681]378 /* Clear the 24th row */
379 xorl %eax, %eax
[22c3444]380 movl $40, %ecx
381 rep stosl
[a35b458]382
[873c681]383 /* Go to row 24 */
384 movl %edx, %esi
385 movl $0xb8f00, %edi
386 movw $1920, %bx
[a35b458]387
[873c681]388 jmp pm_puts_ploop
389 pm_puts_ploop_end:
[a35b458]390
[873c681]391 /* Write bits 8 - 15 of the cursor address */
392 movw $0x3d4, %dx
393 movb $0xe, %al
394 outb %al, %dx
[a35b458]395
[873c681]396 movw $0x3d5, %dx
397 movb %bh, %al
398 outb %al, %dx
[a35b458]399
[873c681]400 /* Write bits 0 - 7 of the cursor address */
401 movw $0x3d4, %dx
402 movb $0xf, %al
403 outb %al, %dx
[a35b458]404
[873c681]405 movw $0x3d5, %dx
406 movb %bl, %al
407 outb %al, %dx
[a35b458]408
[873c681]409 popl %edi
410 popl %edx
411 popl %ecx
412 popl %ebx
413 popl %eax
[a35b458]414
[873c681]415 ret
416
[6f878b7]417.code64
[873c681]418
419.macro long_status msg
420 pushq %rdi
421 movq \msg, %rdi
422 call early_puts
423 popq %rdi
424.endm
425
[6f878b7]426start64:
[a35b458]427
[873c681]428 /*
429 * Long mode.
430 */
[a35b458]431
[c4b3e3e]432 movq $(PA2KA(START_STACK)), %rsp
[a35b458]433
[873c681]434 /* Create the first stack frame */
435 pushq $0
436 movq %rsp, %rbp
[a35b458]437
[873c681]438 long_status $status_long
[a35b458]439
[36df4109]440 /* Call amd64_pre_main(multiboot_eax, multiboot_ebx) */
[1f5c9c96]441 movl multiboot_eax, %edi
442 movl multiboot_ebx, %esi
[a35b458]443
[4bf0926e]444#ifdef MEMORY_MODEL_large
445 movabsq $amd64_pre_main, %rax
446 callq *%rax
447#else
[36df4109]448 callq amd64_pre_main
[4bf0926e]449#endif
[a35b458]450
[873c681]451 long_status $status_main
[a35b458]452
[873c681]453 /* Call main_bsp() */
[4bf0926e]454#ifdef MEMORY_MODEL_large
455 movabsq $main_bsp, %rax
456 callq *%rax
457#else
458 callq main_bsp
459#endif
[a35b458]460
[873c681]461 /* Not reached */
[421c833]462 cli
463 hlt0:
464 hlt
465 jmp hlt0
[ac88c93]466
[873c681]467/** Print string to EGA display.
468 *
469 * Should be called from long mode (with paging enabled
470 * and stack established). This function is ABI compliant
471 * (without red-zone).
472 *
473 * If CONFIG_EGA is undefined or CONFIG_FB is defined
474 * then this function does nothing.
475 *
[da52547]476 * @param %rdi Pointer to the NULL-terminated string
477 * to be printed.
[873c681]478 *
479 */
480early_puts:
[a35b458]481
[873c681]482#if ((defined(CONFIG_EGA)) && (!defined(CONFIG_FB)))
[a35b458]483
[873c681]484 /* Prologue, save preserved registers */
485 pushq %rbp
486 movq %rsp, %rbp
487 pushq %rbx
[a35b458]488
[873c681]489 movq %rdi, %rsi
490 movq $(PA2KA(0xb8000)), %rdi /* base of EGA text mode memory */
491 xorq %rax, %rax
[a35b458]492
[873c681]493 /* Read bits 8 - 15 of the cursor address */
494 movw $0x3d4, %dx
[ac88c93]495 movb $0xe, %al
496 outb %al, %dx
[a35b458]497
[ac88c93]498 movw $0x3d5, %dx
499 inb %dx, %al
500 shl $8, %ax
[a35b458]501
[873c681]502 /* Read bits 0 - 7 of the cursor address */
503 movw $0x3d4, %dx
[ac88c93]504 movb $0xf, %al
505 outb %al, %dx
[a35b458]506
[ac88c93]507 movw $0x3d5, %dx
508 inb %dx, %al
[a35b458]509
[873c681]510 /* Sanity check for the cursor on screen */
511 cmp $2000, %ax
512 jb early_puts_cursor_ok
[a35b458]513
[873c681]514 movw $1998, %ax
[a35b458]515
[873c681]516 early_puts_cursor_ok:
[a35b458]517
[ac88c93]518 movw %ax, %bx
[873c681]519 shl $1, %rax
520 addq %rax, %rdi
[a35b458]521
[873c681]522 early_puts_ploop:
[ac88c93]523 lodsb
[a35b458]524
[ac88c93]525 cmp $0, %al
[873c681]526 je early_puts_ploop_end
[a35b458]527
[873c681]528 movb $0x0e, %ah /* black background, yellow foreground */
[ac88c93]529 stosw
[a35b458]530
[873c681]531 /* Sanity check for the cursor on the last line */
[421c833]532 inc %bx
[873c681]533 cmp $2000, %bx
534 jb early_puts_ploop
[a35b458]535
[873c681]536 /* Scroll the screen (24 rows) */
537 movq %rsi, %rdx
538 movq $(PA2KA(0xb80a0)), %rsi
539 movq $(PA2KA(0xb8000)), %rdi
[e80329d6]540 movl $480, %ecx
[22c3444]541 rep movsq
[a35b458]542
[873c681]543 /* Clear the 24th row */
[e80329d6]544 xorl %eax, %eax
545 movl $20, %ecx
[22c3444]546 rep stosq
[a35b458]547
[873c681]548 /* Go to row 24 */
549 movq %rdx, %rsi
550 movq $(PA2KA(0xb8f00)), %rdi
551 movw $1920, %bx
[a35b458]552
[873c681]553 jmp early_puts_ploop
554 early_puts_ploop_end:
[a35b458]555
[873c681]556 /* Write bits 8 - 15 of the cursor address */
557 movw $0x3d4, %dx
[ac88c93]558 movb $0xe, %al
559 outb %al, %dx
[a35b458]560
[ac88c93]561 movw $0x3d5, %dx
562 movb %bh, %al
563 outb %al, %dx
[a35b458]564
[873c681]565 /* Write bits 0 - 7 of the cursor address */
566 movw $0x3d4, %dx
[ac88c93]567 movb $0xf, %al
568 outb %al, %dx
[a35b458]569
[ac88c93]570 movw $0x3d5, %dx
571 movb %bl, %al
572 outb %al, %dx
[a35b458]573
[873c681]574 /* Epilogue, restore preserved registers */
575 popq %rbx
576 leave
[a35b458]577
[873c681]578#endif
[a35b458]579
[873c681]580 ret
[421c833]581
[19077a5]582.section K_INI_PTLS, "aw", @progbits
583
[873c681]584/** Generate initial page table contents.
585 *
586 * @param cnt Number of entries to generate. Must be multiple of 8.
587 * @param g Number of GB that will be added to the mapping.
588 *
589 */
[a1f60f3]590.macro ptl2gen cnt g
[64f6ef04]591 .if \cnt
592 ptl2gen "\cnt - 8" \g
593 .quad ((\cnt - 8) * 0x200000) + (\g * 1024 * 1024 * 1024) | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
594 .quad ((\cnt - 7) * 0x200000) + (\g * 1024 * 1024 * 1024) | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
595 .quad ((\cnt - 6) * 0x200000) + (\g * 1024 * 1024 * 1024) | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
596 .quad ((\cnt - 5) * 0x200000) + (\g * 1024 * 1024 * 1024) | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
597 .quad ((\cnt - 4) * 0x200000) + (\g * 1024 * 1024 * 1024) | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
598 .quad ((\cnt - 3) * 0x200000) + (\g * 1024 * 1024 * 1024) | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
599 .quad ((\cnt - 2) * 0x200000) + (\g * 1024 * 1024 * 1024) | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
600 .quad ((\cnt - 1) * 0x200000) + (\g * 1024 * 1024 * 1024) | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
601 .endif
[19077a5]602.endm
603
[873c681]604/* Page table for pages in the 1st gigabyte. */
[1141c1a]605.align 4096
[a1f60f3]606ptl_2_0g:
[19077a5]607 ptl2gen 512 0
608
[873c681]609/* Page table for pages in the 2nd gigabyte. */
[19077a5]610.align 4096
611ptl_2_1g:
612 ptl2gen 512 1
613
[873c681]614/* Page table for pages in the 3rd gigabyte. */
[19077a5]615.align 4096
616ptl_2_2g:
617 ptl2gen 512 2
618
[873c681]619/* Page table for pages in the 4th gigabyte. */
[19077a5]620.align 4096
621ptl_2_3g:
622 ptl2gen 512 3
[b9e97fb]623
[873c681]624/* Page table for pages in the 5th gigabyte. */
[64f6ef04]625.align 4096
626ptl_2_4g:
[fef504a]627 ptl2gen 512 4
[64f6ef04]628
[873c681]629/* Page table for pages in the 6th gigabyte. */
[64f6ef04]630.align 4096
631ptl_2_5g:
[fef504a]632 ptl2gen 512 5
[64f6ef04]633
[873c681]634/* Page table for pages in the 7th gigabyte. */
[64f6ef04]635.align 4096
636ptl_2_6g:
[fef504a]637 ptl2gen 512 6
[64f6ef04]638
[873c681]639/* Page table for pages in the 8th gigabyte. */
[64f6ef04]640.align 4096
641ptl_2_7g:
[fef504a]642 ptl2gen 512 7
[64f6ef04]643
[4bf0926e]644#ifdef MEMORY_MODEL_kernel
[6f878b7]645.align 4096
646ptl_1:
[873c681]647 /* Identity mapping for [0; 8G) */
[19077a5]648 .quad ptl_2_0g + (PTL_WRITABLE | PTL_PRESENT)
[a1f60f3]649 .quad ptl_2_1g + (PTL_WRITABLE | PTL_PRESENT)
[19077a5]650 .quad ptl_2_2g + (PTL_WRITABLE | PTL_PRESENT)
651 .quad ptl_2_3g + (PTL_WRITABLE | PTL_PRESENT)
[64f6ef04]652 .quad ptl_2_4g + (PTL_WRITABLE | PTL_PRESENT)
653 .quad ptl_2_5g + (PTL_WRITABLE | PTL_PRESENT)
654 .quad ptl_2_6g + (PTL_WRITABLE | PTL_PRESENT)
655 .quad ptl_2_7g + (PTL_WRITABLE | PTL_PRESENT)
[17af882]656 .fill 502, 8, 0
657 /* Mapping of [0; 2G) at -2G */
658 .quad ptl_2_0g + (PTL_WRITABLE | PTL_PRESENT)
659 .quad ptl_2_1g + (PTL_WRITABLE | PTL_PRESENT)
660
[6f878b7]661.align 4096
[3b0f1b9a]662SYMBOL(ptl_0)
[6f878b7]663 .quad ptl_1 + (PTL_WRITABLE | PTL_PRESENT)
[17af882]664 .fill 510, 8, 0
[6f878b7]665 .quad ptl_1 + (PTL_WRITABLE | PTL_PRESENT)
[4bf0926e]666#endif
667
668#ifdef MEMORY_MODEL_large
669.align 4096
670ptl_1:
671 /* Identity mapping for [0; 8G) */
672 .quad ptl_2_0g + (PTL_WRITABLE | PTL_PRESENT)
673 .quad ptl_2_1g + (PTL_WRITABLE | PTL_PRESENT)
674 .quad ptl_2_2g + (PTL_WRITABLE | PTL_PRESENT)
675 .quad ptl_2_3g + (PTL_WRITABLE | PTL_PRESENT)
676 .quad ptl_2_4g + (PTL_WRITABLE | PTL_PRESENT)
677 .quad ptl_2_5g + (PTL_WRITABLE | PTL_PRESENT)
678 .quad ptl_2_6g + (PTL_WRITABLE | PTL_PRESENT)
679 .quad ptl_2_7g + (PTL_WRITABLE | PTL_PRESENT)
680 .fill 504, 8, 0
681
682.align 4096
683SYMBOL(ptl_0)
684 .quad ptl_1 + (PTL_WRITABLE | PTL_PRESENT)
685 .fill 255, 8, 0
686 .quad ptl_1 + (PTL_WRITABLE | PTL_PRESENT)
687 .fill 255, 8, 0
688#endif
[6f878b7]689
[19077a5]690.section K_DATA_START, "aw", @progbits
691
[3b0f1b9a]692SYMBOL(bootstrap_idtr)
[f66c203d]693 .word 0
694 .long 0
695
[3b0f1b9a]696SYMBOL(bootstrap_gdtr)
[1d3d2cf]697 .word GDT_SELECTOR(GDT_ITEMS)
[1a67595]698 .long KA2PA(gdt)
[46d26ee]699
[3b0f1b9a]700SYMBOL(multiboot_eax)
[46d26ee]701 .long 0
702
[3b0f1b9a]703SYMBOL(multiboot_ebx)
[46d26ee]704 .long 0
[ac88c93]705
[873c681]706err_extended_cpuid:
[fccc236]707 .asciz "Error: Extended CPUID not supported -- CPU is not 64-bit. System halted."
[873c681]708err_long_mode:
[fccc236]709 .asciz "Error: 64-bit long mode not supported. System halted."
[873c681]710err_noexecute:
[fccc236]711 .asciz "Error: No-execute pages not supported. System halted."
[873c681]712err_fx:
[fccc236]713 .asciz "Error: FXSAVE/FXRESTORE instructions not supported. System halted."
[873c681]714err_sse2:
[fccc236]715 .asciz "Error: SSE2 instructions not supported. System halted."
[873c681]716
717status_prot:
718 .asciz "[prot] "
[1f5c9c96]719status_multiboot_cmdline:
720 .asciz "[multiboot_cmdline] "
[873c681]721status_prot2:
722 .asciz "[prot2] "
723status_long:
724 .asciz "[long] "
725status_main:
726 .asciz "[main] "
Note: See TracBrowser for help on using the repository browser.