Changeset a35b458 in mainline for kernel/arch/amd64/src


Ignore:
Timestamp:
2018-03-02T20:10:49Z (7 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f1380b7
Parents:
3061bc1
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-28 17:38:31)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:10:49)
Message:

style: Remove trailing whitespace on _all_ lines, including empty ones, for particular file types.

Command used: tools/srepl '\s\+$' '' -- *.c *.h *.py *.sh *.s *.S *.ag

Currently, whitespace on empty lines is very inconsistent.
There are two basic choices: Either remove the whitespace, or keep empty lines
indented to the level of surrounding code. The former is AFAICT more common,
and also much easier to do automatically.

Alternatively, we could write script for automatic indentation, and use that
instead. However, if such a script exists, it's possible to use the indented
style locally, by having the editor apply relevant conversions on load/save,
without affecting remote repository. IMO, it makes more sense to adopt
the simpler rule.

Location:
kernel/arch/amd64/src
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/amd64/src/amd64.c

    r3061bc1 ra35b458  
    9292        multiboot_info_parse(signature, (multiboot_info_t *) info);
    9393        multiboot2_info_parse(signature, (multiboot2_info_t *) info);
    94        
     94
    9595#ifdef CONFIG_SMP
    9696        /* Copy AP bootstrap routines below 1 MB. */
     
    106106        /* Enable FPU */
    107107        cpu_setup_fpu();
    108        
     108
    109109        /* Initialize segmentation */
    110110        pm_init();
    111        
     111
    112112        /* Disable I/O on nonprivileged levels, clear the nested-thread flag */
    113113        write_rflags(read_rflags() & ~(RFLAGS_IOPL | RFLAGS_NT));
    114114        /* Disable alignment check */
    115115        write_cr0(read_cr0() & ~CR0_AM);
    116        
     116
    117117        if (config.cpu_active == 1) {
    118118                interrupt_init();
    119119                bios_init();
    120                
     120
    121121                /* PIC */
    122122                i8259_init();
     
    132132                /* Initialize IRQ routing */
    133133                irq_init(IRQ_COUNT, IRQ_COUNT);
    134                
     134
    135135                /* hard clock */
    136136                i8254_init();
    137                
     137
    138138#if (defined(CONFIG_FB) || defined(CONFIG_EGA))
    139139                bool bfb = false;
    140140#endif
    141                
     141
    142142#ifdef CONFIG_FB
    143143                bfb = bfb_init();
    144144#endif
    145                
     145
    146146#ifdef CONFIG_EGA
    147147                if (!bfb) {
     
    151151                }
    152152#endif
    153                
     153
    154154                /* Merge all memory zones to 1 big zone */
    155155                zone_merge_all();
    156156        }
    157        
     157
    158158        /* Setup fast SYSCALL/SYSRET */
    159159        syscall_setup_cpu();
     
    235235        }
    236236#endif
    237        
     237
    238238        if (irqs_info != NULL)
    239239                sysinfo_set_item_val(irqs_info, NULL, true);
  • kernel/arch/amd64/src/asm.S

    r3061bc1 ra35b458  
    6060FUNCTION_BEGIN(memcpy_to_uspace)
    6161        movq MEMCPY_DST, %rax
    62        
     62
    6363        movq MEMCPY_SIZE, %rcx
    6464        shrq $3, %rcx           /* size / 8 */
    65        
     65
    6666        rep movsq               /* copy as much as possible word by word */
    67        
     67
    6868        movq MEMCPY_SIZE, %rcx
    6969        andq $7, %rcx           /* size % 8 */
    7070        jz 0f
    71        
     71
    7272        rep movsb               /* copy the rest byte by byte */
    73        
     73
    7474        0:
    7575                ret                 /* return MEMCPY_SRC, success */
     
    9292        popq %rax
    9393        movq %rax, %rdx
    94        
     94
    9595        /* Flip the ID bit */
    9696        xorl $RFLAGS_ID, %edx
    97        
     97
    9898        /* Store RFLAGS */
    9999        pushq %rdx
    100100        popfq
    101101        pushfq
    102        
     102
    103103        /* Get the ID bit again */
    104104        popq %rdx
    105105        andl $RFLAGS_ID, %eax
    106106        andl $RFLAGS_ID, %edx
    107        
     107
    108108        /* 0 if not supported, 1 if supported */
    109109        xorl %edx, %eax
     
    114114        /* Preserve %rbx across function calls */
    115115        movq %rbx, %r10
    116        
     116
    117117        /* Load the command into %eax */
    118118        movl %edi, %eax
    119        
     119
    120120        cpuid
    121121        movl %eax, 0(%rsi)
     
    123123        movl %ecx, 8(%rsi)
    124124        movl %edx, 12(%rsi)
    125        
     125
    126126        movq %r10, %rbx
    127127        ret
     
    161161         * code.
    162162         */
    163        
     163
    164164        .iflt \i-32
    165165                .if (1 << \i) & ERROR_WORD_INTERRUPT_LIST
     
    180180                subq $(ISTATE_SOFT_SIZE + 8), %rsp
    181181        .endif
    182        
     182
    183183        /*
    184184         * Save the general purpose registers.
     
    230230        movq $(\i), %rdi   /* pass intnum in the first argument */
    231231        movq %rsp, %rsi    /* pass istate address in the second argument */
    232        
     232
    233233        cld
    234234
     
    250250        movq ISTATE_OFFSET_R10(%rsp), %r10
    251251        movq ISTATE_OFFSET_R11(%rsp), %r11
    252        
     252
    253253        /* $8 = Skip error word */
    254254        addq $(ISTATE_SOFT_SIZE + 8), %rsp
     
    288288        /* Switch to hidden %gs */
    289289        swapgs
    290        
     290
    291291        movq %rsp, %gs:KSEG_OFFSET_USTACK_RSP  /* save this thread's user RSP */
    292292        movq %gs:KSEG_OFFSET_KSTACK_RSP, %rsp  /* set this thread's kernel RSP */
     
    346346        swapgs
    347347        sti
    348        
     348
    349349        /* Copy the 4th argument where it is expected  */
    350350        movq %r10, %rcx
     
    364364
    365365        cli
    366        
     366
    367367        /*
    368368         * Restore registers needed for return via the SYSRET instruction and
     
    394394        callq fault_from_uspace
    395395        /* not reached */
    396        
     396
    397397bad_rip_msg:
    398398        .asciz "Invalid instruction pointer."
     
    414414FUNCTION_BEGIN(early_putchar)
    415415#if ((defined(CONFIG_EGA)) && (!defined(CONFIG_FB)))
    416        
     416
    417417        /* Prologue, save preserved registers */
    418418        pushq %rbp
    419419        movq %rsp, %rbp
    420420        pushq %rbx
    421        
     421
    422422        movq %rdi, %rsi
    423423        movq $(PA2KA(0xb8000)), %rdi  /* base of EGA text mode memory */
    424424        xorl %eax, %eax
    425        
     425
    426426        /* Read bits 8 - 15 of the cursor address */
    427427        movw $0x3d4, %dx
    428428        movb $0xe, %al
    429429        outb %al, %dx
    430        
     430
    431431        movw $0x3d5, %dx
    432432        inb %dx, %al
    433433        shl $8, %ax
    434        
     434
    435435        /* Read bits 0 - 7 of the cursor address */
    436436        movw $0x3d4, %dx
    437437        movb $0xf, %al
    438438        outb %al, %dx
    439        
     439
    440440        movw $0x3d5, %dx
    441441        inb %dx, %al
    442        
     442
    443443        /* Sanity check for the cursor on screen */
    444444        cmp $2000, %ax
    445445        jb early_putchar_cursor_ok
    446        
     446
    447447                movw $1998, %ax
    448        
     448
    449449        early_putchar_cursor_ok:
    450        
     450
    451451        movw %ax, %bx
    452452        shl $1, %rax
    453453        addq %rax, %rdi
    454        
     454
    455455        movq %rsi, %rax
    456        
     456
    457457        cmp $0x0a, %al
    458458        jne early_putchar_backspace
    459        
     459
    460460                /* Interpret newline */
    461                
     461
    462462                movw %bx, %ax  /* %bx -> %dx:%ax */
    463463                xorw %dx, %dx
    464                
     464
    465465                movw $80, %cx
    466466                idivw %cx, %ax  /* %dx = %bx % 80 */
    467                
     467
    468468                /* %bx <- %bx + 80 - (%bx % 80) */
    469469                addw %cx, %bx
    470470                subw %dx, %bx
    471                
     471
    472472                jmp early_putchar_skip
    473        
     473
    474474        early_putchar_backspace:
    475        
     475
    476476                cmp $0x08, %al
    477477                jne early_putchar_print
    478                
     478
    479479                /* Interpret backspace */
    480                
     480
    481481                cmp $0x0000, %bx
    482482                je early_putchar_skip
    483                
     483
    484484                dec %bx
    485485                jmp early_putchar_skip
    486        
     486
    487487        early_putchar_print:
    488        
     488
    489489                /* Print character */
    490                
     490
    491491                movb $0x0e, %ah  /* black background, yellow foreground */
    492492                stosw
    493493                inc %bx
    494        
     494
    495495        early_putchar_skip:
    496        
     496
    497497        /* Sanity check for the cursor on the last line */
    498498        cmp $2000, %bx
    499499        jb early_putchar_no_scroll
    500        
     500
    501501                /* Scroll the screen (24 rows) */
    502502                movq $(PA2KA(0xb80a0)), %rsi
     
    504504                movl $480, %ecx
    505505                rep movsq
    506                
     506
    507507                /* Clear the 24th row */
    508508                xorl %eax, %eax
    509509                movl $20, %ecx
    510510                rep stosq
    511                
     511
    512512                /* Go to row 24 */
    513513                movw $1920, %bx
    514        
     514
    515515        early_putchar_no_scroll:
    516        
     516
    517517        /* Write bits 8 - 15 of the cursor address */
    518518        movw $0x3d4, %dx
    519519        movb $0xe, %al
    520520        outb %al, %dx
    521        
     521
    522522        movw $0x3d5, %dx
    523523        movb %bh, %al
    524524        outb %al, %dx
    525        
     525
    526526        /* Write bits 0 - 7 of the cursor address */
    527527        movw $0x3d4, %dx
    528528        movb $0xf, %al
    529529        outb %al, %dx
    530        
     530
    531531        movw $0x3d5, %dx
    532532        movb %bl, %al
    533533        outb %al, %dx
    534        
     534
    535535        /* Epilogue, restore preserved registers */
    536536        popq %rbx
    537537        leave
    538        
     538
    539539#endif
    540        
     540
    541541        ret
    542542FUNCTION_END(early_putchar)
  • kernel/arch/amd64/src/boot/multiboot.S

    r3061bc1 ra35b458  
    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
  • kernel/arch/amd64/src/boot/multiboot2.S

    r3061bc1 ra35b458  
    4747        .long multiboot2_header_end - multiboot2_header_start
    4848        .long -(MULTIBOOT2_HEADER_MAGIC + MULTIBOOT2_HEADER_ARCH_I386 + (multiboot2_header_end - multiboot2_header_start))
    49        
     49
    5050        /* Information request tag */
    5151        .align 8
     
    6161#endif
    6262        tag_info_req_end:
    63        
     63
    6464        /* Address tag */
    6565        .align 8
     
    7373                .long 0
    7474        tag_address_end:
    75        
     75
    7676        /* Entry address tag */
    7777        .align 8
     
    8282                .long multiboot2_image_start
    8383        tag_entry_address_end:
    84        
     84
    8585        /* Flags tag */
    8686        .align 8
     
    9191                .long MULTIBOOT2_FLAGS_CONSOLE
    9292        tag_flags_end:
    93        
     93
    9494#ifdef CONFIG_FB
    9595        /* Framebuffer tag */
     
    104104        tag_framebuffer_end:
    105105#endif
    106        
     106
    107107        /* Module alignment tag */
    108108        .align 8
     
    113113                .long 0
    114114        tag_module_align_end:
    115        
     115
    116116        /* Tag terminator */
    117117        .align 8
     
    126126        cli
    127127        cld
    128        
     128
    129129        /* Initialize stack pointer */
    130130        movl $START_STACK, %esp
    131        
     131
    132132        /*
    133133         * Initialize Global Descriptor Table and
     
    136136        lgdtl bootstrap_gdtr
    137137        lidtl bootstrap_idtr
    138        
     138
    139139        /* Kernel data + stack */
    140140        movw $GDT_SELECTOR(KDATA_DES), %cx
     
    142142        movw %cx, %ds
    143143        movw %cx, %ss
    144        
     144
    145145        /*
    146146         * Simics seems to remove hidden part of GS on entering user mode
     
    150150        movw %cx, %fs
    151151        movw %cx, %gs
    152        
     152
    153153        jmpl $GDT_SELECTOR(KTEXT32_DES), $multiboot2_meeting_point
    154154        multiboot2_meeting_point:
    155        
     155
    156156        /*
    157157         * Protected 32-bit. We want to reuse the code-seg descriptor,
    158158         * the Default operand size must not be 1 when entering long mode.
    159159         */
    160        
     160
    161161        /* Save multiboot arguments */
    162162        movl %eax, multiboot_eax
    163163        movl %ebx, multiboot_ebx
    164        
     164
    165165        movl $(INTEL_CPUID_EXTENDED), %eax
    166166        cpuid
    167167        cmp $(INTEL_CPUID_EXTENDED), %eax
    168168        ja extended_cpuid_supported
    169        
    170                 jmp pm_error_halt
    171        
     169
     170                jmp pm_error_halt
     171
    172172        extended_cpuid_supported:
    173        
     173
    174174        movl $(AMD_CPUID_EXTENDED), %eax
    175175        cpuid
    176176        bt $(AMD_EXT_LONG_MODE), %edx
    177177        jc long_mode_supported
    178        
    179                 jmp pm_error_halt
    180        
     178
     179                jmp pm_error_halt
     180
    181181        long_mode_supported:
    182        
     182
    183183        bt $(AMD_EXT_NOEXECUTE), %edx
    184184        jc noexecute_supported
    185        
    186                 jmp pm_error_halt
    187        
     185
     186                jmp pm_error_halt
     187
    188188        noexecute_supported:
    189        
     189
    190190        movl $(INTEL_CPUID_STANDARD), %eax
    191191        cpuid
    192192        bt $(INTEL_FXSAVE), %edx
    193193        jc fx_supported
    194        
    195                 jmp pm_error_halt
    196        
     194
     195                jmp pm_error_halt
     196
    197197        fx_supported:
    198        
     198
    199199        bt $(INTEL_SSE2), %edx
    200200        jc sse2_supported
    201        
    202                 jmp pm_error_halt
    203        
     201
     202                jmp pm_error_halt
     203
    204204        sse2_supported:
    205        
     205
    206206        /*
    207207         * Enable 64-bit page translation entries - CR4.PAE = 1.
    208208         * Paging is not enabled until after long mode is enabled.
    209209         */
    210        
     210
    211211        movl %cr4, %eax
    212212        orl $CR4_PAE, %eax
    213213        movl %eax, %cr4
    214        
     214
    215215        /* Set up paging tables */
    216216        leal ptl_0, %eax
    217217        movl %eax, %cr3
    218        
     218
    219219        /* Enable long mode */
    220220        movl $AMD_MSR_EFER, %ecx
     
    222222        orl $AMD_LME, %eax        /* set LME = 1 */
    223223        wrmsr
    224        
     224
    225225        /* Enable paging to activate long mode (set CR0.PG = 1) */
    226226        movl %cr0, %eax
    227227        orl $CR0_PG, %eax
    228228        movl %eax, %cr0
    229        
     229
    230230        /* At this point we are in compatibility mode */
    231231        jmpl $GDT_SELECTOR(KTEXT_DES), $start64
     
    240240
    241241start64:
    242        
     242
    243243        /*
    244244         * Long mode.
    245245         */
    246        
     246
    247247        movq $(PA2KA(START_STACK)), %rsp
    248        
     248
    249249        /* Create the first stack frame */
    250250        pushq $0
    251251        movq %rsp, %rbp
    252        
     252
    253253        /* Call amd64_pre_main(multiboot_eax, multiboot_ebx) */
    254254        movl multiboot_eax, %edi
    255255        movl multiboot_ebx, %esi
    256        
     256
    257257#ifdef MEMORY_MODEL_large
    258258        movabsq $amd64_pre_main, %rax
     
    261261        callq amd64_pre_main
    262262#endif
    263        
     263
    264264        /* Call main_bsp() */
    265265#ifdef MEMORY_MODEL_large
     
    269269        callq main_bsp
    270270#endif
    271        
     271
    272272        /* Not reached */
    273273        cli
  • kernel/arch/amd64/src/context.S

    r3061bc1 ra35b458  
    4040FUNCTION_BEGIN(context_save_arch)
    4141        movq (%rsp), %rdx     # the caller's return %rip
    42        
     42
    4343        movq %rdx, CONTEXT_OFFSET_PC(%rdi)
    4444        movq %rsp, CONTEXT_OFFSET_SP(%rdi)
    45        
     45
    4646        movq %rbx, CONTEXT_OFFSET_RBX(%rdi)
    4747        movq %rbp, CONTEXT_OFFSET_RBP(%rdi)
     
    5050        movq %r14, CONTEXT_OFFSET_R14(%rdi)
    5151        movq %r15, CONTEXT_OFFSET_R15(%rdi)
    52        
     52
    5353#ifdef MEMORY_MODEL_large
    5454        movabsq $vreg_ptr, %rsi
     
    5959        movq %fs:VREG_TP(%rsi), %rsi
    6060        movq %rsi, CONTEXT_OFFSET_TP(%rdi)
    61        
     61
    6262        xorl %eax, %eax       # context_save returns 1
    6363        incl %eax
     
    7878        movq CONTEXT_OFFSET_RBP(%rdi), %rbp
    7979        movq CONTEXT_OFFSET_RBX(%rdi), %rbx
    80        
     80
    8181        movq CONTEXT_OFFSET_SP(%rdi), %rsp
    82        
     82
    8383        movq CONTEXT_OFFSET_PC(%rdi), %rdx
    8484        movq %rdx, (%rsp)
    85        
     85
    8686        movq CONTEXT_OFFSET_TP(%rdi), %rcx
    8787#ifdef MEMORY_MODEL_large
     
    9292#endif
    9393        movq %rcx, %fs:VREG_TP(%rsi)
    94        
     94
    9595        xorl %eax, %eax       # context_restore returns 0
    9696        ret
  • kernel/arch/amd64/src/cpu/cpu.c

    r3061bc1 ra35b458  
    106106{
    107107        cpu_info_t info;
    108        
     108
    109109        CPU->arch.vendor = VendorUnknown;
    110110        if (has_cpuid()) {
    111111                cpuid(INTEL_CPUID_LEVEL, &info);
    112                
     112
    113113                /*
    114114                 * Check for AMD processor.
     
    119119                        CPU->arch.vendor = VendorAMD;
    120120                }
    121                
     121
    122122                /*
    123123                 * Check for Intel processor.
     
    128128                        CPU->arch.vendor = VendorIntel;
    129129                }
    130                
     130
    131131                cpuid(INTEL_CPUID_STANDARD, &info);
    132132                CPU->arch.family = (info.cpuid_eax >> 8) & 0xf;
  • kernel/arch/amd64/src/ddi/ddi.c

    r3061bc1 ra35b458  
    5959        /* First, copy the I/O Permission Bitmap. */
    6060        irq_spinlock_lock(&TASK->lock, false);
    61        
     61
    6262        size_t ver = TASK->arch.iomapver;
    6363        size_t elements = TASK->arch.iomap.elements;
    64        
     64
    6565        if (elements > 0) {
    6666                assert(TASK->arch.iomap.bits);
    67                
     67
    6868                bitmap_t iomap;
    6969                bitmap_initialize(&iomap, TSS_IOMAP_SIZE * 8,
    7070                    CPU->arch.tss->iomap);
    7171                bitmap_copy(&iomap, &TASK->arch.iomap, elements);
    72                
     72
    7373                /*
    7474                 * Set the trailing bits in the last byte of the map to disable
     
    7777                bitmap_set_range(&iomap, elements,
    7878                    ALIGN_UP(elements, 8) - elements);
    79                
     79
    8080                /*
    8181                 * It is safe to set the trailing eight bits because of the
     
    8484                bitmap_set_range(&iomap, ALIGN_UP(elements, 8), 8);
    8585        }
    86        
     86
    8787        irq_spinlock_unlock(&TASK->lock, false);
    88        
     88
    8989        /*
    9090         * Second, adjust TSS segment limit.
     
    9393        ptr_16_64_t cpugdtr;
    9494        gdtr_store(&cpugdtr);
    95        
     95
    9696        descriptor_t *gdt_p = (descriptor_t *) cpugdtr.base;
    9797        size_t size = bitmap_size(elements);
    9898        gdt_tss_setlimit(&gdt_p[TSS_DES], TSS_BASIC_SIZE + size);
    9999        gdtr_load(&cpugdtr);
    100        
     100
    101101        /*
    102102         * Before we load new TSS limit, the current TSS descriptor
     
    106106        tss_desc->type = AR_TSS;
    107107        tr_load(GDT_SELECTOR(TSS_DES));
    108        
     108
    109109        /*
    110110         * Update the generation count so that faults caused by
  • kernel/arch/amd64/src/debug/stacktrace.c

    r3061bc1 ra35b458  
    5050        uint64_t *stack = (void *) ctx->fp;
    5151        *prev = stack[FRAME_OFFSET_FP_PREV];
    52        
     52
    5353        return true;
    5454}
     
    5858        uint64_t *stack = (void *) ctx->fp;
    5959        *ra = stack[FRAME_OFFSET_RA];
    60        
     60
    6161        return true;
    6262}
  • kernel/arch/amd64/src/delay.S

    r3061bc1 ra35b458  
    3939                dec %rdi
    4040                jnz 0b
    41        
     41
    4242        ret
    4343FUNCTION_END(asm_delay_loop)
     
    4747                dec %rdi
    4848                jz 0b
    49        
     49
    5050        ret
    5151FUNCTION_END(asm_fake_loop)
  • kernel/arch/amd64/src/interrupt.c

    r3061bc1 ra35b458  
    7070            "rfl=%0#18" PRIx64 "\terr=%0#18" PRIx64 "\n",
    7171            istate->cs, istate->rip, istate->rflags, istate->error_word);
    72        
     72
    7373        if (istate_from_uspace(istate))
    7474                log_printf("ss =%0#18" PRIx64 "\n", istate->ss);
    75        
     75
    7676        log_printf("rax=%0#18" PRIx64 "\trbx=%0#18" PRIx64 "\t"
    7777            "rcx=%0#18" PRIx64 "\trdx=%0#18" PRIx64 "\n",
    7878            istate->rax, istate->rbx, istate->rcx, istate->rdx);
    79        
     79
    8080        log_printf("rsi=%0#18" PRIx64 "\trdi=%0#18" PRIx64 "\t"
    8181            "rbp=%0#18" PRIx64 "\trsp=%0#18" PRIx64 "\n",
     
    8383            istate_from_uspace(istate) ? istate->rsp :
    8484            (uintptr_t) &istate->rsp);
    85        
     85
    8686        log_printf("r8 =%0#18" PRIx64 "\tr9 =%0#18" PRIx64 "\t"
    8787            "r10=%0#18" PRIx64 "\tr11=%0#18" PRIx64 "\n",
    8888            istate->r8, istate->r9, istate->r10, istate->r11);
    89        
     89
    9090        log_printf("r12=%0#18" PRIx64 "\tr13=%0#18" PRIx64 "\t"
    9191            "r14=%0#18" PRIx64 "\tr15=%0#18" PRIx64 "\n",
     
    123123                size_t ver = TASK->arch.iomapver;
    124124                irq_spinlock_unlock(&TASK->lock, false);
    125                
     125
    126126                if (CPU->arch.iomapver_copy != ver) {
    127127                        /*
     
    176176{
    177177        assert(n >= IVT_IRQBASE);
    178        
     178
    179179        unsigned int inum = n - IVT_IRQBASE;
    180180        bool ack = false;
    181181        assert(inum < IRQ_COUNT);
    182182        assert((inum != IRQ_PIC_SPUR) && (inum != IRQ_PIC1));
    183        
     183
    184184        irq_t *irq = irq_dispatch_and_lock(inum);
    185185        if (irq) {
     
    187187                 * The IRQ handler was found.
    188188                 */
    189                
     189
    190190                if (irq->preack) {
    191191                        /* Send EOI before processing the interrupt */
     
    204204#endif
    205205        }
    206        
     206
    207207        if (!ack)
    208208                trap_virtual_eoi();
     
    212212{
    213213        unsigned int i;
    214        
     214
    215215        for (i = 0; i < IVT_ITEMS; i++)
    216216                exc_register(i, "null", false, (iroutine_t) null_interrupt);
    217        
     217
    218218        for (i = 0; i < IRQ_COUNT; i++) {
    219219                if ((i != IRQ_PIC_SPUR) && (i != IRQ_PIC1))
     
    221221                            (iroutine_t) irq_interrupt);
    222222        }
    223        
     223
    224224        exc_register(VECTOR_DE, "de_fault", true, (iroutine_t) de_fault);
    225225        exc_register(VECTOR_NM, "nm_fault", true, (iroutine_t) nm_fault);
    226226        exc_register(VECTOR_SS, "ss_fault", true, (iroutine_t) ss_fault);
    227227        exc_register(VECTOR_GP, "gp_fault", true, (iroutine_t) gp_fault);
    228        
     228
    229229#ifdef CONFIG_SMP
    230230        exc_register(VECTOR_TLB_SHOOTDOWN_IPI, "tlb_shootdown", true,
  • kernel/arch/amd64/src/mm/page.c

    r3061bc1 ra35b458  
    5757        unsigned int identity_flags =
    5858            PAGE_GLOBAL | PAGE_CACHEABLE | PAGE_EXEC | PAGE_WRITE | PAGE_READ;
    59                
     59
    6060        page_mapping_operations = &pt_mapping_operations;
    61                
     61
    6262        page_table_lock(AS_KERNEL, true);
    63                
     63
    6464        /*
    6565         * PA2KA(identity) mapping for all low-memory frames.
     
    6868            cur += FRAME_SIZE)
    6969                page_mapping_insert(AS_KERNEL, PA2KA(cur), cur, identity_flags);
    70                
     70
    7171        page_table_unlock(AS_KERNEL, true);
    72                
     72
    7373        exc_register(VECTOR_PF, "page_fault", true, (iroutine_t) page_fault);
    7474        write_cr3((uintptr_t) AS_KERNEL->genarch.page_table);
     
    7878{
    7979        uintptr_t badvaddr = read_cr2();
    80        
     80
    8181        if (istate->error_word & PFERR_CODE_RSVD)
    8282                panic("Reserved bit set in page table entry.");
    83        
     83
    8484        pf_access_t access;
    85        
     85
    8686        if (istate->error_word & PFERR_CODE_RW)
    8787                access = PF_ACCESS_WRITE;
     
    9090        else
    9191                access = PF_ACCESS_READ;
    92        
     92
    9393        (void) as_page_fault(badvaddr, access, istate);
    9494}
  • kernel/arch/amd64/src/pm.c

    r3061bc1 ra35b458  
    130130{
    131131        tss_descriptor_t *td = (tss_descriptor_t *) d;
    132        
     132
    133133        td->base_0_15 = base & 0xffffU;
    134134        td->base_16_23 = ((base) >> 16) & 0xffU;
     
    140140{
    141141        tss_descriptor_t *td = (tss_descriptor_t *) d;
    142        
     142
    143143        td->limit_0_15 = limit & 0xffffU;
    144144        td->limit_16_19 = (limit >> 16) & 0x0fU;
     
    167167        idescriptor_t *d;
    168168        unsigned int i;
    169        
     169
    170170        for (i = 0; i < IDT_ITEMS; i++) {
    171171                d = &idt[i];
    172                
     172
    173173                d->unused = 0;
    174174                d->selector = GDT_SELECTOR(KTEXT_DES);
    175                
     175
    176176                d->present = 1;
    177177                d->type = AR_INTERRUPT;  /* masking interrupt */
    178178        }
    179        
     179
    180180        d = &idt[0];
    181181        idt_setoffset(d++, (uintptr_t) &int_0);
     
    252252        descriptor_t *gdt_p = (descriptor_t *) gdtr.base;
    253253        tss_descriptor_t *tss_desc;
    254        
     254
    255255        /*
    256256         * Each CPU has its private GDT and TSS.
    257257         * All CPUs share one IDT.
    258258         */
    259        
     259
    260260        if (config.cpu_active == 1) {
    261261                idt_init();
     
    270270                 * ahead of page_init */
    271271                write_cr3((uintptr_t) AS_KERNEL->genarch.page_table);
    272                
     272
    273273                tss_p = (tss_t *) malloc(sizeof(tss_t), FRAME_ATOMIC);
    274274                if (!tss_p)
    275275                        panic("Cannot allocate TSS.");
    276276        }
    277        
     277
    278278        tss_initialize(tss_p);
    279        
     279
    280280        tss_desc = (tss_descriptor_t *) (&gdt_p[TSS_DES]);
    281281        tss_desc->present = 1;
    282282        tss_desc->type = AR_TSS;
    283283        tss_desc->dpl = PL_KERNEL;
    284        
     284
    285285        gdt_tss_setbase(&gdt_p[TSS_DES], (uintptr_t) tss_p);
    286286        gdt_tss_setlimit(&gdt_p[TSS_DES], TSS_BASIC_SIZE - 1);
    287        
     287
    288288        gdtr_load(&gdtr);
    289289        idtr_load(&idtr);
  • kernel/arch/amd64/src/smp/ap.S

    r3061bc1 ra35b458  
    5555        xorw %ax, %ax
    5656        movw %ax, %ds
    57        
     57
    5858        lgdtl ap_gdtr       # initialize Global Descriptor Table register
    59        
     59
    6060        movl %cr0, %eax
    6161        orl $CR0_PE, %eax
     
    7171        movw $GDT_SELECTOR(UDATA_DES), %ax
    7272        movw %ax, %gs
    73        
     73
    7474        # Enable 64-bit page transaltion entries (CR4.PAE = 1).
    7575        # Paging is not enabled until after long mode is enabled
    76        
     76
    7777        movl %cr4, %eax
    7878        orl $CR4_PAE, %eax
    7979        movl %eax, %cr4
    80        
     80
    8181        leal ptl_0, %eax
    8282        movl %eax, %cr3
    83        
     83
    8484        # Enable long mode
    8585        movl $AMD_MSR_EFER, %ecx  # EFER MSR number
     
    8787        orl $AMD_LME, %eax        # Set LME=1
    8888        wrmsr                     # Write EFER
    89        
     89
    9090        # Enable paging to activate long mode (set CR0.PG = 1)
    9191        movl %cr0, %eax
    9292        orl $CR0_PG, %eax
    9393        movl %eax, %cr0
    94        
     94
    9595        # At this point we are in compatibility mode
    9696        jmpl $GDT_SELECTOR(KTEXT_DES), $start64 - BOOT_OFFSET + AP_BOOT_OFFSET
     
    100100        movabsq $ctx, %rsp
    101101        movq CONTEXT_OFFSET_SP(%rsp), %rsp
    102        
     102
    103103        pushq $0
    104104        movq %rsp, %rbp
    105        
     105
    106106        movabsq $main_ap, %rax
    107107        callq *%rax   # never returns
  • kernel/arch/amd64/src/syscall.c

    r3061bc1 ra35b458  
    5151
    5252        /* Setup syscall entry address */
    53        
     53
    5454        /* This is _mess_ - the 64-bit CS is argument + 16,
    5555         * the SS is argument + 8. The order is:
  • kernel/arch/amd64/src/userspace.c

    r3061bc1 ra35b458  
    4949{
    5050        uint64_t rflags = read_rflags();
    51        
     51
    5252        rflags &= ~RFLAGS_NT;
    5353        rflags |= RFLAGS_IF;
    54        
     54
    5555        asm volatile (
    5656                "pushq %[udata_des]\n"
     
    6060                "pushq %[entry]\n"
    6161                "movq %[uarg], %%rax\n"
    62                        
     62
    6363                /* %rdi is defined to hold pcb_ptr - set it to 0 */
    6464                "xorq %%rdi, %%rdi\n"
     
    7373                : "rax"
    7474        );
    75        
     75
    7676        /* Unreachable */
    7777        while (1);
Note: See TracChangeset for help on using the changeset viewer.