Main Page | Modules | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

descgate.h

Go to the documentation of this file.
00001 /* ndk - [ descgate.h ]
00002  *
00003  * Support defines and function for working with
00004  * descriptors and gates
00005  *
00006  * (c)2004 dcipher / neuraldk
00007  *           www.neuraldk.org
00008  */
00009 
00018 #ifndef __ndk_descgate_h__
00019 #define __ndk_descgate_h__
00020 
00021 #include "array.h"
00022 
00023 typedef struct _Descriptor Descriptor;
00024 typedef struct _Gate Gate;
00025 
00026 void createDescriptor(Array *table, short desc_num, long base, long limit, long control);
00027 void createGate(Array *table, short gate_num, long offset, short selector, long control);
00028 
00029 // Types of descriptors
00030 #define D_LDT          0x200    /* LDT segment                      */
00031 #define D_TASK         0x500    /* Task gate                        */
00032 #define D_TSS          0x900    /* TSS                              */
00033 #define D_CALL         0x0C00   /* 386 call gate                    */
00034 #define D_INT          0x0E00   /* 386 interrupt gate               */
00035 #define D_TRAP         0x0F00   /* 386 trap gate                    */
00036 #define D_DATA         0x1000   /* Data segment                     */
00037 #define D_CODE         0x1800   /* Code segment                     */
00038 
00039 // attributes for descriptors
00040 #define D_DPL3         0x6000   /* DPL3 or mask for DPL             */
00041 #define D_DPL2         0x4000   /* DPL2 or mask for DPL             */
00042 #define D_DPL1         0x2000   /* DPL1 or mask for DPL             */
00043 #define D_PRESENT      0x8000   /* Present (included by default)    */
00044 #define D_NOT_PRESENT  0x8000   /* Not Present                      */
00045 
00046 // more attributes for segment descriptors (not gates)
00047 #define D_ACC          0x100    /* Accessed (Data or Code)          */
00048 #define D_WRITE        0x200    /* Writable (Data segments only)    */
00049 #define D_READ         0x200    /* Readable (Code segments only)    */
00050 #define D_BUSY         0x200    /* Busy (TSS only)                  */
00051 #define D_EXDOWN       0x400    /* Expand down (Data segments only) */
00052 #define D_CONFORM      0x400    /* Conforming (Code segments only)  */
00053 #define D_BIG          0x40     /* Default to 32 bit mode           */
00054 #define D_BIG_LIM      0x80     /* Limit is in 4K units             */
00055 
00056 struct _Descriptor
00057 {
00058    unsigned short limit_low;    /* limit 0..15    */
00059    unsigned short base_low;     /* base  0..15    */
00060    unsigned char base_med;      /* base  16..23   */
00061    unsigned char access;        /* access byte    */
00062    unsigned int limit_high:4;   /* limit 16..19   */
00063    unsigned int granularity:4;  /* granularity    */
00064    unsigned char base_high;     /* base 24..31    */
00065 } __attribute__ ((packed));
00066 
00067 struct _Gate
00068 {
00069    unsigned short offset_low;   /* offset 0..15    */
00070    unsigned short selector;     /* selector        */
00071    unsigned short access;       /* access flags    */
00072    unsigned short offset_high;  /* offset 16..31   */
00073 } __attribute__ ((packed));
00074 
00075 #endif
00076 

Generated on Wed Mar 22 20:36:33 2006 for ndk by  doxygen 1.4.4