00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "core/kmaster.h"
00019
00020 void clearDESC(SEG_DESC *in)
00021 {
00022 in->base_0_15 = 0x0;
00023 in->base_16_23 = 0x0;
00024 in->base_24_31 = 0x0;
00025 in->lt_0_15 = 0x0;
00026 in->lt_16_19 = 0x0;
00027 in->flags_8_15 = 0x0;
00028 in->flags_20_23= 0x0;
00029 }
00030
00031 void createDESC(SEG_DESC *in, DD base, DD limit, DW flags)
00032 {
00033 clearDESC(in);
00034 flags &= 0x0FFF;
00035 in->lt_0_15 = (DW)(limit & 0xFFFF);
00036 in->lt_16_19 = (limit>>16) & 0xF;
00037
00038 in->base_0_15 = (DW)(base & 0xFFFF);
00039 in->base_16_23 = (DB)((base>>16) & 0xFF);
00040 in->base_24_31 = (DB)((base>>24) & 0xFF);
00041
00042 in->flags_8_15 = (DB)(flags & 0xFF);
00043 in->flags_20_23= (DB)((flags>>8) & 0xF);
00044 }
00045
00046 void createTG(TG_DESC *in, DW tss_sel, boolean p, DPL dpl)
00047 {
00048 clearDESC((SEG_DESC *)in);
00049 }
00050
00051 void createIG(IG_DESC *in, DW seg_sel, DD offset, boolean p, DPL dpl)
00052 {
00053 clearDESC((SEG_DESC *)in);
00054
00055 in->segsel_16_31 = seg_sel;
00056
00057 in->off_0_15 = offset & 0xFFFF;
00058 in->off_16_31 = offset >> 16;
00059
00060 in->flags_0_15 = F_IG | (p?F_IG_P:0) | (dpl<<13);
00061 }
00062
00063 void createTRG(TRG_DESC *in, DW sel_sel, DD offset, boolean p, DPL dpl)
00064 {
00065 clearDESC((SEG_DESC *)in);
00066 }
00067
00068 void printDESC(SEG_DESC *in)
00069 {
00070 DD base, limit;
00071 DW flags;
00072
00073 base = in->base_24_31<<24 | in->base_16_23<<16 | in->base_0_15;
00074 limit = in->lt_16_19<<16 | in->lt_0_15;
00075 flags = in->flags_20_23<<8 | in->flags_8_15;
00076
00077 printf("\nBase:%x\tLimit:%x\tFlags:%x",base,limit,flags);
00078 }
00079
00080
00081 void printIG(IG_DESC *in)
00082 {
00083 printf("\nSelector:%x\tOffset:%x\tFlags:%x",in->segsel_16_31,(in->off_16_31<<16)|in->off_0_15,in->flags_0_15);
00084 }
00085
00086
00087
00088
00089
00090
00091
00092