Add EXT2 stub
diff --git a/src/kernel/Jmk b/src/kernel/Jmk
index 3759fd6..a821bae 100644
--- a/src/kernel/Jmk
+++ b/src/kernel/Jmk
@@ -24,7 +24,7 @@
LDFLAGS += -Tlink.ld -melf_i386
ASMFLAGS += -felf -Fdwarf
-QEMUFLAGS = -d cpu_reset
+QEMUFLAGS = -d cpu_reset -hda hd0.img
OBJECTS = boot.o \
main.o \
@@ -64,7 +64,12 @@
gdb $<
@pkill qemu-system-i38
-qemu: kernel.elf
+hd0.img:
+ status_log(MKFS, $@)
+ @dd bs=4M count=8 if=/dev/zero of=$@
+ @mkfs.ext2 $@
+
+qemu: kernel.elf hd0.img
qemu-system-i386 $(QEMUFLAGS) -monitor stdio -kernel kernel.elf -no-reboot
qemu-iso: install
@@ -73,6 +78,16 @@
scan_codes.c: gen_scan_codes.py scan_codes.tsv
python3 $< > $@
+mount: hd0.img
+ status_log(MOUNT, $^ $(ROOT)/mnt)
+ @mkdir -p $(ROOT)/mnt
+ @mount $^ $(ROOT)/mnt
+ @if [ $$(whoami) = root ]; then echo 'You ran this as root, you probably want to chown $(ROOT)/mnt now.'; fi
+
+umount:
+ status_log(UMOUNT, $(ROOT)/mnt)
+ @umount $(ROOT)/mnt
+
install: kernel.elf lib(initrd)
cp kernel.elf $(ROOT)/boot/
rm -f $(ROOT)/bin/bluejay.iso
diff --git a/src/kernel/dri/ata_pio/ata_pio.c b/src/kernel/dri/ata_pio/ata_pio.c
index cd45998..db1b7cb 100644
--- a/src/kernel/dri/ata_pio/ata_pio.c
+++ b/src/kernel/dri/ata_pio/ata_pio.c
@@ -3,18 +3,23 @@
#include <io.h>
#include <log.h>
+/* TODO: Rewrite all of this to work with dri_ide in the case of multiple
+ * devices */
+
static ushort test_buffer[256];
void ata_pio_wait_bsy()
{
while (inb(ATA_PORT_CMD) & ATA_BSY)
- {}
+ {
+ }
}
void ata_pio_wait_drq()
{
while (!(inb(ATA_PORT_CMD) & ATA_RDY))
- {}
+ {
+ }
}
uint ata_pio_get_error()
@@ -40,9 +45,7 @@
ata_pio_wait_bsy();
- asm volatile("rep insw" ::
- "c"(num_sectors * 256),
- "d"(ATA_PORT_DATA),
+ asm volatile("rep insw" ::"c"(num_sectors * 256), "d"(ATA_PORT_DATA),
"D"(buffer));
ata_pio_wait_bsy();
@@ -57,9 +60,7 @@
ata_pio_wait_bsy();
- asm volatile("rep outsw" ::
- "c"(num_sectors * 256),
- "d"(ATA_PORT_DATA),
+ asm volatile("rep outsw" :: "c"(num_sectors * 256), "d"(ATA_PORT_DATA),
"S"(buffer));
}
@@ -83,8 +84,8 @@
for (int i = 0; i < 256; i++)
test_buffer[i] = i;
- ata_pio_write_sectors(0, 1, test_buffer);
+ // ata_pio_write_sectors(0, 1, test_buffer);
- ata_pio_read_sectors(test_buffer, 0, 1);
- print_buffer();
+ // ata_pio_read_sectors(test_buffer, 0, 1);
+ // print_buffer();
}
diff --git a/src/kernel/dri/fs/ext2/Jmk b/src/kernel/dri/fs/ext2/Jmk
new file mode 100644
index 0000000..b0da0c3
--- /dev/null
+++ b/src/kernel/dri/fs/ext2/Jmk
@@ -0,0 +1,17 @@
+init(ext2, ext2.a)
+
+preset(freestanding)
+preset(optimize)
+preset(debug)
+preset(32)
+preset(warn)
+
+archetype(c)
+
+CFLAGS += -I/include/kernel
+
+OBJECTS = ext2.o
+
+type(static_lib)
+
+finish
diff --git a/src/kernel/dri/fs/ext2/ext2.c b/src/kernel/dri/fs/ext2/ext2.c
new file mode 100644
index 0000000..eb6842b
--- /dev/null
+++ b/src/kernel/dri/fs/ext2/ext2.c
@@ -0,0 +1,7 @@
+#include <dri/fs/ext2/ext2.h>
+#include <kint.h>
+
+void ext2_mount(struct fs_node *where)
+{
+ // TODO
+}
diff --git a/src/kernel/dri/ide/ide.c b/src/kernel/dri/ide/ide.c
index b42873d..21f2651 100644
--- a/src/kernel/dri/ide/ide.c
+++ b/src/kernel/dri/ide/ide.c
@@ -14,9 +14,25 @@
return dev->class == 1 && dev->subclass == 1;
}
+void ide_print_device(struct ide_device *dev)
+{
+ kprintf("<ide-device dma=%b>", dev->supports_dma);
+}
+
void ide_thread(struct ide_thread_data *data)
{
kprintf("IDE driver thread starting: device=0x%x\n", data->dev.device_id);
+
+ struct ide_device dev;
+
+ uchar p = data->dev.prog_if;
+ dev.channel_mode[0] = p & 1;
+ dev.channel_mode_modifiable[0] = p & (1 << 1);
+ dev.channel_mode[1] = p & (1 << 2);
+ dev.channel_mode_modifiable[1] = p & (1 << 3);
+ dev.supports_dma = p & (1 << 7);
+
+ ide_print_device(&dev);
}
void ide_init(struct pci_device dev, uchar bus, uchar slot, uchar func)
diff --git a/src/kernel/log.c b/src/kernel/log.c
index ac49971..11ce505 100644
--- a/src/kernel/log.c
+++ b/src/kernel/log.c
@@ -40,6 +40,13 @@
vga_put(s);
break;
}
+ case 'b': {
+ uint v = va_arg(args, uint);
+ if (v)
+ vga_write("true");
+ else
+ vga_write("false");
+ }
}
format++;
}
diff --git a/src/kernel/vfs.h b/src/kernel/vfs.h
deleted file mode 100644
index 1da0d6e..0000000
--- a/src/kernel/vfs.h
+++ /dev/null
@@ -1,80 +0,0 @@
-#pragma once
-
-#include "kint.h"
-
-struct fs_vtable;
-
-struct fs_node
-{
- char name[128]; /* file name */
- uint inode; /* identifier */
- uint flags; /* type of node */
- uint mask; /* permissions */
- uint gid; /* group id */
- uint uid; /* user id */
- size_t size; /* size in bytes */
- uint dri_res; /* reserved for driver */
-
- struct fs_vtable *vtable;
-
- struct fs_node *mount; /* used for mounts */
-};
-
-struct fs_dirent
-{
- char name[128];
- uint inode;
-};
-
-typedef uint (* fs_read_t)(struct fs_node *node, size_t offset, size_t size, uchar *buffer);
-typedef uint (* fs_write_t)(struct fs_node *node, size_t offset, size_t size, uchar *buffer);
-typedef void (* fs_open_t)(struct fs_node *node);
-typedef void (* fs_close_t)(struct fs_node *node);
-
-typedef bool (* fs_readdir_t)(struct fs_node *node, uint index, struct fs_dirent *dirent);
-typedef struct fs_node *(* fs_finddir_t)(struct fs_node *node, char *name);
-
-struct fs_vtable
-{
- fs_read_t read;
- fs_write_t write;
- fs_open_t open;
- fs_close_t close;
- fs_readdir_t readdir;
- fs_finddir_t finddir;
-};
-
-enum fs_flags
-{
- FS_FILE = 1,
- FS_DIRECTORY,
- FS_CHARDEVICE,
- FS_BLOCKDEVICE,
- FS_PIPE,
- FS_SYMLINK,
-
- FS_MOUNT = 8, /* Can be or'd with others */
-};
-
-extern struct fs_node root, dev, initrd;
-
-/* Not to be confused normal open, close, etc functions, these operate
- * on the VFS directly
- * read and write return the number of bytes written/read, */
-
-uint fs_read(struct fs_node *node, size_t offset, size_t size, uchar *buffer);
-uint fs_write(struct fs_node *node, size_t offset, size_t size, uchar *buffer);
-void fs_open(struct fs_node *node);
-void fs_close(struct fs_node *node);
-
-bool fs_readdir(struct fs_node *node, uint index, struct fs_dirent *out);
-struct fs_node *fs_finddir(struct fs_node *node, char *name);
-
-/* Returns the following error codes:
- * 0: success
- * 1: target is not a directory
- * 2: target is already a mount point
- * 3: source is not a directory */
-uint fs_mount(struct fs_node *target, struct fs_node *source);
-
-void init_vfs();