-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* cleaned up stuff * fixed the looping issue on interrupts. it was the motherfucking kernel_entry page directory offset. * yoinked aaron's GDT code to test paging issue. turns out it was. * GDT fix
- Loading branch information
1 parent
9c791d9
commit c0f2556
Showing
8 changed files
with
68 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#include "gdt.h" | ||
#include <stdint.h> | ||
|
||
gdt_t gdt; | ||
|
||
void init_gdt() { | ||
gdt_entry_t null_entry = {0,0,0,0,0,0}; | ||
gdt_entry_t code_segment = {0xffff,0,0,0b10011010,0b11001111,0}; | ||
gdt_entry_t data_segment = {0xffff,0,0,0b10010010,0b11001111,0}; | ||
gdt = (gdt_t) { | ||
.limit = sizeof(gdt.entries)-1, | ||
.base = (uint32_t) &gdt.entries, | ||
.entries = {null_entry, code_segment, data_segment} | ||
}; | ||
gdt_flush((uint32_t) &gdt); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
global gdt_flush | ||
gdt_flush: | ||
mov eax, [esp+4] ; eax = gdt_ptr | ||
lgdt [eax] ; load the GDT pointer | ||
|
||
mov ax, 0x10 ; 0x10 is kernel segment data descriptor offset | ||
mov ds, ax | ||
mov es, ax | ||
mov fs, ax | ||
mov gs, ax | ||
mov ss, ax | ||
jmp 0x08:.flush ; 0x08 is kernel segment code descriptor offset | ||
; far jump to .flush | ||
.flush: | ||
ret |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#pragma once | ||
#include <stdint.h> | ||
|
||
#define GDT_ENTRIES 3 | ||
|
||
typedef struct { | ||
uint16_t limit; | ||
uint16_t base_low; | ||
uint8_t base_mid; | ||
uint8_t access; | ||
uint8_t granularity; | ||
uint8_t base_high; | ||
} __attribute__((packed)) gdt_entry_t; | ||
|
||
typedef struct { | ||
uint16_t limit; | ||
uint32_t base; | ||
gdt_entry_t entries[GDT_ENTRIES]; | ||
} __attribute__((packed)) gdt_t; | ||
|
||
void init_gdt(); | ||
extern void gdt_flush(uint32_t gdt_descriptor_ptr); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters