mirror of
https://github.com/wichtounet/thor-os.git
synced 2025-09-17 16:51:33 -04:00
Create GDT entries for user code and data
This commit is contained in:
parent
075bde1802
commit
c48cbd2c65
@ -13,6 +13,8 @@ namespace gdt {
|
|||||||
constexpr const uint16_t CODE_SELECTOR = 0x08;
|
constexpr const uint16_t CODE_SELECTOR = 0x08;
|
||||||
constexpr const uint16_t DATA_SELECTOR = 0x10;
|
constexpr const uint16_t DATA_SELECTOR = 0x10;
|
||||||
constexpr const uint16_t LONG_SELECTOR = 0x18;
|
constexpr const uint16_t LONG_SELECTOR = 0x18;
|
||||||
|
constexpr const uint16_t USER_DATA_SELECTOR = 0x20;
|
||||||
|
constexpr const uint16_t USER_CODE_SELECTOR = 0x28;
|
||||||
|
|
||||||
} //end of namespace gdt
|
} //end of namespace gdt
|
||||||
|
|
||||||
|
@ -323,13 +323,29 @@ constexpr uint16_t data_selector(){
|
|||||||
SEG_PRIV(0) | SEG_DATA_RDWR;
|
SEG_PRIV(0) | SEG_DATA_RDWR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
constexpr uint16_t user_data_selector(){
|
||||||
|
return
|
||||||
|
SEG_DESCTYPE(1) | SEG_PRES(1) | SEG_SAVL(0) |
|
||||||
|
SEG_LONG(1) | SEG_SIZE(1) | SEG_GRAN(1) |
|
||||||
|
SEG_PRIV(3) | SEG_DATA_RDWR;
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr uint16_t user_code_64_selector(){
|
||||||
|
return
|
||||||
|
SEG_DESCTYPE(1) | SEG_PRES(1) | SEG_SAVL(0) |
|
||||||
|
SEG_LONG(1) | SEG_SIZE(0) | SEG_GRAN(1) |
|
||||||
|
SEG_PRIV(3) | SEG_CODE_EXRD;
|
||||||
|
}
|
||||||
|
|
||||||
void setup_gdt(){
|
void setup_gdt(){
|
||||||
//TODO On some machines, this should be aligned to 16 bits
|
//TODO On some machines, this should be aligned to 16 bits
|
||||||
static const uint64_t gdt[] = {
|
static const uint64_t gdt[] = {
|
||||||
0, //Null Selector
|
0, //Null Selector
|
||||||
gdt_entry(0, 0xFFFFF, code_32_selector()),
|
gdt_entry(0, 0xFFFFF, code_32_selector()),
|
||||||
gdt_entry(0, 0xFFFFF, data_selector()),
|
gdt_entry(0, 0xFFFFF, data_selector()),
|
||||||
gdt_entry(0, 0xFFFFF, code_64_selector())
|
gdt_entry(0, 0xFFFFF, code_64_selector()),
|
||||||
|
gdt_entry(0, 0xFFFFF, user_data_selector()),
|
||||||
|
gdt_entry(0, 0xFFFFF, user_code_64_selector())
|
||||||
};
|
};
|
||||||
|
|
||||||
static gdt_ptr gdtr;
|
static gdt_ptr gdtr;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user