Merge into main the new state of the operating system/kernel #1
6
Makefile
6
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)/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
|
||||||
@ -77,6 +77,10 @@ $(BUILD_DIR)/PageDirectory.o:
|
|||||||
$(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/arch/i386/idt/idt.cpp -o $(BUILD_DIR)/idt.o $(CFLAGS) -fno-exceptions -fno-rtti
|
||||||
|
|
||||||
|
$(BUILD_DIR)/gdtc.o:
|
||||||
|
$(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/arch/i386/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
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ _start:
|
|||||||
|
|
||||||
call early_main
|
call early_main
|
||||||
cli
|
cli
|
||||||
|
.global load_gdt
|
||||||
load_gdt:
|
load_gdt:
|
||||||
lgdt gdt
|
lgdt gdt
|
||||||
|
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
#include "../tty/kterm.h"
|
#include "../tty/kterm.h"
|
||||||
|
|
||||||
gdtEntry_t gdt[3];
|
gdtEntry_t gdt[3];
|
||||||
|
gdtSegmentPointer gdtPointer{};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void gdtSetGate(int num, uint64_t base, uint64_t limit, uint8_t access,
|
void gdtSetGate(int num, uint64_t base, uint64_t limit, uint8_t access,
|
||||||
@ -18,14 +20,12 @@ void gdtSetGate(int num, uint64_t base, uint64_t limit, uint8_t access,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void setupGdt(){
|
void setupGdt(){
|
||||||
|
|
||||||
printf("setupGdt is called!");
|
|
||||||
gdtPointer.limit = (sizeof(gdtEntry_t) * 3) - 1;
|
gdtPointer.limit = (sizeof(gdtEntry_t) * 3) - 1;
|
||||||
gdtPointer.base = &gdt;
|
gdtPointer.base = (uint32_t) &gdt;
|
||||||
|
|
||||||
gdtSetGate(0, 0, 0, 0, 0);
|
gdtSetGate(0, 0, 0, 0, 0);
|
||||||
gdtSetGate(1, 0, 0xFFFFFFFF, 0x9A, 0xCF);
|
gdtSetGate(1, 0, 0xFFFFFFFF, 0x9A, 0xCF);
|
||||||
gdtSetGate(2, 0, 0xFFFFFFFF, 0x92, 0xCF);
|
gdtSetGate(2, 0, 0xFFFFFFFF, 0x92, 0xCF);
|
||||||
|
printf("call to load gdt\n");
|
||||||
loadGdt();
|
load_gdt();
|
||||||
}
|
}
|
||||||
|
@ -10,11 +10,13 @@ typedef struct {
|
|||||||
uint8_t hBase;
|
uint8_t hBase;
|
||||||
} gdtEntry_t;
|
} gdtEntry_t;
|
||||||
|
|
||||||
struct {
|
struct gdtSegmentPointer {
|
||||||
uint16_t limit;
|
uint16_t limit;
|
||||||
uint32_t base;
|
uint32_t base;
|
||||||
} gdtPointer;
|
};
|
||||||
|
|
||||||
extern void loadGdt();
|
extern gdtSegmentPointer gdtPointer;
|
||||||
|
|
||||||
|
extern void load_gdt();
|
||||||
void setupGdt();
|
void setupGdt();
|
||||||
}
|
}
|
@ -26,17 +26,18 @@
|
|||||||
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");
|
||||||
//setupGdt();
|
setupGdt();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" void kernel_main (void) {
|
extern "C" void kernel_main (void) {
|
||||||
|
|
||||||
|
printf("call to init serial\n");
|
||||||
init_serial();
|
init_serial();
|
||||||
|
|
||||||
while (false){
|
while (true){
|
||||||
//Read time indefinetely
|
//Read time indefinetely
|
||||||
read_rtc();
|
read_rtc();
|
||||||
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);
|
||||||
|
Loading…
Reference in New Issue
Block a user