Subversion Repositories HelenOS

Rev

Rev 206 | Rev 211 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 206 Rev 208
Line 106... Line 106...
106
     * on AMD64 it is 64-bit - 2 items in table */
106
     * on AMD64 it is 64-bit - 2 items in table */
107
    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
107
    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
108
    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
108
    { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
109
};
109
};
110
 
110
 
111
struct ptr_16_64 gdtr = {.limit = sizeof(gdtr), .base= (__u64) &gdtr };
111
struct ptr_16_64 gdtr = {.limit = sizeof(gdtr), .base= (__u64)KA2PA(&gdt) };
112
 
112
 
113
struct idescriptor idt[IDT_ITEMS];
113
struct idescriptor idt[IDT_ITEMS];
114
 
114
 
115
static struct tss tss;
115
static struct tss tss;
-
 
116
struct tss *tss_p = NULL;
116
 
117
 
117
/* TODO: Does not compile correctly if it does not exist ???? */
118
/* TODO: Does not compile correctly if it does not exist ???? */
118
int __attribute__ ((section ("K_DATA_START"))) __fake;
119
int __attribute__ ((section ("K_DATA_START"))) __fake;
119
 
120
 
120
void gdt_tss_setbase(struct descriptor *d, __address base)
121
void gdt_tss_setbase(struct descriptor *d, __address base)
Line 214... Line 215...
214
}
215
}
215
 
216
 
216
void pm_init(void)
217
void pm_init(void)
217
{
218
{
218
    struct descriptor *gdt_p = (struct descriptor *) PA2KA(gdtr.base);
219
    struct descriptor *gdt_p = (struct descriptor *) PA2KA(gdtr.base);
219
    struct tss_descriptor *tss_d;
220
    struct tss_descriptor *tss_desc;
220
 
221
 
221
    /*
222
    /*
222
     * Each CPU has its private GDT and TSS.
223
     * Each CPU has its private GDT and TSS.
223
     * All CPUs share one IDT.
224
     * All CPUs share one IDT.
224
     */
225
     */
Line 237... Line 238...
237
            panic("could not allocate TSS\n");
238
            panic("could not allocate TSS\n");
238
    }
239
    }
239
 
240
 
240
    tss_initialize(tss_p);
241
    tss_initialize(tss_p);
241
 
242
 
242
    tss_d = (struct tss_descriptor *) &gdt_p[TSS_DES];
243
    tss_desc = (struct tss_descriptor *) (&gdt_p[TSS_DES]);
243
    tss_d[TSS_DES].present = 1;
244
    tss_desc->present = 1;
244
    tss_d[TSS_DES].type = AR_TSS;
245
    tss_desc->type = AR_TSS;
245
    tss_d[TSS_DES].dpl = PL_KERNEL;
246
    tss_desc->dpl = PL_KERNEL;
246
   
247
   
247
    gdt_tss_setbase(&gdt_p[TSS_DES], (__address) tss_p);
248
    gdt_tss_setbase(&gdt_p[TSS_DES], (__address) tss_p);
248
    gdt_tss_setlimit(&gdt_p[TSS_DES], sizeof(struct tss) - 1);
249
    gdt_tss_setlimit(&gdt_p[TSS_DES], sizeof(struct tss) - 1);
249
 
250
 
250
    /*
251
    /*