Changeset a35b458 in mainline for kernel/arch/ia32/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/ia32/src
Files:
19 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/ia32/src/asm.S

    r3061bc1 ra35b458  
    6363        movl %edi, %edx  /* save %edi */
    6464        movl %esi, %eax  /* save %esi */
    65        
     65
    6666        movl MEMCPY_SIZE(%esp), %ecx
    6767        shrl $2, %ecx  /* size / 4 */
    68        
     68
    6969        movl MEMCPY_DST(%esp), %edi
    7070        movl MEMCPY_SRC(%esp), %esi
    71        
     71
    7272        /* Copy whole words */
    7373        rep movsl
    74        
     74
    7575        movl MEMCPY_SIZE(%esp), %ecx
    7676        andl $3, %ecx  /* size % 4 */
    7777        jz 0f
    78        
     78
    7979        /* Copy the rest byte by byte */
    8080        rep movsb
    81        
     81
    8282        0:
    83        
     83
    8484                movl %edx, %edi
    8585                movl %eax, %esi
    86                
     86
    8787                /* MEMCPY_DST(%esp), success */
    8888                movl MEMCPY_DST(%esp), %eax
     
    9999        movl %edx, %edi
    100100        movl %eax, %esi
    101        
     101
    102102        /* Return 0, failure */
    103103        xorl %eax, %eax
     
    112112        movl %cr0, %edx
    113113        orl $CR0_PG, %edx  /* paging on */
    114        
     114
    115115        /* Clear Cache Disable and not Write Though */
    116116        andl $~(CR0_CD | CR0_NW), %edx
    117117        movl %edx, %cr0
    118118        jmp 0f
    119        
     119
    120120        0:
    121121                ret
     
    174174        movl %edi, ISTATE_OFFSET_EDI(%esp)      /* observability; not needed */
    175175        movl %ebp, ISTATE_OFFSET_EBP(%esp)      /* observability; not needed */
    176        
     176
    177177        /*
    178178         * Fake up the stack trace linkage.
     
    190190        movl $(GDT_SELECTOR(VREG_DES)), %eax
    191191        movl %eax, %gs
    192        
     192
    193193        /*
    194194         * Sanitize EFLAGS.
     
    207207
    208208        call syscall_handler
    209        
     209
    210210        /*
    211211         * Prepare return address and userspace stack for SYSEXIT.
     
    252252        movl %es, %ecx
    253253        movl %ds, %edx
    254                
     254
    255255        movl %ecx, ISTATE_OFFSET_ES(%esp)
    256256        movl %edx, ISTATE_OFFSET_DS(%esp)
     
    264264        movl $(GDT_SELECTOR(VREG_DES)), %eax
    265265        movl %eax, %gs
    266                
     266
    267267        movl $0, ISTATE_OFFSET_EBP_FRAME(%esp)
    268268        movl ISTATE_OFFSET_EIP(%esp), %eax
    269269        movl %eax, ISTATE_OFFSET_EIP_FRAME(%esp)
    270270        leal ISTATE_OFFSET_EBP_FRAME(%esp), %ebp
    271                
     271
    272272        cld
    273                
     273
    274274        /* Call syscall_handler(edx, ecx, ebx, esi, edi, ebp, eax) */
    275275        call syscall_handler
    276                        
     276
    277277        /*
    278278         * Restore the segment registers.
     
    286286        movl ISTATE_OFFSET_ES(%esp), %ecx
    287287        movl ISTATE_OFFSET_DS(%esp), %edx
    288                        
     288
    289289        movl %ecx, %es
    290290        movl %edx, %ds
    291                        
     291
    292292        /*
    293293         * Restore the preserved registers the handler cloberred itself
     
    295295         */
    296296        movl ISTATE_OFFSET_EBP(%esp), %ebp
    297                        
     297
    298298        addl $(ISTATE_SOFT_SIZE + 4), %esp
    299299        iret
    300                
     300
    301301/**
    302302 * Mask for interrupts 0 - 31 (bits 0 - 31) where 0 means that int
     
    333333                subl $(ISTATE_SOFT_SIZE + 4), %esp
    334334        .endif
    335        
     335
    336336        /*
    337337         * Save the general purpose registers.
     
    344344        movl %esi, ISTATE_OFFSET_ESI(%esp)
    345345        movl %ebp, ISTATE_OFFSET_EBP(%esp)
    346        
     346
    347347        /*
    348348         * Save the segment registers.
     
    356356        movl %es, %ecx
    357357        movl %ds, %edx
    358        
     358
    359359        movl %ecx, ISTATE_OFFSET_ES(%esp)
    360360        movl %edx, ISTATE_OFFSET_DS(%esp)
    361        
     361
    362362        /*
    363363         * Switch to kernel selectors.
     
    368368        movl $(GDT_SELECTOR(VREG_DES)), %eax
    369369        movl %eax, %gs
    370        
     370
    371371        /*
    372372         * Imitate a regular stack frame linkage.
     
    387387        movl %eax, ISTATE_OFFSET_EIP_FRAME(%esp)
    388388        leal ISTATE_OFFSET_EBP_FRAME(%esp), %ebp
    389                
     389
    390390        cld
    391                
     391
    392392        pushl %esp   /* pass istate address */
    393393        pushl $(\i)  /* pass intnum */
    394                
     394
    395395        /* Call exc_dispatch(intnum, istate) */
    396396        call exc_dispatch
    397                
     397
    398398        addl $8, %esp  /* clear arguments from the stack */
    399                
     399
    400400        /*
    401401         * Restore the selector registers.
     
    409409        movl ISTATE_OFFSET_ES(%esp), %ecx
    410410        movl ISTATE_OFFSET_DS(%esp), %edx
    411                
     411
    412412        movl %ecx, %es
    413413        movl %edx, %ds
    414                
     414
    415415        /*
    416416         * Restore the scratch registers and the preserved
     
    422422        movl ISTATE_OFFSET_EDX(%esp), %edx
    423423        movl ISTATE_OFFSET_EBP(%esp), %ebp
    424                
     424
    425425        addl $(ISTATE_SOFT_SIZE + 4), %esp
    426426        iret
     
    452452 */
    453453FUNCTION_BEGIN(early_putchar)
    454        
     454
    455455#if ((defined(CONFIG_EGA)) && (!defined(CONFIG_FB)))
    456        
     456
    457457        /* Prologue, save preserved registers */
    458458        pushl %ebp
     
    461461        pushl %esi
    462462        pushl %edi
    463        
     463
    464464        movl $(PA2KA(0xb8000)), %edi  /* base of EGA text mode memory */
    465465        xorl %eax, %eax
    466        
     466
    467467        /* Read bits 8 - 15 of the cursor address */
    468468        movw $0x3d4, %dx
    469469        movb $0xe, %al
    470470        outb %al, %dx
    471        
     471
    472472        movw $0x3d5, %dx
    473473        inb %dx, %al
    474474        shl $8, %ax
    475        
     475
    476476        /* Read bits 0 - 7 of the cursor address */
    477477        movw $0x3d4, %dx
    478478        movb $0xf, %al
    479479        outb %al, %dx
    480        
     480
    481481        movw $0x3d5, %dx
    482482        inb %dx, %al
    483        
     483
    484484        /* Sanity check for the cursor on screen */
    485485        cmp $2000, %ax
    486486        jb early_putchar_cursor_ok
    487        
     487
    488488                movw $1998, %ax
    489        
     489
    490490        early_putchar_cursor_ok:
    491        
     491
    492492        movw %ax, %bx
    493493        shl $1, %eax
    494494        addl %eax, %edi
    495        
     495
    496496        movl 0x08(%ebp), %eax
    497        
     497
    498498        cmp $0x0a, %al
    499499        jne early_putchar_backspace
    500        
     500
    501501                /* Interpret newline */
    502                
     502
    503503                movw %bx, %ax  /* %bx -> %dx:%ax */
    504504                xorw %dx, %dx
    505                
     505
    506506                movw $80, %cx
    507507                idivw %cx, %ax  /* %dx = %bx % 80 */
    508                
     508
    509509                /* %bx <- %bx + 80 - (%bx % 80) */
    510510                addw %cx, %bx
    511511                subw %dx, %bx
    512                
     512
    513513                jmp early_putchar_skip
    514        
     514
    515515        early_putchar_backspace:
    516        
     516
    517517                cmp $0x08, %al
    518518                jne early_putchar_print
    519                
     519
    520520                /* Interpret backspace */
    521                
     521
    522522                cmp $0x0000, %bx
    523523                je early_putchar_skip
    524                
     524
    525525                dec %bx
    526526                jmp early_putchar_skip
    527        
     527
    528528        early_putchar_print:
    529        
     529
    530530                /* Print character */
    531                
     531
    532532                movb $0x0e, %ah  /* black background, yellow foreground */
    533533                stosw
    534534                inc %bx
    535        
     535
    536536        early_putchar_skip:
    537        
     537
    538538        /* Sanity check for the cursor on the last line */
    539539        cmp $2000, %bx
    540540        jb early_putchar_no_scroll
    541        
     541
    542542                /* Scroll the screen (24 rows) */
    543543                movl $(PA2KA(0xb80a0)), %esi
     
    545545                movl $960, %ecx
    546546                rep movsl
    547                
     547
    548548                /* Clear the 24th row */
    549549                xorl %eax, %eax
    550550                movl $40, %ecx
    551551                rep stosl
    552                
     552
    553553                /* Go to row 24 */
    554554                movw $1920, %bx
    555        
     555
    556556        early_putchar_no_scroll:
    557        
     557
    558558        /* Write bits 8 - 15 of the cursor address */
    559559        movw $0x3d4, %dx
    560560        movb $0xe, %al
    561561        outb %al, %dx
    562        
     562
    563563        movw $0x3d5, %dx
    564564        movb %bh, %al
    565565        outb %al, %dx
    566        
     566
    567567        /* Write bits 0 - 7 of the cursor address */
    568568        movw $0x3d4, %dx
    569569        movb $0xf, %al
    570570        outb %al, %dx
    571        
     571
    572572        movw $0x3d5, %dx
    573573        movb %bl, %al
    574574        outb %al, %dx
    575        
     575
    576576        /* Epilogue, restore preserved registers */
    577577        popl %edi
     
    579579        popl %ebx
    580580        leave
    581        
     581
    582582#endif
    583        
     583
    584584        ret
    585585FUNCTION_END(early_putchar)
  • kernel/arch/ia32/src/atomic.S

    r3061bc1 ra35b458  
    3939        pushl %eax
    4040        pushl %ebx
    41        
     41
    4242        movl 12(%esp),%ebx
    4343
     
    5656        ret
    5757FUNCTION_END(spinlock_arch)
    58        
     58
    5959#endif
  • kernel/arch/ia32/src/boot/multiboot.S

    r3061bc1 ra35b458  
    7777        cli
    7878        cld
    79        
     79
    8080        /* Initialize stack pointer */
    8181        movl $START_STACK, %esp
    82        
     82
    8383        /*
    8484         * Initialize Global Descriptor Table and
     
    8787        lgdtl bootstrap_gdtr
    8888        lidtl bootstrap_idtr
    89        
     89
    9090        /* Kernel data + stack */
    9191        movw $GDT_SELECTOR(KDATA_DES), %cx
     
    9595        movw %cx, %ds
    9696        movw %cx, %ss
    97        
     97
    9898        jmpl $GDT_SELECTOR(KTEXT_DES), $multiboot_meeting_point
    9999        multiboot_meeting_point:
    100        
     100
    101101        /* Save multiboot arguments */
    102102        movl %eax, multiboot_eax
    103103        movl %ebx, multiboot_ebx
    104        
     104
    105105        pm_status $status_prot
    106        
     106
    107107#include "vesa_prot.inc"
    108        
     108
    109109#ifndef PROCESSOR_i486
    110        
     110
    111111        pm_status $status_prot2
    112        
     112
    113113        movl $(INTEL_CPUID_LEVEL), %eax
    114114        cpuid
    115115        cmp $0x0, %eax  /* any function > 0? */
    116116        jbe pse_unsupported
    117        
     117
    118118        movl $(INTEL_CPUID_STANDARD), %eax
    119119        cpuid
    120120        bt $(INTEL_PSE), %edx
    121121        jnc pse_unsupported
    122                
     122
    123123                /* Map kernel and turn paging on */
    124124                pm_status $status_pse
    125125                call map_kernel_pse
    126126                jmp stack_init
    127        
     127
    128128#endif /* PROCESSOR_i486 */
    129        
     129
    130130        pse_unsupported:
    131                
     131
    132132                /* Map kernel and turn paging on */
    133133                pm_status $status_non_pse
    134134                call map_kernel_non_pse
    135        
     135
    136136        stack_init:
    137        
     137
    138138        /* Create the first stack frame */
    139139        pushl $0
    140140        movl %esp, %ebp
    141        
     141
    142142        pm2_status $status_prot3
    143        
     143
    144144        /* Call ia32_pre_main(multiboot_eax, multiboot_ebx) */
    145145        pushl multiboot_ebx
    146146        pushl multiboot_eax
    147147        call ia32_pre_main
    148        
     148
    149149        pm2_status $status_main
    150        
     150
    151151        /* Call main_bsp() */
    152152        call main_bsp
    153        
     153
    154154        /* Not reached */
    155155        cli
     
    170170        andl $~CR4_PAE, %ecx    /* PAE off */
    171171        movl %ecx, %cr4
    172        
     172
    173173        movl $(page_directory + 0), %esi
    174174        movl $(page_directory + 2048), %edi
    175175        xorl %ecx, %ecx
    176176        xorl %ebx, %ebx
    177        
     177
    178178        floop_pse:
    179179                movl $(PDE_4M | PDE_RW | PDE_P), %eax
     
    184184                movl %eax, (%edi, %ecx, 4)
    185185                addl $(4 * 1024 * 1024), %ebx
    186                
     186
    187187                incl %ecx
    188188                cmpl $512, %ecx
    189189                jl floop_pse
    190        
     190
    191191        movl %esi, %cr3
    192        
     192
    193193        movl %cr0, %ebx
    194194        orl $CR0_PG, %ebx       /* paging on */
     
    208208        andl $~CR4_PAE, %ecx  /* PAE off */
    209209        movl %ecx, %cr4
    210        
     210
    211211        call calc_kernel_end
    212212        call find_mem_for_pt
    213        
     213
    214214        mov kernel_end, %esi
    215215        mov free_area, %ecx
    216        
     216
    217217        cmpl %esi, %ecx
    218218        jbe use_kernel_end
    219                
     219
    220220                mov %ecx, %esi
    221                
     221
    222222                /* Align address down to 4k */
    223223                andl $(~(PAGE_SIZE - 1)), %esi
    224                
     224
    225225        use_kernel_end:
    226                
     226
    227227                /* Align address to 4k */
    228228                addl $(PAGE_SIZE - 1), %esi
    229229                andl $(~(PAGE_SIZE - 1)), %esi
    230                
     230
    231231                /* Allocate space for page tables */
    232232                movl %esi, pt_loc
    233233                movl $KA2PA(ballocs), %edi
    234                
     234
    235235                movl %esi, (%edi)
    236236                addl $4, %edi
    237237                movl $(2 * 1024 * 1024), (%edi)
    238                
     238
    239239                /* Fill page tables */
    240240                xorl %ecx, %ecx
    241241                xorl %ebx, %ebx
    242                
     242
    243243                floop_pt:
    244244                        movl $(PTE_RW | PTE_P), %eax
     
    246246                        movl %eax, (%esi, %ecx, 4)
    247247                        addl $PAGE_SIZE, %ebx
    248                        
     248
    249249                        incl %ecx
    250250                        cmpl $(512 * 1024), %ecx
    251                        
     251
    252252                        jl floop_pt
    253                
     253
    254254                /* Fill page directory */
    255255                movl $(page_directory + 0), %esi
     
    257257                xorl %ecx, %ecx
    258258                movl pt_loc, %ebx
    259                
     259
    260260                floop:
    261261                        movl $(PDE_RW | PDE_P), %eax
    262262                        orl %ebx, %eax
    263                        
     263
    264264                        /* Mapping 0x00000000 + %ecx * 4M => 0x00000000 + %ecx * 4M */
    265265                        movl %eax, (%esi, %ecx, 4)
    266                        
     266
    267267                        /* Mapping 0x80000000 + %ecx * 4M => 0x00000000 + %ecx * 4M */
    268268                        movl %eax, (%edi, %ecx, 4)
    269269                        addl $PAGE_SIZE, %ebx
    270                        
     270
    271271                        incl %ecx
    272272                        cmpl $512, %ecx
    273                        
     273
    274274                        jl floop
    275                
     275
    276276                movl %esi, %cr3
    277                
     277
    278278                movl %cr0, %ebx
    279279                orl $CR0_PG, %ebx  /* paging on */
    280280                movl %ebx, %cr0
    281                
     281
    282282                ret
    283283FUNCTION_END(map_kernel_non_pse)
     
    288288        movl (%edi), %esi
    289289        leal KA2PA(0)(%esi), %esi
    290        
     290
    291291        movl $KA2PA(hardcoded_ktext_size), %edi
    292292        addl (%edi), %esi
    293293        leal KA2PA(0)(%esi), %esi
    294        
     294
    295295        movl $KA2PA(hardcoded_kdata_size), %edi
    296296        addl (%edi), %esi
    297297        leal KA2PA(0)(%esi), %esi
    298298        movl %esi, kernel_end
    299        
     299
    300300        ret
    301301
     
    305305        cmpl $MULTIBOOT_LOADER_MAGIC, multiboot_eax
    306306        je check_multiboot_map
    307                
     307
    308308                ret
    309        
     309
    310310        check_multiboot_map:
    311                
     311
    312312                /* Copy address of the multiboot info to ebx */
    313313                movl multiboot_ebx, %ebx
    314                
     314
    315315                /* Check if memory map flag is present */
    316316                movl (%ebx), %edx
    317317                andl $MULTIBOOT_INFO_FLAGS_MMAP, %edx
    318318                jnz use_multiboot_map
    319                        
     319
    320320                        ret
    321                
     321
    322322        use_multiboot_map:
    323                
     323
    324324                /* Copy address of the memory map to edx */
    325325                movl MULTIBOOT_INFO_OFFSET_MMAP_ADDR(%ebx), %edx
    326326                movl %edx, %ecx
    327                
     327
    328328                addl MULTIBOOT_INFO_OFFSET_MMAP_LENGTH(%ebx), %ecx
    329                
     329
    330330                /* Find a free region at least 2M in size */
    331331                check_memmap_loop:
    332                        
     332
    333333                        /* Is this a free region? */
    334334                        cmpl $MEMMAP_MEMORY_AVAILABLE, MULTIBOOT_MEMMAP_OFFSET_MM_INFO + E820MEMMAP_OFFSET_TYPE(%edx)
    335335                        jnz next_region
    336                        
     336
    337337                        /* Check size */
    338338                        cmpl $0, MULTIBOOT_MEMMAP_OFFSET_MM_INFO + E820MEMMAP_OFFSET_SIZE + 4(%edx)
     
    340340                        cmpl $(2 * 1024 * 1024 + PAGE_SIZE), MULTIBOOT_MEMMAP_OFFSET_MM_INFO + E820MEMMAP_OFFSET_SIZE(%edx)
    341341                        jbe next_region
    342                        
     342
    343343                        cmpl $0, MULTIBOOT_MEMMAP_OFFSET_MM_INFO + E820MEMMAP_OFFSET_BASE_ADDRESS + 4(%edx)
    344344                        jz found_region
    345                
     345
    346346                next_region:
    347                        
     347
    348348                        cmp %ecx, %edx
    349349                        jbe next_region_do
    350                        
     350
    351351                                ret
    352                
     352
    353353                next_region_do:
    354                        
     354
    355355                        addl MULTIBOOT_MEMMAP_OFFSET_SIZE(%edx), %edx
    356356                        addl $MULTIBOOT_MEMMAP_SIZE_SIZE, %edx
    357357                        jmp check_memmap_loop
    358                        
     358
    359359                found_region:
    360                        
     360
    361361                        /* Use end of the found region */
    362362                        mov MULTIBOOT_MEMMAP_OFFSET_MM_INFO + E820MEMMAP_OFFSET_BASE_ADDRESS(%edx), %ecx
     
    364364                        sub $(2 * 1024 * 1024), %ecx
    365365                        mov %ecx, free_area
    366                        
     366
    367367                        ret
    368368
     
    381381        movl $0xb8000, %edi  /* base of EGA text mode memory */
    382382        xorl %eax, %eax
    383        
     383
    384384        /* Read bits 8 - 15 of the cursor address */
    385385        movw $0x3d4, %dx
    386386        movb $0xe, %al
    387387        outb %al, %dx
    388        
     388
    389389        movw $0x3d5, %dx
    390390        inb %dx, %al
    391391        shl $8, %ax
    392        
     392
    393393        /* Read bits 0 - 7 of the cursor address */
    394394        movw $0x3d4, %dx
    395395        movb $0xf, %al
    396396        outb %al, %dx
    397        
     397
    398398        movw $0x3d5, %dx
    399399        inb %dx, %al
    400        
     400
    401401        /* Sanity check for the cursor on screen */
    402402        cmp $2000, %ax
    403403        jb err_cursor_ok
    404        
     404
    405405                movw $1998, %ax
    406        
     406
    407407        err_cursor_ok:
    408        
     408
    409409        movw %ax, %bx
    410410        shl $1, %eax
    411411        addl %eax, %edi
    412        
     412
    413413        err_ploop:
    414414                lodsb
    415                
     415
    416416                cmp $0, %al
    417417                je err_ploop_end
    418                
     418
    419419                movb $0x0c, %ah  /* black background, light red foreground */
    420420                stosw
    421                
     421
    422422                /* Sanity check for the cursor on the last line */
    423423                inc %bx
    424424                cmp $2000, %bx
    425425                jb err_ploop
    426                
     426
    427427                /* Scroll the screen (24 rows) */
    428428                movl %esi, %edx
     
    431431                movl $960, %ecx
    432432                rep movsl
    433                
     433
    434434                /* Clear the 24th row */
    435435                xorl %eax, %eax
    436436                movl $40, %ecx
    437437                rep stosl
    438                
     438
    439439                /* Go to row 24 */
    440440                movl %edx, %esi
    441441                movl $0xb8f00, %edi
    442442                movw $1920, %bx
    443                
     443
    444444                jmp err_ploop
    445445        err_ploop_end:
    446        
     446
    447447        /* Write bits 8 - 15 of the cursor address */
    448448        movw $0x3d4, %dx
    449449        movb $0xe, %al
    450450        outb %al, %dx
    451        
     451
    452452        movw $0x3d5, %dx
    453453        movb %bh, %al
    454454        outb %al, %dx
    455        
     455
    456456        /* Write bits 0 - 7 of the cursor address */
    457457        movw $0x3d4, %dx
    458458        movb $0xf, %al
    459459        outb %al, %dx
    460        
     460
    461461        movw $0x3d5, %dx
    462462        movb %bl, %al
    463463        outb %al, %dx
    464        
     464
    465465        cli
    466466        hlt1:
     
    486486        pushl %edx
    487487        pushl %edi
    488        
     488
    489489        movl $0xb8000, %edi  /* base of EGA text mode memory */
    490490        xorl %eax, %eax
    491        
     491
    492492        /* Read bits 8 - 15 of the cursor address */
    493493        movw $0x3d4, %dx
    494494        movb $0xe, %al
    495495        outb %al, %dx
    496        
     496
    497497        movw $0x3d5, %dx
    498498        inb %dx, %al
    499499        shl $8, %ax
    500        
     500
    501501        /* Read bits 0 - 7 of the cursor address */
    502502        movw $0x3d4, %dx
    503503        movb $0xf, %al
    504504        outb %al, %dx
    505        
     505
    506506        movw $0x3d5, %dx
    507507        inb %dx, %al
    508        
     508
    509509        /* Sanity check for the cursor on screen */
    510510        cmp $2000, %ax
    511511        jb pm_puts_cursor_ok
    512        
     512
    513513                movw $1998, %ax
    514        
     514
    515515        pm_puts_cursor_ok:
    516        
     516
    517517        movw %ax, %bx
    518518        shl $1, %eax
    519519        addl %eax, %edi
    520        
     520
    521521        pm_puts_ploop:
    522522                lodsb
    523                
     523
    524524                cmp $0, %al
    525525                je pm_puts_ploop_end
    526                
     526
    527527                movb $0x0a, %ah  /* black background, light green foreground */
    528528                stosw
    529                
     529
    530530                /* Sanity check for the cursor on the last line */
    531531                inc %bx
    532532                cmp $2000, %bx
    533533                jb pm_puts_ploop
    534                
     534
    535535                /* Scroll the screen (24 rows) */
    536536                movl %esi, %edx
     
    539539                movl $960, %ecx
    540540                rep movsl
    541                
     541
    542542                /* Clear the 24th row */
    543543                xorl %eax, %eax
    544544                movl $40, %ecx
    545545                rep stosl
    546                
     546
    547547                /* Go to row 24 */
    548548                movl %edx, %esi
    549549                movl $0xb8f00, %edi
    550550                movw $1920, %bx
    551                
     551
    552552                jmp pm_puts_ploop
    553553        pm_puts_ploop_end:
    554        
     554
    555555        /* Write bits 8 - 15 of the cursor address */
    556556        movw $0x3d4, %dx
    557557        movb $0xe, %al
    558558        outb %al, %dx
    559        
     559
    560560        movw $0x3d5, %dx
    561561        movb %bh, %al
    562562        outb %al, %dx
    563        
     563
    564564        /* Write bits 0 - 7 of the cursor address */
    565565        movw $0x3d4, %dx
    566566        movb $0xf, %al
    567567        outb %al, %dx
    568        
     568
    569569        movw $0x3d5, %dx
    570570        movb %bl, %al
    571571        outb %al, %dx
    572        
     572
    573573        popl %edi
    574574        popl %edx
     
    576576        popl %ebx
    577577        popl %eax
    578        
     578
    579579        ret
    580580
     
    591591 */
    592592early_puts:
    593        
     593
    594594#if ((defined(CONFIG_EGA)) && (!defined(CONFIG_FB)))
    595        
     595
    596596        /* Prologue, save preserved registers */
    597597        pushl %ebp
     
    600600        pushl %esi
    601601        pushl %edi
    602        
     602
    603603        movl 0x08(%ebp), %esi
    604604        movl $(PA2KA(0xb8000)), %edi  /* base of EGA text mode memory */
    605605        xorl %eax, %eax
    606        
     606
    607607        /* Read bits 8 - 15 of the cursor address */
    608608        movw $0x3d4, %dx
    609609        movb $0xe, %al
    610610        outb %al, %dx
    611        
     611
    612612        movw $0x3d5, %dx
    613613        inb %dx, %al
    614614        shl $8, %ax
    615        
     615
    616616        /* Read bits 0 - 7 of the cursor address */
    617617        movw $0x3d4, %dx
    618618        movb $0xf, %al
    619619        outb %al, %dx
    620        
     620
    621621        movw $0x3d5, %dx
    622622        inb %dx, %al
    623        
     623
    624624        /* Sanity check for the cursor on screen */
    625625        cmp $2000, %ax
    626626        jb early_puts_cursor_ok
    627        
     627
    628628                movw $1998, %ax
    629        
     629
    630630        early_puts_cursor_ok:
    631        
     631
    632632        movw %ax, %bx
    633633        shl $1, %eax
    634634        addl %eax, %edi
    635        
     635
    636636        early_puts_ploop:
    637637                lodsb
    638                
     638
    639639                cmp $0, %al
    640640                je early_puts_ploop_end
    641                
     641
    642642                movb $0x0e, %ah  /* black background, yellow foreground */
    643643                stosw
    644                
     644
    645645                /* Sanity check for the cursor on the last line */
    646646                inc %bx
    647647                cmp $2000, %bx
    648648                jb early_puts_ploop
    649                
     649
    650650                /* Scroll the screen (24 rows) */
    651651                movl %esi, %edx
     
    654654                movl $960, %ecx
    655655                rep movsl
    656                
     656
    657657                /* Clear the 24th row */
    658658                xorl %eax, %eax
    659659                movl $40, %ecx
    660660                rep stosl
    661                
     661
    662662                /* Go to row 24 */
    663663                movl %edx, %esi
    664664                movl $(PA2KA(0xb8f00)), %edi
    665665                movw $1920, %bx
    666                
     666
    667667                jmp early_puts_ploop
    668668        early_puts_ploop_end:
    669        
     669
    670670        /* Write bits 8 - 15 of the cursor address */
    671671        movw $0x3d4, %dx
    672672        movb $0xe, %al
    673673        outb %al, %dx
    674        
     674
    675675        movw $0x3d5, %dx
    676676        movb %bh, %al
    677677        outb %al, %dx
    678        
     678
    679679        /* Write bits 0 - 7 of the cursor address */
    680680        movw $0x3d4, %dx
    681681        movb $0xf, %al
    682682        outb %al, %dx
    683        
     683
    684684        movw $0x3d5, %dx
    685685        movb %bl, %al
    686686        outb %al, %dx
    687        
     687
    688688        /* Epilogue, restore preserved registers */
    689689        popl %edi
     
    691691        popl %ebx
    692692        leave
    693        
     693
    694694#endif
    695        
     695
    696696        ret
    697697
  • kernel/arch/ia32/src/boot/multiboot2.S

    r3061bc1 ra35b458  
    4545        .long multiboot2_header_end - multiboot2_header_start
    4646        .long -(MULTIBOOT2_HEADER_MAGIC + MULTIBOOT2_HEADER_ARCH_I386 + (multiboot2_header_end - multiboot2_header_start))
    47        
     47
    4848        /* Information request tag */
    4949        .align 8
     
    5959#endif
    6060        tag_info_req_end:
    61        
     61
    6262        /* Address tag */
    6363        .align 8
     
    7171                .long 0
    7272        tag_address_end:
    73        
     73
    7474        /* Entry address tag */
    7575        .align 8
     
    8080                .long multiboot2_image_start
    8181        tag_entry_address_end:
    82        
     82
    8383        /* Flags tag */
    8484        .align 8
     
    8989                .long MULTIBOOT2_FLAGS_CONSOLE
    9090        tag_flags_end:
    91        
     91
    9292#ifdef CONFIG_FB
    9393        /* Framebuffer tag */
     
    102102        tag_framebuffer_end:
    103103#endif
    104        
     104
    105105        /* Module alignment tag */
    106106        .align 8
     
    111111                .long 0
    112112        tag_module_align_end:
    113        
     113
    114114        /* Tag terminator */
    115115        .align 8
     
    124124        cli
    125125        cld
    126        
     126
    127127        /* Initialize stack pointer */
    128128        movl $START_STACK, %esp
    129        
     129
    130130        /*
    131131         * Initialize Global Descriptor Table and
     
    134134        lgdtl bootstrap_gdtr
    135135        lidtl bootstrap_idtr
    136        
     136
    137137        /* Kernel data + stack */
    138138        movw $GDT_SELECTOR(KDATA_DES), %cx
     
    142142        movw %cx, %ds
    143143        movw %cx, %ss
    144        
     144
    145145        jmpl $GDT_SELECTOR(KTEXT_DES), $multiboot2_meeting_point
    146146        multiboot2_meeting_point:
    147        
     147
    148148        /* Save multiboot arguments */
    149149        movl %eax, multiboot_eax
    150150        movl %ebx, multiboot_ebx
    151        
     151
    152152#ifndef PROCESSOR_i486
    153        
     153
    154154        movl $(INTEL_CPUID_LEVEL), %eax
    155155        cpuid
    156156        cmp $0x0, %eax  /* any function > 0? */
    157157        jbe pse_unsupported
    158        
     158
    159159        movl $(INTEL_CPUID_STANDARD), %eax
    160160        cpuid
    161161        bt $(INTEL_PSE), %edx
    162162        jnc pse_unsupported
    163                
     163
    164164                /* Map kernel and turn paging on */
    165165                call map_kernel_pse
    166166                jmp stack_init
    167        
     167
    168168#endif /* PROCESSOR_i486 */
    169        
     169
    170170        pse_unsupported:
    171                
     171
    172172                /* Map kernel and turn paging on */
    173173                call map_kernel_non_pse
    174        
     174
    175175        stack_init:
    176        
     176
    177177        /* Create the first stack frame */
    178178        pushl $0
    179179        movl %esp, %ebp
    180        
     180
    181181        /* Call ia32_pre_main(multiboot_eax, multiboot_ebx) */
    182182        pushl multiboot_ebx
    183183        pushl multiboot_eax
    184184        call ia32_pre_main
    185        
     185
    186186        /* Call main_bsp() */
    187187        call main_bsp
    188        
     188
    189189        /* Not reached */
    190190        cli
  • kernel/arch/ia32/src/cpu/cpu.c

    r3061bc1 ra35b458  
    8484        cpu_info_t info;
    8585        uint32_t help = 0;
    86        
     86
    8787        CPU->arch.tss = tss_p;
    8888        CPU->arch.tss->iomap_base = &CPU->arch.tss->iomap[0] - ((uint8_t *) CPU->arch.tss);
    89        
     89
    9090        CPU->fpu_owner = NULL;
    91        
     91
    9292        cpuid(INTEL_CPUID_STANDARD, &info);
    93        
     93
    9494        CPU->arch.fi.word = info.cpuid_edx;
    95        
     95
    9696        if (CPU->arch.fi.bits.fxsr)
    9797                fpu_fxsr();
    9898        else
    9999                fpu_fsr();
    100        
     100
    101101        if (CPU->arch.fi.bits.sse) {
    102102                asm volatile (
     
    108108                );
    109109        }
    110        
     110
    111111#ifndef PROCESSOR_i486
    112112        if (CPU->arch.fi.bits.sep) {
     
    132132                    && (info.cpuid_edx == AMD_CPUID_EDX))
    133133                        CPU->arch.vendor = VendorAMD;
    134                
     134
    135135                /*
    136136                 * Check for Intel processor.
     
    140140                    && (info.cpuid_edx == INTEL_CPUID_EDX))
    141141                        CPU->arch.vendor = VendorIntel;
    142                
     142
    143143                cpuid(INTEL_CPUID_STANDARD, &info);
    144144                CPU->arch.family = (info.cpuid_eax >> 8) & 0x0fU;
  • kernel/arch/ia32/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_32_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_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
     
    105105        gdt_p[TSS_DES].access = AR_PRESENT | AR_TSS | DPL_KERNEL;
    106106        tr_load(GDT_SELECTOR(TSS_DES));
    107        
     107
    108108        /*
    109109         * Update the generation count so that faults caused by
  • kernel/arch/ia32/src/drivers/i8254.c

    r3061bc1 ra35b458  
    8989        i8254_irq.handler = i8254_irq_handler;
    9090        irq_register(&i8254_irq);
    91        
     91
    9292        i8254_normal_operation();
    9393}
     
    111111        pio_write_8(CLK_PORT1, 0xff);
    112112        pio_write_8(CLK_PORT1, 0xff);
    113        
     113
    114114        uint8_t not_ok;
    115115        uint32_t t1;
    116116        uint32_t t2;
    117        
     117
    118118        do {
    119119                /* will read both status and count */
     
    123123                t1 |= pio_read_8(CLK_PORT1) << 8;
    124124        } while (not_ok);
    125        
     125
    126126        asm_delay_loop(LOOPS);
    127        
     127
    128128        pio_write_8(CLK_PORT4, 0xd2);
    129129        t2 = pio_read_8(CLK_PORT1);
    130130        t2 |= pio_read_8(CLK_PORT1) << 8;
    131        
     131
    132132        /*
    133133         * We want to determine the overhead of the calibrating mechanism.
     
    136136        uint32_t o1 = pio_read_8(CLK_PORT1);
    137137        o1 |= pio_read_8(CLK_PORT1) << 8;
    138        
     138
    139139        asm_fake_loop(LOOPS);
    140        
     140
    141141        pio_write_8(CLK_PORT4, 0xd2);
    142142        uint32_t o2 = pio_read_8(CLK_PORT1);
    143143        o2 |= pio_read_8(CLK_PORT1) << 8;
    144        
     144
    145145        CPU->delay_loop_const =
    146146            ((MAGIC_NUMBER * LOOPS) / 1000) / ((t1 - t2) - (o1 - o2)) +
    147147            (((MAGIC_NUMBER * LOOPS) / 1000) % ((t1 - t2) - (o1 - o2)) ? 1 : 0);
    148        
     148
    149149        uint64_t clk1 = get_cycle();
    150150        delay(1 << SHIFT);
    151151        uint64_t clk2 = get_cycle();
    152        
     152
    153153        CPU->frequency_mhz = (clk2 - clk1) >> SHIFT;
    154        
     154
    155155        return;
    156156}
  • kernel/arch/ia32/src/fpu_context.c

    r3061bc1 ra35b458  
    5959        X87_DENORMAL_EXC_FLAG = (1 << 1),
    6060        X87_INVALID_OP_EXC_FLAG = (1 << 0),
    61        
     61
    6262        X87_ALL_MASK = X87_PRECISION_MASK | X87_UNDERFLOW_MASK | X87_OVERFLOW_MASK | X87_ZERO_DIV_MASK | X87_DENORMAL_OP_MASK | X87_INVALID_OP_MASK,
    6363};
     
    129129        uint32_t help0 = 0;
    130130        uint32_t help1 = 0;
    131        
     131
    132132        asm volatile (
    133133                "fninit\n"
  • kernel/arch/ia32/src/ia32.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. */
     
    107107                interrupt_init();
    108108                bios_init();
    109                
     109
    110110                /* PIC */
    111111                i8259_init();
     
    120120                /* Initialize IRQ routing */
    121121                irq_init(IRQ_COUNT, IRQ_COUNT);
    122                
     122
    123123                /* hard clock */
    124124                i8254_init();
    125                
     125
    126126#if (defined(CONFIG_FB) || defined(CONFIG_EGA))
    127127                bool bfb = false;
    128128#endif
    129                
     129
    130130#ifdef CONFIG_FB
    131131                bfb = bfb_init();
    132132#endif
    133                
     133
    134134#ifdef CONFIG_EGA
    135135                if (!bfb) {
     
    139139                }
    140140#endif
    141                
     141
    142142                /* Merge all memory zones to 1 big zone */
    143143                zone_merge_all();
     
    220220        }
    221221#endif
    222        
     222
    223223        if (irqs_info != NULL)
    224224                sysinfo_set_item_val(irqs_info, NULL, true);
  • kernel/arch/ia32/src/interrupt.c

    r3061bc1 ra35b458  
    7272            "efl=%0#10" PRIx32 "\terr=%0#10" PRIx32 "\n",
    7373            istate->cs, istate->eip, istate->eflags, istate->error_word);
    74        
     74
    7575        printf("ds =%0#10" PRIx32 "\tes =%0#10" PRIx32 "\t"
    7676            "fs =%0#10" PRIx32 "\tgs =%0#10" PRIx32 "\n",
    7777            istate->ds, istate->es, istate->fs, istate->gs);
    78        
     78
    7979        if (istate_from_uspace(istate))
    8080                printf("ss =%0#10" PRIx32 "\n", istate->ss);
    81        
     81
    8282        printf("eax=%0#10" PRIx32 "\tebx=%0#10" PRIx32 "\t"
    8383            "ecx=%0#10" PRIx32 "\tedx=%0#10" PRIx32 "\n",
    8484            istate->eax, istate->ebx, istate->ecx, istate->edx);
    85        
     85
    8686        printf("esi=%0#10" PRIx32 "\tedi=%0#10" PRIx32 "\t"
    8787            "ebp=%0#10" PRIx32 "\tesp=%0#10" PRIxn "\n",
     
    119119                size_t ver = TASK->arch.iomapver;
    120120                irq_spinlock_unlock(&TASK->lock, false);
    121                
     121
    122122                if (CPU->arch.iomapver_copy != ver) {
    123123                        /*
     
    149149                : [mxcsr] "=m" (mxcsr)
    150150        );
    151        
     151
    152152        fault_if_from_uspace(istate, "SIMD FP exception(19), MXCSR=%#0" PRIx32 ".",
    153153            mxcsr);
     
    185185{
    186186        assert(n >= IVT_IRQBASE);
    187        
     187
    188188        unsigned int inum = n - IVT_IRQBASE;
    189189        bool ack = false;
    190190        assert(inum < IRQ_COUNT);
    191191        assert((inum != IRQ_PIC_SPUR) && (inum != IRQ_PIC1));
    192        
     192
    193193        irq_t *irq = irq_dispatch_and_lock(inum);
    194194        if (irq) {
     
    196196                 * The IRQ handler was found.
    197197                 */
    198                
     198
    199199                if (irq->preack) {
    200200                        /* Send EOI before processing the interrupt */
     
    212212#endif
    213213        }
    214        
     214
    215215        if (!ack)
    216216                trap_virtual_eoi();
     
    220220{
    221221        unsigned int i;
    222        
     222
    223223        for (i = 0; i < IVT_ITEMS; i++)
    224224                exc_register(i, "null", false, (iroutine_t) null_interrupt);
    225        
     225
    226226        for (i = 0; i < IRQ_COUNT; i++) {
    227227                if ((i != IRQ_PIC_SPUR) && (i != IRQ_PIC1))
     
    229229                            (iroutine_t) irq_interrupt);
    230230        }
    231        
     231
    232232        exc_register(VECTOR_DE, "de_fault", true, (iroutine_t) de_fault);
    233233        exc_register(VECTOR_NM, "nm_fault", true, (iroutine_t) nm_fault);
     
    235235        exc_register(VECTOR_GP, "gp_fault", true, (iroutine_t) gp_fault);
    236236        exc_register(VECTOR_XM, "simd_fp", true, (iroutine_t) simd_fp_exception);
    237        
     237
    238238#ifdef CONFIG_SMP
    239239        exc_register(VECTOR_TLB_SHOOTDOWN_IPI, "tlb_shootdown", true,
  • kernel/arch/ia32/src/mm/frame.c

    r3061bc1 ra35b458  
    5454{
    5555        unsigned int i;
    56        
     56
    5757        for (i = 0; i < e820counter; i++) {
    5858                uint64_t base64 = e820table[i].base_address;
    5959                uint64_t size64 = e820table[i].size;
    60                
     60
    6161#ifdef KARCH_ia32
    6262                /*
     
    6565                if (base64 >= PHYSMEM_LIMIT32)
    6666                        continue;
    67                
     67
    6868                if (base64 + size64 > PHYSMEM_LIMIT32)
    6969                        size64 = PHYSMEM_LIMIT32 - base64;
    7070#endif
    71                
     71
    7272                uintptr_t base = (uintptr_t) base64;
    7373                size_t size = (size_t) size64;
    74                
     74
    7575                if (!frame_adjust_zone_bounds(low, &base, &size))
    7676                        continue;
    77                
     77
    7878                if (e820table[i].type == MEMMAP_MEMORY_AVAILABLE) {
    7979                        /* To be safe, make the available zone possibly smaller */
     
    8181                        uint64_t new_size = ALIGN_DOWN(size - (new_base - base),
    8282                            FRAME_SIZE);
    83                        
     83
    8484                        size_t count = SIZE2FRAMES(new_size);
    8585                        pfn_t pfn = ADDR2PFN(new_base);
    8686                        pfn_t conf;
    87                        
     87
    8888                        if (low) {
    8989                                if ((minconf < pfn) || (minconf >= pfn + count))
     
    105105                        uint64_t new_size = ALIGN_UP(size + (base - new_base),
    106106                            FRAME_SIZE);
    107                        
     107
    108108                        zone_create(ADDR2PFN(new_base), SIZE2FRAMES(new_size), 0,
    109109                            ZONE_FIRMWARE);
     
    113113                        uint64_t new_size = ALIGN_UP(size + (base - new_base),
    114114                            FRAME_SIZE);
    115                        
     115
    116116                        zone_create(ADDR2PFN(new_base), SIZE2FRAMES(new_size), 0,
    117117                            ZONE_RESERVED);
     
    133133        unsigned int i;
    134134        printf("[base            ] [size            ] [name   ]\n");
    135        
     135
    136136        for (i = 0; i < e820counter; i++) {
    137137                const char *name;
    138                
     138
    139139                if (e820table[i].type <= MEMMAP_MEMORY_UNUSABLE)
    140140                        name = e820names[e820table[i].type];
    141141                else
    142142                        name = "invalid";
    143                
     143
    144144                printf("%#018" PRIx64 " %#018" PRIx64" %s\n", e820table[i].base_address,
    145145                    e820table[i].size, name);
     
    150150{
    151151        pfn_t minconf;
    152        
     152
    153153        if (config.cpu_active == 1) {
    154154                minconf = 1;
    155                
     155
    156156#ifdef CONFIG_SMP
    157157                minconf = max(minconf,
     
    159159                    hardcoded_unmapped_kdata_size));
    160160#endif
    161                
     161
    162162                init_e820_memory(minconf, true);
    163                
     163
    164164                /* Reserve frame 0 (BIOS data) */
    165165                frame_mark_unavailable(0, 1);
    166                
     166
    167167#ifdef CONFIG_SMP
    168168                /* Reserve AP real mode bootstrap memory */
  • kernel/arch/ia32/src/mm/page.c

    r3061bc1 ra35b458  
    5454        uintptr_t cur;
    5555        int flags;
    56        
     56
    5757        if (config.cpu_active > 1) {
    5858                /* Fast path for non-boot CPUs */
     
    6363
    6464        page_mapping_operations = &pt_mapping_operations;
    65        
     65
    6666        /*
    6767         * PA2KA(identity) mapping for all low-memory frames.
     
    7474        }
    7575        page_table_unlock(AS_KERNEL, true);
    76                
     76
    7777        exc_register(VECTOR_PF, "page_fault", true, (iroutine_t) page_fault);
    7878        write_cr3((uintptr_t) AS_KERNEL->genarch.page_table);
    79        
     79
    8080        paging_on();
    8181}
     
    8585        uintptr_t badvaddr;
    8686        pf_access_t access;
    87        
     87
    8888        badvaddr = read_cr2();
    89                
     89
    9090        if (istate->error_word & PFERR_CODE_RSVD)
    9191                panic("Reserved bit set in page directory.");
    92        
     92
    9393        if (istate->error_word & PFERR_CODE_RW)
    9494                access = PF_ACCESS_WRITE;
    9595        else
    9696                access = PF_ACCESS_READ;
    97        
     97
    9898        (void) as_page_fault(badvaddr, access, istate);
    9999}
  • kernel/arch/ia32/src/pm.c

    r3061bc1 ra35b458  
    269269        gdtr_load(&gdtr);
    270270        idtr_load(&idtr);
    271        
     271
    272272        /*
    273273         * Each CPU has its private GDT and TSS.
     
    289289
    290290        tss_initialize(tss_p);
    291        
     291
    292292        gdt_p[TSS_DES].access = AR_PRESENT | AR_TSS | DPL_KERNEL;
    293293        gdt_p[TSS_DES].special = 1;
    294294        gdt_p[TSS_DES].granularity = 0;
    295        
     295
    296296        gdt_setbase(&gdt_p[TSS_DES], (uintptr_t) tss_p);
    297297        gdt_setlimit(&gdt_p[TSS_DES], TSS_BASIC_SIZE - 1);
     
    302302         */
    303303        tr_load(GDT_SELECTOR(TSS_DES));
    304        
     304
    305305        /* Disable I/O on nonprivileged levels and clear NT flag. */
    306306        write_eflags(read_eflags() & ~(EFLAGS_IOPL | EFLAGS_NT));
  • kernel/arch/ia32/src/proc/scheduler.c

    r3061bc1 ra35b458  
    5959{
    6060        uintptr_t kstk = (uintptr_t) &THREAD->kstack[STACK_SIZE];
    61        
     61
    6262#ifndef PROCESSOR_i486
    6363        if (CPU->arch.fi.bits.sep) {
     
    6666        }
    6767#endif
    68        
     68
    6969        /* Set kernel stack for CPL3 -> CPL0 switch via interrupt */
    7070        CPU->arch.tss->esp0 = kstk;
  • kernel/arch/ia32/src/smp/ap.S

    r3061bc1 ra35b458  
    6262        /* initialize Global Descriptor Table register */
    6363        lgdtl ap_gdtr
    64        
     64
    6565        /* switch to protected mode */
    6666        movl %cr0, %eax
     
    6868        movl %eax, %cr0
    6969        jmpl $KTEXT, $jump_to_kernel - BOOT_OFFSET + AP_BOOT_OFFSET
    70        
     70
    7171jump_to_kernel:
    7272.code32
     
    8484         */
    8585        call map_kernel_pse
    86        
     86
    8787        addl $PA2KA(0), %esp            /* PA2KA(ctx.sp) */
    88        
     88
    8989        /* create the first stack frame */
    9090        pushl $0
  • kernel/arch/ia32/src/smp/apic.c

    r3061bc1 ra35b458  
    164164{
    165165        l_apic_id_t idreg;
    166        
     166
    167167        idreg.value = l_apic[L_APIC_ID];
    168168        return idreg.apic_id;
     
    174174        exc_register(VECTOR_APIC_SPUR, "apic_spurious", false,
    175175            (iroutine_t) apic_spurious);
    176        
     176
    177177        enable_irqs_function = io_apic_enable_irqs;
    178178        disable_irqs_function = io_apic_disable_irqs;
    179179        eoi_function = l_apic_eoi;
    180180        irqs_info = "apic";
    181        
     181
    182182        /*
    183183         * Configure interrupt routing.
     
    186186         */
    187187        io_apic_disable_irqs(0xffffU);
    188        
     188
    189189        irq_initialize(&l_apic_timer_irq);
    190190        l_apic_timer_irq.preack = true;
     
    193193        l_apic_timer_irq.handler = l_apic_timer_irq_handler;
    194194        irq_register(&l_apic_timer_irq);
    195        
     195
    196196        uint8_t i;
    197197        for (i = 0; i < IRQ_COUNT; i++) {
    198198                int pin;
    199                
     199
    200200                if ((pin = smp_irq_to_pin(i)) != -1)
    201201                        io_apic_change_ioredtbl((uint8_t) pin, DEST_ALL, (uint8_t) (IVT_IRQBASE + i), LOPRI);
    202202        }
    203        
     203
    204204        /*
    205205         * Ensure that io_apic has unique ID.
    206206         */
    207207        io_apic_id_t idreg;
    208        
     208
    209209        idreg.value = io_apic_read(IOAPICID);
    210210        if ((1 << idreg.apic_id) & apic_id_mask) {  /* See if IO APIC ID is used already */
     
    217217                }
    218218        }
    219        
     219
    220220        /*
    221221         * Configure the BSP's lapic.
     
    223223        l_apic_init();
    224224        l_apic_debug();
    225        
     225
    226226        bsp_l_apic = l_apic_id();
    227227}
     
    237237{
    238238        esr_t esr;
    239        
     239
    240240        esr.value = l_apic[ESR];
    241        
     241
    242242        if (esr.err_bitmap) {
    243243                log_begin(LF_ARCH, LVL_ERROR);
     
    259259                log_end();
    260260        }
    261        
     261
    262262        return !esr.err_bitmap;
    263263}
     
    267267{
    268268        icr_t icr;
    269        
     269
    270270        do {
    271271                icr.lo = l_apic[ICRlo];
     
    286286        /* Wait for a destination cpu to accept our previous ipi. */
    287287        l_apic_wait_for_delivery();
    288        
     288
    289289        icr.lo = l_apic[ICRlo];
    290290        icr.hi = l_apic[ICRhi];
    291        
     291
    292292        icr.delmod = DELMOD_FIXED;
    293293        icr.destmod = DESTMOD_PHYS;
     
    301301        l_apic[ICRhi] = icr.hi;
    302302        l_apic[ICRlo] = icr.lo;
    303        
     303
    304304        return apic_poll_errors();
    305305}
     
    318318        /* Wait for a destination cpu to accept our previous ipi. */
    319319        l_apic_wait_for_delivery();
    320        
     320
    321321        icr.lo = l_apic[ICRlo];
    322322        icr.delmod = DELMOD_FIXED;
     
    326326        icr.trigger_mode = TRIGMOD_LEVEL;
    327327        icr.vector = vector;
    328        
     328
    329329        l_apic[ICRlo] = icr.lo;
    330        
     330
    331331        return apic_poll_errors();
    332332}
     
    345345         */
    346346        icr_t icr;
    347        
     347
    348348        icr.lo = l_apic[ICRlo];
    349349        icr.hi = l_apic[ICRhi];
    350        
     350
    351351        icr.delmod = DELMOD_INIT;
    352352        icr.destmod = DESTMOD_PHYS;
     
    356356        icr.vector = 0;
    357357        icr.dest = apicid;
    358        
     358
    359359        l_apic[ICRhi] = icr.hi;
    360360        l_apic[ICRlo] = icr.lo;
    361        
     361
    362362        /*
    363363         * According to MP Specification, 20us should be enough to
     
    365365         */
    366366        delay(20);
    367        
     367
    368368        if (!apic_poll_errors())
    369369                return 0;
    370        
     370
    371371        l_apic_wait_for_delivery();
    372372
     
    379379        icr.vector = 0;
    380380        l_apic[ICRlo] = icr.lo;
    381        
     381
    382382        /*
    383383         * Wait 10ms as MP Specification specifies.
    384384         */
    385385        delay(10000);
    386        
     386
    387387        if (!is_82489DX_apic(l_apic[LAVR])) {
    388388                /*
     
    402402                }
    403403        }
    404        
     404
    405405        return apic_poll_errors();
    406406}
     
    411411        /* Initialize LVT Error register. */
    412412        lvt_error_t error;
    413        
     413
    414414        error.value = l_apic[LVT_Err];
    415415        error.masked = true;
    416416        l_apic[LVT_Err] = error.value;
    417        
     417
    418418        /* Initialize LVT LINT0 register. */
    419419        lvt_lint_t lint;
    420        
     420
    421421        lint.value = l_apic[LVT_LINT0];
    422422        lint.masked = true;
    423423        l_apic[LVT_LINT0] = lint.value;
    424        
     424
    425425        /* Initialize LVT LINT1 register. */
    426426        lint.value = l_apic[LVT_LINT1];
    427427        lint.masked = true;
    428428        l_apic[LVT_LINT1] = lint.value;
    429        
     429
    430430        /* Task Priority Register initialization. */
    431431        tpr_t tpr;
    432        
     432
    433433        tpr.value = l_apic[TPR];
    434434        tpr.pri_sc = 0;
    435435        tpr.pri = 0;
    436436        l_apic[TPR] = tpr.value;
    437        
     437
    438438        /* Spurious-Interrupt Vector Register initialization. */
    439439        svr_t svr;
    440        
     440
    441441        svr.value = l_apic[SVR];
    442442        svr.vector = VECTOR_APIC_SPUR;
     
    444444        svr.focus_checking = true;
    445445        l_apic[SVR] = svr.value;
    446        
     446
    447447        if (CPU->arch.family >= 6)
    448448                enable_l_apic_in_msr();
    449        
     449
    450450        /* Interrupt Command Register initialization. */
    451451        icr_t icr;
    452        
     452
    453453        icr.lo = l_apic[ICRlo];
    454454        icr.delmod = DELMOD_INIT;
     
    458458        icr.trigger_mode = TRIGMOD_LEVEL;
    459459        l_apic[ICRlo] = icr.lo;
    460        
     460
    461461        /* Timer Divide Configuration Register initialization. */
    462462        tdcr_t tdcr;
    463        
     463
    464464        tdcr.value = l_apic[TDCR];
    465465        tdcr.div_value = DIVIDE_1;
    466466        l_apic[TDCR] = tdcr.value;
    467        
     467
    468468        /* Program local timer. */
    469469        lvt_tm_t tm;
    470        
     470
    471471        tm.value = l_apic[LVT_Tm];
    472472        tm.vector = VECTOR_CLK;
     
    474474        tm.masked = false;
    475475        l_apic[LVT_Tm] = tm.value;
    476        
     476
    477477        /*
    478478         * Measure and configure the timer to generate timer
     
    481481        uint32_t t1 = l_apic[CCRT];
    482482        l_apic[ICRT] = 0xffffffff;
    483        
     483
    484484        while (l_apic[CCRT] == t1);
    485        
     485
    486486        t1 = l_apic[CCRT];
    487487        delay(1000000 / HZ);
    488488        uint32_t t2 = l_apic[CCRT];
    489        
     489
    490490        l_apic[ICRT] = t1 - t2;
    491        
     491
    492492        /* Program Logical Destination Register. */
    493493        assert(CPU->id < 8);
    494494        ldr_t ldr;
    495        
     495
    496496        ldr.value = l_apic[LDR];
    497497        ldr.id = (uint8_t) (1 << CPU->id);
    498498        l_apic[LDR] = ldr.value;
    499        
     499
    500500        /* Program Destination Format Register for Flat mode. */
    501501        dfr_t dfr;
    502        
     502
    503503        dfr.value = l_apic[DFR];
    504504        dfr.model = MODEL_FLAT;
     
    519519        log_printf("LVT on cpu%u, LAPIC ID: %" PRIu8 "\n",
    520520            CPU->id, l_apic_id());
    521        
     521
    522522        lvt_tm_t tm;
    523523        tm.value = l_apic[LVT_Tm];
     
    525525            tm.vector, delivs_str[tm.delivs], mask_str[tm.masked],
    526526            tm_mode_str[tm.mode]);
    527        
     527
    528528        lvt_lint_t lint;
    529529        lint.value = l_apic[LVT_LINT0];
     
    532532            intpol_str[lint.intpol], lint.irr, trigmod_str[lint.trigger_mode],
    533533            mask_str[lint.masked]);
    534        
     534
    535535        lint.value = l_apic[LVT_LINT1];
    536536        log_printf("LVT LINT1: vector=%" PRIu8 ", %s, %s, %s, irr=%u, %s, %s\n",
     
    538538            intpol_str[lint.intpol], lint.irr, trigmod_str[lint.trigger_mode],
    539539            mask_str[lint.masked]);
    540        
     540
    541541        lvt_error_t error;
    542542        error.value = l_apic[LVT_Err];
     
    557557{
    558558        io_regsel_t regsel;
    559        
     559
    560560        regsel.value = io_apic[IOREGSEL];
    561561        regsel.reg_addr = address;
     
    573573{
    574574        io_regsel_t regsel;
    575        
     575
    576576        regsel.value = io_apic[IOREGSEL];
    577577        regsel.reg_addr = address;
     
    592592{
    593593        unsigned int dlvr;
    594        
     594
    595595        if (flags & LOPRI)
    596596                dlvr = DELMOD_LOWPRI;
    597597        else
    598598                dlvr = DELMOD_FIXED;
    599        
     599
    600600        io_redirection_reg_t reg;
    601601        reg.lo = io_apic_read((uint8_t) (IOREDTBL + pin * 2));
    602602        reg.hi = io_apic_read((uint8_t) (IOREDTBL + pin * 2 + 1));
    603        
     603
    604604        reg.dest = dest;
    605605        reg.destmod = DESTMOD_LOGIC;
     
    608608        reg.delmod = dlvr;
    609609        reg.intvec = vec;
    610        
     610
    611611        io_apic_write((uint8_t) (IOREDTBL + pin * 2), reg.lo);
    612612        io_apic_write((uint8_t) (IOREDTBL + pin * 2 + 1), reg.hi);
     
    630630                        if (pin != -1) {
    631631                                io_redirection_reg_t reg;
    632                                
     632
    633633                                reg.lo = io_apic_read((uint8_t) (IOREDTBL + pin * 2));
    634634                                reg.masked = true;
    635635                                io_apic_write((uint8_t) (IOREDTBL + pin * 2), reg.lo);
    636636                        }
    637                        
     637
    638638                }
    639639        }
     
    657657                        if (pin != -1) {
    658658                                io_redirection_reg_t reg;
    659                                
     659
    660660                                reg.lo = io_apic_read((uint8_t) (IOREDTBL + pin * 2));
    661661                                reg.masked = false;
    662662                                io_apic_write((uint8_t) (IOREDTBL + pin * 2), reg.lo);
    663663                        }
    664                        
     664
    665665                }
    666666        }
  • kernel/arch/ia32/src/smp/mps.c

    r3061bc1 ra35b458  
    7575{
    7676        assert(i < processor_entry_cnt);
    77        
     77
    7878        return processor_entries[i].l_apic_id;
    7979}
     
    8282{
    8383        assert(i < processor_entry_cnt);
    84        
     84
    8585        /*
    8686         * FIXME: The current local APIC driver limits usable
     
    9090        if (i > 7)
    9191                return false;
    92        
     92
    9393        return ((processor_entries[i].cpu_flags & 0x01) == 0x01);
    9494}
     
    9797{
    9898        assert(i < processor_entry_cnt);
    99        
     99
    100100        return ((processor_entries[i].cpu_flags & 0x02) == 0x02);
    101101}
     
    104104{
    105105        size_t i;
    106        
     106
    107107        for (i = 0; i < io_intr_entry_cnt; i++) {
    108108                if (io_intr_entries[i].src_bus_irq == irq &&
     
    110110                        return io_intr_entries[i].dst_io_apic_pin;
    111111        }
    112        
     112
    113113        return -1;
    114114}
     
    131131        unsigned int i;
    132132        uint8_t sum;
    133        
     133
    134134        for (i = 0, sum = 0; i < 16; i++)
    135135                sum = (uint8_t) (sum + base[i]);
    136        
     136
    137137        return (sum == 0);
    138138}
     
    147147        uint8_t sum;
    148148        uint16_t i;
    149        
     149
    150150        /* Compute the checksum for the base table */
    151151        for (i = 0, sum = 0; i < ct->base_table_length; i++)
    152152                sum = (uint8_t) (sum + base[i]);
    153        
     153
    154154        if (sum)
    155155                return false;
    156        
     156
    157157        /* Compute the checksum for the extended table */
    158158        for (i = 0, sum = 0; i < ct->ext_table_length; i++)
    159159                sum = (uint8_t) (sum + ext[i]);
    160        
     160
    161161        return (sum == ct->ext_table_checksum);
    162162}
     
    169169        if ((pr->cpu_flags & (1 << 0)) == 0)
    170170                return;
    171        
     171
    172172        apic_id_mask |= (1 << pr->l_apic_id);
    173173}
     
    177177#ifdef MPSCT_VERBOSE
    178178        char buf[7];
    179        
     179
    180180        memcpy((void *) buf, (void *) bus->bus_type, 6);
    181181        buf[6] = 0;
    182        
     182
    183183        log(LF_ARCH, LVL_DEBUG, "MPS: bus=%" PRIu8 " (%s)", bus->bus_id, buf);
    184184#endif
     
    190190        if ((ioa->io_apic_flags & 1) == 0)
    191191                return;
    192        
     192
    193193        if (io_apic_cnt++ > 0) {
    194194                /*
     
    197197                return;
    198198        }
    199        
     199
    200200        io_apic = (uint32_t *) (uintptr_t) ioa->io_apic;
    201201}
     
    207207        log_begin(LF_ARCH, LVL_DEBUG);
    208208        log_printf("MPS: ");
    209        
     209
    210210        switch (iointr->intr_type) {
    211211        case 0:
     
    222222                break;
    223223        }
    224        
     224
    225225        log_printf(", ");
    226        
     226
    227227        switch (iointr->poel & 3) {
    228228        case 0:
     
    239239                break;
    240240        }
    241        
     241
    242242        log_printf(", ");
    243        
     243
    244244        switch ((iointr->poel >> 2) & 3) {
    245245        case 0:
     
    256256                break;
    257257        }
    258        
     258
    259259        log_printf(", bus=%" PRIu8 " irq=%" PRIu8 " io_apic=%" PRIu8" pin=%"
    260260            PRIu8, iointr->src_bus_id, iointr->src_bus_irq,
     
    270270        log_begin(LF_ARCH, LVL_DEBUG);
    271271        log_printf("MPS: ");
    272        
     272
    273273        switch (lintr->intr_type) {
    274274        case 0:
     
    285285                break;
    286286        }
    287        
     287
    288288        log_printf(", ");
    289        
     289
    290290        switch (lintr->poel & 3) {
    291291        case 0:
     
    302302                break;
    303303        }
    304        
     304
    305305        log_printf(", ");
    306        
     306
    307307        switch ((lintr->poel >> 2) & 3) {
    308308        case 0:
     
    319319                break;
    320320        }
    321        
     321
    322322        log_printf(", bus=%" PRIu8 " irq=%" PRIu8 " l_apic=%" PRIu8" pin=%"
    323323            PRIu8, lintr->src_bus_id, lintr->src_bus_irq,
     
    331331        uint8_t *ext = (uint8_t *) ct + ct->base_table_length;
    332332        uint8_t *cur;
    333        
     333
    334334        for (cur = ext; cur < ext + ct->ext_table_length;
    335335            cur += cur[CT_EXT_ENTRY_LEN]) {
     
    349349                return;
    350350        }
    351        
     351
    352352        if (!mps_ct_check()) {
    353353                log(LF_ARCH, LVL_WARN, "MPS: Wrong ct checksum");
    354354                return;
    355355        }
    356        
     356
    357357        if (ct->oem_table) {
    358358                log(LF_ARCH, LVL_WARN, "MPS: ct->oem_table not supported");
    359359                return;
    360360        }
    361        
     361
    362362        l_apic = (uint32_t *) (uintptr_t) ct->l_apic;
    363        
     363
    364364        uint8_t *cur = &ct->base_table[0];
    365365        uint16_t i;
    366        
     366
    367367        for (i = 0; i < ct->entry_count; i++) {
    368368                switch (*cur) {
     
    411411                }
    412412        }
    413        
     413
    414414        /*
    415415         * Process extended entries.
     
    432432        unsigned int j;
    433433        unsigned int length[2] = { 1024, 64 * 1024 };
    434        
     434
    435435        /*
    436436         * Find MP Floating Pointer Structure
     
    439439         *  2.  search 64K starting at 0xf0000
    440440         */
    441        
     441
    442442        addr[0] = (uint8_t *) PA2KA(ebda ? ebda : 639 * 1024);
    443443        for (i = 0; i < 2; i++) {
     
    450450                }
    451451        }
    452        
     452
    453453        return;
    454        
     454
    455455fs_found:
    456456        log(LF_ARCH, LVL_NOTE, "%p: MPS Floating Pointer Structure", fs);
    457        
     457
    458458        if ((fs->config_type == 0) && (fs->configuration_table)) {
    459459                if (fs->mpfib2 >> 7) {
     
    461461                        return;
    462462                }
    463                
     463
    464464                ct = (struct mps_ct *) PA2KA((uintptr_t) fs->configuration_table);
    465465                configure_via_ct();
    466466        } else
    467467                configure_via_default(fs->config_type);
    468        
     468
    469469        if (processor_entry_cnt > 0)
    470470                config.cpu_count = processor_entry_cnt;
  • kernel/arch/ia32/src/smp/smp.c

    r3061bc1 ra35b458  
    6868                ops = &madt_config_operations;
    6969        }
    70        
     70
    7171        if (config.cpu_count == 1) {
    7272                mps_init();
    7373                ops = &mps_config_operations;
    7474        }
    75        
     75
    7676        if (config.cpu_count > 1) {
    7777                l_apic = (uint32_t *) km_map((uintptr_t) l_apic, PAGE_SIZE,
     
    8686        assert(ops != NULL);
    8787        assert(cpus != NULL);
    88        
     88
    8989        for (unsigned int i = 0; i < config.cpu_count; ++i) {
    9090                cpus[i].arch.id = ops->cpu_apic_id(i);
     
    102102{
    103103        unsigned int i;
    104        
     104
    105105        assert(ops != NULL);
    106106
     
    110110         */
    111111        cpu_arch_id_init();
    112        
     112
    113113        /*
    114114         * We need to access data in frame 0.
    115115         * We boldly make use of kernel address space mapping.
    116116         */
    117        
     117
    118118        /*
    119119         * Set the warm-reset vector to the real-mode address of 4K-aligned ap_boot()
     
    122122            (uint16_t) (((uintptr_t) ap_boot) >> 4);  /* segment */
    123123        *((uint16_t *) (PA2KA(0x467 + 2))) = 0;       /* offset */
    124        
     124
    125125        /*
    126126         * Save 0xa to address 0xf of the CMOS RAM.
     
    129129        pio_write_8((ioport8_t *) 0x70, 0xf);
    130130        pio_write_8((ioport8_t *) 0x71, 0xa);
    131        
     131
    132132        pic_disable_irqs(0xffff);
    133133        apic_init();
    134        
     134
    135135        for (i = 0; i < config.cpu_count; i++) {
    136136                /*
     
    139139                if (!ops->cpu_enabled(i))
    140140                        continue;
    141                
     141
    142142                /*
    143143                 * The bootstrap processor is already up.
     
    145145                if (ops->cpu_bootstrap(i))
    146146                        continue;
    147                
     147
    148148                if (ops->cpu_apic_id(i) == bsp_l_apic) {
    149149                        log(LF_ARCH, LVL_ERROR, "kmp: bad processor entry #%u, "
     
    151151                        continue;
    152152                }
    153                
     153
    154154                /*
    155155                 * Prepare new GDT for CPU in question.
    156156                 */
    157                
     157
    158158                /* XXX Flag FRAME_LOW_4_GiB was removed temporarily,
    159159                 * it needs to be replaced by a generic fuctionality of
     
    165165                if (!gdt_new)
    166166                        panic("Cannot allocate memory for GDT.");
    167                
     167
    168168                memcpy(gdt_new, gdt, GDT_ITEMS * sizeof(descriptor_t));
    169169                memsetb(&gdt_new[TSS_DES], sizeof(descriptor_t), 0);
     
    171171                protected_ap_gdtr.base = KA2PA((uintptr_t) gdt_new);
    172172                gdtr.base = (uintptr_t) gdt_new;
    173                
     173
    174174                if (l_apic_send_init_ipi(ops->cpu_apic_id(i))) {
    175175                        /*
  • kernel/arch/ia32/src/userspace.c

    r3061bc1 ra35b458  
    5050{
    5151        uint32_t eflags = read_eflags();
    52        
     52
    5353        asm volatile (
    5454                /* Set up GS register (virtual register segment) */
    5555                "movl %[vreg_des], %%gs\n"
    56                
     56
    5757                "pushl %[udata_des]\n"
    5858                "pushl %[stack_top]\n"
     
    6161                "pushl %[entry]\n"
    6262                "movl %[uarg], %%eax\n"
    63                
     63
    6464                /* %edi is defined to hold pcb_ptr - set it to 0 */
    6565                "xorl %%edi, %%edi\n"
    66                
     66
    6767                "iret\n"
    6868                :
     
    7777                  [vreg_des] "r" (GDT_SELECTOR(VREG_DES))
    7878                : "eax");
    79        
     79
    8080        /* Unreachable */
    8181        while (1);
Note: See TracChangeset for help on using the changeset viewer.