diff --git a/filesystem/Makefile b/filesystem/Makefile index 1bea9fd..7865c3b 100644 --- a/filesystem/Makefile +++ b/filesystem/Makefile @@ -3,8 +3,8 @@ MEM = filesystem.a VFS_SRC = vfs/vfs.c VFS_OBJ = vfs/vfs.o -IRD_SRC = initrd/initrd.c -IRD_OBJ = initrd/initrd.o +#IRD_SRC = initrd/initrd.c +#IRD_OBJ = initrd/initrd.o AR = ../gcc_kfs/bin/i386-elf-ar rcs CC = ../gcc_kfs/bin/i386-elf-gcc @@ -16,7 +16,7 @@ FLAGS = -ffreestanding \ all: $(MEM) -$(MEM): $(VFS_OBJ) $(IRD_OBJ) +$(MEM): $(VFS_OBJ) #$(IRD_OBJ) $(AR) $@ $^ vfs/%.o: vfs/%.c diff --git a/filesystem/vfs/vfs.c b/filesystem/vfs/vfs.c index 435f7a5..cceed94 100644 --- a/filesystem/vfs/vfs.c +++ b/filesystem/vfs/vfs.c @@ -23,6 +23,6 @@ uint32_t fs_close(PFILE node) { } dentry* fs_readdir(PFILE node, uint32_t index) { - if ((node->type & FS_DIR) && node->node_operations.readdir) return node->readdir(node, index); + if ((node->type & FS_DIR) && node->node_operations.readdir) return node->node_operations.readdir(node, index); return NULL; } diff --git a/filesystem/vfs/vfs.h b/filesystem/vfs/vfs.h index 6d1bfef..ad29790 100644 --- a/filesystem/vfs/vfs.h +++ b/filesystem/vfs/vfs.h @@ -6,7 +6,7 @@ #include "../../lib/string/string.h" #include "../../memory/vmm/vmm.h" -typedef enum node_type { +enum node_type { FS_FILE, FS_DIR, FS_CHARDEVICE, @@ -16,7 +16,7 @@ typedef enum node_type { FS_MOUNTPOINT }; -typedef enum open_flags { +enum open_flags { READ, WRITE }; @@ -35,12 +35,12 @@ typedef struct _FILE { uint32_t inode; uint32_t length; struct node_operations { - uint32_t (*read)(struct FILE*,uint32_t,uint32_t,char*buffer); - uint32_t (*write)(struct FILE*,uint32_t,uint32_t,char*buffer); - uint32_t (*open)(struct FILE*, enum open_flags); - uint32_t (*close)(struct FILE*); - dentry* (*readdir)(struct FILE*,uint32_t); - }; + uint32_t (*read)(struct _FILE*,uint32_t,uint32_t,char*buffer); + uint32_t (*write)(struct _FILE*,uint32_t,uint32_t,char*buffer); + uint32_t (*open)(struct _FILE*, enum open_flags); + uint32_t (*close)(struct _FILE*); + dentry* (*readdir)(struct _FILE*,uint32_t); + } node_operations; } FILE, *PFILE; uint32_t fs_close(PFILE); diff --git a/isoroot/boot/grub/grub.cfg b/isoroot/boot/grub/grub.cfg index d755194..4dd36e4 100644 --- a/isoroot/boot/grub/grub.cfg +++ b/isoroot/boot/grub/grub.cfg @@ -3,6 +3,5 @@ set default=0 menuentry "KFS" { multiboot /boot/kfs.elf - module /boot/initrd.img boot } diff --git a/isoroot/boot/initrd.img b/isoroot/boot/initrd.img deleted file mode 100644 index ae0fc55..0000000 Binary files a/isoroot/boot/initrd.img and /dev/null differ diff --git a/kernel/kernel.c b/kernel/kernel.c index cd12ab3..b876b43 100644 --- a/kernel/kernel.c +++ b/kernel/kernel.c @@ -31,8 +31,8 @@ void kernel_main(uint32_t magic, uint32_t addr) { multiboot_info_t* mbi = (multiboot_info_t*)addr; struct multiboot_mmap_entry* region = (struct multiboot_mmap_entry*) mbi->mmap_addr; uint32_t mem_size = MAX_MEMORY_SIZE; -// uint32_t initrd_location = *(uint32_t*)(mbi->mods_addr); -// uint32_t initrd_end = *(uint32_t*)(mbi->mods_addr + 4); + uint32_t initrd_location = *(uint32_t*)(mbi->mods_addr); + uint32_t initrd_end = *(uint32_t*)(mbi->mods_addr + 4); init_current_screen(BLUE, WHITE); term_clear(); @@ -54,6 +54,8 @@ void kernel_main(uint32_t magic, uint32_t addr) { asm volatile("mov %%cr0, %0" : "=r" (cr0)); if (cr0 & 0x80000000) printf("Paging enabled: cr0 == %p\n", cr0); else printf("Paging disabled: cr0 == %p\n", cr0); + printf("addr: %p value: %d\n", initrd_location, *(uint32_t*)initrd_location); + printf("addr: %p value: %d\n", initrd_end, *(uint32_t*)initrd_end); // if (!mbi->mods_count) printf("no mods added\n"); // fs_root = initialise_initrd(initrd_location); } diff --git a/kernel/kernel.h b/kernel/kernel.h index 59b4aac..6712ec8 100644 --- a/kernel/kernel.h +++ b/kernel/kernel.h @@ -11,5 +11,5 @@ #include "../multiboot/multiboot.h" #include "../memory/pmm/pmm.h" #include "../memory/vmm/vmm.h" -#include "../filesystem/initrd/initrd.h" +#include "../filesystem/ext2/fs.h" #endif diff --git a/make_initrd.sh b/make_initrd.sh deleted file mode 100755 index 6644d89..0000000 --- a/make_initrd.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash - -mkdir -p rootfs/{bin,sbin,etc,proc,sys,dev,tmp} # Create the root directory - -dd if=/dev/zero of=./isoroot/boot/initrd.img bs=1M count=4 # Create a 4MB blank image -mkfs.ext2 -F ./isoroot/boot/initrd.img # Format it as ext2 -sudo mount -o loop ./isoroot/boot/initrd.img /mnt # Mount the image -sudo cp -r rootfs/* /mnt # Copy your root filesystem to the image -sudo umount /mnt # Unmount the image