segm.h

Go to the documentation of this file.
00001 /* segm.h */
00002 
00003 #ifndef __SYSTEM
00004 #include "routix/system.h"
00005 #endif
00006 
00007 typedef struct gdtr_t {
00008         word limite;
00009         dword base;
00010 } gdtr_t;
00011 
00012 typedef gdtr_t idtr_t;
00013 
00014 
00015 typedef struct descriptor_t {
00016         word limite1;                   // Limite 0:15
00017         word base1;                     // Base 0:15
00018         byte base2;                     // Base 16:23
00019         byte atr1;                      // P, DPL(2bits),S, Tipo(4bits)
00020         byte atr2;                      // G, D/B, 0, AVL, Limite 16:19 (4bits) 
00021         byte base3;                     // Base  24:31
00022 } descriptor_t;
00023 
00024 
00025 #define PRESENTE 1 << 7
00026 #define DPL_0    0 << 6
00027 #define DPL_1    1 << 5
00028 #define DPL_2    2 << 5
00029 #define DPL_3    3 << 5
00030 #define GENERAL  1 << 4
00031 #define SISTEMA  0
00032 
00033 //Descriptor de tipo GENERAL
00034 //Tipos
00035 #define DATA            0 << 3
00036 #define EXPAND_DOWN     1 << 2
00037 #define WRITE           1 << 1
00038 
00039 
00040 #define CODIGO          1 << 3
00041 #define CONFORMING      1 << 2
00042 #define READ            1 << 1
00043 
00044 #define ACCESED         1 << 0
00045 
00046 // Descriptor de tipo SISTEMA
00047 // Tipos
00048 #define LDT             2
00049 #define TASK_GATE       5
00050 #define TSS_AVAILABLE   9
00051 #define TSS_BUSY        0xb
00052 #define CALL_GATE       0xc
00053 #define INT_GATE        0xe
00054 #define TRAP_GATE       0xf
00055 
00056 
00057 // 2do byte
00058 #define GRANULARIDAD    1 << 7
00059 #define DB              1 << 6
00060 
00061 
00062 __inline__ void lgdt (gdtr_t *dir_gdtr_so);
00063 descriptor_t make_descriptor( dword base, dword limite, byte atr1, byte atr2 );
00064 descriptor_t make_int_gate( word segselector, dword offset, byte atr);
00065 descriptor_t make_trap_gate( word segselector, dword offset, byte atr);
00066 descriptor_t make_task_gate( word segselector, byte atr);
00067 
00068 
00069 
00070 #define _set_ds(valor) __asm__ __volatile__ ("movw %w0,%%ds\n\t" : : "r" (valor))
00071 #define _set_es(valor) __asm__ __volatile__ ("movw %w0,%%es\n\t" : : "r" (valor))
00072 #define _set_fs(valor) __asm__ __volatile__ ("movw %w0,%%fs\n\t" : : "r" (valor))
00073 #define _set_gs(valor) __asm__ __volatile__ ("movw %w0,%%gs\n\t" : : "r" (valor))
00074 #define _set_ss(valor) __asm__ __volatile__ ("movw %w0,%%ss\n\t" : : "r" (valor))
00075 #define _set_esp(valor) __asm__ __volatile__ ("movl %0,%%esp\n\t" : : "r" (valor))
00076 
00077 #define _lidt(valor) __asm__ __volatile__ ("lidt (%0)" : : "q" (valor));
00078 #define ldtr(valor) __asm__ __volatile__ ("lldt %w0" : : "a" (valor));
00079 
00080 
00081 

Generated on Sun May 30 18:38:35 2004 for Routix OS by doxygen 1.3.6