summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Makefile91
-rw-r--r--src/README34
-rw-r--r--src/drivers/driver.c (renamed from src/driver.c)0
-rw-r--r--src/drivers/driver.h (renamed from src/driver.h)0
-rw-r--r--src/drivers/hdi/ps2/keyboard.c (renamed from src/keyboard.c)0
-rw-r--r--src/drivers/hdi/ps2/keyboard.h (renamed from src/keyboard.h)0
-rw-r--r--src/drivers/hdi/ps2/mouse.c (renamed from src/mouse.c)0
-rw-r--r--src/drivers/hdi/ps2/mouse.h (renamed from src/mouse.h)0
-rw-r--r--src/hardware/interrupts.asm (renamed from src/interrupts.asm)0
-rw-r--r--src/hardware/interrupts.c (renamed from src/interrupts.c)0
-rw-r--r--src/hardware/interrupts.h (renamed from src/interrupts.h)0
-rw-r--r--src/hardware/pci.c (renamed from src/pci.c)0
-rw-r--r--src/hardware/pci.h (renamed from src/pci.h)0
-rw-r--r--src/hardware/port.asm (renamed from src/port.asm)0
-rw-r--r--src/hardware/port.c (renamed from src/port.c)0
-rw-r--r--src/hardware/port.h (renamed from src/port.h)0
-rw-r--r--src/kernel/console.c (renamed from src/console.c)0
-rw-r--r--src/kernel/console.h (renamed from src/console.h)0
-rw-r--r--src/kernel/kernel.asm (renamed from src/kernel.asm)0
-rw-r--r--src/kernel/kernel.c (renamed from src/kernel.c)0
-rw-r--r--src/kernel/kernel.h (renamed from src/kernel.h)0
-rw-r--r--src/kernel/serial.c (renamed from src/serial.c)0
-rw-r--r--src/kernel/serial.h (renamed from src/serial.h)0
-rw-r--r--src/kernel/vgatext.c (renamed from src/vgatext.c)0
-rw-r--r--src/kernel/vgatext.h (renamed from src/vgatext.h)0
-rw-r--r--src/libc/limits.h (renamed from src/limits.h)0
-rw-r--r--src/libc/setjmp.asm (renamed from src/setjmp.asm)0
-rw-r--r--src/libc/setjmp.h (renamed from src/setjmp.h)0
-rw-r--r--src/libc/stddef.h (renamed from src/stddef.h)4
-rw-r--r--src/libc/stdio.c (renamed from src/stdio.c)0
-rw-r--r--src/libc/stdio.h (renamed from src/stdio.h)0
-rw-r--r--src/libc/stdlib.c (renamed from src/stdlib.c)0
-rw-r--r--src/libc/stdlib.h (renamed from src/stdlib.h)0
-rw-r--r--src/libc/string.c (renamed from src/string.c)0
-rw-r--r--src/libc/string.h (renamed from src/string.h)2
-rw-r--r--src/sys/types.h8
36 files changed, 82 insertions, 57 deletions
diff --git a/src/Makefile b/src/Makefile
index c89f9c3..f352a6c 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -1,5 +1,6 @@
CC := gcc
-CFLAGS := -std=c99 -m32 -ffreestanding -O0 -g -Wall -Werror
+INCLUDES = -I. -Ilibc -Ihardware -Idrivers -Idrivers/hdi -Idrivers/hdi/ps2 -Ikernel
+CFLAGS := -std=c99 -m32 -ffreestanding -O0 -g -Wall -Werror $(INCLUDES)
LD := ld
NASMFLAGS := -f elf32
NASM := nasm
@@ -33,70 +34,76 @@ kernel.bin: kernel.elf
kernel.sym: kernel.elf
$(OBJCOPY) --only-keep-debug kernel.elf kernel.sym
-kernel.elf: kernel.o kernel_asm.o console.o vgatext.o serial.o port.o port_asm.o interrupts.o interrupts_asm.o driver.o pci.o keyboard.o mouse.o string.o stdlib.o stdio.o setjmp.o
+kernel.elf: kernel/kernel.o kernel/kernel_asm.o kernel/console.o kernel/vgatext.o kernel/serial.o hardware/port.o hardware/port_asm.o hardware/interrupts.o hardware/interrupts_asm.o hardware/pci.o drivers/driver.o drivers/hdi/ps2/keyboard.o drivers/hdi/ps2/mouse.o libc/string.o libc/stdlib.o libc/stdio.o libc/setjmp.o
$(LD) -o kernel.elf -N -n -Ttext 0x8400 --oformat elf32-i386 \
- kernel.o kernel_asm.o console.o vgatext.o serial.o \
- port.o port_asm.o interrupts.o interrupts_asm.o \
- driver.o pci.o \
- keyboard.o mouse.o \
- string.o stdlib.o stdio.o setjmp.o
+ kernel/kernel.o kernel/kernel_asm.o \
+ kernel/console.o kernel/vgatext.o kernel/serial.o \
+ hardware/port.o hardware/port_asm.o \
+ hardware/interrupts.o hardware/interrupts_asm.o \
+ hardware/pci.o \
+ drivers/driver.o \
+ drivers/hdi/ps2/keyboard.o drivers/hdi/ps2/mouse.o \
+ libc/string.o libc/stdlib.o libc/stdio.o libc/setjmp.o
magic.bin: boot/magic.asm
$(NASM) boot/magic.asm -DMAGIC='"$(MAGIC)"' -f bin -o magic.bin
-kernel.o: kernel.c
- $(CC) $(CFLAGS) -c -o kernel.o kernel.c
+kernel/kernel.o: kernel/kernel.c
+ $(CC) $(CFLAGS) -c -o kernel/kernel.o kernel/kernel.c
-kernel_asm.o: kernel.asm
- $(NASM) kernel.asm $(NASMFLAGS) -o kernel_asm.o
+kernel/kernel_asm.o: kernel/kernel.asm
+ $(NASM) kernel/kernel.asm $(NASMFLAGS) -o kernel/kernel_asm.o
-port.o: port.c port.h
- $(CC) $(CFLAGS) -c -o port.o port.c
+hardware/port.o: hardware/port.c hardware/port.h
+ $(CC) $(CFLAGS) -c -o hardware/port.o hardware/port.c
-port_asm.o: port.asm
- $(NASM) port.asm $(NASMFLAGS) -o port_asm.o
+hardware/port_asm.o: hardware/port.asm
+ $(NASM) hardware/port.asm $(NASMFLAGS) -o hardware/port_asm.o
-console.o: console.c console.h vgatext.h serial.h
- $(CC) $(CFLAGS) -c -o console.o console.c
+kernel/console.o: kernel/console.c kernel/console.h kernel/vgatext.h kernel/serial.h
+ $(CC) $(CFLAGS) -c -o kernel/console.o kernel/console.c
-vgatext.o: vgatext.c vgatext.h
- $(CC) $(CFLAGS) -c -o vgatext.o vgatext.c
+kernel/vgatext.o: kernel/vgatext.c kernel/vgatext.h
+ $(CC) $(CFLAGS) -c -o kernel/vgatext.o kernel/vgatext.c
-serial.o: serial.c serial.h
- $(CC) $(CFLAGS) -c -o serial.o serial.c
+kernel/serial.o: kernel/serial.c kernel/serial.h
+ $(CC) $(CFLAGS) -c -o kernel/serial.o kernel/serial.c
-interrupts.o: interrupts.c interrupts.h
- $(CC) $(CFLAGS) -c -o interrupts.o interrupts.c
+hardware/interrupts.o: hardware/interrupts.c hardware/interrupts.h
+ $(CC) $(CFLAGS) -c -o hardware/interrupts.o hardware/interrupts.c
-interrupts_asm.o: interrupts.asm
- $(NASM) interrupts.asm $(NASMFLAGS) -o interrupts_asm.o
+hardware/interrupts_asm.o: hardware/interrupts.asm
+ $(NASM) hardware/interrupts.asm $(NASMFLAGS) -o hardware/interrupts_asm.o
-driver.o: driver.c driver.h
- $(CC) $(CFLAGS) -c -o driver.o driver.c
+hardware/pci.o: hardware/pci.c hardware/pci.h
+ $(CC) $(CFLAGS) -c -o hardware/pci.o hardware/pci.c
-pci.o: pci.c pci.h
- $(CC) $(CFLAGS) -c -o pci.o pci.c
+drivers/driver.o: drivers/driver.c drivers/driver.h
+ $(CC) $(CFLAGS) -c -o drivers/driver.o drivers/driver.c
-keyboard.o: keyboard.c keyboard.h
- $(CC) $(CFLAGS) -c -o keyboard.o keyboard.c
+drivers/hdi/ps2/keyboard.o: drivers/hdi/ps2/keyboard.c drivers/hdi/ps2/keyboard.h
+ $(CC) $(CFLAGS) -c -o drivers/hdi/ps2/keyboard.o drivers/hdi/ps2/keyboard.c
-mouse.o: mouse.c mouse.h
- $(CC) $(CFLAGS) -c -o mouse.o mouse.c
+drivers/hdi/ps2/mouse.o: drivers/hdi/ps2/mouse.c drivers/hdi/ps2/mouse.h
+ $(CC) $(CFLAGS) -c -o drivers/hdi/ps2/mouse.o drivers/hdi/ps2/mouse.c
-string.o: string.c string.h
- $(CC) $(CFLAGS) -c -o string.o string.c
+libc/string.o: libc/string.c libc/string.h
+ $(CC) $(CFLAGS) -c -o libc/string.o libc/string.c
-stdlib.o: stdlib.c stdlib.h
- $(CC) $(CFLAGS) -c -o stdlib.o stdlib.c
+libc/stdlib.o: libc/stdlib.c libc/stdlib.h
+ $(CC) $(CFLAGS) -c -o libc/stdlib.o libc/stdlib.c
-stdio.o: stdio.c stdio.h
- $(CC) $(CFLAGS) -c -o stdio.o stdio.c
+libc/stdio.o: libc/stdio.c libc/stdio.h
+ $(CC) $(CFLAGS) -c -o libc/stdio.o libc/stdio.c
-setjmp.o: setjmp.asm
- $(NASM) setjmp.asm $(NASMFLAGS) -o setjmp.o
+libc/setjmp.o: libc/setjmp.asm
+ $(NASM) libc/setjmp.asm $(NASMFLAGS) -o libc/setjmp.o
clean:
- -rm -f boot.bin kernel.bin kernel.sym kernel.elf image.bin magic.bin *.o boot.map image.tmp
+ -rm -f boot.bin kernel.bin kernel.sym kernel.elf image.bin magic.bin boot.map image.tmp \
+ serial.log \
+ libc/*.o hardware/*.o kernel/*.o \
+ drivers/*.o drivers/*/*.o drivers/*/*/*.o
run-qemu-hd: image.bin
qemu-system-i386 -net nic,model=ne2k_pci -d guest_errors -m 32 -drive "file=image.bin,if=ide,format=raw" \
diff --git a/src/README b/src/README
index 0d1719c..c1f1577 100644
--- a/src/README
+++ b/src/README
@@ -1,3 +1,8 @@
+boot
+----
+
+Simple bootloader, loading in two phases and loading the kernel itself
+
* boot.bin - boot sector (stage 1 and 2, total 2k), offset 0x7c00
* boot.asm - the main boot sector code using:
* kernel.bin - linked kernel with fix start offset 0x8400
@@ -9,20 +14,39 @@
* magic.bin (512 bytes magic marker sector)
* magic.asm
-kernel utility routines
+kernel
+------
+
+Kernel main and utility routines like early consoles.
+
* kernel.c - kernel helper functions
-* port.c, port.asm - I/O ports
-* interrupts.c, interrups.asm - interrupt handlers
-* pci.c - PCI introspection and driver initialization
* console.c - the kernel console, can use VGA or serial port for now
* vga.c - VGA basic output routines for early kernel output
* serial.c - serial output to COM1 (only sequential ASCII chars, no terminal)
-kernel drivers
+hardware
+--------
+
+Hardware abstraction layer.
+
+* port.c, port.asm - I/O ports
+* interrupts.c, interrups.asm - interrupt handlers
+* pci.c - PCI introspection and driver initialization
+
+drivers
+-------
+
+Driver framework and specific drivers.
+
* driver.c - generic driver manager
* keyboard.c - PS/2 keyboard
* mouse.c - PS/2 mouse
+libc
+----
+
+Stub C library implementation.
+
C library definitions
* stddef.h - definition of NULL, size_t
* limits.h - domain range constants like INT_MAX
diff --git a/src/driver.c b/src/drivers/driver.c
index 5a1a479..5a1a479 100644
--- a/src/driver.c
+++ b/src/drivers/driver.c
diff --git a/src/driver.h b/src/drivers/driver.h
index c110308..c110308 100644
--- a/src/driver.h
+++ b/src/drivers/driver.h
diff --git a/src/keyboard.c b/src/drivers/hdi/ps2/keyboard.c
index d7d8d88..d7d8d88 100644
--- a/src/keyboard.c
+++ b/src/drivers/hdi/ps2/keyboard.c
diff --git a/src/keyboard.h b/src/drivers/hdi/ps2/keyboard.h
index 5f90ee8..5f90ee8 100644
--- a/src/keyboard.h
+++ b/src/drivers/hdi/ps2/keyboard.h
diff --git a/src/mouse.c b/src/drivers/hdi/ps2/mouse.c
index 46984eb..46984eb 100644
--- a/src/mouse.c
+++ b/src/drivers/hdi/ps2/mouse.c
diff --git a/src/mouse.h b/src/drivers/hdi/ps2/mouse.h
index cbd02ef..cbd02ef 100644
--- a/src/mouse.h
+++ b/src/drivers/hdi/ps2/mouse.h
diff --git a/src/interrupts.asm b/src/hardware/interrupts.asm
index 155b2af..155b2af 100644
--- a/src/interrupts.asm
+++ b/src/hardware/interrupts.asm
diff --git a/src/interrupts.c b/src/hardware/interrupts.c
index 614dbf0..614dbf0 100644
--- a/src/interrupts.c
+++ b/src/hardware/interrupts.c
diff --git a/src/interrupts.h b/src/hardware/interrupts.h
index 8ab485e..8ab485e 100644
--- a/src/interrupts.h
+++ b/src/hardware/interrupts.h
diff --git a/src/pci.c b/src/hardware/pci.c
index 6b124b2..6b124b2 100644
--- a/src/pci.c
+++ b/src/hardware/pci.c
diff --git a/src/pci.h b/src/hardware/pci.h
index ddbc990..ddbc990 100644
--- a/src/pci.h
+++ b/src/hardware/pci.h
diff --git a/src/port.asm b/src/hardware/port.asm
index 555a4e8..555a4e8 100644
--- a/src/port.asm
+++ b/src/hardware/port.asm
diff --git a/src/port.c b/src/hardware/port.c
index 46e7f37..46e7f37 100644
--- a/src/port.c
+++ b/src/hardware/port.c
diff --git a/src/port.h b/src/hardware/port.h
index ec96d09..ec96d09 100644
--- a/src/port.h
+++ b/src/hardware/port.h
diff --git a/src/console.c b/src/kernel/console.c
index 6113823..6113823 100644
--- a/src/console.c
+++ b/src/kernel/console.c
diff --git a/src/console.h b/src/kernel/console.h
index a1c55ac..a1c55ac 100644
--- a/src/console.h
+++ b/src/kernel/console.h
diff --git a/src/kernel.asm b/src/kernel/kernel.asm
index f024897..f024897 100644
--- a/src/kernel.asm
+++ b/src/kernel/kernel.asm
diff --git a/src/kernel.c b/src/kernel/kernel.c
index 3c520d6..3c520d6 100644
--- a/src/kernel.c
+++ b/src/kernel/kernel.c
diff --git a/src/kernel.h b/src/kernel/kernel.h
index dc23fd6..dc23fd6 100644
--- a/src/kernel.h
+++ b/src/kernel/kernel.h
diff --git a/src/serial.c b/src/kernel/serial.c
index c5a6d95..c5a6d95 100644
--- a/src/serial.c
+++ b/src/kernel/serial.c
diff --git a/src/serial.h b/src/kernel/serial.h
index b30fe55..b30fe55 100644
--- a/src/serial.h
+++ b/src/kernel/serial.h
diff --git a/src/vgatext.c b/src/kernel/vgatext.c
index cbee587..cbee587 100644
--- a/src/vgatext.c
+++ b/src/kernel/vgatext.c
diff --git a/src/vgatext.h b/src/kernel/vgatext.h
index 499e3d8..499e3d8 100644
--- a/src/vgatext.h
+++ b/src/kernel/vgatext.h
diff --git a/src/limits.h b/src/libc/limits.h
index 1fc4e37..1fc4e37 100644
--- a/src/limits.h
+++ b/src/libc/limits.h
diff --git a/src/setjmp.asm b/src/libc/setjmp.asm
index a20a0af..a20a0af 100644
--- a/src/setjmp.asm
+++ b/src/libc/setjmp.asm
diff --git a/src/setjmp.h b/src/libc/setjmp.h
index 5f987f1..5f987f1 100644
--- a/src/setjmp.h
+++ b/src/libc/setjmp.h
diff --git a/src/stddef.h b/src/libc/stddef.h
index 57a0297..4333661 100644
--- a/src/stddef.h
+++ b/src/libc/stddef.h
@@ -1,8 +1,10 @@
#ifndef STDDEF_H
#define STDDEF_H
+#include <stdint.h>
+
#define NULL ( (void *)0 )
-#define size_t uint32_t
+typedef uint32_t size_t;
#endif /* STDDEF_H */
diff --git a/src/stdio.c b/src/libc/stdio.c
index 1d53f7a..1d53f7a 100644
--- a/src/stdio.c
+++ b/src/libc/stdio.c
diff --git a/src/stdio.h b/src/libc/stdio.h
index bc7fac0..bc7fac0 100644
--- a/src/stdio.h
+++ b/src/libc/stdio.h
diff --git a/src/stdlib.c b/src/libc/stdlib.c
index 46bdce8..46bdce8 100644
--- a/src/stdlib.c
+++ b/src/libc/stdlib.c
diff --git a/src/stdlib.h b/src/libc/stdlib.h
index 331012e..331012e 100644
--- a/src/stdlib.h
+++ b/src/libc/stdlib.h
diff --git a/src/string.c b/src/libc/string.c
index 8d4f876..8d4f876 100644
--- a/src/string.c
+++ b/src/libc/string.c
diff --git a/src/string.h b/src/libc/string.h
index e24df9b..476c8c0 100644
--- a/src/string.h
+++ b/src/libc/string.h
@@ -1,7 +1,7 @@
#ifndef STRING_H
#define STRING_H
-#include "sys/types.h"
+#include "stddef.h"
void *memset( void *s, int c, size_t n );
void *memmove( void *d, const void *s, size_t n );
diff --git a/src/sys/types.h b/src/sys/types.h
deleted file mode 100644
index 1ec9642..0000000
--- a/src/sys/types.h
+++ /dev/null
@@ -1,8 +0,0 @@
-#ifndef SYS_TYPES_H
-#define SYS_TYPES_H
-
-#include <stdint.h>
-
-typedef uint32_t size_t;
-
-#endif /* SYS_TYPES_H */