Compare commits
No commits in common. "23ede25ed61a7f242b5d855e06eb002f6d07e2e5" and "32909aaed9b709a5692c79861b708cdd3942cf17" have entirely different histories.
23ede25ed6
...
32909aaed9
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,27 +19,31 @@ 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
|
all: clean build clean_up
|
||||||
|
|
||||||
build: build_kernel iso
|
build: build_kernel
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
clean_iso:
|
clean_iso:
|
||||||
if [[ -a isodir/boot ]] ; then rm root/boot -rd ; fi
|
if [[ -a isodir/* ]] ; then rm isodir/* -d ; fi
|
||||||
if [ -f build/barinkOS.iso ] ; then rm build/barinkOS.iso ; fi
|
if [ -f barinkOS.iso ] ; then rm barinkOS.iso ; fi
|
||||||
|
|
||||||
iso: clean_iso clean build
|
iso: clean_iso build
|
||||||
mkdir -p root/boot/grub
|
mkdir -p isodir/boot/grub
|
||||||
cp build/myos.bin root/boot/myos.bin
|
cp build/myos.bin isodir/boot/myos.bin
|
||||||
cp src/grub.cfg root/boot/grub/grub.cfg
|
cp src/grub.cfg isodir/boot/grub/grub.cfg
|
||||||
grub-mkrescue -o build/barinkOS.iso root
|
grub-mkrescue -o barinkOS.iso isodir
|
||||||
|
|
||||||
|
clean_up:
|
||||||
|
rm build/*.o
|
||||||
|
|
||||||
test:
|
test:
|
||||||
$(EMULATOR) -kernel $(BUILD_DIR)/myos.bin -serial stdio -vga std -monitor stdio -display gtk -m 2G -cpu core2duo
|
$(EMULATOR) -kernel $(BUILD_DIR)/myos.bin -serial file:CON -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:
|
||||||
@ -53,16 +57,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/tty/kterm.cpp -o $(BUILD_DIR)/kterm.o $(CFLAGS) -fno-exceptions -fno-rtti
|
$(CPP) -c $(SRC_DIR)/kernel/arch/i386/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//boot.S -o $(BUILD_DIR)/boot.o
|
$(AS) $(SRC_DIR)/kernel/arch/i386/boot.S -o $(BUILD_DIR)/boot.o
|
||||||
|
|
||||||
$(BUILD_DIR)/crti.o:
|
$(BUILD_DIR)/crti.o:
|
||||||
$(AS) $(SRC_DIR)/kernel/crti.s -o $(BUILD_DIR)/crti.o
|
$(AS) $(SRC_DIR)/kernel/arch/i386/crti.s -o $(BUILD_DIR)/crti.o
|
||||||
|
|
||||||
$(BUILD_DIR)/crtn.o:
|
$(BUILD_DIR)/crtn.o:
|
||||||
$(AS) $(SRC_DIR)/kernel/crtn.s -o $(BUILD_DIR)/crtn.o
|
$(AS) $(SRC_DIR)/kernel/arch/i386/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
|
||||||
@ -71,14 +75,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/idt/idt.cpp -o $(BUILD_DIR)/idt.o $(CFLAGS) -fno-exceptions -fno-rtti
|
$(CPP) -c $(SRC_DIR)/kernel/arch/i386/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/gdt/gdtc.cpp -o $(BUILD_DIR)/gdtc.o $(CFLAGS) -fno-exceptions -fno-rtti
|
$(CPP) -c $(SRC_DIR)/kernel/arch/i386/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/pic/pic.cpp -o $(BUILD_DIR)/pic.o $(CFLAGS) -fno-exceptions -fno-rtti
|
$(CPP) -c $(SRC_DIR)/kernel/arch/i386/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" checked/> Plan your memory map (virtual, and physical) : decide where you want the data to be. \
|
<input type="checkbox" /> 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" checked/> Memory Management (MMU)
|
<input type="checkbox" /> 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 \
|
@ -21,10 +21,10 @@ stack_bottom:
|
|||||||
stack_top:
|
stack_top:
|
||||||
|
|
||||||
.section .text
|
.section .text
|
||||||
.include "./src/kernel/irs_table.s"
|
.include "./src/kernel/arch/i386/irs_table.s"
|
||||||
.include "./src/kernel/irq_table.s"
|
.include "./src/kernel/arch/i386/irq_table.s"
|
||||||
.include "./src/kernel/idt/idt.s"
|
.include "./src/kernel/arch/i386/idt/idt.s"
|
||||||
.include "./src/kernel/paging.s"
|
.include "./src/kernel/arch/i386/paging.s"
|
||||||
|
|
||||||
|
|
||||||
.global _start
|
.global _start
|
||||||
@ -46,12 +46,23 @@ _start:
|
|||||||
|
|
||||||
call early_main
|
call early_main
|
||||||
cli
|
cli
|
||||||
|
.global load_gdt
|
||||||
|
load_gdt:
|
||||||
|
lgdt gdt
|
||||||
|
|
||||||
|
# set the segment selecters
|
||||||
|
|
||||||
|
movw $0x10, %ax
|
||||||
|
movw %ax, %ds
|
||||||
|
movw %ax, %es
|
||||||
|
movw %ax, %fs
|
||||||
|
movw %ax, %gs
|
||||||
|
movw %ax, %ss
|
||||||
|
ljmp $0x08, $flush
|
||||||
|
|
||||||
|
flush:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
.include "./src/kernel/gdt/gdt.s"
|
|
||||||
|
|
||||||
loadIDT:
|
|
||||||
#load idt
|
#load idt
|
||||||
call init_idt
|
call init_idt
|
||||||
sti
|
sti
|
||||||
@ -75,4 +86,4 @@ _start:
|
|||||||
jmp 1b
|
jmp 1b
|
||||||
|
|
||||||
|
|
||||||
.size _start, . - _start
|
.include "./src/kernel/arch/i386/gdt/gdt.s"
|
37
src/kernel/arch/i386/gdt/gdt.s
Normal file
37
src/kernel/arch/i386/gdt/gdt.s
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
/* 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:
|
31
src/kernel/arch/i386/gdt/gdtc.cpp
Normal file
31
src/kernel/arch/i386/gdt/gdtc.cpp
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
#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();
|
||||||
|
}
|
22
src/kernel/arch/i386/gdt/gdtc.h
Normal file
22
src/kernel/arch/i386/gdt/gdtc.h
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
#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();
|
||||||
|
}
|
@ -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 */
|
@ -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();
|
@ -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 "tty/kterm.h"
|
#include "arch/i386/tty/kterm.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,19 +0,0 @@
|
|||||||
.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
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,61 +0,0 @@
|
|||||||
#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");
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -1,27 +0,0 @@
|
|||||||
#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,7 +26,8 @@
|
|||||||
printf("kernel: 0x%x - 0x%x\n", &kernel_begin , &kernel_end);
|
printf("kernel: 0x%x - 0x%x\n", &kernel_begin , &kernel_end);
|
||||||
}
|
}
|
||||||
|
|
||||||
initGDT();
|
printf("Call to setupGdt!\n");
|
||||||
|
setupGdt();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -43,8 +44,5 @@
|
|||||||
delay(1000);
|
delay(1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,15 +2,15 @@
|
|||||||
extern "C"{
|
extern "C"{
|
||||||
#include "../libc/include/string.h"
|
#include "../libc/include/string.h"
|
||||||
}
|
}
|
||||||
#include "vga/VBE.h"
|
#include "arch/i386/vga/VBE.h"
|
||||||
#include "tty/kterm.h"
|
#include "arch/i386/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 "gdt/gdtc.h"
|
#include "arch/i386/gdt/gdtc.h"
|
||||||
#include "idt/idt.h"
|
#include "arch/i386/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,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "tty/kterm.h"
|
#include "arch/i386/tty/kterm.h"
|
||||||
#include "io.h"
|
#include "io.h"
|
||||||
#define PORT 0x3f8
|
#define PORT 0x3f8
|
||||||
static int init_serial() {
|
static int init_serial() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user