mirror of
https://github.com/tailix/kernel.git
synced 2024-11-27 11:24:34 -05:00
Merge files
This commit is contained in:
parent
a78d9e0085
commit
791cf9cd3d
4 changed files with 29 additions and 53 deletions
|
@ -36,7 +36,6 @@ OBJS += timer.c.o
|
||||||
|
|
||||||
OBJS += protected.c.o
|
OBJS += protected.c.o
|
||||||
|
|
||||||
OBJS += tss.c.o
|
|
||||||
OBJS += tasks.asm.cpp.o
|
OBJS += tasks.asm.cpp.o
|
||||||
|
|
||||||
OBJS += interrupts/main.asm.cpp.o
|
OBJS += interrupts/main.asm.cpp.o
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
#include "protected.h"
|
#include "protected.h"
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
#include "info.h"
|
||||||
#include "interrupts/main.h"
|
#include "interrupts/main.h"
|
||||||
#include "tss.h"
|
|
||||||
|
|
||||||
#include <kernaux/arch/i386.h>
|
#include <kernaux/arch/i386.h>
|
||||||
#include <kernaux/asm/i386.h>
|
#include <kernaux/asm/i386.h>
|
||||||
|
@ -37,6 +37,8 @@ static struct IdtPointer idt_pointer;
|
||||||
static struct KernAux_Arch_I386_DTE gdt_entries[GDT_SIZE];
|
static struct KernAux_Arch_I386_DTE gdt_entries[GDT_SIZE];
|
||||||
static struct IdtEntry idt_entries[IDT_SIZE];
|
static struct IdtEntry idt_entries[IDT_SIZE];
|
||||||
|
|
||||||
|
static struct KernAux_Arch_I386_TSS tss;
|
||||||
|
|
||||||
static void gdt_set_gates();
|
static void gdt_set_gates();
|
||||||
static void idt_set_gates();
|
static void idt_set_gates();
|
||||||
|
|
||||||
|
@ -49,11 +51,15 @@ void protected_initialize(const struct Kernel_Info *const kinfo)
|
||||||
|
|
||||||
kernaux_drivers_console_print("[INFO] protected: Setup GDT.\n");
|
kernaux_drivers_console_print("[INFO] protected: Setup GDT.\n");
|
||||||
gdt_set_gates();
|
gdt_set_gates();
|
||||||
tss_write_to_gdt(kinfo, &gdt_entries[GDT_TSS_INDEX]);
|
|
||||||
|
|
||||||
kernaux_drivers_console_print("[INFO] protected: Setup IDT.\n");
|
kernaux_drivers_console_print("[INFO] protected: Setup IDT.\n");
|
||||||
idt_set_gates();
|
idt_set_gates();
|
||||||
|
|
||||||
|
kernaux_drivers_console_print("[INFO] protected: Setup TSS.\n");
|
||||||
|
memset(&tss, 0, sizeof(tss));
|
||||||
|
tss.ss0 = GDT_KERNEL_DS_SELECTOR;
|
||||||
|
tss.esp0 = kinfo->kernel_stack_start + kinfo->kernel_stack_size;
|
||||||
|
|
||||||
kernaux_drivers_console_print("[INFO] protected: Load GDT.\n");
|
kernaux_drivers_console_print("[INFO] protected: Load GDT.\n");
|
||||||
gdt_pointer.limit = sizeof(struct KernAux_Arch_I386_DTE) * GDT_SIZE - 1;
|
gdt_pointer.limit = sizeof(struct KernAux_Arch_I386_DTE) * GDT_SIZE - 1;
|
||||||
gdt_pointer.base = (unsigned int)&gdt_entries;
|
gdt_pointer.base = (unsigned int)&gdt_entries;
|
||||||
|
@ -154,6 +160,27 @@ void gdt_set_gates()
|
||||||
.DPL = 3,
|
.DPL = 3,
|
||||||
.present = 1,
|
.present = 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
uint32_t base = (uint32_t)&tss;
|
||||||
|
uint32_t limit = sizeof(tss);
|
||||||
|
|
||||||
|
gdt_entries[GDT_TSS_INDEX] = (struct KernAux_Arch_I386_DTE){
|
||||||
|
.base_low = base & 0xFFFFFF,
|
||||||
|
.base_high = (base & 0xFF000000) >> 24,
|
||||||
|
.limit_low = limit & 0xFFFF,
|
||||||
|
.limit_high = (limit & 0xF0000) >> 16,
|
||||||
|
.available = 0,
|
||||||
|
.always_0 = 0,
|
||||||
|
.big = 0,
|
||||||
|
.gran = 0,
|
||||||
|
.accessed = 1,
|
||||||
|
.read_write = 0,
|
||||||
|
.conforming_expand_down = 0,
|
||||||
|
.code = 1,
|
||||||
|
.always_1 = 1, // was 0
|
||||||
|
.DPL = 3,
|
||||||
|
.present = 1,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
void idt_set_gates()
|
void idt_set_gates()
|
||||||
|
|
40
kernel/tss.c
40
kernel/tss.c
|
@ -1,40 +0,0 @@
|
||||||
#include "tss.h"
|
|
||||||
|
|
||||||
#include "config.h"
|
|
||||||
|
|
||||||
#include <kernaux/arch/i386.h>
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
static struct KernAux_Arch_I386_TSS tss;
|
|
||||||
|
|
||||||
void tss_write_to_gdt(const struct Kernel_Info *const kinfo, void *gdt_entry_ptr)
|
|
||||||
{
|
|
||||||
struct KernAux_Arch_I386_DTE *const g = gdt_entry_ptr;
|
|
||||||
|
|
||||||
unsigned long base = (unsigned long)&tss;
|
|
||||||
unsigned long limit = sizeof(tss);
|
|
||||||
|
|
||||||
g->limit_low = limit & 0xFFFF;
|
|
||||||
g->base_low = base & 0xFFFFFF;
|
|
||||||
|
|
||||||
g->base_high = (base & 0xFF000000) >> 24;
|
|
||||||
g->limit_high = (limit & 0xF0000) >> 16;
|
|
||||||
|
|
||||||
g->accessed = 1;
|
|
||||||
g->read_write = 0;
|
|
||||||
g->conforming_expand_down = 0;
|
|
||||||
g->code = 1;
|
|
||||||
g->always_1 = 0;
|
|
||||||
g->DPL = 3;
|
|
||||||
g->present = 1;
|
|
||||||
g->available = 0;
|
|
||||||
g->always_0 = 0;
|
|
||||||
g->big = 0;
|
|
||||||
g->gran = 0;
|
|
||||||
|
|
||||||
memset(&tss, 0, sizeof(tss));
|
|
||||||
|
|
||||||
tss.ss0 = GDT_KERNEL_DS_SELECTOR;
|
|
||||||
tss.esp0 = kinfo->kernel_stack_start + kinfo->kernel_stack_size;
|
|
||||||
}
|
|
10
kernel/tss.h
10
kernel/tss.h
|
@ -1,10 +0,0 @@
|
||||||
#ifndef KERNEL_INCLUDED_TSS
|
|
||||||
#define KERNEL_INCLUDED_TSS 1
|
|
||||||
|
|
||||||
#include "info.h"
|
|
||||||
|
|
||||||
void tss_write_to_gdt(const struct Kernel_Info *kinfo, void *gdt_entry);
|
|
||||||
|
|
||||||
void tss_flush();
|
|
||||||
|
|
||||||
#endif
|
|
Loading…
Reference in a new issue