diff --git a/.gitignore b/.gitignore index 096d5ad..7c46f63 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,5 @@ /config.mk /rootfs/boot/tailix.multiboot2 +/rootfs/boot/procman +/rootfs/boot/memgr diff --git a/Makefile b/Makefile index 180c097..1b9ec31 100644 --- a/Makefile +++ b/Makefile @@ -3,8 +3,10 @@ ROOTFS = rootfs GRUBCFG = $(ROOTFS)/boot/grub/grub.cfg KERNEL = $(ROOTFS)/boot/tailix.multiboot2 +PROCMAN = $(ROOTFS)/boot/procman +MEMGR = $(ROOTFS)/boot/memgr -.PHONY: kernel/tailix.multiboot2 +.PHONY: kernel/tailix.multiboot2 procman/procman memgr/memgr all: run0 @@ -15,14 +17,28 @@ run1: $(IMAGE) qemu-system-i386 -cdrom $< -serial stdio clean: - rm -f $(IMAGE) $(KERNEL) + rm -f $(IMAGE) $(KERNEL) $(PROCMAN) $(MEMGR) make -C kernel clean + make -C procman clean + make -C memgr clean -$(IMAGE): $(GRUBCFG) $(KERNEL) +$(IMAGE): $(GRUBCFG) $(KERNEL) $(PROCMAN) $(MEMGR) grub-mkrescue $(ROOTFS) -o $@ $(KERNEL): kernel/tailix.multiboot2 cp $< $@ +$(PROCMAN): procman/procman + cp $< $@ + +$(MEMGR): memgr/memgr + cp $< $@ + kernel/tailix.multiboot2: make -C kernel tailix.multiboot2 + +procman/procman: + make -C procman procman + +memgr/memgr: + make -C memgr memgr diff --git a/memgr/.gitignore b/memgr/.gitignore new file mode 100644 index 0000000..9a41cad --- /dev/null +++ b/memgr/.gitignore @@ -0,0 +1 @@ +/memgr diff --git a/memgr/Makefile b/memgr/Makefile new file mode 100644 index 0000000..1412ac6 --- /dev/null +++ b/memgr/Makefile @@ -0,0 +1,20 @@ +CCPREFIX = i386-elftailix- + +AS = $(CCPREFIX)as +CC = $(CCPREFIX)gcc +LD = $(CCPREFIX)ld + +MEMGR = memgr + +CFLAGS = -std=gnu99 -ffreestanding -nostdinc -fno-builtin -fno-stack-protector -Wall -Wextra + +all: $(MEMGR) + +clean: + rm -f $(MEMGR) start.o + +$(MEMGR): start.o + $(LD) -o $@ -T linker.ld $^ + +start.o: start.c + $(CC) -c $< -o $@ $(CFLAGS) diff --git a/memgr/linker.ld b/memgr/linker.ld new file mode 100644 index 0000000..6cc6d47 --- /dev/null +++ b/memgr/linker.ld @@ -0,0 +1,29 @@ +OUTPUT_ARCH("i386") +OUTPUT_FORMAT("elf32-i386") +ENTRY(_start) + +SECTIONS +{ + . = 0x0; + + .text BLOCK(4K) : ALIGN(4K) + { + *(.text) + } + + .rodata BLOCK(4K) : ALIGN(4K) + { + *(.rodata) + } + + .data BLOCK(4K) : ALIGN(4K) + { + *(.data) + } + + .bss BLOCK(4K) : ALIGN(4K) + { + *(COMMON) + *(.bss) + } +} diff --git a/memgr/start.c b/memgr/start.c new file mode 100644 index 0000000..d6d4900 --- /dev/null +++ b/memgr/start.c @@ -0,0 +1,8 @@ +void _start() +{ + asm( + "mov $0, %eax \n\t" + "mov $0, %ebx \n\t" + "int $0x80 \n\t" + ); +} diff --git a/procman/.gitignore b/procman/.gitignore new file mode 100644 index 0000000..992a001 --- /dev/null +++ b/procman/.gitignore @@ -0,0 +1 @@ +/procman diff --git a/procman/Makefile b/procman/Makefile new file mode 100644 index 0000000..f8e7c54 --- /dev/null +++ b/procman/Makefile @@ -0,0 +1,20 @@ +CCPREFIX = i386-elftailix- + +AS = $(CCPREFIX)as +CC = $(CCPREFIX)gcc +LD = $(CCPREFIX)ld + +PROCMAN = procman + +CFLAGS = -std=gnu99 -ffreestanding -nostdinc -fno-builtin -fno-stack-protector -Wall -Wextra + +all: $(PROCMAN) + +clean: + rm -f $(PROCMAN) start.o + +$(PROCMAN): start.o + $(LD) -o $@ -T linker.ld $^ + +start.o: start.c + $(CC) -c $< -o $@ $(CFLAGS) diff --git a/procman/linker.ld b/procman/linker.ld new file mode 100644 index 0000000..6cc6d47 --- /dev/null +++ b/procman/linker.ld @@ -0,0 +1,29 @@ +OUTPUT_ARCH("i386") +OUTPUT_FORMAT("elf32-i386") +ENTRY(_start) + +SECTIONS +{ + . = 0x0; + + .text BLOCK(4K) : ALIGN(4K) + { + *(.text) + } + + .rodata BLOCK(4K) : ALIGN(4K) + { + *(.rodata) + } + + .data BLOCK(4K) : ALIGN(4K) + { + *(.data) + } + + .bss BLOCK(4K) : ALIGN(4K) + { + *(COMMON) + *(.bss) + } +} diff --git a/procman/start.c b/procman/start.c new file mode 100644 index 0000000..00a2033 --- /dev/null +++ b/procman/start.c @@ -0,0 +1,32 @@ +void _start() +{ + asm( + "mov $0, %eax \n\t" + "mov $0, %ebx \n\t" + "int $0x80 \n\t" + + "mov $0, %eax \n\t" + "mov $1, %ebx \n\t" + "int $0x80 \n\t" + + "mov $1, %eax \n\t" + "mov $0, %ebx \n\t" + "int $0x80 \n\t" + + "mov $2, %eax \n\t" + "mov $0, %ebx \n\t" + "int $0x80 \n\t" + + "mov $256, %eax \n\t" + "mov $0, %ebx \n\t" + "int $0x80 \n\t" + + "mov $257, %eax \n\t" + "mov $0, %ebx \n\t" + "int $0x80 \n\t" + + "mov $258, %eax \n\t" + "mov $0, %ebx \n\t" + "int $0x80 \n\t" + ); +} diff --git a/rootfs/boot/grub/grub.cfg b/rootfs/boot/grub/grub.cfg index 8a307cc..5db0d7c 100644 --- a/rootfs/boot/grub/grub.cfg +++ b/rootfs/boot/grub/grub.cfg @@ -2,4 +2,6 @@ set timeout=0 menuentry "Tailix" { multiboot2 /boot/tailix.multiboot2 hello kernel + module2 /boot/procman hello module + module2 /boot/memgr }