Beginnings of vfs_initrd driver
diff --git a/src/kernel/Makefile b/src/kernel/Makefile
index 0a95915..9029f26 100644
--- a/src/kernel/Makefile
+++ b/src/kernel/Makefile
@@ -15,7 +15,8 @@
kheap.o \
alloc.o \
vfs.o \
- multiboot.o
+ multiboot.o \
+ vfs_initrd.o
JAYROOT = ../../
CFLAGS = -nostdlib -nostdinc -fno-builtin -fno-stack-protector -ffreestanding \
diff --git a/src/kernel/alloc.c b/src/kernel/alloc.c
index c6e092c..0268928 100644
--- a/src/kernel/alloc.c
+++ b/src/kernel/alloc.c
@@ -269,3 +269,27 @@
return new;
}
}
+
+void test_allocator()
+{
+ int *one = malloc(sizeof(int));
+ int *two = malloc(sizeof(int));
+
+ *one = 1;
+ *two = 2;
+
+ int *array = malloc(sizeof(int[12]));
+
+ for (int i = 0; i < 12; i++)
+ array[i] = i;
+
+ kprintf("Allocated one, two, array[3] = %d, %d, %d\n", *one, *two,
+ array[3]);
+ kprintf("[%x, %x, %x]\n", one, two, array);
+
+ kprintf("Freeing two\n");
+ free(two);
+ int *four = malloc(sizeof(int));
+ *four = 4;
+ kprintf("Allocated four = %d (%x)\n", *four, four);
+}
diff --git a/src/kernel/alloc.h b/src/kernel/alloc.h
index 7312ae2..81ce15b 100644
--- a/src/kernel/alloc.h
+++ b/src/kernel/alloc.h
@@ -12,3 +12,5 @@
void *realloc(void *mem, size_t size);
void init_allocator();
+
+void test_allocator();
diff --git a/src/kernel/main.c b/src/kernel/main.c
index 5c04768..4e5b4ae 100644
--- a/src/kernel/main.c
+++ b/src/kernel/main.c
@@ -11,55 +11,29 @@
{
init_paging();
init_vga();
-
- vga_clear();
- vga_set_color(LIGHT_BLUE, BLACK);
- vga_write("Hello!\nWelcome to Bluejay OS\n");
- vga_set_color(WHITE, BLACK);
-
init_descriptor_tables();
-
- vga_set_color(LIGHT_GREEN, BLACK);
- vga_write("Setup complete!\n");
- vga_set_color(WHITE, BLACK);
+ vga_clear();
init_timer(20);
init_allocator();
init_kbd();
- // Test allocator
+ vga_set_color(LIGHT_GREEN, BLACK);
+ vga_write("Setup complete!\n");
+ vga_set_color(WHITE, BLACK);
- int *one = malloc(sizeof(int));
- int *two = malloc(sizeof(int));
-
- *one = 1;
- *two = 2;
-
- int *array = malloc(sizeof(int[12]));
-
- for (int i = 0; i < 12; i++)
- array[i] = i;
-
- kprintf("Allocated one, two, array[3] = %d, %d, %d\n", *one, *two,
- array[3]);
- kprintf("[%x, %x, %x]\n", one, two, array);
-
- kprintf("Freeing two\n");
- free(two);
- int *four = malloc(sizeof(int));
- *four = 4;
- kprintf("Allocated four = %d (%x)\n", *four, four);
+#ifdef TEST_ALLOC
+ test_allocator();
+#endif
// Load initrd
struct multiboot mb = make_multiboot_physical(mboot);
kassert(mb.mods_count, "No multiboot modules loaded!");
kprintf("mboot->mods_addr = %d (0x%x)\n", mb.mods_addr, mb.mods_addr);
- uint *initrd_loc = mb.mods_addr[0],
- *initrd_end = mboot->mods_addr[1];
+ uchar *initrd_loc = mb.mods_addr[0];
- kprintf("initrd is at 0x%x to 0x%x\n", initrd_loc, initrd_end);
-
+ kprintf("initrd is at 0x%x to 0x%x\n", initrd_loc);
asm volatile("sti");
diff --git a/src/kernel/multiboot.c b/src/kernel/multiboot.c
index 13e1f98..63f6ed1 100644
--- a/src/kernel/multiboot.c
+++ b/src/kernel/multiboot.c
@@ -18,7 +18,7 @@
kassert((size_t)mb.mods_addr > 0xc0000000, "mb.mods_addr PHYSICAL");
for (int i = 0; i < mb.mods_count + 1; i++)
{
- TO_VIRT(mb.mods_addr[i], uint *);
+ TO_VIRT(mb.mods_addr[i], uchar *);
}
return mb;
diff --git a/src/kernel/multiboot.h b/src/kernel/multiboot.h
index 3aaa0d0..059f281 100644
--- a/src/kernel/multiboot.h
+++ b/src/kernel/multiboot.h
@@ -10,7 +10,7 @@
uint boot_device;
char *cmdline;
uint mods_count;
- uint **mods_addr;
+ uchar **mods_addr;
uint num;
uint size;
uint addr;
diff --git a/src/kernel/timer.c b/src/kernel/timer.c
index 145f8f8..d17025c 100644
--- a/src/kernel/timer.c
+++ b/src/kernel/timer.c
@@ -17,8 +17,6 @@
uint divisor = TIMER_FREQ / hz;
- kprintf("Divisor is %d\n", divisor);
-
outb(0x43, 0x36);
io_wait();
uchar l = divisor & 0xff, h = (divisor >> 8) & 0xff;
@@ -27,6 +25,4 @@
io_wait();
outb(0x40, h);
io_wait();
-
- kprintf("Initialized timer\n");
}
diff --git a/src/kernel/vfs.c b/src/kernel/vfs.c
index 59ccaf5..4a584eb 100644
--- a/src/kernel/vfs.c
+++ b/src/kernel/vfs.c
@@ -1,5 +1,7 @@
#include "vfs.h"
+struct fs_node root, dev, initrd;
+
uint fs_read(struct fs_node *node, size_t offset, size_t size, uchar *buffer)
{
if (!node || !node->vtable || !node->vtable->read)
@@ -47,3 +49,12 @@
return node->vtable->finddir(node, name);
}
+
+struct fs_dirent *root_readdir(struct fs_node *node, uint index)
+{
+
+}
+
+void init_vfs()
+{
+}
diff --git a/src/kernel/vfs.h b/src/kernel/vfs.h
index 1c62a80..3bd135e 100644
--- a/src/kernel/vfs.h
+++ b/src/kernel/vfs.h
@@ -31,6 +31,7 @@
typedef void (* fs_open_t)(struct fs_node *node);
typedef void (* fs_close_t)(struct fs_node *node);
+// Dirent should be FREED BY CALLER
typedef struct fs_dirent *(* fs_readdir_t)(struct fs_node *node, uint index);
typedef struct fs_node *(* fs_finddir_t)(struct fs_node *node, char *name);
@@ -66,3 +67,5 @@
struct fs_dirent *fs_readdir(struct fs_node *node, uint index);
struct fs_node *fs_finddir(struct fs_node *node, char *name);
+
+void init_vfs();
diff --git a/src/kernel/vfs_initrd.c b/src/kernel/vfs_initrd.c
new file mode 100644
index 0000000..9298a2d
--- /dev/null
+++ b/src/kernel/vfs_initrd.c
@@ -0,0 +1,4 @@
+#include <initrd/initrd.h>
+#include "kint.h"
+
+
diff --git a/src/kernel/vfs_initrd.h b/src/kernel/vfs_initrd.h
new file mode 100644
index 0000000..6f70f09
--- /dev/null
+++ b/src/kernel/vfs_initrd.h
@@ -0,0 +1 @@
+#pragma once