check if we have initfs instead of assuming first module exists and is initfs
This commit is contained in:
parent
ce37be750d
commit
e04a9b82cf
4 changed files with 67 additions and 4 deletions
|
|
@ -5,3 +5,4 @@ quiet: yes
|
|||
protocol: limine
|
||||
path: boot():/calcite/kernel.elf
|
||||
module_path: boot():/calcite/initfs.tar
|
||||
module_cmdline: initfs
|
||||
|
|
|
|||
21
kernel/include/utility.h
Normal file
21
kernel/include/utility.h
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
/* Calcite, kernel/include/utility.h
|
||||
* Copyright 2025 Benji Dial
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
//returns 1 if equal, 0 if not.
|
||||
int strequ(const char *str1, const char *str2);
|
||||
|
|
@ -15,6 +15,7 @@
|
|||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <utility.h>
|
||||
#include <initfs.h>
|
||||
#include <limine.h>
|
||||
#include <paging.h>
|
||||
|
|
@ -100,7 +101,18 @@ static uint64_t initfs_length;
|
|||
fb->blue_mask_shift != 0 || fb->blue_mask_size != 8)
|
||||
die();
|
||||
|
||||
struct limine_file *initfs = module_request.response->modules[0];
|
||||
//find the initfs, and die if we don't have one.
|
||||
|
||||
struct limine_file *initfs = 0;
|
||||
struct limine_module_response *response = module_request.response;
|
||||
for (uint64_t i = 0; i < response->module_count; ++i)
|
||||
if (strequ(response->modules[i]->cmdline, "initfs")) {
|
||||
initfs = response->modules[i];
|
||||
break;
|
||||
}
|
||||
|
||||
if (!initfs)
|
||||
die();
|
||||
|
||||
//set up page tables. we will mark the regions with bootloader structures as
|
||||
//usable, so we need to be careful not to allocate any physical pages until
|
||||
|
|
|
|||
29
kernel/src/utility.c
Normal file
29
kernel/src/utility.c
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
/* Calcite, kernel/src/utility.c
|
||||
* Copyright 2025 Benji Dial
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <utility.h>
|
||||
|
||||
int strequ(const char *str1, const char *str2) {
|
||||
while (1) {
|
||||
if (!*str1 && !*str2)
|
||||
return 1;
|
||||
if (*str1 != *str2)
|
||||
return 0;
|
||||
++str1;
|
||||
++str2;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue