Commit 9b7f69cf by triazo

Merge branch 'GDTIDTfix' into 'master'

Gdtidtfix

Fixes a lot of mess in GDT and IDT, removes voodoo.

See merge request !9
parents 3b3b9e3c 1c2a56f9
Showing with 9 additions and 10 deletions
#include "gdt.h"
#include "string.h"
#include "serial.h"
//#include "term.h"
#pragma GCC push_options
#pragma GCC optimize ("0")
uint16_t gdt_limit;
uint32_t gdt_base;
gdt_desc _gdt [MAX_GDT_DESC];
#define set_cs( cs ) asm volatile ( "ljmp %0, $1337f \n\t 1337: \n\t" :: "i"(cs) )
void gdt_install(){
struct{
uint16_t limit;
......@@ -17,14 +18,13 @@ void gdt_install(){
gdtr.limit = gdt_limit;
gdtr.base = gdt_base;
asm volatile ("lgdt (%0)": :"r"(&gdtr));
set_cs(8);
asm volatile ( "ljmp %0, $1337f \n\t 1337: \n\t" :: "i"(8) );
asm volatile("mov $0x10, %ax; \
mov %ax, %ds; \
mov %ax, %es; \
mov %ax, %fs; \
mov %ax, %gs; \
mov %ax, %ss;");
strlen("");
}
void gdt_set_desc(uint32_t i, uint64_t base, uint64_t limit, uint8_t access, uint8_t gran){
if (i > MAX_GDT_DESC)
......@@ -58,3 +58,4 @@ int gdt_init() {
gdt_install();
return 0;
}
#pragma GCC pop_options
......@@ -2,6 +2,9 @@
#include "string.h"
#include "serial.h"
#pragma GCC push_options
#pragma GCC optimize ("0")
uint16_t idt_limit;
uint32_t idt_base;
......@@ -14,9 +17,6 @@ void idt_install() {
} __attribute__((packed)) idtr;
idtr.limit = idt_limit;
idtr.base = idt_base;
char f[20];
itoa(idtr.limit, f);
itoa(idtr.base, f);
asm volatile ("lidt (%0)": :"r"(&idtr));
}
......@@ -53,8 +53,6 @@ int idt_init (uint16_t code_sel) {
for (int i=0; i<MAX_IDT_INT; i++)
install_ir (i, IDT_PR|IDT_32,code_sel,(IRQ_HANDLER)default_handler);
idt_install();
char f[20];
itoa((uintptr_t)&_idt,f);
//serial_writestring(f);
return 0;
}
#pragma GCC pop_options
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment