2023-02-08 13:07:44 +00:00
|
|
|
#pragma once
|
2021-05-12 22:03:00 +00:00
|
|
|
#include <stdint.h>
|
2023-02-11 11:22:45 +00:00
|
|
|
|
|
|
|
|
|
|
|
#define NULL_SEGMENT 0
|
|
|
|
#define KERNEL_CODE_SEGMENT 1
|
|
|
|
#define KERNEL_DATA_SEGMENT 2
|
|
|
|
#define USER_CODE_SEGMENT 3
|
|
|
|
#define USER_DATA_SEGMENT 4
|
|
|
|
#define TASK_STATE_SEGMENT 5
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-11-16 20:17:49 +00:00
|
|
|
struct SegmentDescriptor {
|
|
|
|
unsigned short limit_low;
|
|
|
|
unsigned short base_low;
|
|
|
|
unsigned char base_middle;
|
|
|
|
unsigned char access;
|
|
|
|
unsigned char granularity;
|
|
|
|
unsigned char base_high;
|
|
|
|
}__attribute__((packed));
|
|
|
|
|
2023-02-11 11:22:45 +00:00
|
|
|
extern SegmentDescriptor GlobalDescriptorTable[6];
|
2021-11-16 20:17:49 +00:00
|
|
|
|
|
|
|
struct GlobalDescriptorTableDescriptor{
|
|
|
|
unsigned short limit;
|
|
|
|
unsigned int base;
|
2023-02-08 13:07:44 +00:00
|
|
|
}__attribute__((packed)) ;
|
2021-11-16 20:17:49 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void add_descriptor(int which , unsigned long base, unsigned long limit, unsigned char access, unsigned char granularity );
|
|
|
|
|
|
|
|
|
|
|
|
void initGDT();
|