wip: TSS added to the gdt and start to implement scheduler
This commit is contained in:
@ -1,9 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include "tss.h"
|
||||
#include <stdint.h>
|
||||
|
||||
#define GDT_ADDRESS 0xC0105040
|
||||
#define GDT_SIZE 7
|
||||
#define GDT_SIZE 8
|
||||
|
||||
// https://wiki.osdev.org/Global_Descriptor_Table#GDTR
|
||||
struct gdt_descriptor {
|
||||
@ -11,6 +12,8 @@ struct gdt_descriptor {
|
||||
uint32_t base;
|
||||
} __attribute__((packed));
|
||||
|
||||
extern struct tss TSS;
|
||||
|
||||
void init_gdt();
|
||||
|
||||
#define GDT_FLAG_64BIT_MODE 0b0010
|
||||
@ -39,3 +42,4 @@ extern uint8_t gdt_entries[GDT_SIZE * 8];
|
||||
#define GDT_OFFSET_USER_CODE 0x20
|
||||
#define GDT_OFFSET_USER_DATA 0x28
|
||||
#define GDT_OFFSET_USER_STACK 0x30
|
||||
#define GDT_OFFSET_TSS 0x38
|
||||
|
23
headers/task.h
Normal file
23
headers/task.h
Normal file
@ -0,0 +1,23 @@
|
||||
#pragma once
|
||||
|
||||
#include "list.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
enum status { ZOMBIE, THREAD, RUN };
|
||||
|
||||
struct task {
|
||||
uint32_t *esp;
|
||||
uint32_t *esp0;
|
||||
uint32_t *cr3;
|
||||
uint16_t pid;
|
||||
uint8_t status;
|
||||
struct task *daddy;
|
||||
struct task *child;
|
||||
struct list **signals;
|
||||
uint8_t owner_id;
|
||||
struct task *next;
|
||||
};
|
||||
|
||||
void scheduler(void);
|
||||
void switch_to_task(struct task *next_task);
|
60
headers/tss.h
Normal file
60
headers/tss.h
Normal file
@ -0,0 +1,60 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
// _h fields are for the offset
|
||||
struct tss {
|
||||
uint16_t link;
|
||||
uint16_t link_h;
|
||||
|
||||
uint32_t esp0;
|
||||
uint16_t ss0;
|
||||
uint16_t ss0_h;
|
||||
|
||||
uint32_t esp1;
|
||||
uint16_t ss1;
|
||||
uint16_t ss1_h;
|
||||
|
||||
uint32_t esp2;
|
||||
uint16_t ss2;
|
||||
uint16_t ss2_h;
|
||||
|
||||
uint32_t cr3;
|
||||
uint32_t eip;
|
||||
uint32_t eflags;
|
||||
|
||||
uint32_t eax;
|
||||
uint32_t ecx;
|
||||
uint32_t edx;
|
||||
uint32_t ebx;
|
||||
|
||||
uint32_t esp;
|
||||
uint32_t ebp;
|
||||
|
||||
uint32_t esi;
|
||||
uint32_t edi;
|
||||
|
||||
uint16_t es;
|
||||
uint16_t es_h;
|
||||
|
||||
uint16_t cs;
|
||||
uint16_t cs_h;
|
||||
|
||||
uint16_t ss;
|
||||
uint16_t ss_h;
|
||||
|
||||
uint16_t ds;
|
||||
uint16_t ds_h;
|
||||
|
||||
uint16_t fs;
|
||||
uint16_t fs_h;
|
||||
|
||||
uint16_t gs;
|
||||
uint16_t gs_h;
|
||||
|
||||
uint16_t ldt;
|
||||
uint16_t ldt_h;
|
||||
|
||||
uint16_t trap;
|
||||
uint16_t iomap;
|
||||
};
|
Reference in New Issue
Block a user