fix struct packing, weird formatting
This commit is contained in:
parent
c8b445c591
commit
15ab75ffe4
2 changed files with 14 additions and 18 deletions
|
|
@ -8,14 +8,12 @@ void write_segment_descriptor(uint64_t *entry, uint8_t dpl, uint8_t executable)
|
|||
| (dpl << 5) | (1 << 4) // S
|
||||
| (executable << 3) | (0 << 2) // DC
|
||||
| (1 << 1) // RW
|
||||
| (0 << 0) // A
|
||||
;
|
||||
| (0 << 0); // A
|
||||
|
||||
uint8_t flags = (1 << 3) // G
|
||||
| (0 << 2) // DB
|
||||
| (1 << 1) // L
|
||||
| (0 << 0) // reserved
|
||||
;
|
||||
| (0 << 0); // reserved
|
||||
|
||||
*entry = 0xffff // limit
|
||||
| ((uint64_t)0x0000 << 16) // base
|
||||
|
|
@ -23,8 +21,7 @@ void write_segment_descriptor(uint64_t *entry, uint8_t dpl, uint8_t executable)
|
|||
| ((uint64_t)access_byte << 40) // access byte
|
||||
| ((uint64_t)0xf << 48) // limit
|
||||
| ((uint64_t)flags << 52) // flags
|
||||
| ((uint64_t)0x00 << 56) // base
|
||||
;
|
||||
| ((uint64_t)0x00 << 56); // base
|
||||
}
|
||||
|
||||
#define CODE_SEGMENT 1
|
||||
|
|
@ -43,11 +40,12 @@ void init_gdt() {
|
|||
__asm__("lgdt (%0)" ::"r"(gdtr));
|
||||
|
||||
__asm__("mov %0, %%ds" ::"r"(DATA_SEGMENT << 3));
|
||||
|
||||
// TODO set code segment -> iret?
|
||||
}
|
||||
|
||||
__attribute__ ((packed))
|
||||
struct int_desc_entry {
|
||||
struct __attribute__((packed))
|
||||
int_desc_entry {
|
||||
uint16_t offset1;
|
||||
uint16_t selector;
|
||||
uint8_t ist;
|
||||
|
|
@ -63,8 +61,7 @@ struct int_desc_entry {
|
|||
void write_segment_selector(uint16_t *ss, uint16_t index) {
|
||||
*ss = (uint16_t)PRIV_KERNEL
|
||||
| 0 // use GDT
|
||||
| (index << 3)
|
||||
;
|
||||
| (index << 3);
|
||||
}
|
||||
|
||||
#define GATE_TYPE_INTERRUPT 0xe
|
||||
|
|
@ -75,8 +72,7 @@ void write_int_desc_entry(struct int_desc_entry *e, uint64_t offset) {
|
|||
e->ist = 0;
|
||||
e->attr = (uint8_t)GATE_TYPE_INTERRUPT
|
||||
| (uint8_t)(PRIV_KERNEL << 5)
|
||||
| (uint8_t)(1 << 7) // present
|
||||
;
|
||||
| (uint8_t)(1 << 7); // present
|
||||
e->offset2 = (uint16_t) ((offset >> 16) & 0xffff);
|
||||
e->offset3 = (uint32_t) ((offset >> 32) & 0xffffffff);
|
||||
e->pad = 0;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue