[build] Restructure build process.
This commit is contained in:
parent
a38149ee9f
commit
7d3d404264
25
Makefile
25
Makefile
@ -1,12 +1,16 @@
|
||||
include Makefile.inc
|
||||
CC = gcc
|
||||
LD = ld -m elf_i386
|
||||
CFLAGS = -Wall -Wextra -pedantic -m32 -O0 -std=c99 -finline-functions -fno-stack-protector -nostdinc -ffreestanding -Wno-unused-function -Wno-unused-parameter
|
||||
NASM = nasm -f elf
|
||||
ECHO = `which echo` -e
|
||||
MODULES = $(patsubst %.c,%.o,$(wildcard core/*.c))
|
||||
FILESYSTEMS = $(patsubst %.c,%.o,$(wildcard core/fs/*.c))
|
||||
|
||||
DIRS = core
|
||||
.PHONY: all clean install run curses initrd corr
|
||||
|
||||
.PHONY: all clean install run curses initrd core
|
||||
all: kernel initrd
|
||||
|
||||
all: kernel
|
||||
|
||||
install: kernel
|
||||
install: kernel initrd
|
||||
@${ECHO} -n "\e[32m -- Installing floppy image...\e[0m"
|
||||
@cp bootdisk.src.img bootdisk.img
|
||||
@mount bootdisk.img /mnt -o loop
|
||||
@ -23,7 +27,7 @@ run: bootdisk.img
|
||||
curses: bootdisk.img
|
||||
@qemu -curses -fda bootdisk.img
|
||||
|
||||
kernel: start.o link.ld main.o core
|
||||
kernel: start.o link.ld main.o ${MODULES} ${FILESYSEMS}
|
||||
@${ECHO} -n "\e[32m LD $<\e[0m"
|
||||
@${LD} -T link.ld -o kernel *.o core/*.o core/fs/*.o
|
||||
@${ECHO} "\r\e[32;1m LD $<\e[0m"
|
||||
@ -38,9 +42,6 @@ start.o: start.asm
|
||||
@${CC} ${CFLAGS} -I./include -c -o $@ $<
|
||||
@${ECHO} "\r\e[32;1m CC $<\e[0m"
|
||||
|
||||
core:
|
||||
@cd core; ${MAKE} ${MFLAGS}
|
||||
|
||||
initrd: fs
|
||||
@${ECHO} -n "\e[32m initrd Generating initial RAM disk\e[0m"
|
||||
@-rm -f initrd
|
||||
@ -51,5 +52,5 @@ clean:
|
||||
@-rm -f *.o kernel
|
||||
@-rm -f bootdisk.img
|
||||
@-rm -f initrd
|
||||
@-rm -f core.d
|
||||
@-for d in ${DIRS}; do (cd $$d; ${MAKE} clean); done
|
||||
@-rm -f core/*.o
|
||||
@-rm -f core/fs/*.o
|
||||
|
@ -1,5 +0,0 @@
|
||||
CC = gcc
|
||||
LD = ld -m elf_i386
|
||||
CFLAGS = -Wall -Wextra -pedantic -m32 -O0 -std=c99 -finline-functions -fno-stack-protector -nostdinc -ffreestanding -Wno-unused-function -Wno-unused-parameter
|
||||
NASM = nasm -f elf
|
||||
ECHO = `which echo` -e
|
@ -1,18 +0,0 @@
|
||||
include ../Makefile.inc
|
||||
DIRS = fs
|
||||
|
||||
.PHONY: all clean install fs
|
||||
|
||||
all: system.o multiboot.o gdt.o idt.o irq.o isrs.o kbd.o kprintf.o timer.o vga.o mem.o panic.o alloc.o vfs.o shell.o fs
|
||||
|
||||
%.o: %.c
|
||||
@${ECHO} -n "\e[32m CC core/$<\e[0m"
|
||||
@${CC} ${CFLAGS} -I../include -c -o $@ $<
|
||||
@${ECHO} "\r\e[32;1m CC core/$<\e[0m"
|
||||
|
||||
fs:
|
||||
@cd fs; ${MAKE} ${MFLAGS}
|
||||
|
||||
clean:
|
||||
@-rm -f *.o
|
||||
@-for d in ${DIRS}; do (cd $$d; ${MAKE} clean); done
|
@ -1,12 +0,0 @@
|
||||
include ../../Makefile.inc
|
||||
.PHONY: all clean install
|
||||
|
||||
all: ext2_initrd.o
|
||||
|
||||
%.o: %.c
|
||||
@${ECHO} -n "\e[32m CC core/fs/$<\e[0m"
|
||||
@${CC} ${CFLAGS} -I../../include -c -o $@ $<
|
||||
@${ECHO} "\r\e[32;1m CC core/fs/$<\e[0m"
|
||||
|
||||
clean:
|
||||
-rm -f *.o
|
24
main.c
24
main.c
@ -57,16 +57,19 @@
|
||||
int main(struct multiboot *mboot_ptr, uint32_t mboot_mag)
|
||||
{
|
||||
int using_multiboot = 0;
|
||||
char * ramdisk = NULL;
|
||||
if (mboot_mag == MULTIBOOT_EAX_MAGIC) {
|
||||
using_multiboot = 1;
|
||||
/* Realing memory to the end of the multiboot modules */
|
||||
if (mboot_ptr->mods_count > 0) {
|
||||
uint32_t module_end = *(uint32_t *) (mboot_ptr->mods_addr + 4);
|
||||
kmalloc_startat(module_end);
|
||||
kmalloc_startat(0x200000);
|
||||
if (mboot_ptr->flags & 0x04) {
|
||||
if (mboot_ptr->mods_count > 0) {
|
||||
uint32_t module_start = *((uint32_t *) mboot_ptr->mods_addr);
|
||||
uint32_t module_end = *(uint32_t *) (mboot_ptr->mods_addr + 4);
|
||||
ramdisk = (char *)kmalloc(module_end - module_start);
|
||||
memcpy(ramdisk, (char *)module_start, module_end - module_start);
|
||||
}
|
||||
}
|
||||
#if 1
|
||||
mboot_ptr = copy_multiboot(mboot_ptr);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Initialize core modules */
|
||||
@ -92,11 +95,10 @@ int main(struct multiboot *mboot_ptr, uint32_t mboot_mag)
|
||||
/* Print multiboot information */
|
||||
dump_multiboot(mboot_ptr);
|
||||
|
||||
if (mboot_ptr->mods_count > 0) {
|
||||
uint32_t module_start = *((uint32_t *) mboot_ptr->mods_addr);
|
||||
uint32_t module_end = *(uint32_t *) (mboot_ptr->mods_addr + 4);
|
||||
|
||||
initrd_mount(module_start, module_end);
|
||||
if (mboot_ptr->flags & 0x04) {
|
||||
if (mboot_ptr->mods_count > 0) {
|
||||
initrd_mount((uintptr_t)ramdisk, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user