Ignore:
Timestamp:
Jul 20, 2017, 9:55:05 AM (7 years ago)
Author:
max@…
Message:

Make the secondary CPUs jump into kernel_init().

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/hal/x86_64/core/hal_init.c

    r237 r240  
    5858uint8_t mb_mmap[PAGE_SIZE] __in_kdata;
    5959
     60size_t ncpu __in_kdata = 0;
     61static boot_info_t btinfo __in_kdata;
     62
    6063/* x86-specific per-cluster structures */
    6164uint8_t gdtstore[PAGE_SIZE] __in_kdata;
     
    160163static void init_bootinfo_core(boot_core_t *core)
    161164{
    162         memset(core, 0, sizeof(boot_core_t));
    163 
    164         core->gid = hal_lapic_gid();
    165         core->lid = 0;
    166         core->cxy = 0;
     165        size_t i;
     166
     167        // XXX: not necessarily contiguous
     168        for (i = 0; i < ncpu; i++) {
     169                memset(&core[i], 0, sizeof(boot_core_t));
     170
     171                core[i].gid = i;
     172                core[i].lid = i;
     173                core[i].cxy = 0;
     174        }
    167175}
    168176
     
    240248
    241249        info->cxy = 0;
    242         info->cores_nr = 1;
    243         init_bootinfo_core(&info->core[0]);
     250        info->cores_nr = ncpu;
     251        init_bootinfo_core((boot_core_t *)&info->core);
    244252
    245253        info->rsvd_nr = init_bootinfo_rsvd((boot_rsvd_t *)&info->rsvd);
     
    303311void init_x86_64_cpuN()
    304312{
    305         lid_t lid = hal_lapic_gid();
     313        lid_t lid;
     314
     315        cli();
     316
     317        lid = hal_lapic_gid();
    306318
    307319        cpu_attach(lid);
     
    322334        }
    323335
    324         sti();
     336        kernel_init(&btinfo);
     337
     338        reg_t dummy;
     339        hal_enable_irq(&dummy);
     340
    325341        while (1);
    326342}
     
    342358void init_x86_64(paddr_t firstpa)
    343359{
    344         boot_info_t btinfo;
     360        cli();
    345361
    346362        /* Initialize the serial port */
     
    396412        start_secondary_cpus();
    397413
     414        kernel_init(&btinfo);
     415
     416        x86_printf("[+] kernel_init called\n");
     417
    398418        reg_t dummy;
    399419        hal_enable_irq(&dummy);
    400 
    401 while (1);
    402 
    403         kernel_init(&btinfo);
    404 
    405         x86_printf("[+] kernel_init called\n");
    406420/*
    407421        void *ptr;
     
    623637        cputls->tls_gid = hal_lapic_gid();
    624638        cputls->tls_lid = lid;
     639        cputls->tls_intr = INTRS_DISABLED;
    625640
    626641        wrmsr(MSR_FSBASE, 0);
Note: See TracChangeset for help on using the changeset viewer.