Move kernel file code where it belongs
diff --git a/limine.bin b/limine.bin
index 6054e27b..041a0a16 100644
Binary files a/limine.bin and b/limine.bin differ
diff --git a/stage2/lib/blib.c b/stage2/lib/blib.c
index b74a3b57..170f81d8 100644
--- a/stage2/lib/blib.c
+++ b/stage2/lib/blib.c
@@ -9,6 +9,40 @@
#include <sys/cpu.h>
#include <sys/e820.h>
#include <lib/print.h>
+#include <lib/config.h>
+#include <mm/pmm.h>
+
+struct kernel_loc get_kernel_loc(int boot_drive) {
+ int kernel_drive; {
+ char buf[32];
+ if (!config_get_value(buf, 0, 32, "KERNEL_DRIVE")) {
+ kernel_drive = boot_drive;
+ } else {
+ kernel_drive = (int)strtoui(buf);
+ }
+ }
+
+ int kernel_part; {
+ char buf[32];
+ if (!config_get_value(buf, 0, 32, "KERNEL_PARTITION")) {
+ panic("KERNEL_PARTITION not specified");
+ } else {
+ kernel_part = (int)strtoui(buf);
+ }
+ }
+
+ char *kernel_path = conv_mem_alloc(128);
+ if (!config_get_value(kernel_path, 0, 128, "KERNEL_PATH")) {
+ panic("KERNEL_PATH not specified");
+ }
+
+ struct file_handle *fd = conv_mem_alloc(sizeof(struct file_handle));
+ if (fopen(fd, kernel_drive, kernel_part, kernel_path)) {
+ panic("Could not open kernel file");
+ }
+
+ return (struct kernel_loc) { kernel_drive, kernel_part, kernel_path, fd };
+}
// This integer sqrt implementation has been adapted from:
// https://stackoverflow.com/questions/1100090/looking-for-an-efficient-integer-square-root-algorithm-for-arm-thumb2
diff --git a/stage2/lib/blib.h b/stage2/lib/blib.h
index 49577df1..4dbea951 100644
--- a/stage2/lib/blib.h
+++ b/stage2/lib/blib.h
@@ -3,6 +3,16 @@
#include <stddef.h>
#include <stdint.h>
+#include <fs/file.h>
+
+struct kernel_loc {
+ int kernel_drive;
+ int kernel_part;
+ char *kernel_path;
+ struct file_handle *fd;
+};
+
+struct kernel_loc get_kernel_loc(int boot_drive);
uint64_t sqrt(uint64_t a_nInput);
diff --git a/stage2/lib/image.c b/stage2/lib/image.c
index a265a562..40d83c3f 100644
--- a/stage2/lib/image.c
+++ b/stage2/lib/image.c
@@ -1,6 +1,5 @@
#include <stdint.h>
#include <stddef.h>
-#include <lib/image.h>
#include <lib/config.h>
#include <lib/blib.h>
#include <mm/pmm.h>
@@ -14,35 +13,3 @@ int open_image(struct image *image, struct file_handle *file) {
return -1;
}
-
-struct kernel_loc get_kernel_loc(int boot_drive) {
- int kernel_drive; {
- char buf[32];
- if (!config_get_value(buf, 0, 32, "KERNEL_DRIVE")) {
- kernel_drive = boot_drive;
- } else {
- kernel_drive = (int)strtoui(buf);
- }
- }
-
- int kernel_part; {
- char buf[32];
- if (!config_get_value(buf, 0, 32, "KERNEL_PARTITION")) {
- panic("KERNEL_PARTITION not specified");
- } else {
- kernel_part = (int)strtoui(buf);
- }
- }
-
- char *kernel_path = conv_mem_alloc(128);
- if (!config_get_value(kernel_path, 0, 128, "KERNEL_PATH")) {
- panic("KERNEL_PATH not specified");
- }
-
- struct file_handle *fd = conv_mem_alloc(sizeof(struct file_handle));
- if (fopen(fd, kernel_drive, kernel_part, kernel_path)) {
- panic("Could not open kernel file");
- }
-
- return (struct kernel_loc) { kernel_drive, kernel_part, kernel_path, fd };
-}
diff --git a/stage2/lib/image.h b/stage2/lib/image.h
index d0068ff8..09af1228 100644
--- a/stage2/lib/image.h
+++ b/stage2/lib/image.h
@@ -12,15 +12,6 @@ struct image {
void *local;
};
-struct kernel_loc {
- int kernel_drive;
- int kernel_part;
- char *kernel_path;
- struct file_handle *fd;
-};
-
int open_image(struct image *image, struct file_handle *file);
-struct kernel_loc get_kernel_loc(int boot_drive);
-
#endif
diff --git a/stage2/protos/stivale2.c b/stage2/protos/stivale2.c
index dfe88a89..3cef90d8 100644
--- a/stage2/protos/stivale2.c
+++ b/stage2/protos/stivale2.c
@@ -7,7 +7,6 @@
#include <lib/elf.h>
#include <lib/blib.h>
#include <lib/acpi.h>
-#include <lib/image.h>
#include <lib/config.h>
#include <lib/time.h>
#include <lib/print.h>
