cevelop is 🦀

This commit is contained in:
Tunacan 2020-11-21 20:32:22 +03:00
parent 9caf9dcd62
commit 82388809d7
6 changed files with 14 additions and 51 deletions

3
.gitignore vendored
View file

@ -1,5 +1,4 @@
.cproject
.project
.vscode/
*.o
*.bin
*.iso

View file

@ -1,45 +1,36 @@
PROJECT_ROOT = $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
ifeq ($(BUILD_MODE),debug)
CFLAGS += -g
endif
TARGET = i686-elf
CC = $(TARGET)-gcc
STRIP = $(TARGET)-strip
NASM = nasm
QEMU = qemu-system-i386
CFLAGS += -std=gnu17 -ffreestanding -O2 -Wall -Wextra
CFLAGS += -std=gnu18 -ffreestanding -O2 -Wall -Wextra
LDFLAGS += -ffreestanding -O2 -nostdlib -lgcc
NASMFLAGS += -felf32
BIN = isodir/boot/hhhos.bin
BIN = sysroot/boot/hhhos.bin
ISO = HhhOS.iso
OBJS = boot.o kernel.o string.o terminal.o
OBJS = obj/boot.o obj/kernel.o obj/string.o obj/terminal.o
.PHONY: all qemu clean
.PHONY: all run clean build
all: qemu
all: $(BIN)
qemu: $(ISO)
run: $(ISO)
$(QEMU) -cdrom $(ISO)
$(ISO): $(BIN)
mkdir -p isodir/boot/grub
cp $(PROJECT_ROOT)grub.cfg isodir/boot/grub/grub.cfg
grub-mkrescue -o $(ISO) isodir
$(BIN): $(OBJS)
mkdir -p isodir/boot
$(CC) -T $(PROJECT_ROOT)linker.ld $(LDFLAGS) -o $@ $^
$(CC) -T linker.ld $(LDFLAGS) -o $@ $^
%.o: $(PROJECT_ROOT)%.c
$(CC) -c $(CFLAGS) -I$(PROJECT_ROOT)include -o $@ $<
obj/%.o: %.c
$(CC) -c $(CFLAGS) -Iinclude -o $@ $<
%.o: $(PROJECT_ROOT)%.asm
obj/%.o: %.asm
$(NASM) $(NASMFLAGS) -o $@ $<
clean:
rm -fr HhhOS $(OBJS)
rm -rf $(OBJS) $(BIN) $(ISO)

26
gdt.c
View file

@ -21,28 +21,4 @@ const struct gdt_entry {
size_t base_high : 8;
} __attribute__((packed));
void initGDT() {
struct gdt_entry *code;
code->limit_low=0xFFFF;
code->present = 1;
code->DPL = 0;
code->always_1 = 1;
code->code = 1;
code->conforming_expand_down = 0;
code->read_write = 1;
code->accessed = 0;
code->base_high = 0;
code->gran = 1;
code->big = 0;
code->always_0 = 0;
code->available = 1;
code->limit_high = 0xF;
struct gdt_entry *data = *code;
data->code = 0;
struct gdt_entry *tss = 0;
}
void initGDT() {}

View file

@ -1,3 +0,0 @@
menuentry "HhhOS" {
multiboot /boot/hhhos.bin
}

View file

@ -27,7 +27,7 @@ void srand(size_t seed) {
void kernel_main() {
terminal_initialize();
while(true)
terminal_writestring("gnhijsrg");
}