ktypes.h

00001 /***************************************************************************
00002                           ktypes.h  -  description
00003                              -------------------
00004     begin                : Sat Dec 13 2003
00005     copyright            : (C) 2003 by Dynacube Team
00006     email                : mdshah82@yahoo.com
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00018 #ifndef __KTYPES_H
00019 #define __KTYPES_H
00020 
00021         typedef unsigned char   DB;     // 1 byte
00022         typedef unsigned short  DW;     // 2 byte
00023         typedef unsigned int      DD;   // 4 byte
00024 
00025         //Signed xtensions
00026         typedef char      SDB;  // 1 byte
00027         typedef short   SDW;    // 2 byte
00028         typedef int       SDD;  // 4 byte
00029   
00030 
00031         typedef enum {_false, _true} boolean;
00032         typedef enum {dpl_0,dpl_1,dpl_3,dpl_4} DPL;
00033 
00034         #define TI_GLOBAL 0b
00035         #define TI_LOCAL  1b
00036 
00037         #define RPL_0 00b
00038         #define RPL_1 01b
00039         #define RPL_2 10b
00040         #define RPL_3 11b
00041         
00042         #define F_TYPE_CODE     1<<3
00043         #define F_TYPE_C        1<<2
00044         #define F_TYPE_R        1<<1
00045 
00046         #define F_TYPE_DATA     0
00047         #define F_TYPE_E        1<<2
00048         #define F_TYPE_W        1<<1
00049         
00050         #define F_TYPE_A        1
00051 
00052         typedef struct
00053         {
00054          DB rpl : 2;
00055          DB ti : 1;
00056          DW index:13;
00057         } SEG_SEL;
00058 
00059         #define F_DPL_1 01b
00060         #define F_DPL_2 10b
00061         #define F_DPL_3 11b
00062 
00063         #define F_S     1<<4        //Flag for Code/Data
00064 
00065         #define F_SD_DPL_1 1<<5
00066         #define F_SD_DPL_2 1<<6
00067         #define F_SD_DPL_3 (F_SD_DPL_1 | F_SD_DPL_2)
00068 
00069         #define F_P     1<<7    //Always Present in memory
00070 
00071         #define F_AVL   1
00072         #define F_D_B   1<<2
00073         #define F_G     1<<3
00074 
00075         typedef struct
00076         {
00077          DW lt_0_15;
00078          DW base_0_15;
00079          DB base_16_23;
00080          DB flags_8_15;
00081          DB lt_16_19 : 4;
00082          DB flags_20_23 : 4;
00083          DB base_24_31;
00084         } SEG_DESC;
00085 
00086         typedef struct
00087         {
00088                 DW limit;     
00089                 DW lobase;
00090                 DW hibase;
00091         } GDT;
00092 
00093         typedef struct
00094         {
00095                 DW limit;    
00096                 DW lobase;
00097                 DW hibase;
00098         } IDT;
00099 
00100         typedef struct
00101         {
00102                 DW limit;
00103                 DW lobase;
00104                 DW hibase;
00105         } LDT;
00106   
00107         //For the following
00108         //eg:
00109         //      F_IG = F_IG_P | F_IG | F_DPL_0<<13
00110         //      F_TG = F_TG_P | F_TG | F_DPL_0<<13
00111         //      F_TRG = F_TRG_P | F_TRG | F_DPL_0<<13
00112 
00113         //Interrupt Gate
00114         /* P(1) DPL(2) 0 D(1) 1 1 0 | 0 0 0 | 0 0 0 0 0*/
00115         #define F_IG 0x0E00
00116         #define F_IG_P 1<<15
00117 
00118         typedef struct
00119         {
00120          DW off_0_15;
00121          DW segsel_16_31;
00122          DW flags_0_15;
00123          DW off_16_31;
00124         } IG_DESC;
00125 
00126         //Task Gate
00127         /* P(1) DPL(2) | 0 0 1 0 1 | 0 0 0 0 0 0 0 0 */
00128         #define F_TG 0x0500  
00129         #define F_TG_P  1<<15
00130 
00131         typedef struct
00132         {
00133          DW hole_0_15;
00134          DW tss_seg_sel_16_31;
00135          DW flags_0_15;
00136          DW hole_16_31;
00137         } TG_DESC;
00138 
00139         //Trap Gate
00140         /* P(1) DPL(2) 0 D 1 1 1 | 0 0 0 | 0 0 0 0 0 */
00141         #define F_TRG 0F00
00142         #define F_TRG_P 1<<15
00143         
00144         typedef struct
00145         { 
00146          DW off_0_15;
00147          DW segsel_16_31;
00148          DW flags_0_15;
00149          DW off_16_31;
00150         } TRG_DESC;
00151 
00152         typedef struct
00153         {
00154                 DW off_0_15;
00155                 DW segsel_16_31;
00156                 DB param_count;
00157                 DB flags;
00158                 DW off_16_31;
00159         } CALL_GATE;
00160   
00161         extern DW cur_pid;
00162 
00163         #ifndef __SIZE_T
00164                 #define size_t DD
00165         #endif
00166 
00167 #endif

Generated on Thu Jul 27 23:52:27 2006 for Dynacube by  doxygen 1.4.7