X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=sys1%2Fkern%2Fsrc%2Fdesc.c;fp=sys1%2Fkern%2Fsrc%2Fdesc.c;h=4e029911aa8a988ac204250953e78e0409fd17cf;hb=3029144412cf13580e11bc1dffca8b14e05014d0;hp=9af939e28c278df6c5ef682bac1520535a313934;hpb=e05574a9511e724651361905620f96666c7acb04;p=3sys diff --git a/sys1/kern/src/desc.c b/sys1/kern/src/desc.c index 9af939e..4e02991 100644 --- a/sys1/kern/src/desc.c +++ b/sys1/kern/src/desc.c @@ -4,8 +4,6 @@ #define SEG_TYPE_CODE 0x00001800 #define SEG_TYPE_DATA 0x00001000 #define SEG_TYPE_TSS 0x00000100 -#define SEG_TYPE_INTR 0x00000e00 -#define SEG_TYPE_TRAP 0x00000f00 #define SEG_ACCESSED 0x00000100 #define SEG_PRESENT 0x00008000 @@ -29,24 +27,16 @@ void desc_seg(struct desc *desc, int type, uint32_t base, uint32_t limit, int dpl) { + static uint32_t segtype[] = { 0, SEG_TYPE_CODE, SEG_TYPE_DATA, SEG_TYPE_TSS }; + if(type == SEG_NULL) { desc->d[0] = desc->d[1] = 0; return; } desc->d[0] = (limit & 0xffff) | (base << 16); - desc->d[1] = ((base >> 16) & 0xff) | (type << 8) | SEG_PRESENT | (dpl << 13); - desc->d[1] |= (base & 0xff000000) | (limit & 0xf0000) | SEG_AVL | SEG_GRAN; - - switch(type) { - case SEG_CODE: - desc->d[1] |= (3 << 11) | SEG_DEF | SEG_RD; - break; - - case SEG_DATA: - desc->d[1] |= (2 << 11) | SEG_WR; - break; - } + desc->d[1] = ((base >> 16) & 0xff) | (type << 8) | SEG_PRESENT | (dpl << 13) | segtype[type]; + desc->d[1] |= (base & 0xff000000) | (limit & 0xf0000) | SEG_GRAN | SEG_DEF | SEG_RD; }