Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/amd64/src/boot/boot.S

    r64f6ef04 r304342e  
    3131#include <arch/boot/boot.h>
    3232#include <arch/boot/memmap.h>
    33 #include <arch/mm/page.h>
     33#include <arch/mm/page.h>       
    3434#include <arch/mm/ptl.h>
    3535#include <arch/pm.h>
     
    172172        xorq %rsi, %rsi
    173173        movl grub_ebx, %esi
    174        
    175         movabsq $arch_pre_main, %rax
    176         callq *%rax
     174        call arch_pre_main
    177175       
    178176        # create the first stack frame
    179177        pushq $0
    180178        movq %rsp, %rbp
    181        
    182         movabsq $main_bsp, %rax
    183         call *%rax
     179
     180        call main_bsp
    184181       
    185182        # not reached
     
    259256#
    260257# Macro for generating initial page table contents.
    261 # @param cnt Number of entries to generate. Must be multiple of 8.
     258# @param cnt Number of entries to generat. Must be multiple of 8.
    262259# @param g   Number of GB that will be added to the mapping.
    263260#
    264 .macro ptl2gen cnt g
    265         .if \cnt
    266                 ptl2gen "\cnt - 8" \g
    267                 .quad ((\cnt - 8) * 0x200000) + (\g * 1024 * 1024 * 1024) | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
    268                 .quad ((\cnt - 7) * 0x200000) + (\g * 1024 * 1024 * 1024) | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
    269                 .quad ((\cnt - 6) * 0x200000) + (\g * 1024 * 1024 * 1024) | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
    270                 .quad ((\cnt - 5) * 0x200000) + (\g * 1024 * 1024 * 1024) | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
    271                 .quad ((\cnt - 4) * 0x200000) + (\g * 1024 * 1024 * 1024) | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
    272                 .quad ((\cnt - 3) * 0x200000) + (\g * 1024 * 1024 * 1024) | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
    273                 .quad ((\cnt - 2) * 0x200000) + (\g * 1024 * 1024 * 1024) | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
    274                 .quad ((\cnt - 1) * 0x200000) + (\g * 1024 * 1024 * 1024) | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
    275         .endif
     261.macro ptl2gen cnt g 
     262.if \cnt
     263        ptl2gen "\cnt - 8" \g
     264        .quad ((\cnt - 8) * 0x200000) + (\g * 1024 * 1024 * 1024) | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
     265        .quad ((\cnt - 7) * 0x200000) + (\g * 1024 * 1024 * 1024) | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
     266        .quad ((\cnt - 6) * 0x200000) + (\g * 1024 * 1024 * 1024) | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
     267        .quad ((\cnt - 5) * 0x200000) + (\g * 1024 * 1024 * 1024) | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
     268        .quad ((\cnt - 4) * 0x200000) + (\g * 1024 * 1024 * 1024) | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
     269        .quad ((\cnt - 3) * 0x200000) + (\g * 1024 * 1024 * 1024) | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
     270        .quad ((\cnt - 2) * 0x200000) + (\g * 1024 * 1024 * 1024) | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
     271        .quad ((\cnt - 1) * 0x200000) + (\g * 1024 * 1024 * 1024) | (PTL_WRITABLE | PTL_PRESENT | PTL_2MB_PAGE)
     272.endif
    276273.endm
    277274
    278 # Page table for pages in the 1st gigabyte.
    279 .align 4096
    280 ptl_2_0g:
     275# Page table for pages in the first gigabyte.
     276.align 4096
     277.global ptl_2_0g
     278ptl_2_0g:       
    281279        ptl2gen 512 0
    282280
    283 # Page table for pages in the 2nd gigabyte.
    284 .align 4096
     281# Page table for pages in the second gigabyte.
     282.align 4096
     283.global ptl_2_1g
    285284ptl_2_1g:
    286285        ptl2gen 512 1
    287286
    288 # Page table for pages in the 3rd gigabyte.
    289 .align 4096
     287# Page table for pages in the third gigabyte.
     288.align 4096
     289.global ptl_2_2g
    290290ptl_2_2g:
    291291        ptl2gen 512 2
    292292
    293 # Page table for pages in the 4th gigabyte.
    294 .align 4096
     293# Page table for pages in the fourth gigabyte.
     294.align 4096
     295.global ptl_2_3g
    295296ptl_2_3g:
    296297        ptl2gen 512 3
    297298
    298 # Page table for pages in the 5th gigabyte.
    299 .align 4096
    300 ptl_2_4g:
    301         ptl2gen 512 3
    302 
    303 # Page table for pages in the 6th gigabyte.
    304 .align 4096
    305 ptl_2_5g:
    306         ptl2gen 512 3
    307 
    308 # Page table for pages in the 7th gigabyte.
    309 .align 4096
    310 ptl_2_6g:
    311         ptl2gen 512 3
    312 
    313 # Page table for pages in the 8th gigabyte.
    314 .align 4096
    315 ptl_2_7g:
    316         ptl2gen 512 3
    317 
    318 .align 4096
     299.align 4096
     300.global ptl_1
    319301ptl_1:
    320         # Identity mapping for [0; 8G)
     302        # Identity mapping for [0; 4G)
    321303        .quad ptl_2_0g + (PTL_WRITABLE | PTL_PRESENT)
    322         .quad ptl_2_1g + (PTL_WRITABLE | PTL_PRESENT)
     304        .quad ptl_2_1g + (PTL_WRITABLE | PTL_PRESENT) 
    323305        .quad ptl_2_2g + (PTL_WRITABLE | PTL_PRESENT)
    324306        .quad ptl_2_3g + (PTL_WRITABLE | PTL_PRESENT)
    325         .quad ptl_2_4g + (PTL_WRITABLE | PTL_PRESENT)
    326         .quad ptl_2_5g + (PTL_WRITABLE | PTL_PRESENT)
    327         .quad ptl_2_6g + (PTL_WRITABLE | PTL_PRESENT)
    328         .quad ptl_2_7g + (PTL_WRITABLE | PTL_PRESENT)
    329         .fill 504, 8, 0
     307        .fill 506, 8, 0
     308        # Mapping of [0; 1G) at -2G
     309        .quad ptl_2_0g + (PTL_WRITABLE | PTL_PRESENT)
     310        .fill 1, 8, 0
    330311
    331312.align 4096
     
    333314ptl_0:
    334315        .quad ptl_1 + (PTL_WRITABLE | PTL_PRESENT)
    335         .fill 255, 8, 0
     316        .fill 255,8,0
    336317        .quad ptl_1 + (PTL_WRITABLE | PTL_PRESENT)
    337         .fill 255, 8, 0
     318        .fill 254,8,0
     319        .quad ptl_1 + (PTL_WRITABLE | PTL_PRESENT)
    338320
    339321.section K_DATA_START, "aw", @progbits
     
    351333
    352334extended_cpuid_msg:
    353         .asciz "Error: Extended CPUID not supported -- CPU is not 64-bit. System halted."
     335        .asciz "Extended CPUID not supported. System halted."
    354336long_mode_msg:
    355         .asciz "Error: 64-bit long mode not supported. System halted."
     337        .asciz "64 bit long mode not supported. System halted."
    356338noexecute_msg:
    357         .asciz "Error: No-execute pages not supported. System halted."
     339        .asciz "No-execute pages not supported. System halted."
    358340fx_msg:
    359         .asciz "Error: FXSAVE/FXRESTORE instructions not supported. System halted."
     341        .asciz "FXSAVE/FXRESTORE instructions not supported. System halted."
    360342sse2_msg:
    361         .asciz "Error: SSE2 instructions not supported. System halted."
     343        .asciz "SSE2 instructions not supported. System halted."
Note: See TracChangeset for help on using the changeset viewer.