Changeset cefb126 in mainline for kernel/arch/ia32/src/smp/smp.c


Ignore:
Timestamp:
2010-07-02T14:19:30Z (14 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
89c57b6
Parents:
fe7abd0 (diff), e3ee9b9 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge mainline changes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/ia32/src/smp/smp.c

    rfe7abd0 rcefb126  
    6262void smp_init(void)
    6363{
    64         uintptr_t l_apic_address, io_apic_address;
    65 
    6664        if (acpi_madt) {
    6765                acpi_madt_parse();
    6866                ops = &madt_config_operations;
    6967        }
     68       
    7069        if (config.cpu_count == 1) {
    7170                mps_init();
    7271                ops = &mps_config_operations;
    7372        }
    74 
    75         l_apic_address = (uintptr_t) frame_alloc(ONE_FRAME,
    76             FRAME_ATOMIC | FRAME_KA);
    77         if (!l_apic_address)
    78                 panic("Cannot allocate address for l_apic.");
    79 
    80         io_apic_address = (uintptr_t) frame_alloc(ONE_FRAME,
    81             FRAME_ATOMIC | FRAME_KA);
    82         if (!io_apic_address)
    83                 panic("Cannot allocate address for io_apic.");
    84 
     73       
    8574        if (config.cpu_count > 1) {
    86                 page_table_lock(AS_KERNEL, true);
    87                 page_mapping_insert(AS_KERNEL, l_apic_address,
    88                     (uintptr_t) l_apic, PAGE_NOT_CACHEABLE | PAGE_WRITE);
    89                 page_mapping_insert(AS_KERNEL, io_apic_address,
    90                     (uintptr_t) io_apic, PAGE_NOT_CACHEABLE | PAGE_WRITE);
    91                 page_table_unlock(AS_KERNEL, true);
    92                                  
    93                 l_apic = (uint32_t *) l_apic_address;
    94                 io_apic = (uint32_t *) io_apic_address;
     75                l_apic = (uint32_t *) hw_map((uintptr_t) l_apic, PAGE_SIZE);
     76                io_apic = (uint32_t *) hw_map((uintptr_t) io_apic, PAGE_SIZE);
    9577        }
    9678}
     
    10890       
    10991        ASSERT(ops != NULL);
    110 
     92       
    11193        /*
    11294         * We need to access data in frame 0.
    11395         * We boldly make use of kernel address space mapping.
    11496         */
    115 
     97       
    11698        /*
    11799         * Set the warm-reset vector to the real-mode address of 4K-aligned ap_boot()
    118100         */
    119101        *((uint16_t *) (PA2KA(0x467 + 0))) =
    120             (uint16_t) (((uintptr_t) ap_boot) >> 4);    /* segment */
    121         *((uint16_t *) (PA2KA(0x467 + 2))) = 0;         /* offset */
     102            (uint16_t) (((uintptr_t) ap_boot) >> 4);  /* segment */
     103        *((uint16_t *) (PA2KA(0x467 + 2))) = 0;       /* offset */
    122104       
    123105        /*
     
    125107         * BIOS will not do the POST after the INIT signal.
    126108         */
    127         pio_write_8((ioport8_t *)0x70, 0xf);
    128         pio_write_8((ioport8_t *)0x71, 0xa);
    129 
     109        pio_write_8((ioport8_t *) 0x70, 0xf);
     110        pio_write_8((ioport8_t *) 0x71, 0xa);
     111       
    130112        pic_disable_irqs(0xffff);
    131113        apic_init();
    132114       
    133         uint8_t apic = l_apic_id();
    134 
    135         for (i = 0; i < ops->cpu_count(); i++) {
    136                 descriptor_t *gdt_new;
    137                
     115        for (i = 0; i < config.cpu_count; i++) {
    138116                /*
    139117                 * Skip processors marked unusable.
     
    141119                if (!ops->cpu_enabled(i))
    142120                        continue;
    143 
     121               
    144122                /*
    145123                 * The bootstrap processor is already up.
     
    147125                if (ops->cpu_bootstrap(i))
    148126                        continue;
    149 
    150                 if (ops->cpu_apic_id(i) == apic) {
    151                         printf("%s: bad processor entry #%u, will not send IPI "
    152                             "to myself\n", __FUNCTION__, i);
     127               
     128                if (ops->cpu_apic_id(i) == bsp_l_apic) {
     129                        printf("kmp: bad processor entry #%u, will not send IPI "
     130                            "to myself\n", i);
    153131                        continue;
    154132                }
     
    162140                 * the memory subsystem
    163141                 */
    164                 gdt_new = (descriptor_t *) malloc(GDT_ITEMS *
    165                     sizeof(descriptor_t), FRAME_ATOMIC);
     142                descriptor_t *gdt_new =
     143                    (descriptor_t *) malloc(GDT_ITEMS * sizeof(descriptor_t),
     144                    FRAME_ATOMIC);
    166145                if (!gdt_new)
    167146                        panic("Cannot allocate memory for GDT.");
    168 
     147               
    169148                memcpy(gdt_new, gdt, GDT_ITEMS * sizeof(descriptor_t));
    170149                memsetb(&gdt_new[TSS_DES], sizeof(descriptor_t), 0);
     
    172151                protected_ap_gdtr.base = KA2PA((uintptr_t) gdt_new);
    173152                gdtr.base = (uintptr_t) gdt_new;
    174 
     153               
    175154                if (l_apic_send_init_ipi(ops->cpu_apic_id(i))) {
    176155                        /*
     
    181160                        if (waitq_sleep_timeout(&ap_completion_wq, 1000000,
    182161                            SYNCH_FLAGS_NONE) == ESYNCH_TIMEOUT) {
    183                                 unsigned int cpu = (config.cpu_active > i) ?
    184                                     config.cpu_active : i;
    185162                                printf("%s: waiting for cpu%u (APIC ID = %d) "
    186                                     "timed out\n", __FUNCTION__, cpu,
     163                                    "timed out\n", __FUNCTION__, i,
    187164                                    ops->cpu_apic_id(i));
    188165                        }
Note: See TracChangeset for help on using the changeset viewer.