Merge into main the new state of the operating system/kernel #1
							
								
								
									
										16
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								Makefile
									
									
									
									
									
								
							@ -43,7 +43,7 @@ test:
 | 
			
		||||
 | 
			
		||||
build_kernel: $(OBJ_LINK_LIST)
 | 
			
		||||
	
 | 
			
		||||
	$(CC) -T $(SRC_DIR)/kernel/arch/i386/linker.ld -o $(BUILD_DIR)/myos.bin \
 | 
			
		||||
	$(CC) -T $(SRC_DIR)/kernel//linker.ld -o $(BUILD_DIR)/myos.bin \
 | 
			
		||||
	 -ffreestanding -O2 -nostdlib $(OBJ_LINK_LIST) -lgcc
 | 
			
		||||
 | 
			
		||||
build_x86_64: 
 | 
			
		||||
@ -57,16 +57,16 @@ $(BUILD_DIR)/kernel.o:
 | 
			
		||||
	$(CPP) -c $(SRC_DIR)/kernel/kernel.cpp -o $(BUILD_DIR)/kernel.o $(CFLAGS) -fno-exceptions -fno-rtti
 | 
			
		||||
 | 
			
		||||
$(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:
 | 
			
		||||
	$(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:
 | 
			
		||||
	$(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:
 | 
			
		||||
	$(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:
 | 
			
		||||
		$(CPP) -c $(SRC_DIR)/kernel/io.cpp  -o $(BUILD_DIR)/io.o $(CFLAGS) -fno-exceptions -fno-rtti
 | 
			
		||||
@ -75,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 
 | 
			
		||||
 | 
			
		||||
$(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:
 | 
			
		||||
	$(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:
 | 
			
		||||
	$(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:
 | 
			
		||||
	$(CC) -c $(SRC_DIR)/libc/include/string.c  -o $(BUILD_DIR)/string.o $(CFLAGS) -std=gnu99
 | 
			
		||||
 | 
			
		||||
@ -21,10 +21,10 @@ stack_bottom:
 | 
			
		||||
stack_top:
 | 
			
		||||
 
 | 
			
		||||
.section .text
 | 
			
		||||
.include "./src/kernel/arch/i386/irs_table.s"
 | 
			
		||||
.include "./src/kernel/arch/i386/irq_table.s"
 | 
			
		||||
.include "./src/kernel/arch/i386/idt/idt.s"
 | 
			
		||||
.include "./src/kernel/arch/i386/paging.s"
 | 
			
		||||
.include "./src/kernel/irs_table.s"
 | 
			
		||||
.include "./src/kernel/irq_table.s"
 | 
			
		||||
.include "./src/kernel/idt/idt.s"
 | 
			
		||||
.include "./src/kernel/paging.s"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
.global _start
 | 
			
		||||
@ -46,44 +46,7 @@ _start:
 | 
			
		||||
	
 | 
			
		||||
	call early_main
 | 
			
		||||
	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:
 | 
			
		||||
        
 | 
			
		||||
		
 | 
			
		||||
		#load idt
 | 
			
		||||
		call init_idt
 | 
			
		||||
        sti
 | 
			
		||||
        
 | 
			
		||||
        # Try enable A20
 | 
			
		||||
		# mov $0x2401, %ax
 | 
			
		||||
		# int $0x15
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		# enable protected mode
 | 
			
		||||
		mov %cr0, %eax 
 | 
			
		||||
		or $1, %eax
 | 
			
		||||
		mov %eax, %cr0
 | 
			
		||||
 | 
			
		||||
		
 | 
			
		||||
		call kernel_main
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		cli
 | 
			
		||||
	1:	hlt
 | 
			
		||||
		jmp 1b
 | 
			
		||||
	
 | 
			
		||||
	
 | 
			
		||||
 | 
			
		||||
.include "./src/kernel/arch/i386/gdt/gdt.s"
 | 
			
		||||
.include "./src/kernel/gdt/gdt.s"
 | 
			
		||||
@ -2,7 +2,7 @@
 | 
			
		||||
#include "bootloader/multiboot.h"
 | 
			
		||||
#define CHECK_FLAG(flags, bit) ((flags) & (1 <<(bit)))
 | 
			
		||||
 | 
			
		||||
#include "arch/i386/tty/kterm.h"
 | 
			
		||||
#include "tty/kterm.h"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -6,10 +6,48 @@ gdt:
 | 
			
		||||
	
 | 
			
		||||
.att_syntax
 | 
			
		||||
 | 
			
		||||
.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:
 | 
			
		||||
        
 | 
			
		||||
		
 | 
			
		||||
		#load idt
 | 
			
		||||
		call init_idt
 | 
			
		||||
        sti
 | 
			
		||||
        
 | 
			
		||||
        # Try enable A20
 | 
			
		||||
		# mov $0x2401, %ax
 | 
			
		||||
		# int $0x15
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		# enable protected mode
 | 
			
		||||
		mov %cr0, %eax 
 | 
			
		||||
		or $1, %eax
 | 
			
		||||
		mov %eax, %cr0
 | 
			
		||||
 | 
			
		||||
		
 | 
			
		||||
		call kernel_main
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		cli
 | 
			
		||||
	1:	hlt
 | 
			
		||||
		jmp 1b
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
.size _start, . - _start
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
* Create the GDT
 | 
			
		||||
*/
 | 
			
		||||
@ -43,6 +43,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);
 | 
			
		||||
            delay(1000);
 | 
			
		||||
        }
 | 
			
		||||
            
 | 
			
		||||
 | 
			
		||||
        
 | 
			
		||||
       
 | 
			
		||||
    }   
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -2,15 +2,15 @@
 | 
			
		||||
extern "C"{
 | 
			
		||||
   #include "../libc/include/string.h" 
 | 
			
		||||
}
 | 
			
		||||
#include "arch/i386/vga/VBE.h"
 | 
			
		||||
#include "arch/i386/tty/kterm.h"
 | 
			
		||||
#include "vga/VBE.h"
 | 
			
		||||
#include "tty/kterm.h"
 | 
			
		||||
 | 
			
		||||
#include "./bootloader/multiboot.h"
 | 
			
		||||
#include "bootcheck.h"
 | 
			
		||||
#include "memory/PhysicalMemoryManager.h"
 | 
			
		||||
 | 
			
		||||
#include "arch/i386/gdt/gdtc.h"
 | 
			
		||||
#include "arch/i386/idt/idt.h"
 | 
			
		||||
#include "gdt/gdtc.h"
 | 
			
		||||
#include "idt/idt.h"
 | 
			
		||||
 | 
			
		||||
#include "io.h"
 | 
			
		||||
#include "time.h"
 | 
			
		||||
 | 
			
		||||
@ -4,7 +4,7 @@
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void PageDirectory::enable(){
 | 
			
		||||
 | 
			
		||||
    // https://wiki.osdev.org/Setting_Up_Paging
 | 
			
		||||
    //set each entry to not present
 | 
			
		||||
    int i;
 | 
			
		||||
    for(i = 0; i < 1024; i++)
 | 
			
		||||
 | 
			
		||||
@ -1,5 +1,5 @@
 | 
			
		||||
#pragma once 
 | 
			
		||||
#include "../../../io.h"
 | 
			
		||||
#include "../io.h"
 | 
			
		||||
 | 
			
		||||
#define PIC1		0x20		/* IO base address for master PIC */
 | 
			
		||||
#define PIC2		0xA0		/* IO base address for slave PIC */
 | 
			
		||||
@ -1,6 +1,6 @@
 | 
			
		||||
#pragma once
 | 
			
		||||
 | 
			
		||||
#include "arch/i386/tty/kterm.h"
 | 
			
		||||
#include "tty/kterm.h"
 | 
			
		||||
#include "io.h"
 | 
			
		||||
#define PORT 0x3f8 
 | 
			
		||||
static int init_serial() {
 | 
			
		||||
 | 
			
		||||
@ -5,10 +5,10 @@
 | 
			
		||||
#include <stdbool.h>
 | 
			
		||||
 | 
			
		||||
#include "../vga/colors.h"
 | 
			
		||||
#include "../../../io.h"
 | 
			
		||||
#include "../io.h"
 | 
			
		||||
 | 
			
		||||
extern "C"{
 | 
			
		||||
    #include "./../../../../libc/include/string.h"
 | 
			
		||||
    #include "./../../libc/include/string.h"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void kterm_init();
 | 
			
		||||
		Reference in New Issue
	
	Block a user