From acba87c1e946118f0ba4308a7211199cf9b7cbb2 Mon Sep 17 00:00:00 2001 From: Jake Mannens Date: Sun, 24 Jun 2018 01:49:05 +1000 Subject: Modified makefiles to use the more appropriate variable $(MAKE) when invoking the tool recursively. Disabled GCC's position-independent-code generation in makefiles. Modified makefile for kernel/usrbin so that it now compiles and links C code into the userspace test. Created errno.h and populated it with standard error definitions. Replaced the va_list based system call handlers with a system call table defined in the header kernel/sys.h. NOTE: This header is included in kmain.c and should ONLY be included there! Do NOT include this header in sys.c. Rather than fetching the user's stack pointer and using it to initialize a va_list, parameters are now passed to the call handlers via the general purpose registers EAX, EBX, ECX and EDX where EAX contains the requested call number and conveys the return value. Setup macros in unistd.h to aid to making system calls from userspace. Implemented two basic system calls; sys_print and sys_dummy. The former takes a single char* argument and displays it on screen whilst the latter is used to populate otherwise empty entries of the system call table. sys_dummy returns the error ENOSYS whenever it is called. --- kernel/Makefile | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'kernel/Makefile') diff --git a/kernel/Makefile b/kernel/Makefile index 3427449..6cf8ae4 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -2,10 +2,10 @@ TARGET = kernel SRCS = $(wildcard *.c) ASMS = $(wildcard *.s) -OBJS = $(SRCS:.c=.o) $(ASMS:.s=.o) usrbin/usrbin.o +OBJS = $(SRCS:.c=.o) $(ASMS:.s=.o) usrbin/usrbin_blob.o -CFLAGS = -m32 -I../include -ffreestanding -nostdinc -nostdlib -fno-stack-protector -gstabs+ -LDFLAGS = -m elf_i386 -Tlink.ld +CFLAGS = -m32 -I../include -ffreestanding -nostdinc -nostdlib -fno-stack-protector -fno-pie -gstabs+ +LDFLAGS = -m elf_i386 -T link.ld ASMFLAGS = -f elf32 CC = gcc $(CFLAGS) @@ -16,8 +16,8 @@ all: build build: $(TARGET) -usrbin/usrbin.o: usrbin/usrbin.s - make -C usrbin +usrbin/usrbin_blob.o: $(wildcard usrbin/*.s) $(wildcard usrbin/*.c) + $(MAKE) -C usrbin .s.o: $(ASM) -o $*.o $^ @@ -31,6 +31,7 @@ $(TARGET): $(OBJS) clean: rm -f $(OBJS) rm -f $(TARGET) + $(MAKE) -C usrbin clean run: $(TARGET) qemu-system-x86_64 -s -kernel $(TARGET) -- cgit v1.3