Wir haben jetzt den Code geändert, aber es funktioniert immer noch nicht. Wir wissen jedoch nicht was daran falsch ist.
In unserer init.c steht folgendes:
#include "inttypes.h"
#define GDT_SIZE 5
#define GDT_CODESEG 0x0A //10
#define GDT_DATASEG 0x02 //02
#define GDT_TSS 0x09 //09
#define GDT_PRESENT 0x80 //128
#define GDT_SEGMENT 0x80 //128
#define SYS_CODE_SEL 0x08 //08
#define SYS_DATA_SEL 0x10 //16
#define USER_CODE_SEL 0x18 //24
#define USER_DATA_SEL 0x20 //32
#define TSS_SEL 0x28 //40
typedef struct {
uint16_t size;
uint16_t base;
uint8_t base2;
uint8_t access;
uint8_t size2;
uint8_t base3;
} segment_descriptor;
segment_descriptor gdt[GDT_SIZE];
void gdt_set_descriptor(int i, uint64_t size, uint32_t base, uint8_t access, int dpl)
{
gdt[i].size = size & 0xFFFF; //65535
gdt[i].size2 = ((size >> 16) & 0x0F) | 0xC0; //16,192
gdt[i].base = base & 0xFFFF; //65535
gdt[i].base2 = (base >> 16) & 0xFF; //255
gdt[i].base3 = ((base >> 24) & 0xFF); //255
gdt[i].access = access | ((dpl & 3) << 5);
}
void load_gdt()
{
struct {
uint16_t size;
uint32_t base;
}
__attribute__((packed)) gdt_ptr =
{
.size = GDT_SIZE*8 - 1,
.base = (uint32_t)gdt,
};
asm("lgdtl %0\n\t"
"ljmpl $0x08, $1f\n\t"
"1:\n\t"
"mov $0x10, %%eax\n\t"
"mov %%eax, %%ds\n\t"
"mov %%eax, %%es\n\t"
"mov %%eax, %%fs\n\t"
"mov %%eax, %%gs\n\t"
"mov %%eax, %%ss\n\t" : : "m" (gdt_ptr) : "eax");
}
void init_gdt(void)
{
gdt_set_descriptor(0, 0, 0, 0, 0);
gdt_set_descriptor(1, 0x000FFFFF, 0x00000000, GDT_SEGMENT | GDT_PRESENT | GDT_CODESEG, 0); //65535, 0, 154, 0
gdt_set_descriptor(2, 0x000FFFFF, 0x00000000, GDT_SEGMENT | GDT_PRESENT | GDT_DATASEG, 0); //65535, 0, 146, 0
gdt_set_descriptor(3, 0x000FFFFF, 0x00000000, GDT_SEGMENT | GDT_PRESENT | GDT_CODESEG, 3); //65535, 0, 154, 3
gdt_set_descriptor(4, 0x000FFFFF, 0x00000000, GDT_SEGMENT | GDT_PRESENT | GDT_DATASEG, 3); //65535, 0, 146, 3
load_gdt();
}
void init(void){
init_gdt();
}
Kann mal jemand sich diesen angucken und sagen was falsch ist?
Vielen Dank schon einaml im voraus
spaceemotion