From 4aa74dbe2a35a45668b33d688f17b680c2232572 Mon Sep 17 00:00:00 2001 From: EmulatedSeasons <89668582+EmulatedSeasons@users.noreply.github.com> Date: Sun, 5 May 2024 01:08:00 -0400 Subject: improved makefile somewhat --- libc/putchar.c | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 libc/putchar.c (limited to 'libc/putchar.c') diff --git a/libc/putchar.c b/libc/putchar.c new file mode 100644 index 0000000..c5a7976 --- /dev/null +++ b/libc/putchar.c @@ -0,0 +1,9 @@ +#include + +#include + +int putchar(int ic) { + char c = (char) ic; + terminal_write(&c, sizeof(c)); + return ic; +} \ No newline at end of file -- cgit v1.2.3-70-g09d2 From 33bc3446d237a95f1bbf9d5d70a170fa4c4241cd Mon Sep 17 00:00:00 2001 From: EmulatedSeasons <89668582+EmulatedSeasons@users.noreply.github.com> Date: Mon, 6 May 2024 23:00:36 -0400 Subject: Improved makefile a bit more and got it working with the other files --- kernel/arch/x86_64/limine.cpp | 6 ++-- kernel/arch/x86_64/limine.h | 2 +- kernel/arch/x86_64/linker.ld | 78 +++++++++++++++++++++++++++++++++++++++++++ kernel/dev/ps2kbd.cpp | 34 +++++++++---------- kernel/kernel.cpp | 6 ++-- kernel/makefile | 68 ++++++++++++++++++------------------- libc/makefile | 4 +-- libc/putchar.c | 4 +-- makefile | 25 +++++++------- run-qemu.bat | 2 +- setup_sysroot.sh | 9 +++++ 11 files changed, 163 insertions(+), 75 deletions(-) create mode 100644 kernel/arch/x86_64/linker.ld create mode 100644 setup_sysroot.sh (limited to 'libc/putchar.c') diff --git a/kernel/arch/x86_64/limine.cpp b/kernel/arch/x86_64/limine.cpp index 84f8642..8c67c52 100644 --- a/kernel/arch/x86_64/limine.cpp +++ b/kernel/arch/x86_64/limine.cpp @@ -1,4 +1,3 @@ -#include #include #include #include "limine.h" @@ -37,6 +36,7 @@ void hcf() { extern void (*__init_array[])(); extern void (*__init_array_end[])(); +extern "C" void kernel_main(); extern "C" void _start() { if (!LIMINE_BASE_REVISION_SUPPORTED) { @@ -58,11 +58,13 @@ extern "C" void _start() { limine_framebuffer *framebuffer = framebuffer_request.response->framebuffers[0]; // Note: we assume the framebuffer model is RGB with 32-bit pixels. - for (std::size_t i = 0; i < 100; i++) { + for (size_t i = 0; i < 100; i++) { volatile uint32_t *fb_ptr = static_cast(framebuffer->address); fb_ptr[i * (framebuffer->pitch / 4) + i] = 0xffffff; } + + // We're done, just hang... hcf(); } \ No newline at end of file diff --git a/kernel/arch/x86_64/limine.h b/kernel/arch/x86_64/limine.h index 0e7e87a..b4afb43 100644 --- a/kernel/arch/x86_64/limine.h +++ b/kernel/arch/x86_64/limine.h @@ -584,4 +584,4 @@ struct limine_dtb_request { } #endif -#endif \ No newline at end of file +#endif diff --git a/kernel/arch/x86_64/linker.ld b/kernel/arch/x86_64/linker.ld new file mode 100644 index 0000000..5724ecf --- /dev/null +++ b/kernel/arch/x86_64/linker.ld @@ -0,0 +1,78 @@ +OUTPUT_FORMAT(elf64-x86-64) +OUTPUT_ARCH(i386:x86-64) + +/* Excecution entry point symbol */ +ENTRY(_start) + +PHDRS +{ + requests PT_LOAD FLAGS((1 << 1) | (1 << 2)); /* Write + Read */ + text PT_LOAD FLAGS((1 << 0) | (1 << 2)); /* Execute + Read */ + rodata PT_LOAD FLAGS((1 << 2)); /* Read only */ + data PT_LOAD FLAGS((1 << 1) | (1 << 2)); /* Write + Read */ + dynamic PT_DYNAMIC FLAGS((1 << 1) | (1 << 2)); /* Dynamic PHDR for relocations */ +} + +SECTIONS +{ + /* Places kernel in the top 2GiB of the address space */ + . = 0xffffffff80000000; + + /* Used to get the beginning and end address of the kernel */ + __kernel_begin = .; + + .requests : { + KEEP(*(.requests_start_marker)) + KEEP(*(.requests)) + KEEP(*(.requests_end_marker)) + } :requests + + . += CONSTANT(MAXPAGESIZE); + + /* code. multiboot header comes first */ + .text : { + *(.text .text.*) + } :text + + . += CONSTANT(MAXPAGESIZE); + + /* read only data */ + .rodata : { + *(. .rodata.*) + } :rodata + + /* init array symbols used to get start and end address of the array */ + .init_array : { + __init_array = .; + *(.init_array .init_array.*) + __init_array_end = .; + } :rodata + + . += CONSTANT(MAXPAGESIZE); + + /* read write data (initialized) */ + .data : { + *(.data .data.*) + } :data + + /* Dynamic section for relocations, both in its own PHDR and inside data PHDR */ + .dynamic : { + *(.dynamic) + } :data :dynamic + + . += CONSTANT(MAXPAGESIZE); + + /* read write data (uninitialized) and stack */ + .bss : { + *(.bss .bss.*) + *(COMMON) + } :data + + /* Discard .note.* and .eh_frame since they may cause issues on some hosts */ + /DISCARD/ : { + *(.eh_frame) + *(.note .note.*) + } + + __kernel_end = .; +} \ No newline at end of file diff --git a/kernel/dev/ps2kbd.cpp b/kernel/dev/ps2kbd.cpp index ee282b6..ffb1189 100644 --- a/kernel/dev/ps2kbd.cpp +++ b/kernel/dev/ps2kbd.cpp @@ -1,25 +1,25 @@ #include -#include -#include +//#include +//#include #include // Keycodes are sorted from left to right, up to down starting with esc // 0x80 is reserved for nonexistant scancodes // used for scan code set 2 -constexpr uint8_t scancodes[] = { - 9, 0x80, 5, 3, 1, 2, 12, 0x80, - 10, 8, 6, 4, 27, -}; +// constexpr uint8_t scancodes[] = { +// 9, 0x80, 5, 3, 1, 2, 12, 0x80, +// 10, 8, 6, 4, 27, +// }; -void keyboard_init() { - irq_clear_mask(1); - outb(0x60, 0xF4); - inb(0x60); -} +// void keyboard_init() { +// irq_clear_mask(1); +// outb(0x60, 0xF4); +// inb(0x60); +// } -void keyboard_write(uint8_t scancode) { - printf("a\n"); - /*for (int i = 0; i < 7; i++) { - inputbuffer |= inb(PS2_DATA) << (i * 8); // lsb is the first scan code - }*/ -} \ No newline at end of file +// void keyboard_write(uint8_t scancode) { +// printf("a\n"); +// /*for (int i = 0; i < 7; i++) { +// inputbuffer |= inb(PS2_DATA) << (i * 8); // lsb is the first scan code +// }*/ +// } \ No newline at end of file diff --git a/kernel/kernel.cpp b/kernel/kernel.cpp index f8f36b5..a0394ea 100644 --- a/kernel/kernel.cpp +++ b/kernel/kernel.cpp @@ -1,7 +1,7 @@ #include -#include -#include -#include +//#include +//#include +//#include //#include //#include diff --git a/kernel/makefile b/kernel/makefile index b2a2660..8c2832d 100644 --- a/kernel/makefile +++ b/kernel/makefile @@ -1,14 +1,14 @@ # Kernel makefile -CFLAGS := -ffreestanding -Wall -Wextra -g -std=gnu99 -O2 -Iinclude -CXXFLAGS := -ffreestanding -Wall -Wextra -fno-exceptions -fno-rtti -g -O2 -Iinclude -LDFLAGS := -T arch/$(ARCH)/linker.ld -ffreestanding -g -O2 -Iinclude +CFLAGS := -ffreestanding -Wall -Wextra -g -std=gnu99 -O2 -Iinclude --sysroot=$(SYSROOT) +CXXFLAGS := -ffreestanding -Wall -Wextra -fno-exceptions -fno-rtti -g -O2 -Iinclude --sysroot=$(SYSROOT) +LDFLAGS := -T arch/$(ARCH)/linker.ld -ffreestanding -g -O2 -Iinclude --sysroot=$(SYSROOT) ASMFLAGS := ifeq ($(ARCH),x86_64) -CFLAGS += -mno-red-zone -CXXFLAGS += -mno-red-zone -LDFLAGS += -mno-red-zone +CFLAGS += -mno-red-zone -mcmodel=kernel -mno-sse -mno-sse2 -mno-mmx +CXXFLAGS += -mno-red-zone -mcmodel=kernel -mno-sse -mno-sse2 -mno-mmx +LDFLAGS += -mno-red-zone -mcmodel=kernel -mno-sse -mno-sse2 -mno-mmx ASMFLAGS += -felf64 endif @@ -16,38 +16,36 @@ ifndef SYSROOT $(error No sysroot specified) endif - -LIBS = -nostdlib -lck -lgcc +LIBS = -nostdlib -lc -lgcc #Find all the source files -C_SOURCES := $(shell find $(PWD)/kernel -type f -name '*.c') -CPP_SOURCES := $(shell find $(PWD)/kernel -type f -name '*.cpp') -HEADERS := $(shell find $(PWD) -type f -name '*.h') -ASMFILES := $(shell find $(PWD) -type f -name '*.asm' ! -name 'crti.asm' ! -name 'crtn.asm') -CRTBEGIN := $(shell $(CXX) $(CXXFLAGS) -print-file-name=crtbegin.o) -CRTEND := $(shell $(CXX) $(CXXFLAGS) -print-file-name=crtend.o) - -OBJECTS := $(patsubst %.c,%.o,$(C_SOURCES)) -OBJECTS += $(patsubst %.cpp,%.o,$(CPP_SOURCES)) -OBJECTS += $(patsubst %.asm,%.o,$(ASMFILES)) - -DEPFILES := $(patsubst %.c,%.d,$(C_SOURCES)) -DEPFILES += $(patsubst %.cpp,%.d,$(CPP_SOURCES)) - -LINKLST := crti.o -LINKLST += $(CRTBEGIN) -LINKLST += $(OBJECTS) +CPP_SRCS := $(shell find . -type f -name '*.cpp' -not -path './arch/*') \ + $(shell find $(PWD)/kernel/arch/$(ARCH) -type f -name '*.cpp') +#HEADERS := $(shell find $(PWD) -type f -name '*.h') +#ASMFILES := $(shell find $(PWD) -type f -name '*.asm' -prune $(PWD)/arch) \ + $(shell find $(PWD)/kernel/arch/$(ARCH) -type f -name '*.asm') + +#OBJS := $(patsubst %.c,%.o,$(C_SOURCES)) +OBJS := $(patsubst %.cpp,%.o,$(CPP_SRCS)) +OBJS += $(patsubst %.asm,%.o,$(ASMFILES)) + +#DEPFILES := $(patsubst %.c,%.d,$(C_SOURCES)) +DEPFILES := $(patsubst %.cpp,%.d,$(CPP_SRCS)) + +# LINKLST := crti.o +# LINKLST += $(CRTBEGIN) +LINKLST += $(OBJS) LINKLST += $(LIBS) -LINKLST += $(CRTEND) -LINKLST += crtn.o +# LINKLST += $(CRTEND) +# LINKLST += crtn.o -include $(DEPFILES) -.PHONY: all crt clean kernel.bin +.PHONY: all clean -all: crti.o crtn.o kernel.bin +all: kernel.bin -kernel.bin: ${OBJECTS} +kernel.bin: ${OBJS} $(info [INFO] Linking kernel) $(CXX) ${LDFLAGS} -o $@ $(LINKLST) @@ -63,15 +61,15 @@ kernel.bin: ${OBJECTS} $(info [INFO] Assembling $<) $(NASM) $< $(ASMFLAGS) -o $@ -g -crti.o: - $(NASM) arch/$(ARCH)/crti.asm $(ASMFLAGS) -o $@ +# crti.o: +# $(NASM) arch/$(ARCH)/crti.asm $(ASMFLAGS) -o $@ -crtn.o: - $(NASM) arch/$(ARCH)/crtn.asm $(ASMFLAGS) -o $@ +# crtn.o: +# $(NASM) arch/$(ARCH)/crtn.asm $(ASMFLAGS) -o $@ install-headers: cp -r --preserve=timestamps include/. $(SYSROOT)/usr/include clean: $(info [INFO] Cleaning) - $(RM) ${OBJECTS} $(DEPFILES) crti.o crtn.o \ No newline at end of file + $(RM) ${OBJS} $(DEPFILES) \ No newline at end of file diff --git a/libc/makefile b/libc/makefile index 2e1912e..560efb7 100644 --- a/libc/makefile +++ b/libc/makefile @@ -1,4 +1,4 @@ -# libck makefile +# libc makefile ifndef AR AR = i686-elf-ar @@ -71,7 +71,7 @@ libc.a: ${OBJECTS} install-headers: cp -r --preserve=timestamps include/. $(SYSROOT)/usr/include -install-lib: libck.a +install-lib: libc.a cp -r $< $(SYSROOT)/usr/lib/. clean: diff --git a/libc/putchar.c b/libc/putchar.c index c5a7976..48147bf 100644 --- a/libc/putchar.c +++ b/libc/putchar.c @@ -1,9 +1,9 @@ #include -#include +//#include int putchar(int ic) { char c = (char) ic; - terminal_write(&c, sizeof(c)); + //terminal_write(&c, sizeof(c)); return ic; } \ No newline at end of file diff --git a/makefile b/makefile index 21c698c..2581e21 100644 --- a/makefile +++ b/makefile @@ -1,24 +1,24 @@ # The makefile -OS_NAME := emuos -ARCH ?= x86_64 -export SYSROOT = $(PWD)/sysroot +OS_NAME := emuos +export ARCH ?= x86_64 +export SYSROOT = $(PWD)/sysroot # Variables for easy access of tools like gcc and nasm export CC = $(ARCH)-elf-gcc export CXX = $(ARCH)-elf-g++ export AR = $(ARCH)-elf-ar export NASM = nasm -QEMU = qemu-system-x86_64 +QEMU = qemu-system-$(ARCH) #ASMFLAGS = -felf32 #CXXFLAGS := -ffreestanding -O2 -Wall -Wextra -fno-exceptions -fno-rtti #LDFLAGS := -ffreestanding -O2 -nostdlib -.PHONY: all grub clean build-all +.PHONY: all limine clean build-all -all: build-all grub +all: build-all limine -build-all: kernel/kernel.bin libc.a +build-all: kernel/kernel.bin libc/libc.a libc/libc.a: install-headers $(info [INFO] Building libc) @@ -28,26 +28,27 @@ kernel/kernel.bin: libc/libc.a install-headers $(info [INFO] Building kernel) $(MAKE) -C ./kernel/ ARCH=$(ARCH) PREFIX=$(PWD) -grub: build-all grub.cfg +limine: build-all + cp kernel/kernel.bin isodir/boot xorriso -as mkisofs -b boot/limine/limine-bios-cd.bin \ -no-emul-boot -boot-load-size 4 -boot-info-table \ --efi-boot boot/limine/limine-uefi-cd.bin \ -efi-boot-part --efi-boot-image --protective-msdos-label \ isodir -o emuos.iso -qemu: grub +qemu: limine $(QEMU) -no-shutdown -no-reboot --serial stdio -s -m 512 -hda $(OS_NAME).iso install: install-headers install-libraries install-headers: $(MAKE) -C ./kernel/ install-headers - $(MAKE) -C ./libs/libc/ install-headers + $(MAKE) -C ./libc/ install-headers install-libraries: - $(MAKE) -C ./libs/libc/ install-lib + $(MAKE) -C ./libc/ install-lib clean: -@$(MAKE) -C ./kernel/ clean - -@$(MAKE) -C ./libs/libc/ clean + -@$(MAKE) -C ./libc/ clean -@$(RM) $(wildcard *.bin *.a) diff --git a/run-qemu.bat b/run-qemu.bat index 19a5ae8..ddf7afa 100644 --- a/run-qemu.bat +++ b/run-qemu.bat @@ -1,2 +1,2 @@ @echo off -qemu-system-i386 -m 128 -drive format=raw,media=cdrom,file=emuos.iso \ No newline at end of file +qemu-system-x86_64 -m 128 -drive format=raw,media=cdrom,file=emuos.iso \ No newline at end of file diff --git a/setup_sysroot.sh b/setup_sysroot.sh new file mode 100644 index 0000000..5c48677 --- /dev/null +++ b/setup_sysroot.sh @@ -0,0 +1,9 @@ +# Copies include/ header files to sysroot/ + +# creates the needed sysroot folders if non existant +mkdir -p sysroot/usr/include +mkdir -p sysroot/usr/lib + +# copies all needed header files for compiling +cp -r kernel/include/* sysroot/usr/include +cp -r libc/include/* sysroot/usr/include \ No newline at end of file -- cgit v1.2.3-70-g09d2 From abaab98bd757cd0818cfcddc983eee25ab7672ed Mon Sep 17 00:00:00 2001 From: EmulatedSeasons <89668582+EmulatedSeasons@users.noreply.github.com> Date: Tue, 7 May 2024 11:07:03 -0400 Subject: Made framebuffer class, serial write functions, and finally got makefile to build without having to make clean --- .gitignore | 1 + kernel/arch/x86_64/limine.cpp | 8 ++++++++ kernel/arch/x86_64/serial.cpp | 23 +++++++++++++++++++++++ kernel/framebuffer.cpp | 22 ++++++++++++++++++++++ kernel/include/arch/x86_64/serial.h | 19 +++++++++++++++++++ kernel/include/framebuffer.h | 18 ++++++++++++++++++ kernel/makefile | 19 +++++++++++-------- libc/makefile | 14 +++++++------- libc/putchar.c | 2 ++ makefile | 4 ++-- run-qemu.bat | 2 +- 11 files changed, 114 insertions(+), 18 deletions(-) create mode 100644 kernel/arch/x86_64/serial.cpp create mode 100644 kernel/framebuffer.cpp create mode 100644 kernel/include/arch/x86_64/serial.h create mode 100644 kernel/include/framebuffer.h (limited to 'libc/putchar.c') diff --git a/.gitignore b/.gitignore index ce75dcb..2d6918b 100644 --- a/.gitignore +++ b/.gitignore @@ -19,5 +19,6 @@ misc/ # not important make.png +.clangd .vscode/ diff --git a/kernel/arch/x86_64/limine.cpp b/kernel/arch/x86_64/limine.cpp index 8c67c52..9ea2bbc 100644 --- a/kernel/arch/x86_64/limine.cpp +++ b/kernel/arch/x86_64/limine.cpp @@ -1,6 +1,9 @@ #include #include +#include +#include #include "limine.h" +#include namespace { __attribute__((used, section(".requests"))) @@ -63,7 +66,12 @@ extern "C" void _start() { fb_ptr[i * (framebuffer->pitch / 4) + i] = 0xffffff; } + Framebuffer fb((uint32_t*)framebuffer->address, framebuffer->width, framebuffer->height); + fb.drawpixel(727, 727, 0x9528fd); + printf("video modes: %lx", framebuffer->mode_count); + + kernel_main(); // We're done, just hang... hcf(); diff --git a/kernel/arch/x86_64/serial.cpp b/kernel/arch/x86_64/serial.cpp new file mode 100644 index 0000000..e90bcde --- /dev/null +++ b/kernel/arch/x86_64/serial.cpp @@ -0,0 +1,23 @@ +#include +#include + +#define PORT 0x3f8 + +int is_transmit_empty() { + return inb(PORT + 5) & 0x20; +} + +extern "C" void serial_putchar(char c) { + while (is_transmit_empty() == 0); + outb(PORT, c); +} + +void serial_write(const char* data, size_t size) { + for (size_t i = 0; i < size; i++) { + serial_putchar(data[i]); + } +} + +void serial_writestring(const char* data) { + serial_write(data, strlen(data)); +} \ No newline at end of file diff --git a/kernel/framebuffer.cpp b/kernel/framebuffer.cpp new file mode 100644 index 0000000..a07d61a --- /dev/null +++ b/kernel/framebuffer.cpp @@ -0,0 +1,22 @@ +#include +#include +#include + +Framebuffer::Framebuffer(uint32_t* addr, const uint64_t width, const uint64_t height) + : addr {addr}, width {width}, height {height} { + clear(); +} + +void Framebuffer::clear() { + for (size_t y = 0; y < height; y++) { + for (size_t x = 0; x < width; x++) { + const size_t i = y * width + x; + addr[i] = 0x000000; + } + } +} + +void Framebuffer::drawpixel(const uint64_t x, const uint64_t y, const uint32_t color) { + const size_t pos = y * width + x; + addr[pos] = color; +} \ No newline at end of file diff --git a/kernel/include/arch/x86_64/serial.h b/kernel/include/arch/x86_64/serial.h new file mode 100644 index 0000000..2ee63c5 --- /dev/null +++ b/kernel/include/arch/x86_64/serial.h @@ -0,0 +1,19 @@ +#ifndef SERIAL_H +#define SERIAL_H + +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + +void serial_putchar(char c); +void serial_write(const char* data, size_t size); +void serial_writestring(const char* data); + +#ifdef __cplusplus +} +#endif + +#endif \ No newline at end of file diff --git a/kernel/include/framebuffer.h b/kernel/include/framebuffer.h new file mode 100644 index 0000000..6080810 --- /dev/null +++ b/kernel/include/framebuffer.h @@ -0,0 +1,18 @@ +#ifndef FRAMEBUFFER_H +#define FRAMEBUFFER_H + +#include + +class Framebuffer { + private: + uint32_t* addr; + const uint64_t width; + const uint64_t height; + + public: + Framebuffer(uint32_t* addr, const uint64_t width, const uint64_t height); + void clear(); + void drawpixel(const uint64_t x, const uint64_t y, const uint32_t color); +}; + +#endif \ No newline at end of file diff --git a/kernel/makefile b/kernel/makefile index 8c2832d..33ab941 100644 --- a/kernel/makefile +++ b/kernel/makefile @@ -1,8 +1,11 @@ # Kernel makefile -CFLAGS := -ffreestanding -Wall -Wextra -g -std=gnu99 -O2 -Iinclude --sysroot=$(SYSROOT) -CXXFLAGS := -ffreestanding -Wall -Wextra -fno-exceptions -fno-rtti -g -O2 -Iinclude --sysroot=$(SYSROOT) -LDFLAGS := -T arch/$(ARCH)/linker.ld -ffreestanding -g -O2 -Iinclude --sysroot=$(SYSROOT) +CFLAGS := -ffreestanding -Wall -Wextra -g -std=gnu99 -O2 -Iinclude --sysroot=$(SYSROOT) \ + -isystem="/usr/include" +CXXFLAGS := -ffreestanding -Wall -Wextra -fno-exceptions -fno-rtti -g -O2 -Iinclude --sysroot=$(SYSROOT) \ + -isystem="/usr/include" +LDFLAGS := -T arch/$(ARCH)/linker.ld -ffreestanding -g -O2 -Iinclude --sysroot=$(SYSROOT) \ + -isystem="/usr/include" ASMFLAGS := ifeq ($(ARCH),x86_64) @@ -21,7 +24,7 @@ LIBS = -nostdlib -lc -lgcc #Find all the source files CPP_SRCS := $(shell find . -type f -name '*.cpp' -not -path './arch/*') \ $(shell find $(PWD)/kernel/arch/$(ARCH) -type f -name '*.cpp') -#HEADERS := $(shell find $(PWD) -type f -name '*.h') +HEADERS := $(shell find ./include -type f -name '*.h') #ASMFILES := $(shell find $(PWD) -type f -name '*.asm' -prune $(PWD)/arch) \ $(shell find $(PWD)/kernel/arch/$(ARCH) -type f -name '*.asm') @@ -50,11 +53,11 @@ kernel.bin: ${OBJS} $(CXX) ${LDFLAGS} -o $@ $(LINKLST) %.o: %.cpp - $(info [INFO] Compiling $<) +# $(info [INFO] Compiling $<) $(CXX) ${CXXFLAGS} -MMD -MP -c $< -o $@ %.o: %.c - $(info [INFO] Compiling $<) +# $(info [INFO] Compiling $<) $(CC) $(CFLAGS) -MMD -MP -c $< -o $@ %.o: %.asm @@ -67,9 +70,9 @@ kernel.bin: ${OBJS} # crtn.o: # $(NASM) arch/$(ARCH)/crtn.asm $(ASMFLAGS) -o $@ -install-headers: +install-headers: $(HEADERS) cp -r --preserve=timestamps include/. $(SYSROOT)/usr/include clean: $(info [INFO] Cleaning) - $(RM) ${OBJS} $(DEPFILES) \ No newline at end of file + $(RM) ${OBJS} $(DEPFILES) kernel.bin \ No newline at end of file diff --git a/libc/makefile b/libc/makefile index 560efb7..aec21ef 100644 --- a/libc/makefile +++ b/libc/makefile @@ -6,21 +6,21 @@ endif ifndef CFLAGS CFLAGS = -ffreestanding -Wall -Wextra -g -std=gnu11 -O2 -Iinclude - CFLAGS += --sysroot="$(SYSROOT)" - CFLAGS += -isystem="/usr/include" + CFLAGS += --sysroot=$(SYSROOT) + CFLAGS += -isystem $(SYSROOT)/usr/include endif ifndef CXXFLAGS CXXFLAGS = -ffreestanding -Wall -Wextra -fno-exceptions -fno-rtti -D__is_kernel -g -O2 -Iinclude CXXFLAGS += -Iinclude - CXXFLAGS += --sysroot="$(SYSROOT)" - CXXFLAGS += -isystem="/usr/include" + CXXFLAGS += --sysroot=$(SYSROOT) + CXXFLAGS += -isystem $(SYSROOT)/usr/include endif ifndef LDFLAGS LDFLAGS = -T arch/$(ARCH)/linker.ld -ffreestanding -g -O2 -Iinclude - LDFLAGS += --sysroot="$(SYSROOT)" - LDFLAGS += -isystem="/usr/include" + LDFLAGS += --sysroot=$(SYSROOT) + LDFLAGS += -isystem $(SYSROOT)/usr/include endif ifndef SYSROOT @@ -76,4 +76,4 @@ install-lib: libc.a clean: $(info [INFO] Cleaning) - $(RM) ${OBJECTS} $(DEPFILES) \ No newline at end of file + $(RM) ${OBJECTS} $(DEPFILES) libc.a \ No newline at end of file diff --git a/libc/putchar.c b/libc/putchar.c index 48147bf..f0f5783 100644 --- a/libc/putchar.c +++ b/libc/putchar.c @@ -1,9 +1,11 @@ #include //#include +#include int putchar(int ic) { char c = (char) ic; + serial_putchar(c); //terminal_write(&c, sizeof(c)); return ic; } \ No newline at end of file diff --git a/makefile b/makefile index 2581e21..d8535bc 100644 --- a/makefile +++ b/makefile @@ -22,11 +22,11 @@ build-all: kernel/kernel.bin libc/libc.a libc/libc.a: install-headers $(info [INFO] Building libc) - $(MAKE) -C ./libc/ ARCH=$(ARCH) PREFIX=$(PWD) + $(MAKE) -C ./libc/ all kernel/kernel.bin: libc/libc.a install-headers $(info [INFO] Building kernel) - $(MAKE) -C ./kernel/ ARCH=$(ARCH) PREFIX=$(PWD) + $(MAKE) -C ./kernel/ all limine: build-all cp kernel/kernel.bin isodir/boot diff --git a/run-qemu.bat b/run-qemu.bat index ddf7afa..b9c277b 100644 --- a/run-qemu.bat +++ b/run-qemu.bat @@ -1,2 +1,2 @@ @echo off -qemu-system-x86_64 -m 128 -drive format=raw,media=cdrom,file=emuos.iso \ No newline at end of file +qemu-system-x86_64 -m 128 -drive format=raw,media=cdrom,file=emuos.iso -serial stdio \ No newline at end of file -- cgit v1.2.3-70-g09d2