summaryrefslogtreecommitdiffstats
path: root/ird
diff options
context:
space:
mode:
authorJon Santmyer <jon@jonsantmyer.com>2024-05-22 13:00:41 -0400
committerJon Santmyer <jon@jonsantmyer.com>2024-05-22 13:00:41 -0400
commitace65b453151845bc361f21f3e5b651c35f9f126 (patch)
tree262ebd29b0ca1d8584f0b6f1efa7a00d9f4f3e43 /ird
parentf004c1ade8d617a82cea2fe249434cccb47a2358 (diff)
downloadjove-kernel-ace65b453151845bc361f21f3e5b651c35f9f126.tar.gz
jove-kernel-ace65b453151845bc361f21f3e5b651c35f9f126.tar.bz2
jove-kernel-ace65b453151845bc361f21f3e5b651c35f9f126.zip
massive refactor for mp and organizationHEADmaster
Diffstat (limited to 'ird')
-rw-r--r--ird/initrd.c88
-rw-r--r--ird/initrd.h21
-rw-r--r--ird/tar.h18
3 files changed, 0 insertions, 127 deletions
diff --git a/ird/initrd.c b/ird/initrd.c
deleted file mode 100644
index f219243..0000000
--- a/ird/initrd.c
+++ /dev/null
@@ -1,88 +0,0 @@
-#include "initrd.h"
-#include "lib/string.h"
-#include "io/log.h"
-#include "boot/boot.h"
-#include "boot/cmdline.h"
-#include "mem/memory.h"
-
-struct SlabCache s_initrd_cache;
-struct SLinkedList s_initrd_files;
-
-static size_t
-s_tar_oct_dec(const char *oct)
-{
- size_t value = 0;
- while(*oct != 0) {
- value *= 8;
- value += (*oct) - '0';
- oct++;
- }
- return value;
-}
-
-static void
-s_initrd_parse(struct BootModule *module)
-{
- struct TARSector *sector = (struct TARSector*)module->addr;
- while(true) {
- struct TARHeader *header = (struct TARHeader*)sector;
- if(header->name[0] == 0) break;
-
- struct InitrdFile *file = mem_slab_alloc(&s_initrd_cache);
- *file = (struct InitrdFile){
- .header = header,
- .name = header->name,
- .size = s_tar_oct_dec(header->size),
- .data = &sector[1]
- };
- klogf("File %s size %i\n", file->name, file->size);
- sll_push(&s_initrd_files, file);
-
- sector = &sector[(file->size / 512) + 1];
- if(file->size % 512 > 0) sector = &sector[1];
- }
-}
-
-struct InitrdFile *
-ird_getfile(const char *path)
-{
- for(struct SLLNode *node = s_initrd_files.head; node != NULL; node = node->next) {
- struct InitrdFile *file = (struct InitrdFile*)node;
- if(strcmp(file->name, path) == 0) return file;
- }
- return NULL;
-}
-
-struct SLinkedList *
-ird_getfiles(void)
-{
- return &s_initrd_files;
-}
-
-void
-initrd_setup(void)
-{
- const char *initrd_path = cmdline_get("initrd");
- if(initrd_path == 0) {
- klogf("No initrd loaded!\n");
- return;
- }
- klogf("Initrd located in module path %s\n", initrd_path);
- struct BootModule *initrd_module = NULL;
- for(size_t i = 0; i < boot_module_count; i++) {
- struct BootModule *module = &boot_modules[i];
- if(strcmp(module->path, initrd_path) == 0) {
- initrd_module = module;
- break;
- }
- }
-
- if(initrd_module == NULL) {
- klogf("Initrd not found in modules!\n");
- return;
- }
-
- sll_new(&s_initrd_files, sizeof(struct InitrdFile));
- mem_slabcache_new(&s_initrd_cache, "initrd files", sizeof(struct InitrdFile));
- s_initrd_parse(initrd_module);
-}
diff --git a/ird/initrd.h b/ird/initrd.h
deleted file mode 100644
index f236fa1..0000000
--- a/ird/initrd.h
+++ /dev/null
@@ -1,21 +0,0 @@
-#ifndef JOVE_INITRD_H
-#define JOVE_INITRD_H 1
-
-#include <stddef.h>
-#include "tar.h"
-#include "lib/linkedlist.h"
-
-struct InitrdFile {
- struct InitrdFile *next;
- struct TARHeader *header;
- const char *name;
- size_t size;
- const void *data;
-};
-
-void initrd_setup(void);
-
-struct InitrdFile *ird_getfile(const char *path);
-struct SLinkedList *ird_getfiles(void);
-
-#endif
diff --git a/ird/tar.h b/ird/tar.h
deleted file mode 100644
index 5c72620..0000000
--- a/ird/tar.h
+++ /dev/null
@@ -1,18 +0,0 @@
-#ifndef JOVE_INITRD_TAR_H
-#define JOVE_INITRD_TAR_H 1
-
-struct TARSector { char data[512]; };
-
-struct TARHeader {
- char name[100];
- char mode[8];
- char owner[8];
- char group[8];
- char size[12];
- char modified[12];
- char checksum[8];
- char link;
- char linkname[100];
-};
-
-#endif