Improved build system
Added new entries to .gitignore Moved away from source directory as central spot for all source code
This commit is contained in:
		
							
								
								
									
										19
									
								
								kernel/memory/gdt/gdt.s
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								kernel/memory/gdt/gdt.s
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,19 @@
 | 
			
		||||
.global LoadGlobalDescriptorTable
 | 
			
		||||
 | 
			
		||||
	LoadGlobalDescriptorTable:
 | 
			
		||||
		lgdt gdtDescriptor
 | 
			
		||||
 | 
			
		||||
		movw $16, %ax 
 | 
			
		||||
		movw %ax, %ds
 | 
			
		||||
		movw %ax, %es
 | 
			
		||||
		movw %ax, %fs
 | 
			
		||||
		movw %ax, %gs
 | 
			
		||||
		movw %ax, %ss
 | 
			
		||||
		
 | 
			
		||||
		jmp $8,$flush 
 | 
			
		||||
 | 
			
		||||
		flush: 
 | 
			
		||||
		ret
 | 
			
		||||
		
 | 
			
		||||
	
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										46
									
								
								kernel/memory/gdt/gdtc.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										46
									
								
								kernel/memory/gdt/gdtc.cpp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,46 @@
 | 
			
		||||
#include "gdtc.h"
 | 
			
		||||
#include "../../terminal/kterm.h"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
SegmentDescriptor GlobalDescriptorTable[6];
 | 
			
		||||
GlobalDescriptorTableDescriptor gdtDescriptor;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void add_descriptor(int which , unsigned long base, unsigned long limit, unsigned char access, unsigned char granularity ){
 | 
			
		||||
   GlobalDescriptorTable[which].base_low = (base & 0xFFFF );
 | 
			
		||||
   GlobalDescriptorTable[which].base_middle = (base >> 6) & 0xFF;
 | 
			
		||||
   GlobalDescriptorTable[which].base_high = (base >> 24) & 0xFF;
 | 
			
		||||
   
 | 
			
		||||
   GlobalDescriptorTable[which].limit_low = (limit & 0xFFFF);
 | 
			
		||||
   GlobalDescriptorTable[which].granularity = ((limit >> 16) & 0x0F);
 | 
			
		||||
 | 
			
		||||
   GlobalDescriptorTable[which].granularity |= (granularity & 0xF0);
 | 
			
		||||
   GlobalDescriptorTable[which].access = access;
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void initGDT(){
 | 
			
		||||
 | 
			
		||||
      // NULL segment
 | 
			
		||||
      add_descriptor(NULL_SEGMENT, 0,0,0,0);
 | 
			
		||||
 | 
			
		||||
      // Kernel Code Segment
 | 
			
		||||
      add_descriptor(KERNEL_CODE_SEGMENT, 0, 0xFFFFFFFF, 0x9A, 0xCF);
 | 
			
		||||
 | 
			
		||||
      // Kernel Data Segment
 | 
			
		||||
      add_descriptor(KERNEL_DATA_SEGMENT, 0, 0xFFFFFFFF, 0x92, 0xCF);      
 | 
			
		||||
 | 
			
		||||
      // User Code Segment
 | 
			
		||||
      add_descriptor(USER_CODE_SEGMENT, 0, 0xFFFFFFFF, 0xFA, 0xCF);
 | 
			
		||||
      
 | 
			
		||||
      // User Data Segement
 | 
			
		||||
      add_descriptor(USER_DATA_SEGMENT, 0, 0xFFFFFFFF, 0xF2, 0xCF);
 | 
			
		||||
 | 
			
		||||
      // init Gdt Descriptor
 | 
			
		||||
      gdtDescriptor.limit = ((sizeof(SegmentDescriptor ) * 6 ) - 1);
 | 
			
		||||
      gdtDescriptor.base = (unsigned int) (&GlobalDescriptorTable);
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										35
									
								
								kernel/memory/gdt/gdtc.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								kernel/memory/gdt/gdtc.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,35 @@
 | 
			
		||||
#pragma once
 | 
			
		||||
#include <stdint.h>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#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
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
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));
 | 
			
		||||
 | 
			
		||||
extern SegmentDescriptor GlobalDescriptorTable[6];
 | 
			
		||||
 | 
			
		||||
struct GlobalDescriptorTableDescriptor{
 | 
			
		||||
   unsigned short limit;
 | 
			
		||||
   unsigned int base;
 | 
			
		||||
}__attribute__((packed)) ;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void add_descriptor(int which , unsigned long base, unsigned long limit, unsigned char access, unsigned char granularity );
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void initGDT();
 | 
			
		||||
		Reference in New Issue
	
	Block a user