kern
diff src/segm.c @ 54:4eaecb14fe31
bringing the task switching thing into shape with proper per-process kernel stacks and shit
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sun, 14 Aug 2011 16:57:23 +0300 |
parents | f65b348780e3 |
children | 88a6c4e192f9 |
line diff
1.1 --- a/src/segm.c Mon Aug 08 09:53:10 2011 +0300 1.2 +++ b/src/segm.c Sun Aug 14 16:57:23 2011 +0300 1.3 @@ -21,8 +21,7 @@ 1.4 1.5 enum {TYPE_DATA, TYPE_CODE}; 1.6 1.7 -#define TSS_TYPE_BITS 0x900 1.8 -#define TSS_BUSY BIT_BUSY 1.9 +#define TSS_TYPE_BITS (BIT_ACCESSED | BIT_CODE) 1.10 1.11 static void segm_desc(desc_t *desc, uint32_t base, uint32_t limit, int dpl, int type); 1.12 static void task_desc(desc_t *desc, uint32_t base, uint32_t limit, int dpl, unsigned int busy); 1.13 @@ -30,6 +29,7 @@ 1.14 /* these functions are implemented in segm-asm.S */ 1.15 void setup_selectors(uint16_t code, uint16_t data); 1.16 void set_gdt(uint32_t addr, uint16_t limit); 1.17 +void set_task_reg(uint16_t tss_selector); 1.18 1.19 1.20 /* our global descriptor table */ 1.21 @@ -43,7 +43,6 @@ 1.22 segm_desc(gdt + SEGM_KDATA, 0, 0xffffffff, 0, TYPE_DATA); 1.23 segm_desc(gdt + SEGM_UCODE, 0, 0xffffffff, 3, TYPE_CODE); 1.24 segm_desc(gdt + SEGM_UDATA, 0, 0xffffffff, 3, TYPE_DATA); 1.25 - task_desc(gdt + SEGM_TASK, 0, 0xffffffff, 3, TSS_BUSY); 1.26 1.27 set_gdt((uint32_t)gdt, sizeof gdt - 1); 1.28 1.29 @@ -56,6 +55,12 @@ 1.30 return (idx << 3) | (rpl & 3); 1.31 } 1.32 1.33 +void set_tss(uint32_t addr) 1.34 +{ 1.35 + task_desc(gdt + SEGM_TASK, 0, sizeof(struct tss) - 1, 3, TSS_BUSY); 1.36 + set_task_reg(selector(SEGM_TASK, 0)); 1.37 +} 1.38 + 1.39 static void segm_desc(desc_t *desc, uint32_t base, uint32_t limit, int dpl, int type) 1.40 { 1.41 desc->d[0] = limit & 0xffff; /* low order 16bits of limit */