Merge into main the new state of the operating system/kernel #1
9
.gitignore
vendored
9
.gitignore
vendored
@ -1,10 +1,13 @@
|
||||
build
|
||||
CON
|
||||
.vscode
|
||||
build/
|
||||
bin/
|
||||
.vscode/
|
||||
.idea/
|
||||
isodir/
|
||||
root/
|
||||
*.iso
|
||||
*.img
|
||||
*.sym
|
||||
*.o
|
||||
*.a
|
||||
|
||||
|
||||
|
@ -1,17 +1,15 @@
|
||||
CPP = ${HOME}/opt/cross/bin/i686-elf-g++
|
||||
CFLAGS = -ffreestanding -Og -ggdb -Wall -Wextra
|
||||
|
||||
SRC_DIR = .
|
||||
BUILD_DIR = build
|
||||
OBJ_FOLDER = bin
|
||||
BUILD_DIR = ../build/CoreLib
|
||||
OBJ_FOLDER = ../bin/CoreLib
|
||||
OUTPUTFILE = $(BUILD_DIR)/libCoreLib.a
|
||||
|
||||
OFILES = $(OBJ_FOLDER)/memory.o $(OBJ_FOLDER)/path.o $(OBJ_FOLDER)/stack.o $(OBJ_FOLDER)/string.o $(OBJ_FOLDER)/stringview.o
|
||||
|
||||
|
||||
.phony: all
|
||||
all: $(OUTPUTFILE)
|
||||
cp *.h build/include/
|
||||
cp *.h $(BUILD_DIR)/include/CoreLib
|
||||
|
||||
$(OUTPUTFILE): $(OFILES)
|
||||
ar -rc $(OUTPUTFILE) $(OFILES)
|
142
Makefile
142
Makefile
@ -1,142 +0,0 @@
|
||||
EMULATOR = qemu-system-i386
|
||||
AS = ${HOME}/opt/cross/bin/i686-elf-as
|
||||
CC = ${HOME}/opt/cross/bin/i686-elf-gcc
|
||||
CPP = ${HOME}/opt/cross/bin/i686-elf-g++
|
||||
CFLAGS = -ffreestanding -Og -ggdb -Wall -Wextra -I source/CoreLib/build/include
|
||||
|
||||
OFILES =$(BUILD_DIR)/boot.o $(BUILD_DIR)/kterm.o $(BUILD_DIR)/kernel.o $(BUILD_DIR)/memory.o $(BUILD_DIR)/paging.o $(BUILD_DIR)/VFS.o $(BUILD_DIR)/pit.o $(BUILD_DIR)/time.o $(BUILD_DIR)/keyboard.o $(BUILD_DIR)/io.o $(BUILD_DIR)/processor.o $(BUILD_DIR)/gdtc.o $(BUILD_DIR)/idt.o $(BUILD_DIR)/pic.o $(BUILD_DIR)/sv-terminal.o $(BUILD_DIR)/prekernel.o $(BUILD_DIR)/KHeap.o $(BUILD_DIR)/pci.o $(BUILD_DIR)/pcidevice.o $(BUILD_DIR)/atapiDevice.o $(BUILD_DIR)/ataDevice.o $(BUILD_DIR)/rsdp.o $(BUILD_DIR)/acpi.o
|
||||
|
||||
SRC_DIR = source
|
||||
BUILD_DIR = build
|
||||
|
||||
CRTBEGIN_OBJ = $(shell $(CC) $(CFLAGS) -print-file-name=crtbegin.o)
|
||||
CRTEND_OBJ = $(shell $(CC) $(CFLAGS) -print-file-name=crtend.o)
|
||||
|
||||
CRTI_OBJ = $(BUILD_DIR)/crti.o
|
||||
CRTN_OBJ = $(BUILD_DIR)/crtn.o
|
||||
OBJ_LINK_LIST = $(CRTI_OBJ) $(CRTBEGIN_OBJ) $(OFILES) $(CRTEND_OBJ) $(CRTN_OBJ)
|
||||
INTERNAL_OBJS = $(CRTI_OBJ) $(OFILES) $(CRTN_OBJ)
|
||||
|
||||
|
||||
all: clean build
|
||||
|
||||
build: build_kernel iso
|
||||
|
||||
clean_iso:
|
||||
if [[ -a isodir/boot ]] ; then rm root/boot -rd ; fi
|
||||
if [ -f build/barinkOS.iso ] ; then rm build/barinkOS.iso ; fi
|
||||
|
||||
iso: clean_iso clean build
|
||||
mkdir -p root/boot/grub
|
||||
cp build/myos.bin root/boot/myos.bin
|
||||
cp source/grub.cfg root/boot/grub/grub.cfg
|
||||
grub-mkrescue -o build/barinkOS.iso root
|
||||
run: all
|
||||
virtualboxvm --startvm "BarinkOS_test"
|
||||
debug: all
|
||||
objcopy --only-keep-debug build/myos.bin kernel.sym
|
||||
$(EMULATOR) -cdrom build/barinkOS.iso -serial stdio -vga std -display gtk -m 2G -cpu core2duo -s -d int -no-shutdown -no-reboot
|
||||
test:
|
||||
$(EMULATOR) -kernel $(BUILD_DIR)/myos.bin -serial stdio -vga std -display gtk -m 2G -cpu core2duo -d int -no-shutdown -no-reboot
|
||||
|
||||
test_iso:
|
||||
$(EMULATOR) -boot d -cdrom $(BUILD_DIR)/barinkOS.iso -serial stdio -vga std -display gtk -m 2G -cpu core2duo -d int -no-reboot -no-shutdown
|
||||
test_disk: all
|
||||
sudo losetup /dev/loop9 build/disk.img
|
||||
sudo mount /dev/loop9 /mnt
|
||||
sudo cp build/myos.bin /mnt/boot/myos.bin
|
||||
sudo umount /mnt
|
||||
sudo losetup -d /dev/loop9
|
||||
|
||||
$(EMULATOR) -boot d -drive format=raw,file=build/disk.img -serial stdio -vga std -display gtk -m 2G -cpu core2duo
|
||||
|
||||
|
||||
build_kernel: $(OBJ_LINK_LIST)
|
||||
$(CPP) -T $(SRC_DIR)/kernel/linker.ld -o $(BUILD_DIR)/myos.bin -ffreestanding -ggdb -Og -nostdlib $(OBJ_LINK_LIST) -lgcc -L source/CoreLib/build -lCoreLib
|
||||
|
||||
build_x86_64:
|
||||
$(AS) $(SRC_DIR)/cgc/x86_64/crti.s -o $(BUILD_DIR)/crti_64.o
|
||||
$(AS) $(SRC_DIR)/cgc/x86_64/crtn.s -o $(BUILD_DIR)/crtn.o
|
||||
|
||||
clean:
|
||||
rm -f $(BUILD_DIR)/myos.bin $(INTERNAL_OBJS)
|
||||
|
||||
# C++ definition -> Object files
|
||||
$(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/terminal/kterm.cpp -o $(BUILD_DIR)/kterm.o $(CFLAGS) -fno-exceptions -fno-rtti
|
||||
|
||||
$(BUILD_DIR)/io.o:
|
||||
$(CPP) -c $(SRC_DIR)/kernel/drivers/io/io.cpp -o $(BUILD_DIR)/io.o $(CFLAGS) -fno-exceptions -fno-rtti
|
||||
|
||||
$(BUILD_DIR)/idt.o:
|
||||
$(CPP) -c $(SRC_DIR)/kernel/interrupts/idt.cpp -o $(BUILD_DIR)/idt.o $(CFLAGS) -fno-exceptions -fno-rtti
|
||||
|
||||
$(BUILD_DIR)/gdtc.o:
|
||||
$(CPP) -c $(SRC_DIR)/kernel/memory/gdt/gdtc.cpp -o $(BUILD_DIR)/gdtc.o $(CFLAGS) -fno-exceptions -fno-rtti
|
||||
|
||||
$(BUILD_DIR)/pic.o:
|
||||
$(CPP) -c $(SRC_DIR)/kernel/drivers/pic/pic.cpp -o $(BUILD_DIR)/pic.o $(CFLAGS) -fno-exceptions -fno-rtti
|
||||
|
||||
$(BUILD_DIR)/PhysicalMemoryManager.o:
|
||||
$(CPP) -c $(SRC_DIR)/kernel/memory/PhysicalMemoryManager.cpp -o $(BUILD_DIR)/PhysicalMemoryManager.o $(CFLAGS) -fno-exceptions -fno-rtti
|
||||
|
||||
$(BUILD_DIR)/pci.o:
|
||||
$(CPP) -c $(SRC_DIR)/kernel/drivers/pci/pci.cpp -o $(BUILD_DIR)/pci.o $(CFLAGS) -fno-exceptions -fno-rtti
|
||||
|
||||
$(BUILD_DIR)/pcidevice.o:
|
||||
$(CPP) -c $(SRC_DIR)/kernel/drivers/pci/pciDevice.cpp -o $(BUILD_DIR)/pcidevice.o $(CFLAGS) -fno-exceptions -fno-rtti
|
||||
|
||||
$(BUILD_DIR)/atapiDevice.o:
|
||||
$(CPP) -c $(SRC_DIR)/kernel/drivers/atapi/atapiDevice.cpp -o $(BUILD_DIR)/atapiDevice.o $(CFLAGS) -fno-exceptions -fno-rtti
|
||||
|
||||
$(BUILD_DIR)/ataDevice.o:
|
||||
$(CPP) -c $(SRC_DIR)/kernel/drivers/ata/ataDevice.cpp -o $(BUILD_DIR)/ataDevice.o $(CFLAGS) -fno-exceptions -fno-rtti
|
||||
|
||||
$(BUILD_DIR)/rsdp.o:
|
||||
$(CPP) -c $(SRC_DIR)/kernel/drivers/acpi/rsdp.cpp -o $(BUILD_DIR)/rsdp.o $(CFLAGS) -fno-exceptions -fno-rtti
|
||||
|
||||
$(BUILD_DIR)/acpi.o:
|
||||
$(CPP) -c $(SRC_DIR)/kernel/drivers/acpi/acpi.cpp -o $(BUILD_DIR)/acpi.o $(CFLAGS) -fno-exceptions -fno-rtti
|
||||
|
||||
$(BUILD_DIR)/pit.o:
|
||||
$(CPP) -c $(SRC_DIR)/kernel/drivers/pit/pit.cpp -o $(BUILD_DIR)/pit.o $(CFLAGS) -fno-exceptions -fno-rtti
|
||||
|
||||
$(BUILD_DIR)/VFS.o:
|
||||
$(CPP) -c $(SRC_DIR)/kernel/vfs/VFS.cpp -o $(BUILD_DIR)/VFS.o $(CFLAGS) -fno-exceptions -fno-rtti
|
||||
|
||||
$(BUILD_DIR)/keyboard.o:
|
||||
$(CPP) -c $(SRC_DIR)/kernel/drivers/ps-2/keyboard.cpp -o $(BUILD_DIR)/keyboard.o $(CFLAGS) -fno-exceptions -fno-rtti
|
||||
|
||||
$(BUILD_DIR)/time.o:
|
||||
$(CPP) -c $(SRC_DIR)/kernel/time.cpp -o $(BUILD_DIR)/time.o $(CFLAGS) -fno-exceptions -fno-rtti
|
||||
|
||||
$(BUILD_DIR)/sv-terminal.o:
|
||||
$(CPP) -c $(SRC_DIR)/kernel/supervisorterminal/superVisorTerminal.cpp -o $(BUILD_DIR)/sv-terminal.o $(CFLAGS) -fno-exceptions -fno-rtti
|
||||
|
||||
$(BUILD_DIR)/memory.o:
|
||||
$(CPP) -c $(SRC_DIR)/kernel/memory/PhysicalMemoryManager.cpp -o $(BUILD_DIR)/memory.o $(CFLAGS) -fno-exceptions -fno-rtti
|
||||
|
||||
$(BUILD_DIR)/paging.o:
|
||||
$(CPP) -c $(SRC_DIR)/kernel/memory/VirtualMemoryManager.cpp -o $(BUILD_DIR)/paging.o $(CFLAGS) -fno-exceptions -fno-rtti
|
||||
|
||||
$(BUILD_DIR)/KHeap.o:
|
||||
$(CPP) -c $(SRC_DIR)/kernel/memory/KernelHeap.cpp -o $(BUILD_DIR)/KHeap.o $(CFLAGS) -fno-exceptions -fno-rtti
|
||||
|
||||
$(BUILD_DIR)/prekernel.o:
|
||||
$(CPP) -c $(SRC_DIR)/kernel/prekernel/prekernel.cpp -o $(BUILD_DIR)/prekernel.o $(CFLAGS) -fno-exceptions -fno-rtti
|
||||
|
||||
$(BUILD_DIR)/processor.o:
|
||||
$(CPP) -c $(SRC_DIR)/kernel/i386/processor.cpp -o $(BUILD_DIR)/processor.o $(CFLAGS) -fno-exceptions -fno-rtti
|
||||
|
||||
# Assembly -> Object files
|
||||
$(BUILD_DIR)/boot.o:
|
||||
$(AS) $(SRC_DIR)/kernel/boot/boot.s -o $(BUILD_DIR)/boot.o
|
||||
|
||||
$(BUILD_DIR)/crti.o:
|
||||
$(AS) $(SRC_DIR)/kernel/crti.s -o $(BUILD_DIR)/crti.o
|
||||
|
||||
$(BUILD_DIR)/crtn.o:
|
||||
$(AS) $(SRC_DIR)/kernel/crtn.s -o $(BUILD_DIR)/crtn.o
|
125
kernel/Makefile
Normal file
125
kernel/Makefile
Normal file
@ -0,0 +1,125 @@
|
||||
EMULATOR = qemu-system-i386
|
||||
AS = ${HOME}/opt/cross/bin/i686-elf-as
|
||||
CC = ${HOME}/opt/cross/bin/i686-elf-gcc
|
||||
CPP = ${HOME}/opt/cross/bin/i686-elf-g++
|
||||
CFLAGS = -ffreestanding -Og -ggdb -Wall -Wextra -I ../build/CoreLib/include
|
||||
BUILD_DIR = ../build/kernel
|
||||
OBJ_DIR = ../bin/kernel
|
||||
|
||||
CRTBEGIN_OBJ = $(shell $(CC) $(CFLAGS) -print-file-name=crtbegin.o)
|
||||
CRTEND_OBJ = $(shell $(CC) $(CFLAGS) -print-file-name=crtend.o)
|
||||
|
||||
CRTI_OBJ = $(OBJ_DIR)/crti.o
|
||||
CRTN_OBJ = $(OBJ_DIR)/crtn.o
|
||||
|
||||
OFILES = $(OBJ_DIR)/boot.o \
|
||||
$(OBJ_DIR)/kterm.o \
|
||||
$(OBJ_DIR)/kernel.o \
|
||||
$(OBJ_DIR)/memory.o \
|
||||
$(OBJ_DIR)/paging.o \
|
||||
$(OBJ_DIR)/VFS.o \
|
||||
$(OBJ_DIR)/pit.o \
|
||||
$(OBJ_DIR)/time.o \
|
||||
$(OBJ_DIR)/keyboard.o \
|
||||
$(OBJ_DIR)/io.o \
|
||||
$(OBJ_DIR)/processor.o \
|
||||
$(OBJ_DIR)/gdtc.o \
|
||||
$(OBJ_DIR)/idt.o \
|
||||
$(OBJ_DIR)/pic.o \
|
||||
$(OBJ_DIR)/sv-terminal.o \
|
||||
$(OBJ_DIR)/prekernel.o \
|
||||
$(OBJ_DIR)/KHeap.o \
|
||||
$(OBJ_DIR)/pci.o \
|
||||
$(OBJ_DIR)/pcidevice.o \
|
||||
$(OBJ_DIR)/atapiDevice.o \
|
||||
$(OBJ_DIR)/ataDevice.o \
|
||||
$(OBJ_DIR)/rsdp.o \
|
||||
$(OBJ_DIR)/acpi.o
|
||||
|
||||
OBJ_LINK_LIST = $(CRTI_OBJ) $(CRTBEGIN_OBJ) $(OFILES) $(CRTEND_OBJ) $(CRTN_OBJ)
|
||||
INTERNAL_OBJS = $(CRTI_OBJ) $(OFILES) $(CRTN_OBJ)
|
||||
|
||||
all: build
|
||||
|
||||
build: $(OBJ_LINK_LIST)
|
||||
$(CPP) -T linker.ld -o $(BUILD_DIR)/myos.bin -ffreestanding -ggdb -Og -nostdlib $(OBJ_LINK_LIST) -lgcc -L ../build/CoreLib -lCoreLib
|
||||
|
||||
# C++ definition -> Object files
|
||||
$(OBJ_DIR)/kernel.o:
|
||||
$(CPP) -c kernel.cpp -o $(OBJ_DIR)/kernel.o $(CFLAGS) -fno-exceptions -fno-rtti
|
||||
|
||||
$(OBJ_DIR)/kterm.o:
|
||||
$(CPP) -c terminal/kterm.cpp -o $(OBJ_DIR)/kterm.o $(CFLAGS) -fno-exceptions -fno-rtti
|
||||
|
||||
$(OBJ_DIR)/io.o:
|
||||
$(CPP) -c drivers/io/io.cpp -o $(OBJ_DIR)/io.o $(CFLAGS) -fno-exceptions -fno-rtti
|
||||
|
||||
$(OBJ_DIR)/idt.o:
|
||||
$(CPP) -c interrupts/idt.cpp -o $(OBJ_DIR)/idt.o $(CFLAGS) -fno-exceptions -fno-rtti
|
||||
|
||||
$(OBJ_DIR)/gdtc.o:
|
||||
$(CPP) -c memory/gdt/gdtc.cpp -o $(OBJ_DIR)/gdtc.o $(CFLAGS) -fno-exceptions -fno-rtti
|
||||
|
||||
$(OBJ_DIR)/pic.o:
|
||||
$(CPP) -c drivers/pic/pic.cpp -o $(OBJ_DIR)/pic.o $(CFLAGS) -fno-exceptions -fno-rtti
|
||||
|
||||
$(OBJ_DIR)/PhysicalMemoryManager.o:
|
||||
$(CPP) -c memory/PhysicalMemoryManager.cpp -o $(OBJ_DIR)/PhysicalMemoryManager.o $(CFLAGS) -fno-exceptions -fno-rtti
|
||||
|
||||
$(OBJ_DIR)/pci.o:
|
||||
$(CPP) -c drivers/pci/pci.cpp -o $(OBJ_DIR)/pci.o $(CFLAGS) -fno-exceptions -fno-rtti
|
||||
|
||||
$(OBJ_DIR)/pcidevice.o:
|
||||
$(CPP) -c drivers/pci/pciDevice.cpp -o $(OBJ_DIR)/pcidevice.o $(CFLAGS) -fno-exceptions -fno-rtti
|
||||
|
||||
$(OBJ_DIR)/atapiDevice.o:
|
||||
$(CPP) -c drivers/atapi/atapiDevice.cpp -o $(OBJ_DIR)/atapiDevice.o $(CFLAGS) -fno-exceptions -fno-rtti
|
||||
|
||||
$(OBJ_DIR)/ataDevice.o:
|
||||
$(CPP) -c drivers/ata/ataDevice.cpp -o $(OBJ_DIR)/ataDevice.o $(CFLAGS) -fno-exceptions -fno-rtti
|
||||
|
||||
$(OBJ_DIR)/rsdp.o:
|
||||
$(CPP) -c drivers/acpi/rsdp.cpp -o $(OBJ_DIR)/rsdp.o $(CFLAGS) -fno-exceptions -fno-rtti
|
||||
|
||||
$(OBJ_DIR)/acpi.o:
|
||||
$(CPP) -c drivers/acpi/acpi.cpp -o $(OBJ_DIR)/acpi.o $(CFLAGS) -fno-exceptions -fno-rtti
|
||||
|
||||
$(OBJ_DIR)/pit.o:
|
||||
$(CPP) -c drivers/pit/pit.cpp -o $(OBJ_DIR)/pit.o $(CFLAGS) -fno-exceptions -fno-rtti
|
||||
|
||||
$(OBJ_DIR)/VFS.o:
|
||||
$(CPP) -c vfs/VFS.cpp -o $(OBJ_DIR)/VFS.o $(CFLAGS) -fno-exceptions -fno-rtti
|
||||
|
||||
$(OBJ_DIR)/keyboard.o:
|
||||
$(CPP) -c drivers/ps-2/keyboard.cpp -o $(OBJ_DIR)/keyboard.o $(CFLAGS) -fno-exceptions -fno-rtti
|
||||
|
||||
$(OBJ_DIR)/time.o:
|
||||
$(CPP) -c time.cpp -o $(OBJ_DIR)/time.o $(CFLAGS) -fno-exceptions -fno-rtti
|
||||
|
||||
$(OBJ_DIR)/sv-terminal.o:
|
||||
$(CPP) -c supervisorterminal/superVisorTerminal.cpp -o $(OBJ_DIR)/sv-terminal.o $(CFLAGS) -fno-exceptions -fno-rtti
|
||||
|
||||
$(OBJ_DIR)/memory.o:
|
||||
$(CPP) -c memory/PhysicalMemoryManager.cpp -o $(OBJ_DIR)/memory.o $(CFLAGS) -fno-exceptions -fno-rtti
|
||||
|
||||
$(OBJ_DIR)/paging.o:
|
||||
$(CPP) -c memory/VirtualMemoryManager.cpp -o $(OBJ_DIR)/paging.o $(CFLAGS) -fno-exceptions -fno-rtti
|
||||
|
||||
$(OBJ_DIR)/KHeap.o:
|
||||
$(CPP) -c memory/KernelHeap.cpp -o $(OBJ_DIR)/KHeap.o $(CFLAGS) -fno-exceptions -fno-rtti
|
||||
|
||||
$(OBJ_DIR)/prekernel.o:
|
||||
$(CPP) -c prekernel/prekernel.cpp -o $(OBJ_DIR)/prekernel.o $(CFLAGS) -fno-exceptions -fno-rtti
|
||||
|
||||
$(OBJ_DIR)/processor.o:
|
||||
$(CPP) -c i386/processor.cpp -o $(OBJ_DIR)/processor.o $(CFLAGS) -fno-exceptions -fno-rtti
|
||||
|
||||
# Assembly -> Object files
|
||||
$(OBJ_DIR)/boot.o:
|
||||
$(AS) boot/boot.s -o $(OBJ_DIR)/boot.o
|
||||
|
||||
$(OBJ_DIR)/crti.o:
|
||||
$(AS) crti.s -o $(OBJ_DIR)/crti.o
|
||||
|
||||
$(OBJ_DIR)/crtn.o:
|
||||
$(AS) crtn.s -o $(OBJ_DIR)/crtn.o
|
@ -1,4 +1,4 @@
|
||||
.include "./source/kernel/boot/multiboot.s"
|
||||
.include "./boot/multiboot.s"
|
||||
/*
|
||||
* Allocate initial stack
|
||||
*/
|
||||
@ -108,10 +108,10 @@ isPaging:
|
||||
jmp 1b
|
||||
|
||||
|
||||
.include "./source/kernel/memory/gdt/gdt.s"
|
||||
.include "./source/kernel/irs_table.s"
|
||||
.include "./source/kernel/irq_table.s"
|
||||
.include "./source/kernel/interrupts/idt.s"
|
||||
.include "./memory/gdt/gdt.s"
|
||||
.include "./irs_table.s"
|
||||
.include "./irq_table.s"
|
||||
.include "./interrupts/idt.s"
|
||||
|
||||
.globl jump_usermode
|
||||
jump_usermode:
|
@ -5,7 +5,7 @@
|
||||
|
||||
#include "../drivers/vga/colors.h"
|
||||
#include "../drivers/io/io.h"
|
||||
#include "CoreLib/Memory.h"
|
||||
#include <CoreLib/Memory.h>
|
||||
|
||||
void kterm_init();
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user