[make] Clean everything up nice and tidy.
This commit is contained in:
parent
ae98614ec6
commit
8c818ea064
46
Makefile
46
Makefile
@ -7,38 +7,48 @@ DIRS = core
|
||||
all: kernel
|
||||
|
||||
install: kernel
|
||||
cp bootdisk.src.img bootdisk.img
|
||||
mount bootdisk.img /mnt -o loop
|
||||
cp kernel /mnt/kernel
|
||||
cp initrd /mnt/initrd
|
||||
umount /mnt
|
||||
cp kernel /boot/toaruos-kernel
|
||||
cp initrd /boot/toaruos-initrd
|
||||
@${ECHO} -n "\e[32m -- Installing floppy image...\e[0m"
|
||||
@cp bootdisk.src.img bootdisk.img
|
||||
@mount bootdisk.img /mnt -o loop
|
||||
@cp kernel /mnt/kernel
|
||||
@cp initrd /mnt/initrd
|
||||
@umount /mnt
|
||||
@cp kernel /boot/toaruos-kernel
|
||||
@cp initrd /boot/toaruos-initrd
|
||||
@${ECHO} "\r\e[32;1m -- Floppy image created. \e[0m"
|
||||
|
||||
run: bootdisk.img
|
||||
qemu -fda bootdisk.img
|
||||
|
||||
curses: bootdisk.img
|
||||
qemu -curses -fda bootdisk.img
|
||||
@qemu -curses -fda bootdisk.img
|
||||
|
||||
kernel: start.o link.ld main.o core
|
||||
${LD} -T link.ld -o kernel *.o core/*.o core/fs/*.o
|
||||
@${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"
|
||||
|
||||
%.o: %.c
|
||||
${CC} ${CFLAGS} -I./include -c -o $@ $<
|
||||
@${ECHO} -n "\e[32m CC $<\e[0m"
|
||||
@${CC} ${CFLAGS} -I./include -c -o $@ $<
|
||||
@${ECHO} "\r\e[32;1m CC $<\e[0m"
|
||||
|
||||
core:
|
||||
cd core; ${MAKE} ${MFLAGS}
|
||||
@cd core; ${MAKE} ${MFLAGS}
|
||||
|
||||
start.o: start.asm
|
||||
nasm -f elf -o start.o start.asm
|
||||
@${ECHO} -n "\e[32m nasm start.asm\e[0m"
|
||||
@nasm -f elf -o start.o start.asm
|
||||
@${ECHO} "\r\e[32;1m nasm start.asm\e[0m"
|
||||
|
||||
initrd: fs
|
||||
-rm -f initrd
|
||||
genext2fs -d fs -q -b 249 -v initrd
|
||||
@${ECHO} -n "\e[32m initrd Generating initial RAM disk\e[0m"
|
||||
@-rm -f initrd
|
||||
@genext2fs -d fs -q -b 249 initrd
|
||||
@${ECHO} "\r\e[32;1m initrd Generated initial RAM disk image\e[0m"
|
||||
|
||||
clean:
|
||||
-rm -f *.o kernel
|
||||
-rm -f bootdisk.img
|
||||
-rm -f initrd
|
||||
-for d in ${DIRS}; do (cd $$d; ${MAKE} clean); done
|
||||
@-rm -f *.o kernel
|
||||
@-rm -f bootdisk.img
|
||||
@-rm -f initrd
|
||||
@-for d in ${DIRS}; do (cd $$d; ${MAKE} clean); done
|
||||
|
@ -1,5 +1,5 @@
|
||||
CC = gcc
|
||||
LD = ld -m elf_i386
|
||||
CFLAGS = -Wall -Wextra -pedantic -m32 -O0 -std=c99 -finline-functions -fno-stack-protector -nostdinc -ffreestanding
|
||||
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
|
||||
|
@ -4,10 +4,12 @@ include ../Makefile.inc
|
||||
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 fs
|
||||
|
||||
%.o: %.c
|
||||
${CC} ${CFLAGS} -I../include -c -o $@ $<
|
||||
@${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}
|
||||
@cd fs; ${MAKE} ${MFLAGS}
|
||||
|
||||
clean:
|
||||
-rm -f *.o
|
||||
@-rm -f *.o
|
||||
|
@ -163,12 +163,12 @@ void free(void * ptr) {
|
||||
*/
|
||||
static size_t __attribute__ ((always_inline, pure)) klmalloc_adjust_bin(size_t bin)
|
||||
{
|
||||
if (bin <= SMALLEST_BIN_LOG)
|
||||
if (bin <= (size_t)SMALLEST_BIN_LOG)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
bin -= SMALLEST_BIN_LOG + 1;
|
||||
if (bin > BIG_BIN) {
|
||||
if (bin > (size_t)BIG_BIN) {
|
||||
return BIG_BIN;
|
||||
}
|
||||
return bin;
|
||||
@ -696,7 +696,7 @@ static void klfree(void *ptr) {
|
||||
* easy to tell which is which, though.
|
||||
*/
|
||||
size_t bucket_id = header->size;
|
||||
if (bucket_id > NUM_BINS) {
|
||||
if (bucket_id > (size_t)NUM_BINS) {
|
||||
bucket_id = BIG_BIN;
|
||||
klmalloc_big_bin_header *bheader = (klmalloc_big_bin_header*)header;
|
||||
|
||||
@ -848,7 +848,7 @@ static void * __attribute__ ((malloc)) klrealloc(void *ptr, size_t size) {
|
||||
void * newptr = klmalloc(size);
|
||||
if (__builtin_expect(newptr != NULL, 1)) {
|
||||
size_t old_size = header_old->size;
|
||||
if (old_size < BIG_BIN) {
|
||||
if (old_size < (size_t)BIG_BIN) {
|
||||
/*
|
||||
* If we are copying from a small bin,
|
||||
* we need to get the size of the bin
|
||||
|
@ -6,7 +6,7 @@
|
||||
#include <system.h>
|
||||
|
||||
extern uintptr_t end;
|
||||
uintptr_t placement_pointer = &end;
|
||||
uintptr_t placement_pointer = (uintptr_t)&end;
|
||||
|
||||
void
|
||||
kmalloc_startat(
|
||||
@ -226,7 +226,7 @@ page_fault(
|
||||
int reserved = r->err_code & 0x8;
|
||||
int id = r->err_code & 0x10;
|
||||
|
||||
kprintf("Page fault! (p:%d,rw:%d,user:%d,res:%d) at 0x%x\n", present, rw, user, reserved, faulting_address);
|
||||
kprintf("Page fault! (p:%d,rw:%d,user:%d,res:%d,id:%d) at 0x%x\n", present, rw, user, reserved, id, faulting_address);
|
||||
HALT_AND_CATCH_FIRE("Page fault");
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,7 @@ dump_multiboot(
|
||||
kprintf("(%dMB)\n", mem_mb);
|
||||
kprintf("Found %d module(s).\n", mboot_ptr->mods_count);
|
||||
if (mboot_ptr->mods_count > 0) {
|
||||
int i;
|
||||
uint32_t i;
|
||||
for (i = 0; i < mboot_ptr->mods_count; ++i ) {
|
||||
uint32_t module_start = *((uint32_t*)mboot_ptr->mods_addr + 8 * i);
|
||||
uint32_t module_end = *(uint32_t*)(mboot_ptr->mods_addr + 8 * i + 4);
|
||||
|
7
main.c
7
main.c
@ -59,7 +59,6 @@ int main(struct multiboot *mboot_ptr)
|
||||
|
||||
/* Realing memory to the end of the multiboot modules */
|
||||
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);
|
||||
kmalloc_startat(module_end);
|
||||
}
|
||||
@ -95,17 +94,17 @@ int main(struct multiboot *mboot_ptr)
|
||||
uint32_t module_end = *(uint32_t *) (mboot_ptr->mods_addr + 4);
|
||||
|
||||
initrd_mount(module_start, module_end);
|
||||
fs_node_t *test_file = kopen("/etc/motd", NULL);
|
||||
fs_node_t *test_file = kopen("/etc/motd", 0);
|
||||
if (!test_file) {
|
||||
kprintf("Could not find an MOTD in the provided initial RAMdisk.\n");
|
||||
return 0;
|
||||
}
|
||||
char * buffer = malloc(sizeof(char) * 2048);
|
||||
uint32_t bytes_read;
|
||||
bytes_read = read_fs(test_file, 0, 2047, buffer);
|
||||
bytes_read = read_fs(test_file, 0, 2047, (uint8_t *) buffer);
|
||||
uint32_t i = 0;
|
||||
for (i = 0; i < bytes_read; ++i) {
|
||||
kprintf("%c", buffer[i]);
|
||||
putch(buffer[i]);
|
||||
}
|
||||
close_fs(test_file);
|
||||
free(test_file);
|
||||
|
Loading…
Reference in New Issue
Block a user