Changeset 162 for trunk


Ignore:
Timestamp:
Jul 7, 2017, 2:39:34 PM (7 years ago)
Author:
max@…
Message:

start making these variables per-cpu

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

Legend:

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

    r154 r162  
    264264
    265265        /* Attach cpu0 */
    266         cpu_attach();
     266        cpu_attach(0);
    267267        x86_printf("[+] cpu_attach called\n");
    268268
     
    315315uint8_t gdtstore[PAGE_SIZE] __in_kdata;
    316316uint8_t idtstore[PAGE_SIZE] __in_kdata;
    317 struct tss cpu0_tss __in_kdata;
    318 uint8_t cpu0_intr_stack[STKSIZE] __in_kdata;
    319 uint8_t cpu0_dbfl_stack[STKSIZE] __in_kdata;
    320 uint8_t cpu0_nmfl_stack[STKSIZE] __in_kdata;
     317struct tss cpu_tss[CONFIG_MAX_LOCAL_CORES] __in_kdata;
     318uint8_t cpu_intr_stack[CONFIG_MAX_LOCAL_CORES][STKSIZE] __in_kdata;
     319uint8_t cpu_dbfl_stack[CONFIG_MAX_LOCAL_CORES][STKSIZE] __in_kdata;
     320uint8_t cpu_nmfl_stack[CONFIG_MAX_LOCAL_CORES][STKSIZE] __in_kdata;
    321321
    322322static void
     
    453453}
    454454
    455 void cpu_create_tss()
    456 {
    457         struct tss *tss = &cpu0_tss;
     455void cpu_create_tss(size_t lid)
     456{
     457        struct tss *tss = &cpu_tss[lid];
    458458        int sel;
    459459
    460460        /* Create the tss */
    461461        memset(tss, 0, sizeof(*tss));
     462
     463        /* tss->tss_rsp0 */
     464        tss->tss_ist[0] = (uint64_t)cpu_intr_stack[lid] + STKSIZE;
     465        tss->tss_ist[1] = (uint64_t)cpu_dbfl_stack[lid] + STKSIZE;
     466        tss->tss_ist[2] = (uint64_t)cpu_nmfl_stack[lid] + STKSIZE;
    462467        tss->tss_iobase = IOMAP_INVALOFF << 16;
    463         tss->tss_ist[0] = (uint64_t)cpu0_intr_stack + STKSIZE;
    464         tss->tss_ist[1] = (uint64_t)cpu0_dbfl_stack + STKSIZE;
    465         tss->tss_ist[2] = (uint64_t)cpu0_nmfl_stack + STKSIZE;
    466468        sel = tss_alloc(tss);
    467469
     
    472474/* -------------------------------------------------------------------------- */
    473475
    474 void cpu_attach()
     476void cpu_attach(size_t lid)
    475477{
    476478        cpu_load_gdt();
    477479        cpu_load_idt();
    478         cpu_create_tss();
    479 }
    480 
     480        cpu_create_tss(lid);
     481}
     482
  • trunk/hal/x86_64/core/hal_segmentation.h

    r152 r162  
    133133struct tss {
    134134        uint32_t tss_reserved1;
    135         uint64_t tss_rsp0;
    136         uint64_t tss_rsp1;
    137         uint64_t tss_rsp3;
     135        uint64_t tss_rsp0;      /* kernel stack pointer ring 0 */
     136        uint64_t tss_rsp1;      /* kernel stack pointer ring 1 */
     137        uint64_t tss_rsp2;      /* kernel stack pointer ring 2 */
    138138        uint32_t tss_reserved2;
    139139        uint32_t tss_reserved3;
    140         uint64_t tss_ist[7];
     140        uint64_t tss_ist[7];    /* Interrupt stack table */
    141141        uint32_t tss_reserved4;
    142142        uint32_t tss_reserved5;
Note: See TracChangeset for help on using the changeset viewer.