add structure to differentiate image type

we now have three image types: inie, inif, inis; migrate
away from a simple "xip" flag to something that can differentiate
between all three options.
This commit is contained in:
bunnie 2024-04-01 15:28:04 +08:00
parent 9afc7cd605
commit bae3102e87

View file

@ -59,6 +59,16 @@ pub struct PageTable {
entries: [usize; PAGE_SIZE / WORD_SIZE],
}
#[derive(Copy, Clone, Eq, PartialEq)]
pub enum IniType {
// RAM
IniE,
// XIP
IniF,
// Swap
IniS,
}
/// Entrypoint
/// This makes the program self-sufficient by setting up memory page assignment
/// and copying the arguments to RAM.
@ -344,7 +354,10 @@ pub fn read_initial_config(cfg: &mut BootConfig) {
assert!(!kernel_seen, "kernel appears twice");
assert!(tag.size as usize == mem::size_of::<ProgramDescription>(), "invalid XKrn size");
kernel_seen = true;
} else if tag.name == u32::from_le_bytes(*b"IniE") || tag.name == u32::from_le_bytes(*b"IniF") {
} else if tag.name == u32::from_le_bytes(*b"IniE")
|| tag.name == u32::from_le_bytes(*b"IniF")
|| tag.name == u32::from_le_bytes(*b"IniS")
{
assert!(tag.size >= 4, "invalid Init size");
init_seen = true;
cfg.init_process_count += 1;
@ -467,6 +480,11 @@ fn check_load(cfg: &mut BootConfig) {
println!("\n\nChecking IniF region");
inif.check(cfg, inif.load_offset as usize, pid, true);
pid += 1;
} else if tag.name == u32::from_le_bytes(*b"IniS") {
let inis = MiniElf::new(&tag);
println!("\n\nChecking IniS region");
inis.check(cfg, inis.load_offset as usize, pid, true);
pid += 1;
}
}
}