diff --git a/Makefile b/Makefile index 5e1ccf7..2eb8485 100644 --- a/Makefile +++ b/Makefile @@ -90,7 +90,6 @@ $(KERNEL): $(KOBJ) linker.ld .PHONY: clean clean: $(Q)$(MAKE) -f scripts/Makefile.build _clean obj=. - $(Q)rm -rf $(INITRAMFS) $(Q)rm -rf $(IMG) $(Q)rm -rf iso_root $(Q)rm -rf os_root diff --git a/amd64/amd64_init.c b/amd64/amd64_init.c index fd8a3e6..76b7f99 100644 --- a/amd64/amd64_init.c +++ b/amd64/amd64_init.c @@ -28,7 +28,7 @@ void arch_early_init() cr4 |= (1 << 9) | (1 << 10); cr4_write(cr4); - tty_early.serial_ops = tty_early_ops; + tty_early.serial_ops = &tty_early_ops; tty_early.priv = (void *)COM1; tty_printf = &tty_early; diff --git a/amd64/drivers/serial.c b/amd64/drivers/serial.c index 38dd216..6507804 100644 --- a/amd64/drivers/serial.c +++ b/amd64/drivers/serial.c @@ -1,7 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0-only */ #include #include -#include #include #include @@ -31,6 +30,11 @@ void init_serial_port(int port) outb(port | 4, 0x0F); /* Enter normal operation */ } +void *arch_serial_init() +{ + return (void *)COM1; +} + void arch_serial_write(struct tty *tty, char c) { /* Wait for line to be clear */ @@ -50,23 +54,3 @@ char arch_serial_read(struct tty *tty) return inb(port); } - -int serial_port_tty_init(struct tty **out) -{ - init_serial_port(COM1); - - *out = kalloc(sizeof(struct tty), ALLOC_KERN); - - if (!(*out)) - return -ENOMEM; - - (*out)[0].priv = (void *)COM1; - (*out)[0].serial_ops.serial_getchar = arch_serial_read; - (*out)[0].serial_ops.serial_putchar = arch_serial_write; - - dev_t com1 = device_create((*out + 0), DEV_CLASS_TTY, "ttyS0"); - - (*out)[0].dev = com1; - - return 1; -} diff --git a/amd64/include/drivers/serial.h b/amd64/include/drivers/serial.h index 0bf3184..a9061d8 100644 --- a/amd64/include/drivers/serial.h +++ b/amd64/include/drivers/serial.h @@ -7,6 +7,6 @@ #include -int serial_port_tty_init(struct tty **out); +void *arch_serial_init(); #endif /* _SERIAL_H_ */ diff --git a/kernel/block.c b/drivers/block.c similarity index 92% rename from kernel/block.c rename to drivers/block.c index 401b8de..cc958da 100644 --- a/kernel/block.c +++ b/drivers/block.c @@ -1,6 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0-only */ #include -#include + +#include ssize_t block_read(struct block_device *dev, char *buf, size_t offset, size_t n) { diff --git a/drivers/tty/tty.c b/drivers/tty/tty.c index 1c3d21e..0f8fd2c 100644 --- a/drivers/tty/tty.c +++ b/drivers/tty/tty.c @@ -17,19 +17,19 @@ struct tty *tty_create(const char *name, void *priv) tty->dev = tty_device; tty->priv = priv; - tty->serial_ops = arch_serial_ops; + tty->serial_ops = &arch_serial_ops; return tty; } void tty_putchar(struct tty *tty, char c) { - tty->serial_ops.serial_putchar(tty, c); + tty->serial_ops->serial_putchar(tty, c); } char tty_getchar(struct tty *tty) { - return tty->serial_ops.serial_getchar(tty); + return tty->serial_ops->serial_getchar(tty); } void tty_write(struct tty *tty, const char *s) diff --git a/fs/vfs/Makefile b/fs/vfs/Makefile index c84ae09..7da549d 100644 --- a/fs/vfs/Makefile +++ b/fs/vfs/Makefile @@ -1,7 +1,5 @@ # SPDX-License-Identifier: GPL-2.0-only obj-y += vfs.o -obj-y += mount.o obj-y += inode.o obj-y += ramfs.o -obj-y += devfs.o obj-y += initcpio.o diff --git a/fs/vfs/devfs.c b/fs/vfs/devfs.c deleted file mode 100644 index 50f61d5..0000000 --- a/fs/vfs/devfs.c +++ /dev/null @@ -1,93 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ -#include -#include -#include - -#include -#include -#include -#include - -#include - -static fs_t *f_devfs = NULL; - -static ssize_t i_read_chr(inode_t *inode, char *buf, size_t size, size_t offset) -{ - *buf = tty_getchar(inode->data); - return 1; -} - -static ssize_t i_write_chr(inode_t *inode, char *buf, size_t size, size_t offset) -{ - for (size_t i = offset; i < size + offset; i++) - tty_putchar(inode->data, buf[offset + i]); - - return size; -} - -static ssize_t i_read_blk(inode_t *inode, char *buf, size_t size, size_t offset) -{ - return block_read(inode->data, buf, offset, size); -} - -static ssize_t i_write_blk(inode_t *inode, char *buf, size_t size, size_t offset) -{ - return block_write(inode->data, buf, offset, size); -} - -static int devfs_insert_device(const char *name, u64 mode, dirent_t **out) -{ - return vfs_creat(f_devfs->root_dirent, name, mode, 0, out); -} - -int devfs_insert_device_chr(const char *name, struct tty *device, dirent_t **out) -{ - int res = devfs_insert_device(name, S_IFCHR, out); - - if (res < 0) - return res; - - inode_t *ino = (*out)->inode; - write_lock(&ino->rwlock); - - ino->data = device; - ino->i_ops.write = i_write_chr; - ino->i_ops.read = i_read_chr; - - write_unlock(&ino->rwlock); - - return res; -} - -int devfs_insert_device_blk(const char *name, struct block_device *device, dirent_t **out) -{ - int res = devfs_insert_device(name, S_IFBLK, out); - - if (res < 0) - return res; - - inode_t *ino = (*out)->inode; - write_lock(&ino->rwlock); - - ino->data = device; - ino->i_ops.write = i_write_blk; - ino->i_ops.read = i_read_blk; - - write_unlock(&ino->rwlock); - - return res; -} - -void devfs_init(void) -{ - int res = ramfs_create(0, &f_devfs); - if (res < 0) - panic("failed to create devfs: %s\n", strerror(-res)); - - res = vfs_mount("/dev", f_devfs, 0); - if (res < 0) - panic("failed to mount /dev: %s\n", strerror(-res)); - - krdy("devfs ready\n"); -} diff --git a/fs/vfs/initcpio.c b/fs/vfs/initcpio.c index f6ff845..6444f80 100644 --- a/fs/vfs/initcpio.c +++ b/fs/vfs/initcpio.c @@ -150,7 +150,7 @@ int cpio_read_and_init(const char *file, size_t len, fs_t **out) if (res < 0) return res; - res = vfs_mount(NULL, initramfs, 0); + res = vfs_mount(NULL, initramfs); if (res < 0) return res; diff --git a/fs/vfs/mount.c b/fs/vfs/mount.c deleted file mode 100644 index d39f6d2..0000000 --- a/fs/vfs/mount.c +++ /dev/null @@ -1,283 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ -#include -#include - -#include - -#include -#include - -static struct mount *root_mount = NULL; -static spinlock_t mount_lock = 0; - -fs_t *vfs_get_root(void) -{ - if (!root_mount) - return NULL; - return root_mount->fs; -} - -struct mount *vfs_get_root_mount(void) -{ - return root_mount; -} - -struct mount *mount_find_child(struct mount *parent, dirent_t *dent) -{ - spinlock_acquire(&mount_lock); - - list_item_t *item = parent->children.head; - while (item) { - struct mount *m = item->ptr; - if (m->mountpoint == dent) { - spinlock_release(&mount_lock); - return m; - } - item = item->next; - } - - spinlock_release(&mount_lock); - return NULL; -} - -static int load_inode(dirent_t *dent) -{ - if (dent->inode) - return 0; - - int res = dent->fs->fs_ops.open_inode(dent->fs, dent->ino_num, dent, &dent->inode); - return res; -} - -static int mount_traverse(const char *path, struct mount **out_mount, dirent_t **out_dirent) -{ - if (!root_mount) - return -ENOSYS; - - while (*path == '/') - path++; - - if (*path == '\0') { - *out_mount = root_mount; - *out_dirent = root_mount->fs->root_dirent; - if (*out_dirent) - dirent_inc_ref(*out_dirent); - return 0; - } - - struct mount *cur = root_mount; - dirent_t *cur_dent = root_mount->fs->root_dirent; - - if (!cur_dent) - return -ENOENT; - - dirent_inc_ref(cur_dent); - - const char *p = path; - - while (*p != '\0') { - const char *comp_start = p; - while (*p != '/' && *p != '\0') - p++; - - size_t comp_len = p - comp_start; - if (comp_len > FILE_NAME_MAX_LEN) { - dirent_dec_ref(cur_dent); - return -ENAMETOOLONG; - } - - char name[FILE_NAME_MAX_LEN + 1]; - memcpy(name, comp_start, comp_len); - name[comp_len] = '\0'; - - while (*p == '/') - p++; - - bool is_last = (*p == '\0'); - - dirent_t *found = NULL; - int res = inode_find_dirent(cur_dent->inode, name, &found); - if (res < 0) { - dirent_dec_ref(cur_dent); - return res; - } - - res = load_inode(found); - if (res < 0) { - dirent_dec_ref(found); - dirent_dec_ref(cur_dent); - return res; - } - - if (is_last) { - dirent_dec_ref(cur_dent); - *out_mount = cur; - *out_dirent = found; - return 0; - } - - struct mount *child = NULL; - list_item_t *item = cur->children.head; - while (item) { - struct mount *m = item->ptr; - if (m->mountpoint == found) { - child = m; - break; - } - item = item->next; - } - - dirent_dec_ref(cur_dent); - - if (child) { - dirent_dec_ref(found); - cur = child; - cur_dent = cur->fs->root_dirent; - if (!cur_dent) - return -ENOENT; - dirent_inc_ref(cur_dent); - } else { - cur_dent = found; - } - } - - dirent_dec_ref(cur_dent); - *out_mount = cur; - *out_dirent = cur->fs->root_dirent; - if (*out_dirent) - dirent_inc_ref(*out_dirent); - return 0; -} - -int vfs_mount(const char *path, fs_t *fs, u64 flags) -{ - if (!fs) - return -EINVAL; - - spinlock_acquire(&mount_lock); - - if (!path) { - if (root_mount) { - spinlock_release(&mount_lock); - return -EBUSY; - } - - struct mount *m = kzalloc(sizeof(*m), ALLOC_KERN); - if (!m) { - spinlock_release(&mount_lock); - return -ENOMEM; - } - - m->parent = NULL; - m->fs = fs; - m->mountpoint = NULL; - m->flags = flags; - m->child_link = NULL; - list_create(&m->children); - - root_mount = m; - spinlock_release(&mount_lock); - return 0; - } - - struct mount *parent = NULL; - dirent_t *mp = NULL; - int res = mount_traverse(path, &parent, &mp); - if (res < 0) { - spinlock_release(&mount_lock); - return res; - } - - if ((mp->inode->mode & S_IFMT) != S_IFDIR) { - dirent_dec_ref(mp); - spinlock_release(&mount_lock); - return -ENOTDIR; - } - - list_item_t *item = parent->children.head; - while (item) { - struct mount *m = item->ptr; - if (m->mountpoint == mp) { - dirent_dec_ref(mp); - spinlock_release(&mount_lock); - return -EBUSY; - } - item = item->next; - } - - struct mount *m = kzalloc(sizeof(*m), ALLOC_KERN); - if (!m) { - dirent_dec_ref(mp); - spinlock_release(&mount_lock); - return -ENOMEM; - } - - m->parent = parent; - m->fs = fs; - m->mountpoint = mp; - m->flags = flags; - - list_create(&m->children); - - m->child_link = list_insert(&parent->children, m); - if (!m->child_link) { - dirent_dec_ref(mp); - kfree(m); - spinlock_release(&mount_lock); - return -ENOMEM; - } - - spinlock_release(&mount_lock); - return 0; -} - -int vfs_umount(const char *path) -{ - if (!path) - return -EINVAL; - - spinlock_acquire(&mount_lock); - - struct mount *parent = NULL; - dirent_t *mp = NULL; - int res = mount_traverse(path, &parent, &mp); - if (res < 0) { - spinlock_release(&mount_lock); - return res; - } - - struct mount *target = NULL; - list_item_t *item = parent->children.head; - while (item) { - struct mount *m = item->ptr; - if (m->mountpoint == mp) { - target = m; - break; - } - item = item->next; - } - - dirent_dec_ref(mp); - - if (!target) { - spinlock_release(&mount_lock); - return -EINVAL; - } - - if (target == root_mount) { - spinlock_release(&mount_lock); - return -EINVAL; - } - - if (target->children.head) { - spinlock_release(&mount_lock); - return -EBUSY; - } - - list_remove(target->child_link); - dirent_dec_ref(target->mountpoint); - kfree(target); - - spinlock_release(&mount_lock); - return 0; -} diff --git a/fs/vfs/ramfs.c b/fs/vfs/ramfs.c index 61433ad..cd62dfa 100644 --- a/fs/vfs/ramfs.c +++ b/fs/vfs/ramfs.c @@ -243,3 +243,4 @@ void ramfs_init(void) vfs_register(&ramfs_type); } +DRIVER_ENTRY(ramfs_init); diff --git a/fs/vfs/vfs.c b/fs/vfs/vfs.c index 8a2faad..a673cc5 100644 --- a/fs/vfs/vfs.c +++ b/fs/vfs/vfs.c @@ -6,6 +6,7 @@ #include #include +static fs_t *root_fs = NULL; static list_t fs_type_list = {0}; static char *path_trim(const char *name) @@ -84,7 +85,7 @@ static int next_level(const char *path, dirent_t *dent, dirent_t **out_dirent) return -ENOENT; } -int vfs_openat(struct mount *mnt, dirent_t *in, const char *name, dirent_t **out) +int vfs_openat(dirent_t *in, const char *name, dirent_t **out) { if (!in || !name || !out) return -EINVAL; @@ -93,7 +94,6 @@ int vfs_openat(struct mount *mnt, dirent_t *in, const char *name, dirent_t **out if (!path_optr) return -ENOMEM; - struct mount *cur_mount = mnt; dirent_t *current_dir = in; dirent_inc_ref(current_dir); @@ -118,19 +118,6 @@ int vfs_openat(struct mount *mnt, dirent_t *in, const char *name, dirent_t **out dirent_dec_ref(current_dir); current_dir = next_dir; - - struct mount *child = mount_find_child(cur_mount, current_dir); - if (child) { - dirent_dec_ref(current_dir); - cur_mount = child; - current_dir = child->fs->root_dirent; - if (!current_dir) { - ret = -ENOENT; - goto out; - } - dirent_inc_ref(current_dir); - } - cur_path += res; while (*cur_path == '/') @@ -153,11 +140,10 @@ int vfs_open(const char *abs_path, dirent_t **out) if (!abs_path || !out) return -EINVAL; - struct mount *root = vfs_get_root_mount(); - if (!root || !root->fs || !root->fs->root_dirent) + if (!root_fs->root_dirent) return -ENOENT; - return vfs_openat(root, root->fs->root_dirent, abs_path, out); + return vfs_openat(root_fs->root_dirent, abs_path, out); } void vfs_close(dirent_t *dent) @@ -298,6 +284,16 @@ int vfs_unlink(dirent_t *parent, const char *name) return res; } +int vfs_mount(const char *mount_point, fs_t *fs_to_mount) +{ + if (!mount_point || !strcmp(mount_point, "/")) { + root_fs = fs_to_mount; + return 0; + } + + return -ENOSYS; +} + void vfs_register(struct fs_driver *fs) { struct fs_driver *ins = kalloc(sizeof(*fs), ALLOC_KERN); @@ -312,5 +308,8 @@ void vfs_register(struct fs_driver *fs) void vfs_init(void) { inode_init(); + root_fs = kalloc(sizeof(fs_t), ALLOC_KERN); + memset(root_fs, 0, sizeof(*root_fs)); + list_create(&fs_type_list); } diff --git a/include/kernel/block.h b/include/drivers/block.h similarity index 100% rename from include/kernel/block.h rename to include/drivers/block.h diff --git a/include/drivers/tty.h b/include/drivers/tty.h index 33f74c4..b50758f 100644 --- a/include/drivers/tty.h +++ b/include/drivers/tty.h @@ -12,7 +12,7 @@ struct tty_serial_ops { struct tty { dev_t dev; void *priv; - struct tty_serial_ops serial_ops; + struct tty_serial_ops *serial_ops; }; void tty_layer_init(); diff --git a/include/fs/devfs.h b/include/fs/devfs.h deleted file mode 100644 index 7b18283..0000000 --- a/include/fs/devfs.h +++ /dev/null @@ -1,15 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ -#ifndef _DEVFS_H_ -#define _DEVFS_H_ - -#include - -#include - -#include - -int devfs_insert_device_chr(const char *name, struct tty *device, dirent_t **out); -int devfs_insert_device_blk(const char *name, struct block_device *device, dirent_t **out); -void devfs_init(); - -#endif /* _DEVFS_H_ */ diff --git a/include/fs/ramfs.h b/include/fs/ramfs.h index 5fea5ff..ba28b58 100644 --- a/include/fs/ramfs.h +++ b/include/fs/ramfs.h @@ -9,6 +9,4 @@ int ramfs_create(u64 flags, fs_t **out); int ramfs_umount(fs_t *fs); -void ramfs_init(void); - #endif /* _RAMFS_H_ */ diff --git a/include/fs/vfs.h b/include/fs/vfs.h index e8a2062..d6add85 100644 --- a/include/fs/vfs.h +++ b/include/fs/vfs.h @@ -3,7 +3,6 @@ #define _VFS_H_ #include -#include #include #include @@ -82,32 +81,19 @@ struct _fs { struct dir_context { void *cookie; - bool init; -}; - -struct mount { - struct mount *parent; - list_t children; - list_item_t *child_link; - fs_t *fs; - dirent_t *mountpoint; - u64 flags; + bool init; }; void vfs_init(void); void vfs_register(struct fs_driver *fs); int vfs_open(const char *abs_path, dirent_t **out); -int vfs_openat(struct mount *mnt, dirent_t *in, const char *name, dirent_t **out); +int vfs_openat(dirent_t *in, const char *name, dirent_t **out); void vfs_close(dirent_t *dent); int vfs_readdir(dirent_t *dir, struct dir_context *ctx, dirent_t **out); int vfs_creat(dirent_t *parent, const char *name, u64 mode, int flags, dirent_t **out); int vfs_unlink(dirent_t *parent, const char *name); -int vfs_mount(const char *path, fs_t *fs, u64 flags); -int vfs_umount(const char *path); -fs_t *vfs_get_root(void); -struct mount *vfs_get_root_mount(void); -struct mount *mount_find_child(struct mount *parent, dirent_t *dent); +int vfs_mount(const char *mount_point, fs_t *fs_to_mount); ssize_t vfs_write(inode_t *ino, char *buf, size_t size, size_t offset); ssize_t vfs_read(inode_t *ino, char *buf, size_t size, size_t offset); diff --git a/include/kernel/device.h b/include/kernel/device.h index ce7c1e0..60a78d8 100644 --- a/include/kernel/device.h +++ b/include/kernel/device.h @@ -5,9 +5,8 @@ #include #define DEV_CLASS_TTY 1 -#define DEV_CLASS_BLK 2 -typedef i64 dev_t; +typedef u64 dev_t; typedef u64 dev_class_t; diff --git a/init/main.c b/init/main.c index 80c855a..3a37c76 100644 --- a/init/main.c +++ b/init/main.c @@ -25,8 +25,6 @@ #include #include #include -#include -#include #include #include @@ -45,6 +43,13 @@ static void do_initcalls() (*fn)(); } +static void indent(int indent) +{ + for (int i = 0; i < indent; i++) { + kprintf(" "); + } +} + static void kmain() { /* data types */ @@ -53,9 +58,24 @@ static void kmain() kalloc_init(); vfs_init(); arch_init(); + device_layer_init(); + tty_layer_init(); + void *serial_port = arch_serial_init(); + tty_printf = tty_create("ttyS0", serial_port); + + int rows; + int cols; + + tty_clear_screen(tty_printf); + tty_get_size(tty_printf, &rows, &cols); + tty_setlf(tty_printf); + tty_set_cursor_pos(tty_printf, 0, 0); + + /* start the kernel */ page_init(); - ramfs_init(); + do_initcalls(); + struct limine_file *file = module_res->modules[0]; fs_t *initramfs; @@ -65,19 +85,6 @@ static void kmain() if (res < 0) panic("failed to load initramfs: %s\n", strerror(-res)); - /* start the kernel */ - devfs_init(); - device_layer_init(); - tty_layer_init(); - - /* init main fallback tty */ - struct tty *main_tty = NULL; - serial_port_tty_init(&main_tty); - - tty_printf = main_tty; - - do_initcalls(); - /* do nothing, for now :) */ yield(); } diff --git a/kernel/Makefile b/kernel/Makefile index af3538b..b8039ae 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -1,3 +1,2 @@ # SPDX-License-Identifier: GPL-2.0-only obj-y += device.o -obj-y += block.o diff --git a/kernel/device.c b/kernel/device.c index b3fc145..1d7ff74 100644 --- a/kernel/device.c +++ b/kernel/device.c @@ -1,12 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0-only */ -#include #include -#include #include -#include - -#include - #include #include #include @@ -22,11 +16,9 @@ static mem_cache_t *dev_info_cache = NULL; static rbtree_t device_tree = {0}; -static u64 device_ticker = 0; - dev_t device_create(void *private, dev_class_t class, const char *name) { - dev_t key = atomic_xadd(&device_ticker, 1); + dev_t key = rbt_next_key(&device_tree); rbnode_t *node = rbt_insert(&device_tree, key); size_t name_len = strlen(name); @@ -39,26 +31,6 @@ dev_t device_create(void *private, dev_class_t class, const char *name) node->value = (vaddr_t)info; - dirent_t *devfile = NULL; - - if (class == DEV_CLASS_BLK) { - int res = devfs_insert_device_blk(name, private, &devfile); - - if (res < 0) { - kerr("failed to insert blk device node: %s\n", strerror(-res)); - return res; - } - } else if (class == DEV_CLASS_TTY) { - int res = devfs_insert_device_chr(name, private, &devfile); - - if (res < 0) { - kerr("failed to insert chr device node: %s\n", strerror(-res)); - return res; - } else { - krdy("inserted chrdev node %s: value %d\n", name, res); - } - } - return key; } diff --git a/lib/string.c b/lib/string.c index a6d9517..1f33ef9 100644 --- a/lib/string.c +++ b/lib/string.c @@ -225,8 +225,6 @@ char *dirname(const char *path) if (!path) return strdup("."); char *copy = strdup(path); - if (!copy) - return NULL; char *res = udirname(copy); char *ret = strdup(res); kfree(copy); @@ -238,8 +236,6 @@ char *basename(const char *path) if (!path) return strdup("."); char *copy = strdup(path); - if (!copy) - return NULL; char *res = ubasename(copy); char *ret = strdup(res); kfree(copy); diff --git a/mem/alloc.c b/mem/alloc.c index f2ded45..3b88050 100644 --- a/mem/alloc.c +++ b/mem/alloc.c @@ -88,9 +88,6 @@ void *kzalloc(size_t size, u64 flags) void kfree(void *ptr) { - if (!ptr) - return; - rbnode_t *node = rbt_search(&kalloc_tree, (u64)ptr); if (!node) diff --git a/mem/buddy.c b/mem/buddy.c index c9c6e9c..3a5f014 100644 --- a/mem/buddy.c +++ b/mem/buddy.c @@ -138,8 +138,6 @@ static void init_freelist(struct buddy_zone *bzone) while (remaining >= PAGE_SIZE) { size_t order = buddy_order(remaining); - if (order > bzone->max_order) - order = bzone->max_order; cur->order = order; cur->zone = bzone; diff --git a/scripts/Makefile.limine b/scripts/Makefile.limine index 309ef77..66e92f9 100644 --- a/scripts/Makefile.limine +++ b/scripts/Makefile.limine @@ -1,7 +1,5 @@ # SPDX-License-Identifier: GPL-2.0-only # Makefile stuff for all the booting and bootloader related stuff -# -INITRAMFS := initramfs.cpio $(IMG): limine/limine $(KERNEL) rm -rf $(IMG) @@ -34,17 +32,11 @@ limine/limine: LDFLAGS="$(HOST_LDFLAGS)" \ LIBS="$(HOST_LIBS)" -$(INITRAMFS): initramfs/ - $(Q)echo " CPIO $@" - $(Q)mkdir -p initramfs/ - $(Q)cd initramfs/ && find . | cpio -oH newc > ../$(INITRAMFS) - .PHONY += run -run: edk2-ovmf $(INITRAMFS) $(IMG) +run: edk2-ovmf $(IMG) qemu-system-$(ARCH) \ -M q35 \ -drive if=pflash,unit=0,format=raw,file=edk2-ovmf/ovmf-code-$(ARCH).fd,readonly=on \ - -accel kvm \ -nographic \ -hda $(IMG) \ $(QEMUFLAGS)