Changeset a35b458 in mainline for kernel/arch/ia32/src/smp


Ignore:
Timestamp:
2018-03-02T20:10:49Z (8 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/smp
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • 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                        /*
Note: See TracChangeset for help on using the changeset viewer.