POK(kernelpart)
|
00001 /* 00002 * POK header 00003 * 00004 * The following file is a part of the POK project. Any modification should 00005 * made according to the POK licence. You CANNOT use this file or a part of 00006 * this file is this part of a file for your own project 00007 * 00008 * For more information on the POK licence, please see our LICENCE FILE 00009 * 00010 * Please follow the coding guidelines described in doc/CODING_GUIDELINES 00011 * 00012 * Copyright (c) 2007-2009 POK team 00013 * 00014 * Created by julien on Thu Jan 15 23:34:13 2009 00015 */ 00016 00017 00018 #ifndef __POK_X86_GDT_H__ 00019 #define __POK_X86_GDT_H__ 00020 00021 #include <types.h> 00022 00023 typedef enum e_gdte_type 00024 { 00025 GDTE_CODE = 0xB, 00026 GDTE_DATA = 0x3, 00027 GDTE_TSS = 0x9 00028 } e_gdte_type; 00029 00030 typedef struct 00031 { 00032 uint32_t limit_low:16; 00033 uint32_t base_low:24 __attribute__ ((packed)); 00034 uint32_t type:4; 00035 uint32_t s:1; 00036 uint32_t dpl:2; 00037 uint32_t present:1; 00038 uint32_t limit_high:4; 00039 uint32_t available:2; 00040 uint32_t op_size:1; 00041 uint32_t granularity:1; 00042 uint32_t base_high:8; 00043 } __attribute__((packed)) gdt_entry_t; 00044 00045 #define GDT_CORE_CODE_SEGMENT 1 00046 #define GDT_CORE_DATA_SEGMENT 2 00047 #define GDT_TSS_SEGMENT 3 00048 00049 #define GDT_PARTITION_CODE_SEGMENT(partition_id) (4 + 2 * partition_id) 00050 #define GDT_PARTITION_DATA_SEGMENT(partition_id) (4 + 2 * partition_id + 1) 00051 00052 #define GDT_BUILD_SELECTOR(seg, local, rpl) \ 00053 ((seg << 3) | ((local & 0x1) << 2) | (rpl & 0x3)) 00054 00055 pok_ret_t pok_gdt_init(); 00056 int pok_tss_init(); 00057 00058 void tss_set_esp0(uint32_t esp0); 00059 00060 void gdt_set_segment (uint16_t index, 00061 uint32_t base_address, 00062 uint32_t limit, 00063 e_gdte_type t, 00064 int dpl); 00065 00066 void gdt_set_system (uint16_t index, 00067 uint32_t base_address, 00068 uint32_t limit, 00069 e_gdte_type t, 00070 int dpl); 00071 00072 void gdt_enable (uint16_t index); 00073 void gdt_disable (uint16_t index); 00074 00075 /* 00076 * DEPRECATED 00077 uint32_t gdt_segment_base(uint16_t idx); 00078 */ 00079 00080 #endif /* !__POK_X86_GDT_H__ */ 00081