Implemented GDT initialisation
This commit is contained in:
42
arch/x86_64/include/socks/machine/_gdt.h
Normal file
42
arch/x86_64/include/socks/machine/_gdt.h
Normal file
@@ -0,0 +1,42 @@
|
||||
#ifndef SOCKS_X86_64__GDT_H_
|
||||
#define SOCKS_X86_64__GDT_H_
|
||||
|
||||
#include <socks/compiler.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#define NR_GDT_ENTRIES 5
|
||||
|
||||
#define GDT_A_PRESENT (1 << 7)
|
||||
#define GDT_A_USER (3 << 5)
|
||||
#define GDT_A_CODE (3 << 3)
|
||||
#define GDT_A_DATA (8 << 1)
|
||||
#define GDT_A_RPLK (1 << 5)
|
||||
#define GDT_A_CODEREAD (1 << 1)
|
||||
#define GDT_A_DATAWRITE (1 << 1)
|
||||
#define GDT_A_GROWUP (1 << 5)
|
||||
#define GDT_F_64BIT (0x2F)
|
||||
#define GDT_F_32BIT (0x4F)
|
||||
#define GDT_F_16BIT (0xF)
|
||||
|
||||
struct gdt_entry {
|
||||
uint16_t ge_limit_low;
|
||||
uint16_t ge_base_low;
|
||||
uint8_t ge_base_mid;
|
||||
uint8_t ge_access;
|
||||
uint8_t ge_gran;
|
||||
uint8_t ge_base_hi;
|
||||
} __packed;
|
||||
|
||||
struct gdt {
|
||||
struct gdt_entry g_entries[NR_GDT_ENTRIES];
|
||||
} __packed;
|
||||
|
||||
struct gdt_ptr {
|
||||
uint16_t g_limit;
|
||||
uint64_t g_ptr;
|
||||
} __packed;
|
||||
|
||||
extern int gdt_init(struct gdt *gdt, struct gdt_ptr *gdtp);
|
||||
extern int gdt_load(struct gdt_ptr *gdtp);
|
||||
|
||||
#endif
|
||||
0
arch/x86_64/include/socks/machine/_tss.h
Normal file
0
arch/x86_64/include/socks/machine/_tss.h
Normal file
@@ -1,10 +1,15 @@
|
||||
#ifndef SOCKS_X86_64_CPU_H_
|
||||
#define SOCKS_X86_64_CPU_H_
|
||||
|
||||
typedef struct ml_cpu_block {
|
||||
#include <socks/machine/_gdt.h>
|
||||
|
||||
typedef struct ml_cpu_block {
|
||||
struct gdt c_gdt;
|
||||
struct gdt_ptr c_gdt_ptr;
|
||||
} ml_cpu_block;
|
||||
|
||||
extern int ml_init_bootcpu(void);
|
||||
|
||||
extern int ml_cpu_block_init(ml_cpu_block *p);
|
||||
extern int ml_cpu_block_use(ml_cpu_block *p);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user