Compare commits
4 Commits
32909aaed9
...
23ede25ed6
Author | SHA1 | Date | |
---|---|---|---|
23ede25ed6 | |||
ba043ef31b | |||
88c5196586 | |||
3a87b74224 |
42
Makefile
42
Makefile
@ -5,7 +5,7 @@ CC = ${HOME}/opt/cross/bin/i686-elf-gcc
|
|||||||
CPP = ${HOME}/opt/cross/bin/i686-elf-g++
|
CPP = ${HOME}/opt/cross/bin/i686-elf-g++
|
||||||
CFLAGS = -ffreestanding -O2 -Wall -Wextra
|
CFLAGS = -ffreestanding -O2 -Wall -Wextra
|
||||||
|
|
||||||
OFILES = $(BUILD_DIR)/boot.o $(BUILD_DIR)/kterm.o $(BUILD_DIR)/kernel.o $(BUILD_DIR)/PhysicalMemoryManager.o $(BUILD_DIR)/io.o $(BUILD_DIR)/PageDirectory.o $(BUILD_DIR)/gdtc.o $(BUILD_DIR)/idt.o $(BUILD_DIR)/pic.o $(BUILD_DIR)/string.o
|
OFILES = $(BUILD_DIR)/boot.o $(BUILD_DIR)/kterm.o $(BUILD_DIR)/kernel.o $(BUILD_DIR)/PhysicalMemoryManager.o $(BUILD_DIR)/io.o $(BUILD_DIR)/PageDirectory.o $(BUILD_DIR)/gdtc.o $(BUILD_DIR)/idt.o $(BUILD_DIR)/pic.o $(BUILD_DIR)/string.o
|
||||||
|
|
||||||
SRC_DIR = src
|
SRC_DIR = src
|
||||||
BUILD_DIR = build
|
BUILD_DIR = build
|
||||||
@ -19,31 +19,27 @@ OBJ_LINK_LIST = $(CRTI_OBJ) $(CRTBEGIN_OBJ) $(OFILES) $(CRTEND_OBJ) $(CRTN_OBJ)
|
|||||||
INTERNAL_OBJS = $(CRTI_OBJ) $(OFILES) $(CRTN_OBJ)
|
INTERNAL_OBJS = $(CRTI_OBJ) $(OFILES) $(CRTN_OBJ)
|
||||||
|
|
||||||
|
|
||||||
all: clean build clean_up
|
all: clean build
|
||||||
|
|
||||||
build: build_kernel
|
build: build_kernel iso
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
clean_iso:
|
clean_iso:
|
||||||
if [[ -a isodir/* ]] ; then rm isodir/* -d ; fi
|
if [[ -a isodir/boot ]] ; then rm root/boot -rd ; fi
|
||||||
if [ -f barinkOS.iso ] ; then rm barinkOS.iso ; fi
|
if [ -f build/barinkOS.iso ] ; then rm build/barinkOS.iso ; fi
|
||||||
|
|
||||||
iso: clean_iso build
|
iso: clean_iso clean build
|
||||||
mkdir -p isodir/boot/grub
|
mkdir -p root/boot/grub
|
||||||
cp build/myos.bin isodir/boot/myos.bin
|
cp build/myos.bin root/boot/myos.bin
|
||||||
cp src/grub.cfg isodir/boot/grub/grub.cfg
|
cp src/grub.cfg root/boot/grub/grub.cfg
|
||||||
grub-mkrescue -o barinkOS.iso isodir
|
grub-mkrescue -o build/barinkOS.iso root
|
||||||
|
|
||||||
clean_up:
|
|
||||||
rm build/*.o
|
|
||||||
|
|
||||||
test:
|
test:
|
||||||
$(EMULATOR) -kernel $(BUILD_DIR)/myos.bin -serial file:CON -vga std -monitor stdio -display gtk -m 2G -cpu core2duo
|
$(EMULATOR) -kernel $(BUILD_DIR)/myos.bin -serial stdio -vga std -monitor stdio -display gtk -m 2G -cpu core2duo
|
||||||
|
|
||||||
build_kernel: $(OBJ_LINK_LIST)
|
build_kernel: $(OBJ_LINK_LIST)
|
||||||
|
$(CC) -T $(SRC_DIR)/kernel//linker.ld -o $(BUILD_DIR)/myos.bin \
|
||||||
$(CC) -T $(SRC_DIR)/kernel/arch/i386/linker.ld -o $(BUILD_DIR)/myos.bin \
|
|
||||||
-ffreestanding -O2 -nostdlib $(OBJ_LINK_LIST) -lgcc
|
-ffreestanding -O2 -nostdlib $(OBJ_LINK_LIST) -lgcc
|
||||||
|
|
||||||
build_x86_64:
|
build_x86_64:
|
||||||
@ -57,16 +53,16 @@ $(BUILD_DIR)/kernel.o:
|
|||||||
$(CPP) -c $(SRC_DIR)/kernel/kernel.cpp -o $(BUILD_DIR)/kernel.o $(CFLAGS) -fno-exceptions -fno-rtti
|
$(CPP) -c $(SRC_DIR)/kernel/kernel.cpp -o $(BUILD_DIR)/kernel.o $(CFLAGS) -fno-exceptions -fno-rtti
|
||||||
|
|
||||||
$(BUILD_DIR)/kterm.o:
|
$(BUILD_DIR)/kterm.o:
|
||||||
$(CPP) -c $(SRC_DIR)/kernel/arch/i386/tty/kterm.cpp -o $(BUILD_DIR)/kterm.o $(CFLAGS) -fno-exceptions -fno-rtti
|
$(CPP) -c $(SRC_DIR)/kernel/tty/kterm.cpp -o $(BUILD_DIR)/kterm.o $(CFLAGS) -fno-exceptions -fno-rtti
|
||||||
|
|
||||||
$(BUILD_DIR)/boot.o:
|
$(BUILD_DIR)/boot.o:
|
||||||
$(AS) $(SRC_DIR)/kernel/arch/i386/boot.S -o $(BUILD_DIR)/boot.o
|
$(AS) $(SRC_DIR)/kernel//boot.S -o $(BUILD_DIR)/boot.o
|
||||||
|
|
||||||
$(BUILD_DIR)/crti.o:
|
$(BUILD_DIR)/crti.o:
|
||||||
$(AS) $(SRC_DIR)/kernel/arch/i386/crti.s -o $(BUILD_DIR)/crti.o
|
$(AS) $(SRC_DIR)/kernel/crti.s -o $(BUILD_DIR)/crti.o
|
||||||
|
|
||||||
$(BUILD_DIR)/crtn.o:
|
$(BUILD_DIR)/crtn.o:
|
||||||
$(AS) $(SRC_DIR)/kernel/arch/i386/crtn.s -o $(BUILD_DIR)/crtn.o
|
$(AS) $(SRC_DIR)/kernel/crtn.s -o $(BUILD_DIR)/crtn.o
|
||||||
|
|
||||||
$(BUILD_DIR)/io.o:
|
$(BUILD_DIR)/io.o:
|
||||||
$(CPP) -c $(SRC_DIR)/kernel/io.cpp -o $(BUILD_DIR)/io.o $(CFLAGS) -fno-exceptions -fno-rtti
|
$(CPP) -c $(SRC_DIR)/kernel/io.cpp -o $(BUILD_DIR)/io.o $(CFLAGS) -fno-exceptions -fno-rtti
|
||||||
@ -75,14 +71,14 @@ $(BUILD_DIR)/PageDirectory.o:
|
|||||||
$(CPP) -c $(SRC_DIR)/kernel/memory/PageDirectory.cpp -o $(BUILD_DIR)/PageDirectory.o $(CFLAGS) -fno-exceptions -fno-rtti
|
$(CPP) -c $(SRC_DIR)/kernel/memory/PageDirectory.cpp -o $(BUILD_DIR)/PageDirectory.o $(CFLAGS) -fno-exceptions -fno-rtti
|
||||||
|
|
||||||
$(BUILD_DIR)/idt.o:
|
$(BUILD_DIR)/idt.o:
|
||||||
$(CPP) -c $(SRC_DIR)/kernel/arch/i386/idt/idt.cpp -o $(BUILD_DIR)/idt.o $(CFLAGS) -fno-exceptions -fno-rtti
|
$(CPP) -c $(SRC_DIR)/kernel/idt/idt.cpp -o $(BUILD_DIR)/idt.o $(CFLAGS) -fno-exceptions -fno-rtti
|
||||||
|
|
||||||
$(BUILD_DIR)/gdtc.o:
|
$(BUILD_DIR)/gdtc.o:
|
||||||
$(CPP) -c $(SRC_DIR)/kernel/arch/i386/gdt/gdtc.cpp -o $(BUILD_DIR)/gdtc.o $(CFLAGS) -fno-exceptions -fno-rtti
|
$(CPP) -c $(SRC_DIR)/kernel/gdt/gdtc.cpp -o $(BUILD_DIR)/gdtc.o $(CFLAGS) -fno-exceptions -fno-rtti
|
||||||
|
|
||||||
|
|
||||||
$(BUILD_DIR)/pic.o:
|
$(BUILD_DIR)/pic.o:
|
||||||
$(CPP) -c $(SRC_DIR)/kernel/arch/i386/pic/pic.cpp -o $(BUILD_DIR)/pic.o $(CFLAGS) -fno-exceptions -fno-rtti
|
$(CPP) -c $(SRC_DIR)/kernel/pic/pic.cpp -o $(BUILD_DIR)/pic.o $(CFLAGS) -fno-exceptions -fno-rtti
|
||||||
|
|
||||||
$(BUILD_DIR)/string.o:
|
$(BUILD_DIR)/string.o:
|
||||||
$(CC) -c $(SRC_DIR)/libc/include/string.c -o $(BUILD_DIR)/string.o $(CFLAGS) -std=gnu99
|
$(CC) -c $(SRC_DIR)/libc/include/string.c -o $(BUILD_DIR)/string.o $(CFLAGS) -std=gnu99
|
||||||
|
@ -28,8 +28,8 @@ screen. The terminal/screen has scrolling so the latest messages are visible on
|
|||||||
|
|
||||||
________________________
|
________________________
|
||||||
### Planning
|
### Planning
|
||||||
[See TODO](TODO.md)
|
[See TODO](todo.md) \
|
||||||
|
[See Features](features.md)
|
||||||
________________________
|
________________________
|
||||||
### Docs
|
### Docs
|
||||||
[Intro](docs/Intro.md) \
|
[Intro](docs/Intro.md) \
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
<input type="checkbox" /> Detect CPU speed \
|
<input type="checkbox" /> Detect CPU speed \
|
||||||
<input type="checkbox" checked/> Interrupt / exception system (API) \
|
<input type="checkbox" checked/> Interrupt / exception system (API) \
|
||||||
|
|
||||||
<input type="checkbox" /> Plan your memory map (virtual, and physical) : decide where you want the data to be. \
|
<input type="checkbox" checked/> Plan your memory map (virtual, and physical) : decide where you want the data to be. \
|
||||||
<input type="checkbox" /> The heap: allocating memory at runtime (malloc and free) is almost impossible to go without. \
|
<input type="checkbox" /> The heap: allocating memory at runtime (malloc and free) is almost impossible to go without. \
|
||||||
<input type="checkbox" /> Enable SIMD Extensions (SSE)
|
<input type="checkbox" /> Enable SIMD Extensions (SSE)
|
||||||
|
|
||||||
@ -23,13 +23,13 @@
|
|||||||
<input type="checkbox" /> ACPI support ( Or some other basic way to support shutdown, reboot and possibly hibernation ) \
|
<input type="checkbox" /> ACPI support ( Or some other basic way to support shutdown, reboot and possibly hibernation ) \
|
||||||
<input type="checkbox" /> ATAPI support \
|
<input type="checkbox" /> ATAPI support \
|
||||||
<input type="checkbox" /> Keyboard support ( P/S2 Keyboard) \
|
<input type="checkbox" /> Keyboard support ( P/S2 Keyboard) \
|
||||||
<input type="checkbox" /> Memory Management (MMU)\
|
<input type="checkbox" checked/> Memory Management (MMU)
|
||||||
<input type="checkbox" /> Preemptive multi tasking
|
<input type="checkbox" /> Preemptive multi tasking \
|
||||||
<input type="checkbox" /> Processes
|
<input type="checkbox" /> Processes \
|
||||||
<input type="checkbox" /> Threads
|
<input type="checkbox" /> Threads
|
||||||
<input type="checkbox" /> Scheduling (SRV2 Unix OR Priority Based Round Robin) \
|
<input type="checkbox" /> Scheduling (SRV2 Unix OR Priority Based Round Robin) \
|
||||||
<input type="checkbox" /> System V ABI compliance (partially)
|
<input type="checkbox" /> System V ABI compliance (partially) \
|
||||||
<input type="checkbox" /> POSIX compliance (partially)
|
<input type="checkbox" /> POSIX compliance (partially) \
|
||||||
<input type="checkbox" /> RPC - for interprocess communication \
|
<input type="checkbox" /> RPC - for interprocess communication \
|
||||||
<input type="checkbox" /> Sync primitives - Semaphores, Mutexes, spinlocks et al. \
|
<input type="checkbox" /> Sync primitives - Semaphores, Mutexes, spinlocks et al. \
|
||||||
<input type="checkbox" /> Basic Terminal \
|
<input type="checkbox" /> Basic Terminal \
|
||||||
@ -37,4 +37,4 @@
|
|||||||
<input type="checkbox" /> Basic Window server/client \
|
<input type="checkbox" /> Basic Window server/client \
|
||||||
## Support for more filesystems if I like the challenge in writing these ...
|
## Support for more filesystems if I like the challenge in writing these ...
|
||||||
<input type="checkbox" /> FAT Filesystem \
|
<input type="checkbox" /> FAT Filesystem \
|
||||||
<input type="checkbox" /> EXT2 Filesystem \
|
<input type="checkbox" /> EXT2 Filesystem
|
@ -1,37 +0,0 @@
|
|||||||
/* Tell processor to use our gdt*/
|
|
||||||
gdt:
|
|
||||||
.word (gdt_end - gdt_start -1) # Size of the GDT in bytes minus 1 for math reasons
|
|
||||||
.int gdt_start # linear address of our GDT
|
|
||||||
|
|
||||||
|
|
||||||
.att_syntax
|
|
||||||
|
|
||||||
|
|
||||||
.size _start, . - _start
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Create the GDT
|
|
||||||
*/
|
|
||||||
.section .data
|
|
||||||
gdt_start:
|
|
||||||
gdt_null:
|
|
||||||
.long 0x0
|
|
||||||
.long 0x0
|
|
||||||
|
|
||||||
gdt_kcode:
|
|
||||||
.word 0xFFFF # limit
|
|
||||||
.word 0x0 # base
|
|
||||||
.byte 0x0 # base
|
|
||||||
.byte 0b10011010 # 1st flags | type flags
|
|
||||||
.byte 0b11001111 # 2nd flags | limit
|
|
||||||
.byte 0x0 # base
|
|
||||||
|
|
||||||
gdt_kdata:
|
|
||||||
.word 0xFFFF # limit
|
|
||||||
.word 0x0 # base
|
|
||||||
.byte 0x0 # base
|
|
||||||
.byte 0b10010010 # 1st flags | type flags
|
|
||||||
.byte 0b11001111 # 2nd flags | limit
|
|
||||||
.byte 0x0 # base
|
|
||||||
gdt_end:
|
|
@ -1,31 +0,0 @@
|
|||||||
#include "gdtc.h"
|
|
||||||
#include "../tty/kterm.h"
|
|
||||||
|
|
||||||
gdtEntry_t gdt[3];
|
|
||||||
gdtSegmentPointer gdtPointer{};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void gdtSetGate(int num, uint64_t base, uint64_t limit, uint8_t access,
|
|
||||||
uint8_t gran){
|
|
||||||
gdt[num].lBase = (base & 0xFFFF);
|
|
||||||
gdt[num].mBase = (base >> 16) & 0xFF;
|
|
||||||
gdt[num].hBase = (base >> 24) & 0xFF;
|
|
||||||
|
|
||||||
gdt[num].lLimit = (limit & 0xFFFF);
|
|
||||||
gdt[num].granularity = ((limit >> 16) & 0x0F);
|
|
||||||
|
|
||||||
gdt[num].granularity |= (gran & 0xF0);
|
|
||||||
gdt[num].access = access;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setupGdt(){
|
|
||||||
gdtPointer.limit = (sizeof(gdtEntry_t) * 3) - 1;
|
|
||||||
gdtPointer.base = (uint32_t) &gdt;
|
|
||||||
|
|
||||||
gdtSetGate(0, 0, 0, 0, 0);
|
|
||||||
gdtSetGate(1, 0, 0xFFFFFFFF, 0x9A, 0xCF);
|
|
||||||
gdtSetGate(2, 0, 0xFFFFFFFF, 0x92, 0xCF);
|
|
||||||
printf("call to load gdt\n");
|
|
||||||
load_gdt();
|
|
||||||
}
|
|
@ -1,22 +0,0 @@
|
|||||||
#include <stdint.h>
|
|
||||||
extern "C"{
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
uint16_t lLimit;
|
|
||||||
uint16_t lBase;
|
|
||||||
uint8_t mBase;
|
|
||||||
uint8_t access;
|
|
||||||
uint8_t granularity;
|
|
||||||
uint8_t hBase;
|
|
||||||
} gdtEntry_t;
|
|
||||||
|
|
||||||
struct gdtSegmentPointer {
|
|
||||||
uint16_t limit;
|
|
||||||
uint32_t base;
|
|
||||||
};
|
|
||||||
|
|
||||||
extern gdtSegmentPointer gdtPointer;
|
|
||||||
|
|
||||||
extern void load_gdt();
|
|
||||||
void setupGdt();
|
|
||||||
}
|
|
@ -21,10 +21,10 @@ stack_bottom:
|
|||||||
stack_top:
|
stack_top:
|
||||||
|
|
||||||
.section .text
|
.section .text
|
||||||
.include "./src/kernel/arch/i386/irs_table.s"
|
.include "./src/kernel/irs_table.s"
|
||||||
.include "./src/kernel/arch/i386/irq_table.s"
|
.include "./src/kernel/irq_table.s"
|
||||||
.include "./src/kernel/arch/i386/idt/idt.s"
|
.include "./src/kernel/idt/idt.s"
|
||||||
.include "./src/kernel/arch/i386/paging.s"
|
.include "./src/kernel/paging.s"
|
||||||
|
|
||||||
|
|
||||||
.global _start
|
.global _start
|
||||||
@ -46,23 +46,12 @@ _start:
|
|||||||
|
|
||||||
call early_main
|
call early_main
|
||||||
cli
|
cli
|
||||||
.global load_gdt
|
|
||||||
load_gdt:
|
|
||||||
lgdt gdt
|
|
||||||
|
|
||||||
# set the segment selecters
|
.include "./src/kernel/gdt/gdt.s"
|
||||||
|
|
||||||
movw $0x10, %ax
|
loadIDT:
|
||||||
movw %ax, %ds
|
|
||||||
movw %ax, %es
|
|
||||||
movw %ax, %fs
|
|
||||||
movw %ax, %gs
|
|
||||||
movw %ax, %ss
|
|
||||||
ljmp $0x08, $flush
|
|
||||||
|
|
||||||
flush:
|
|
||||||
|
|
||||||
|
|
||||||
#load idt
|
#load idt
|
||||||
call init_idt
|
call init_idt
|
||||||
sti
|
sti
|
||||||
@ -84,6 +73,6 @@ _start:
|
|||||||
cli
|
cli
|
||||||
1: hlt
|
1: hlt
|
||||||
jmp 1b
|
jmp 1b
|
||||||
|
|
||||||
|
|
||||||
.include "./src/kernel/arch/i386/gdt/gdt.s"
|
|
||||||
|
.size _start, . - _start
|
@ -2,7 +2,7 @@
|
|||||||
#include "bootloader/multiboot.h"
|
#include "bootloader/multiboot.h"
|
||||||
#define CHECK_FLAG(flags, bit) ((flags) & (1 <<(bit)))
|
#define CHECK_FLAG(flags, bit) ((flags) & (1 <<(bit)))
|
||||||
|
|
||||||
#include "arch/i386/tty/kterm.h"
|
#include "tty/kterm.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
19
src/kernel/gdt/gdt.s
Normal file
19
src/kernel/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
|
||||||
|
|
||||||
|
|
||||||
|
|
61
src/kernel/gdt/gdtc.cpp
Normal file
61
src/kernel/gdt/gdtc.cpp
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
#include "gdtc.h"
|
||||||
|
#include "../tty/kterm.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
|
||||||
|
|
||||||
|
SegmentDescriptor GlobalDescriptorTable[5];
|
||||||
|
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
|
||||||
|
// TODO:
|
||||||
|
|
||||||
|
// User Data Segement
|
||||||
|
// TODO:
|
||||||
|
|
||||||
|
// init Gdt Descriptor
|
||||||
|
gdtDescriptor.limit = ((sizeof(SegmentDescriptor ) * 5 ) - 1);
|
||||||
|
gdtDescriptor.base = (unsigned int) &GlobalDescriptorTable;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
LoadGlobalDescriptorTable();
|
||||||
|
|
||||||
|
while (true)
|
||||||
|
asm volatile("hlt");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
27
src/kernel/gdt/gdtc.h
Normal file
27
src/kernel/gdt/gdtc.h
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
|
||||||
|
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));
|
||||||
|
|
||||||
|
|
||||||
|
struct GlobalDescriptorTableDescriptor{
|
||||||
|
unsigned short limit;
|
||||||
|
unsigned int base;
|
||||||
|
}__attribute__((packed));
|
||||||
|
|
||||||
|
extern SegmentDescriptor GlobalDescriptorTable[];
|
||||||
|
extern GlobalDescriptorTableDescriptor gdtDescriptor;
|
||||||
|
|
||||||
|
|
||||||
|
void add_descriptor(int which , unsigned long base, unsigned long limit, unsigned char access, unsigned char granularity );
|
||||||
|
|
||||||
|
|
||||||
|
extern "C" void LoadGlobalDescriptorTable();
|
||||||
|
void initGDT();
|
@ -26,8 +26,7 @@
|
|||||||
printf("kernel: 0x%x - 0x%x\n", &kernel_begin , &kernel_end);
|
printf("kernel: 0x%x - 0x%x\n", &kernel_begin , &kernel_end);
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Call to setupGdt!\n");
|
initGDT();
|
||||||
setupGdt();
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -43,6 +42,9 @@
|
|||||||
printf( "UTC time: %02d-%02d-%02d %02d:%02d:%02d [ Formatted as YY-MM-DD h:mm:ss]\r" ,year, month, day, hour, minute, second);
|
printf( "UTC time: %02d-%02d-%02d %02d:%02d:%02d [ Formatted as YY-MM-DD h:mm:ss]\r" ,year, month, day, hour, minute, second);
|
||||||
delay(1000);
|
delay(1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,15 +2,15 @@
|
|||||||
extern "C"{
|
extern "C"{
|
||||||
#include "../libc/include/string.h"
|
#include "../libc/include/string.h"
|
||||||
}
|
}
|
||||||
#include "arch/i386/vga/VBE.h"
|
#include "vga/VBE.h"
|
||||||
#include "arch/i386/tty/kterm.h"
|
#include "tty/kterm.h"
|
||||||
|
|
||||||
#include "./bootloader/multiboot.h"
|
#include "./bootloader/multiboot.h"
|
||||||
#include "bootcheck.h"
|
#include "bootcheck.h"
|
||||||
#include "memory/PhysicalMemoryManager.h"
|
#include "memory/PhysicalMemoryManager.h"
|
||||||
|
|
||||||
#include "arch/i386/gdt/gdtc.h"
|
#include "gdt/gdtc.h"
|
||||||
#include "arch/i386/idt/idt.h"
|
#include "idt/idt.h"
|
||||||
|
|
||||||
#include "io.h"
|
#include "io.h"
|
||||||
#include "time.h"
|
#include "time.h"
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
|
|
||||||
void PageDirectory::enable(){
|
void PageDirectory::enable(){
|
||||||
|
// https://wiki.osdev.org/Setting_Up_Paging
|
||||||
//set each entry to not present
|
//set each entry to not present
|
||||||
int i;
|
int i;
|
||||||
for(i = 0; i < 1024; i++)
|
for(i = 0; i < 1024; i++)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "../../../io.h"
|
#include "../io.h"
|
||||||
|
|
||||||
#define PIC1 0x20 /* IO base address for master PIC */
|
#define PIC1 0x20 /* IO base address for master PIC */
|
||||||
#define PIC2 0xA0 /* IO base address for slave PIC */
|
#define PIC2 0xA0 /* IO base address for slave PIC */
|
@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "arch/i386/tty/kterm.h"
|
#include "tty/kterm.h"
|
||||||
#include "io.h"
|
#include "io.h"
|
||||||
#define PORT 0x3f8
|
#define PORT 0x3f8
|
||||||
static int init_serial() {
|
static int init_serial() {
|
||||||
|
@ -5,10 +5,10 @@
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
#include "../vga/colors.h"
|
#include "../vga/colors.h"
|
||||||
#include "../../../io.h"
|
#include "../io.h"
|
||||||
|
|
||||||
extern "C"{
|
extern "C"{
|
||||||
#include "./../../../../libc/include/string.h"
|
#include "./../../libc/include/string.h"
|
||||||
}
|
}
|
||||||
|
|
||||||
void kterm_init();
|
void kterm_init();
|
Loading…
x
Reference in New Issue
Block a user