Ignore:
File:
1 edited

Legend:

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

    ra35b458 r4bf0926e  
    7878        cli
    7979        cld
    80 
     80       
    8181        /* Initialize stack pointer */
    8282        movl $START_STACK, %esp
    83 
     83       
    8484        /*
    8585         * Initialize Global Descriptor Table and
     
    8888        lgdtl bootstrap_gdtr
    8989        lidtl bootstrap_idtr
    90 
     90       
    9191        /* Kernel data + stack */
    9292        movw $GDT_SELECTOR(KDATA_DES), %cx
     
    9494        movw %cx, %ds
    9595        movw %cx, %ss
    96 
     96       
    9797        /*
    9898         * Simics seems to remove hidden part of GS on entering user mode
     
    102102        movw %cx, %fs
    103103        movw %cx, %gs
    104 
     104       
    105105        jmpl $GDT_SELECTOR(KTEXT32_DES), $multiboot_meeting_point
    106106        multiboot_meeting_point:
    107 
     107       
    108108        /*
    109109         * Protected 32-bit. We want to reuse the code-seg descriptor,
    110110         * the Default operand size must not be 1 when entering long mode.
    111111         */
    112 
     112       
    113113        /* Save multiboot arguments */
    114114        movl %eax, multiboot_eax
    115115        movl %ebx, multiboot_ebx
    116 
     116       
    117117        pm_status $status_prot
    118 
     118       
    119119        movl $(INTEL_CPUID_EXTENDED), %eax
    120120        cpuid
    121121        cmp $(INTEL_CPUID_EXTENDED), %eax
    122122        ja extended_cpuid_supported
    123 
     123       
    124124                pm_error $err_extended_cpuid
    125 
     125       
    126126        extended_cpuid_supported:
    127 
     127       
    128128        movl $(AMD_CPUID_EXTENDED), %eax
    129129        cpuid
    130130        bt $(AMD_EXT_LONG_MODE), %edx
    131131        jc long_mode_supported
    132 
     132       
    133133                pm_error $err_long_mode
    134 
     134       
    135135        long_mode_supported:
    136 
     136       
    137137        bt $(AMD_EXT_NOEXECUTE), %edx
    138138        jc noexecute_supported
    139 
     139       
    140140                pm_error $err_noexecute
    141 
     141       
    142142        noexecute_supported:
    143 
     143       
    144144        movl $(INTEL_CPUID_STANDARD), %eax
    145145        cpuid
    146146        bt $(INTEL_FXSAVE), %edx
    147147        jc fx_supported
    148 
     148       
    149149                pm_error $err_fx
    150 
     150       
    151151        fx_supported:
    152 
     152       
    153153        bt $(INTEL_SSE2), %edx
    154154        jc sse2_supported
    155 
     155       
    156156                pm_error $err_sse2
    157 
     157       
    158158        sse2_supported:
    159 
     159       
    160160#include "vesa_prot.inc"
    161 
     161       
    162162        pm2_status $status_prot2
    163 
     163       
    164164        /*
    165165         * Enable 64-bit page translation entries - CR4.PAE = 1.
    166166         * Paging is not enabled until after long mode is enabled.
    167167         */
    168 
     168       
    169169        movl %cr4, %eax
    170170        orl $CR4_PAE, %eax
    171171        movl %eax, %cr4
    172 
     172       
    173173        /* Set up paging tables */
    174174        leal ptl_0, %eax
    175175        movl %eax, %cr3
    176 
     176       
    177177        /* Enable long mode */
    178178        movl $AMD_MSR_EFER, %ecx
     
    180180        orl $AMD_LME, %eax        /* set LME = 1 */
    181181        wrmsr
    182 
     182       
    183183        /* Enable paging to activate long mode (set CR0.PG = 1) */
    184184        movl %cr0, %eax
    185185        orl $CR0_PG, %eax
    186186        movl %eax, %cr0
    187 
     187       
    188188        /* At this point we are in compatibility mode */
    189189        jmpl $GDT_SELECTOR(KTEXT_DES), $start64
     
    204204        movl $0xb8000, %edi  /* base of EGA text mode memory */
    205205        xorl %eax, %eax
    206 
     206       
    207207        /* Read bits 8 - 15 of the cursor address */
    208208        movw $0x3d4, %dx
    209209        movb $0xe, %al
    210210        outb %al, %dx
    211 
     211       
    212212        movw $0x3d5, %dx
    213213        inb %dx, %al
    214214        shl $8, %ax
    215 
     215       
    216216        /* Read bits 0 - 7 of the cursor address */
    217217        movw $0x3d4, %dx
    218218        movb $0xf, %al
    219219        outb %al, %dx
    220 
     220       
    221221        movw $0x3d5, %dx
    222222        inb %dx, %al
    223 
     223       
    224224        /* Sanity check for the cursor on screen */
    225225        cmp $2000, %ax
    226226        jb err_cursor_ok
    227 
     227       
    228228                movw $1998, %ax
    229 
     229       
    230230        err_cursor_ok:
    231 
     231       
    232232        movw %ax, %bx
    233233        shl $1, %eax
    234234        addl %eax, %edi
    235 
     235       
    236236        err_ploop:
    237237                lodsb
    238 
     238               
    239239                cmp $0, %al
    240240                je err_ploop_end
    241 
     241               
    242242                movb $0x0c, %ah  /* black background, light red foreground */
    243243                stosw
    244 
     244               
    245245                /* Sanity check for the cursor on the last line */
    246246                inc %bx
    247247                cmp $2000, %bx
    248248                jb err_ploop
    249 
     249               
    250250                /* Scroll the screen (24 rows) */
    251251                movl %esi, %edx
     
    254254                movl $960, %ecx
    255255                rep movsl
    256 
     256               
    257257                /* Clear the 24th row */
    258258                xorl %eax, %eax
    259259                movl $40, %ecx
    260260                rep stosl
    261 
     261               
    262262                /* Go to row 24 */
    263263                movl %edx, %esi
    264264                movl $0xb8f00, %edi
    265265                movw $1920, %bx
    266 
     266               
    267267                jmp err_ploop
    268268        err_ploop_end:
    269 
     269       
    270270        /* Write bits 8 - 15 of the cursor address */
    271271        movw $0x3d4, %dx
    272272        movb $0xe, %al
    273273        outb %al, %dx
    274 
     274       
    275275        movw $0x3d5, %dx
    276276        movb %bh, %al
    277277        outb %al, %dx
    278 
     278       
    279279        /* Write bits 0 - 7 of the cursor address */
    280280        movw $0x3d4, %dx
    281281        movb $0xf, %al
    282282        outb %al, %dx
    283 
     283       
    284284        movw $0x3d5, %dx
    285285        movb %bl, %al
    286286        outb %al, %dx
    287 
     287       
    288288        cli
    289289        hlt1:
     
    311311        pushl %edx
    312312        pushl %edi
    313 
     313       
    314314        movl $0xb8000, %edi  /* base of EGA text mode memory */
    315315        xorl %eax, %eax
    316 
     316       
    317317        /* Read bits 8 - 15 of the cursor address */
    318318        movw $0x3d4, %dx
    319319        movb $0xe, %al
    320320        outb %al, %dx
    321 
     321       
    322322        movw $0x3d5, %dx
    323323        inb %dx, %al
    324324        shl $8, %ax
    325 
     325       
    326326        /* Read bits 0 - 7 of the cursor address */
    327327        movw $0x3d4, %dx
    328328        movb $0xf, %al
    329329        outb %al, %dx
    330 
     330       
    331331        movw $0x3d5, %dx
    332332        inb %dx, %al
    333 
     333       
    334334        /* Sanity check for the cursor on screen */
    335335        cmp $2000, %ax
    336336        jb pm_puts_cursor_ok
    337 
     337       
    338338                movw $1998, %ax
    339 
     339       
    340340        pm_puts_cursor_ok:
    341 
     341       
    342342        movw %ax, %bx
    343343        shl $1, %eax
    344344        addl %eax, %edi
    345 
     345       
    346346        pm_puts_ploop:
    347347                lodsb
    348 
     348               
    349349                cmp $0, %al
    350350                je pm_puts_ploop_end
    351 
     351               
    352352                movb $0x0a, %ah  /* black background, light green foreground */
    353353                stosw
    354 
     354               
    355355                /* Sanity check for the cursor on the last line */
    356356                inc %bx
    357357                cmp $2000, %bx
    358358                jb pm_puts_ploop
    359 
     359               
    360360                /* Scroll the screen (24 rows) */
    361361                movl %esi, %edx
     
    364364                movl $960, %ecx
    365365                rep movsl
    366 
     366               
    367367                /* Clear the 24th row */
    368368                xorl %eax, %eax
    369369                movl $40, %ecx
    370370                rep stosl
    371 
     371               
    372372                /* Go to row 24 */
    373373                movl %edx, %esi
    374374                movl $0xb8f00, %edi
    375375                movw $1920, %bx
    376 
     376               
    377377                jmp pm_puts_ploop
    378378        pm_puts_ploop_end:
    379 
     379       
    380380        /* Write bits 8 - 15 of the cursor address */
    381381        movw $0x3d4, %dx
    382382        movb $0xe, %al
    383383        outb %al, %dx
    384 
     384       
    385385        movw $0x3d5, %dx
    386386        movb %bh, %al
    387387        outb %al, %dx
    388 
     388       
    389389        /* Write bits 0 - 7 of the cursor address */
    390390        movw $0x3d4, %dx
    391391        movb $0xf, %al
    392392        outb %al, %dx
    393 
     393       
    394394        movw $0x3d5, %dx
    395395        movb %bl, %al
    396396        outb %al, %dx
    397 
     397       
    398398        popl %edi
    399399        popl %edx
     
    401401        popl %ebx
    402402        popl %eax
    403 
     403       
    404404        ret
    405405
     
    414414
    415415start64:
    416 
     416       
    417417        /*
    418418         * Long mode.
    419419         */
    420 
     420       
    421421        movq $(PA2KA(START_STACK)), %rsp
    422 
     422       
    423423        /* Create the first stack frame */
    424424        pushq $0
    425425        movq %rsp, %rbp
    426 
     426       
    427427        long_status $status_long
    428 
     428       
    429429        /* Call amd64_pre_main(multiboot_eax, multiboot_ebx) */
    430430        movl multiboot_eax, %edi
    431431        movl multiboot_ebx, %esi
    432 
     432       
    433433#ifdef MEMORY_MODEL_large
    434434        movabsq $amd64_pre_main, %rax
     
    437437        callq amd64_pre_main
    438438#endif
    439 
     439       
    440440        long_status $status_main
    441 
     441       
    442442        /* Call main_bsp() */
    443443#ifdef MEMORY_MODEL_large
     
    447447        callq main_bsp
    448448#endif
    449 
     449       
    450450        /* Not reached */
    451451        cli
     
    468468 */
    469469early_puts:
    470 
     470       
    471471#if ((defined(CONFIG_EGA)) && (!defined(CONFIG_FB)))
    472 
     472       
    473473        /* Prologue, save preserved registers */
    474474        pushq %rbp
    475475        movq %rsp, %rbp
    476476        pushq %rbx
    477 
     477       
    478478        movq %rdi, %rsi
    479479        movq $(PA2KA(0xb8000)), %rdi  /* base of EGA text mode memory */
    480480        xorq %rax, %rax
    481 
     481       
    482482        /* Read bits 8 - 15 of the cursor address */
    483483        movw $0x3d4, %dx
    484484        movb $0xe, %al
    485485        outb %al, %dx
    486 
     486       
    487487        movw $0x3d5, %dx
    488488        inb %dx, %al
    489489        shl $8, %ax
    490 
     490       
    491491        /* Read bits 0 - 7 of the cursor address */
    492492        movw $0x3d4, %dx
    493493        movb $0xf, %al
    494494        outb %al, %dx
    495 
     495       
    496496        movw $0x3d5, %dx
    497497        inb %dx, %al
    498 
     498       
    499499        /* Sanity check for the cursor on screen */
    500500        cmp $2000, %ax
    501501        jb early_puts_cursor_ok
    502 
     502       
    503503                movw $1998, %ax
    504 
     504       
    505505        early_puts_cursor_ok:
    506 
     506       
    507507        movw %ax, %bx
    508508        shl $1, %rax
    509509        addq %rax, %rdi
    510 
     510       
    511511        early_puts_ploop:
    512512                lodsb
    513 
     513               
    514514                cmp $0, %al
    515515                je early_puts_ploop_end
    516 
     516               
    517517                movb $0x0e, %ah  /* black background, yellow foreground */
    518518                stosw
    519 
     519               
    520520                /* Sanity check for the cursor on the last line */
    521521                inc %bx
    522522                cmp $2000, %bx
    523523                jb early_puts_ploop
    524 
     524               
    525525                /* Scroll the screen (24 rows) */
    526526                movq %rsi, %rdx
     
    529529                movl $480, %ecx
    530530                rep movsq
    531 
     531               
    532532                /* Clear the 24th row */
    533533                xorl %eax, %eax
    534534                movl $20, %ecx
    535535                rep stosq
    536 
     536               
    537537                /* Go to row 24 */
    538538                movq %rdx, %rsi
    539539                movq $(PA2KA(0xb8f00)), %rdi
    540540                movw $1920, %bx
    541 
     541               
    542542                jmp early_puts_ploop
    543543        early_puts_ploop_end:
    544 
     544       
    545545        /* Write bits 8 - 15 of the cursor address */
    546546        movw $0x3d4, %dx
    547547        movb $0xe, %al
    548548        outb %al, %dx
    549 
     549       
    550550        movw $0x3d5, %dx
    551551        movb %bh, %al
    552552        outb %al, %dx
    553 
     553       
    554554        /* Write bits 0 - 7 of the cursor address */
    555555        movw $0x3d4, %dx
    556556        movb $0xf, %al
    557557        outb %al, %dx
    558 
     558       
    559559        movw $0x3d5, %dx
    560560        movb %bl, %al
    561561        outb %al, %dx
    562 
     562       
    563563        /* Epilogue, restore preserved registers */
    564564        popq %rbx
    565565        leave
    566 
     566       
    567567#endif
    568 
     568       
    569569        ret
    570570
Note: See TracChangeset for help on using the changeset viewer.