Changeset 240 for trunk/hal/x86_64


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

Make the secondary CPUs jump into kernel_init().

Location:
trunk/hal/x86_64/core
Files:
4 edited

Legend:

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

    r235 r240  
    116116        subheader_t *sub;
    117117        size_t nioapic = 0;
    118         size_t ncpu = 0;
     118        extern size_t ncpu;
    119119
    120120        extern paddr_t lapic_pa;
  • 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);
  • trunk/hal/x86_64/core/hal_irqmask.c

    r234 r240  
    2222#include <hal_types.h>
    2323#include <hal_internal.h>
    24 
    25 #define INTRS_ENABLED   0xFFEFAAAA
    26 #define INTRS_DISABLED  0xD0CCCCC0
    27 
    28 static uint32_t intrs_state __in_kdata = INTRS_DISABLED;
     24#include <hal_segmentation.h>
    2925
    3026inline void hal_disable_irq(uint32_t *old)
    3127{
    32         *old = intrs_state;
    33         intrs_state = INTRS_DISABLED;
     28        tls_t *tls = curcpu();
     29
     30        *old = tls->tls_intr;
     31        tls->tls_intr = INTRS_DISABLED;
     32
    3433        cli();
    3534}
     
    3736inline void hal_enable_irq(uint32_t *old)
    3837{
    39         *old = intrs_state;
    40         intrs_state = INTRS_ENABLED;
     38        tls_t *tls = curcpu();
     39
     40        *old = tls->tls_intr;
     41        tls->tls_intr = INTRS_ENABLED;
     42
    4143        sti();
    4244}
     
    4446inline void hal_restore_irq(uint32_t old)
    4547{
    46         intrs_state = old;
     48        tls_t *tls = curcpu();
    4749
    48         if (intrs_state == INTRS_ENABLED)
     50        tls->tls_intr = old;
     51
     52        if (old == INTRS_ENABLED)
    4953                sti();
    50         else if(intrs_state == INTRS_DISABLED)
     54        else if(old == INTRS_DISABLED)
    5155                cli();
    5256        else
  • trunk/hal/x86_64/core/hal_segmentation.h

    r234 r240  
    154154        uint32_t tls_lid;
    155155        void *tls_thr;
     156        reg_t tls_intr;
    156157} __packed;
    157158typedef struct tls tls_t;
     
    160161void lidt(struct region_descriptor *);
    161162void ltr(uint16_t);
     163tls_t *curcpu();
     164
     165#define INTRS_ENABLED   0xFFEFAAAA
     166#define INTRS_DISABLED  0xD0CCCCC0
    162167
    163168#endif /* !x86_ASM */
Note: See TracChangeset for help on using the changeset viewer.