From cf3c200863fd1ff00fdf4ef0c390cdbfaf192da3 Mon Sep 17 00:00:00 2001 From: Matheus Date: Fri, 4 Nov 2022 16:02:29 -0300 Subject: [PATCH] Makefile: add USE_E9 to the preprocessor flags and make the relevant files understand it --- Makefile | 7 ++++--- src/arch/x86_64/e9.c | 4 ++++ src/arch/x86_64/e9out.c | 4 ++++ src/arch/x86_64/main.c | 4 ++++ 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index bbf4efa9..2a8aa56d 100644 --- a/Makefile +++ b/Makefile @@ -23,9 +23,10 @@ KERNELDEPS=$(call rwildcard,bin,*.o) KERNELSRCDEPS=$(call rwildcard,src,*.c) INCLUDEDIR=$(SRCDIR)/include ARCHINCLUDE=$(SRCDIR)/arch/$(TARGET)/include +KERNELCONFIG= KERNEL=$(ISO)/kernel INITRD=$(ISO)/initrd -CFLAGS=-c -ffreestanding -mcmodel=kernel -O2 -mno-red-zone -mno-mmx -mno-sse -mno-sse2 -nostdlib -I$(INCLUDEDIR) -I$(ARCHINCLUDE) --debug +CFLAGS=-c -ffreestanding -mcmodel=kernel -O2 -mno-red-zone -mno-mmx -mno-sse -mno-sse2 -nostdlib -I$(INCLUDEDIR) -I$(ARCHINCLUDE) --debug $(KERNELCONFIG) LDFLAGS=-ffreestanding -nostdlib -lgcc -Wl,-T,kernel.ld -debug ISO=$(PWD)/boot/$(TARGET)/iso SRCDIR=$(PWD)/src/ @@ -60,10 +61,10 @@ sysdisk.iso: $(ISO) xorriso -as mkisofs -b limine-cd.bin -no-emul-boot -boot-load-size 4 -boot-info-table --efi-boot limine-cd-efi.bin -efi-boot-part --efi-boot-image --protective-msdos-label $(ISO) -o sysdisk.iso run: - qemu-system-x86_64 -cdrom sysdisk.iso -m 8G -smp cpus=6 + qemu-system-x86_64 -cdrom sysdisk.iso -m 8G -smp cpus=6 -debugcon stdio run-kvm: - qemu-system-x86_64 -cdrom sysdisk.iso -m 8G -smp cpus=6 -enable-kvm + qemu-system-x86_64 -cdrom sysdisk.iso -m 8G -smp cpus=6 -enable-kvm -debugcon stdio test: qemu-system-x86_64 -monitor stdio -cdrom sysdisk.iso -d int -no-reboot -no-shutdown -m 8G -smp cpus=6 diff --git a/src/arch/x86_64/e9.c b/src/arch/x86_64/e9.c index 932f86fb..d94d193d 100644 --- a/src/arch/x86_64/e9.c +++ b/src/arch/x86_64/e9.c @@ -1,12 +1,16 @@ #include void e9_putc(char c){ + #ifdef USE_E9 outb(0xE9, c); + #endif } void e9_puts(char* s){ + #ifdef USE_E9 size_t len = strlen(s); for(uintmax_t i = 0; i < len; ++i) outb(0xE9, s[i]); + #endif } diff --git a/src/arch/x86_64/e9out.c b/src/arch/x86_64/e9out.c index d9baa24a..7abd4573 100644 --- a/src/arch/x86_64/e9out.c +++ b/src/arch/x86_64/e9out.c @@ -2,6 +2,8 @@ #include #include +#ifdef USE_E9 + #include #include @@ -26,3 +28,5 @@ static devcalls calls = { void e9out_init(){ devman_newdevice("e9out", TYPE_CHARDEV, MAJOR_E9OUT, 0, &calls); } + +#endif diff --git a/src/arch/x86_64/main.c b/src/arch/x86_64/main.c index 8cc90c68..767b01ae 100644 --- a/src/arch/x86_64/main.c +++ b/src/arch/x86_64/main.c @@ -66,8 +66,12 @@ void kmain(){ consoledev_init(); pseudodevs_init(); + + #ifdef USE_E9 e9out_init(); + + #endif fb_init();