Move kernel file code where it belongs
This commit is contained in:
parent
53339c806b
commit
d9e40a7dff
BIN
limine.bin
BIN
limine.bin
Binary file not shown.
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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 };
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in New Issue