Ignore:
File:
1 edited

Legend:

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

    rd6f9fff rd242cb6  
    4141#include <panic.h>
    4242#include <arch/mm/page.h>
    43 #include <mm/km.h>
    44 #include <mm/frame.h>
    4543#include <mm/slab.h>
    4644#include <memstr.h>
     
    5351
    5452/*
    55  * We don't have much use for segmentation so we set up flat mode.
    56  * In this mode, we use, for each privilege level, two segments spanning the
     53 * We have no use for segmentation so we set up flat mode. In this
     54 * mode, we use, for each privilege level, two segments spanning the
    5755 * whole memory. One is for code and one is for data.
    5856 *
    59  * One special segment apart of that is for the GS register which holds
    60  * a pointer to the VREG page in its base.
     57 * One is for GS register which holds pointer to the TLS thread
     58 * structure in it's base.
    6159 */
    6260descriptor_t gdt[GDT_ITEMS] = {
     
    7371        /* TSS descriptor - set up will be completed later */
    7472        { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
    75         /* VREG descriptor - segment used for virtual registers, will be reinitialized later */
    76         { 0xffff, 0 , 0, AR_PRESENT | AR_DATA | AR_WRITABLE | DPL_USER, 0xf, 0, 0, 1, 1, 0 },
     73        /* TLS descriptor */
     74        { 0xffff, 0, 0, AR_PRESENT | AR_DATA | AR_WRITABLE | DPL_USER, 0xf, 0, 0, 1, 1, 0 },
    7775        /* VESA Init descriptor */
    7876#ifdef CONFIG_FB
     
    8482static idescriptor_t idt[IDT_ITEMS];
    8583
    86 static tss_t tss0;
     84static tss_t tss;
    8785
    8886tss_t *tss_p = NULL;
     
    9795{
    9896        d->base_0_15 = base & 0xffff;
    99         d->base_16_23 = (base >> 16) & 0xff;
    100         d->base_24_31 = (base >> 24) & 0xff;
     97        d->base_16_23 = ((base) >> 16) & 0xff;
     98        d->base_24_31 = ((base) >> 24) & 0xff;
    10199}
    102100
     
    267265                 * the heap hasn't been initialized so far.
    268266                 */
    269                 tss_p = &tss0;
    270         } else {
     267                tss_p = &tss;
     268        }
     269        else {
    271270                tss_p = (tss_t *) malloc(sizeof(tss_t), FRAME_ATOMIC);
    272271                if (!tss_p)
     
    293292}
    294293
     294void set_tls_desc(uintptr_t tls)
     295{
     296        ptr_16_32_t cpugdtr;
     297        descriptor_t *gdt_p;
     298
     299        gdtr_store(&cpugdtr);
     300        gdt_p = (descriptor_t *) cpugdtr.base;
     301        gdt_setbase(&gdt_p[TLS_DES], tls);
     302        /* Reload gdt register to update GS in CPU */
     303        gdtr_load(&cpugdtr);
     304}
     305
    295306/** @}
    296307 */
Note: See TracChangeset for help on using the changeset viewer.