[USER] TSS

This commit is contained in:
2016-11-26 13:20:57 +01:00
parent 474914ab1e
commit f63afbb3b1
6 changed files with 42 additions and 19 deletions

View File

@@ -34,9 +34,10 @@ typedef struct cpu_t
thread_t *current_thread;
thread_t *last_thread;
process_t *current_process;
uint64_t gdt[5];
uint64_t gdt[7];
struct gdtp_st gdt_p;
thread_t *scheduler;
tss_t tss;
}__attribute__((packed)) cpu_t;
extern cpu_t cpus[];

View File

@@ -4,6 +4,7 @@
#define SEG_KDATA 0x10
#define SEG_UDATA 0x18
#define SEG_UCODE 0x20
#define SEG_TSS 0x28
#ifdef __ASSEMBLER__
#define GDT_WRITE (1<<41)
@@ -20,6 +21,10 @@
#define GDT_RING3 (3LL<<45)
#define GDT_TSS (9LL<<40)
#define TSS_BLO(base) ((((base)&0xFFFF)<<16) | ((((base)>>16)&0xFF)<<32) | ((((base)>>24)&0xFF)<<56))
#define TSS_BHI(base) (((base)>>32)&0xFFFFFFFF)
#define TSS_LIM(lim) (((lim)&0xFFFF) | ((((lim)>>16)&0xF)<<48))
#include <stdint.h>
extern uint64_t BootGDT;
@@ -32,6 +37,27 @@ struct gdtp_st
uint32_t pad2;
}__attribute__((packed));
typedef struct
{
uint32_t r1;
uint64_t rsp0;
uint64_t rsp1;
uint64_t rsp2;
uint64_t r2;
uint64_t ist1;
uint64_t ist2;
uint64_t ist3;
uint64_t ist4;
uint64_t ist5;
uint64_t ist6;
uint64_t ist7;
uint64_t r3;
uint16_t r4;
uint16_t io_mba;
}__attribute__((packed)) tss_t;
void load_gdt(struct gdtp_st *);
void gdt_init();
void load_tr(uint32_t segment);
#endif