segm.c

Go to the documentation of this file.
00001 
00008 #include "routix/segm.h"
00009 
00010 #ifndef __SYSTEM
00011 #include "routix/system.h"
00012 #endif
00013 
00015 descriptor_t make_descriptor( dword base, dword limite, byte atr1, byte atr2 )
00016 {
00017  descriptor_t gdt_entry;
00018 
00019  gdt_entry.base1 = (word) (base & 0Xffff);
00020  gdt_entry.base2 = (byte) ((base & 0xff0000) >> 16);
00021  gdt_entry.base3 = (byte) ((base & 0xff000000) >> 24);
00022  
00023  gdt_entry.limite1 = (word) (limite & 0xffff);
00024  gdt_entry.atr2    = (byte) (atr2 | ((limite & 0xf0000) >> 16));
00025  gdt_entry.atr1    = atr1;
00026 
00027  return gdt_entry;
00028 }
00029 
00031 descriptor_t make_int_gate( word segselector, dword offset, byte atr)
00032 {
00033  descriptor_t int_gate;
00034 
00035  int_gate.base1   = segselector;
00036  int_gate.limite1 = (word) (offset & 0xffff);
00037  int_gate.atr1    = (byte) (atr | INT_GATE);
00038  int_gate.atr2    = (byte) ((offset & 0xff0000) >> 16);
00039  int_gate.base3   = (byte) ((offset & 0xff000000) >> 24);
00040  
00041  return int_gate;
00042 }
00043 
00045 descriptor_t make_trap_gate( word segselector, dword offset, byte atr)
00046 {
00047  descriptor_t int_gate;
00048 
00049  int_gate.base1   = segselector;
00050  int_gate.limite1 = (word) (offset & 0xffff);
00051  int_gate.atr1    = (byte) (atr | TRAP_GATE);
00052  int_gate.atr2    = (byte) ((offset & 0xff0000) >> 16);
00053  int_gate.base3   = (byte) ((offset & 0xff000000) >> 24);
00054  
00055  return int_gate;
00056 }
00057 
00058 
00059 descriptor_t make_task_gate( word segselector, byte atr)
00060 {
00061  descriptor_t task_gate;
00062 
00063  task_gate.base1   = segselector;
00064  task_gate.atr1    = (byte) (atr | TASK_GATE);
00065  
00066  return task_gate;
00067 }
00068 
00069 
00071 inline void clear_busy_bit(descriptor_t *desc)
00072 {
00073  desc->atr1 = desc->atr1 & ~2;
00074 }
00075 
00076 
00078 __inline__ void lgdt (gdtr_t *dir_gdtr_so)
00079 {
00080  __asm__("lgdt (%0)" : : "q" (dir_gdtr_so) );
00081 }
00082 
00084 __inline__ void lidt (gdtr_t *dir_gdtr_so)
00085 {
00086  __asm__("lidt (%0)" : : "q" (dir_gdtr_so) );
00087 }
00088 

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