diff options
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | Makefile | 19 | ||||
-rw-r--r-- | Makefile.config | 2 | ||||
-rw-r--r-- | devices/Makefile | 2 | ||||
-rw-r--r-- | devices/uart.h (renamed from devices/uart_16550.h) | 3 | ||||
-rw-r--r-- | devices/uart_16550.c | 4 | ||||
-rw-r--r-- | devices/vga.c | 4 | ||||
-rw-r--r-- | grub/multiboot2.h (renamed from grub/include/multiboot2.h) | 0 | ||||
-rw-r--r-- | i686/Makefile | 2 | ||||
-rw-r--r-- | i686/boot.S | 2 | ||||
-rw-r--r-- | i686/lidt.c | 1 | ||||
-rw-r--r-- | i686/sys/syscall.h | 8 | ||||
-rw-r--r-- | i686/toolchain.mk | 2 | ||||
-rw-r--r-- | lib/Makefile | 2 | ||||
-rw-r--r-- | lib/stdio.h | 8 | ||||
-rw-r--r-- | rules.mk | 4 | ||||
-rw-r--r-- | src/Makefile | 2 | ||||
-rw-r--r-- | src/kernel.c | 6 | ||||
-rw-r--r-- | src/mem/vmm.c | 2 | ||||
-rw-r--r-- | src/mmap.h | 2 |
20 files changed, 46 insertions, 30 deletions
@@ -9,3 +9,4 @@ src/conf.h .config.old test_* doc +include/ @@ -1,5 +1,6 @@ MAKE = make MAKEFLAGS += --no-print-directory +SRC_ROOT := $(shell pwd) include Makefile.config @@ -28,8 +29,10 @@ info: @echo " ${LDFLAGS}" test: - grep -r 'asm' devices lib src - make -C lib test + @echo Looking for inline assembly + @grep -rn 'asm' devices lib src + @echo Running tests + @make -C lib test FORCE: @@ -41,6 +44,18 @@ Makefile.config: .config @echo -e '\n# toolchain.mk' >> Makefile.config @cat $$(sed -nE "s/CONFIG_ARCH_(.+)=y/\1/p" .config)/toolchain.mk >> Makefile.config +symlinks: + mkdir -p src/include + ln -sTf $(SRC_ROOT)/grub src/include/grub + ln -sTf $(SRC_ROOT)/${ARCH} src/include/arch + ln -sTf $(SRC_ROOT)/${ARCH}/sys src/include/sys + ln -sTf $(SRC_ROOT)/devices src/include/devices + ln -sTf $(SRC_ROOT)/lib src/include/lib + mkdir -p devices/include + ln -sTf $(SRC_ROOT)/${ARCH}/sys devices/include/sys + mkdir -p i686/include + ln -sTf $(SRC_ROOT)/grub i686/include/grub + lib/libk.a: FORCE @${MAKE} -C lib libk.a i686/arch.a: FORCE diff --git a/Makefile.config b/Makefile.config index a683ac8..47176b4 100644 --- a/Makefile.config +++ b/Makefile.config @@ -28,7 +28,7 @@ ARCH=i686 # AS := i686-elf-as CC := i686-elf-gcc -CCFLAGS := -Wall -Wextra -Wpedantic -fanalyzer -ffreestanding -std=gnu11 -mgeneral-regs-only +CCFLAGS := -Wall -Wextra -Wpedantic -Wshadow -Wconversion -fanalyzer -ffreestanding -std=gnu11 -mgeneral-regs-only CCFLAGS += $(shell echo ${CONFIG_CCFLAGS}) LD := i686-elf-ld LDFLAGS := -static -nostdlib diff --git a/devices/Makefile b/devices/Makefile index 3b7f163..0c3a0b1 100644 --- a/devices/Makefile +++ b/devices/Makefile @@ -1,7 +1,5 @@ include ../Makefile.config -CCFLAGS += -I. -I../${ARCH} -I../lib - devs.SRCS = pic_8259.c uart_16550.c vga.c i8042.c pckbd.c mouse.c include ../rules.mk diff --git a/devices/uart_16550.h b/devices/uart.h index 5e5ee13..ee74e98 100644 --- a/devices/uart_16550.h +++ b/devices/uart.h @@ -1,5 +1,6 @@ #pragma once +// TODO #include <arch/platform.h> #include <stdio.h> enum UART { @@ -14,5 +15,3 @@ enum UART { }; FILE *uart_init(enum UART port); -// void uart_write(enum UART port, char a); -// int uart_puts(enum UART port, const char *string, int length); diff --git a/devices/uart_16550.c b/devices/uart_16550.c index 40ac594..1adcf38 100644 --- a/devices/uart_16550.c +++ b/devices/uart_16550.c @@ -1,4 +1,4 @@ -#include "uart_16550.h" +#include "uart.h" #include <stddef.h> #include <sys/io.h> @@ -83,7 +83,7 @@ uart_puts(const FILE *self, const char *string, int length) } void -uart_flush(const FILE *self) +uart_flush(__attribute__((unused)) const FILE *self) { } diff --git a/devices/vga.c b/devices/vga.c index 12ac880..6d64c0a 100644 --- a/devices/vga.c +++ b/devices/vga.c @@ -57,7 +57,7 @@ vga_update_cursor() // *** Text Mode Output *** void -vga_putc(const FILE *self, char a) +vga_putc(__attribute__((unused)) const FILE *self, char a) { switch (a) { case '\n': @@ -115,7 +115,7 @@ vga_puts(const FILE *self, const char *string, int len) } void -vga_flush(const FILE *self) +vga_flush(__attribute__((unused)) const FILE *self) { vga_update_cursor(); } diff --git a/grub/include/multiboot2.h b/grub/multiboot2.h index 5a3db5a..5a3db5a 100644 --- a/grub/include/multiboot2.h +++ b/grub/multiboot2.h diff --git a/i686/Makefile b/i686/Makefile index 8575d99..9d7f06c 100644 --- a/i686/Makefile +++ b/i686/Makefile @@ -1,7 +1,5 @@ include ../Makefile.config -CCFLAGS += -I../grub/include -I../lib -mgeneral-regs-only - arch.SRCS = boot.S init.s \ gdt.c lgdt.c \ lidt.c isr.c diff --git a/i686/boot.S b/i686/boot.S index 1eea9a3..16d54a3 100644 --- a/i686/boot.S +++ b/i686/boot.S @@ -1,5 +1,5 @@ #define ASM_FILE -#include <multiboot2.h> +#include <grub/multiboot2.h> #include "macros.s" /* Declare a multiboot header that marks this program as a kernel */ diff --git a/i686/lidt.c b/i686/lidt.c index 59a2611..cf8084e 100644 --- a/i686/lidt.c +++ b/i686/lidt.c @@ -1,6 +1,5 @@ #include "idt.h" #include <stdint.h> -#include <stdio.h> struct __attribute__((packed)) Pointer { uint16_t limit; diff --git a/i686/sys/syscall.h b/i686/sys/syscall.h new file mode 100644 index 0000000..9e62c89 --- /dev/null +++ b/i686/sys/syscall.h @@ -0,0 +1,8 @@ +#pragma once + +static inline int +syscall(int number) +{ + asm volatile("int $0x80"); + return 0; +} diff --git a/i686/toolchain.mk b/i686/toolchain.mk index 1747a8b..6f69cdb 100644 --- a/i686/toolchain.mk +++ b/i686/toolchain.mk @@ -4,7 +4,7 @@ ARCH=i686 # AS := i686-elf-as CC := i686-elf-gcc -CCFLAGS := -Wall -Wextra -Wpedantic -fanalyzer -ffreestanding -std=gnu11 -mgeneral-regs-only +CCFLAGS := -Wall -Wextra -Wpedantic -Wshadow -Wconversion -fanalyzer -ffreestanding -std=gnu11 -mgeneral-regs-only CCFLAGS += $(shell echo ${CONFIG_CCFLAGS}) LD := i686-elf-ld LDFLAGS := -static -nostdlib diff --git a/lib/Makefile b/lib/Makefile index f564ee0..68d1e74 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -1,7 +1,5 @@ include ../Makefile.config -CCFLAGS += -I. -I.. - libk.SRCS = stdio/printf.c stdio/fprintf.c stdio/vfprintf.c \ stdlib/memcpy.c stdlib/memset.c \ string/itoa.c diff --git a/lib/stdio.h b/lib/stdio.h index 4711a29..f7c1846 100644 --- a/lib/stdio.h +++ b/lib/stdio.h @@ -3,14 +3,14 @@ #include <stdarg.h> /** An object type used for streams */ -typedef struct FILE_t { +typedef struct kIoDevice { int id; /** Functions that prints a character to the stream */ - void (*putc)(const struct FILE_t *, char); + void (*putc)(const struct kIoDevice *, char); /** Function that prints a string to the stream */ - int (*puts)(const struct FILE_t *, const char *, int); + int (*puts)(const struct kIoDevice *, const char *, int); /** Flush all buffers */ - void (*flush)(const struct FILE_t *); + void (*flush)(const struct kIoDevice *); } FILE; /** A FILE value corresponding to stdin, the keyboard buffer */ @@ -5,6 +5,9 @@ $(foreach V,$(filter %.SRCS, ${.VARIABLES}),\ $(eval all: $($(V:%.SRCS=%.OBJS))) \ ) +# extra flags +CCFLAGS += -isysteminclude -I../lib + # Suffix rules %.a: @echo ' AR $@' @@ -32,6 +35,7 @@ tst/test_%: tst/%.cc .PHONY: clean FORCE clean: @$(foreach V,$(filter %.OBJS, ${.VARIABLES}), rm -rf $($(V))) + @rm -rf include @rm -rf tst/test_* FORCE: diff --git a/src/Makefile b/src/Makefile index f58ec04..de59cfb 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,7 +1,5 @@ include ../Makefile.config -CCFLAGS += -I. -isystem../grub/include -I../${ARCH} -I../lib -I.. - kernel.SRCS := multiboot2.c mmap.c kernel.c mem/vmm.c kernel.OBJS := conf.h diff --git a/src/kernel.c b/src/kernel.c index a315f3b..b8432a8 100644 --- a/src/kernel.c +++ b/src/kernel.c @@ -4,14 +4,14 @@ // description: kernel entry point //===================================================================== +#include "conf.h" #include "devices/keyboard.h" #include "devices/mouse.h" #include "devices/pic.h" #include "devices/ps2_controller.h" -#include "devices/uart_16550.h" +#include "devices/uart.h" #include "devices/vga.h" #include "mem.h" -#include <conf.h> #include <stdio.h> #include <sys/cpuid.h> @@ -50,7 +50,5 @@ void kmain() { if (*c == 0) printf("c is 0\r\n"); */ - // asm volatile("int $0x80"); - while (1) {} } diff --git a/src/mem/vmm.c b/src/mem/vmm.c index 431f0df..3d34a0a 100644 --- a/src/mem/vmm.c +++ b/src/mem/vmm.c @@ -1,5 +1,5 @@ #include "../mem.h" -#include "paging.h" +#include <arch/paging.h> extern struct DirectoryEntry k_pagedir[1024]; extern struct TableEntry k_ptable0x300[1024]; @@ -1,7 +1,7 @@ #pragma once #include "boot.h" -#include <multiboot2.h> +#include <grub/multiboot2.h> __attribute__((section(".multiboot.text"))) unsigned multiboot2_mmap(const struct multiboot_mmap_entry entries[], unsigned entry_count, unsigned bitmap[1024 * 32]); |