From b96927d61ab9a3c5bc39d56dfc66200895fce05d Mon Sep 17 00:00:00 2001 From: Christian Westrom Date: Mon, 6 May 2024 00:48:24 +0900 Subject: [PATCH 1/2] remove the fuckywucky memory shit --- sysdata/test-programs/main.rhai | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/sysdata/test-programs/main.rhai b/sysdata/test-programs/main.rhai index f92748f08..827b3850f 100644 --- a/sysdata/test-programs/main.rhai +++ b/sysdata/test-programs/main.rhai @@ -7,23 +7,23 @@ fn main(){ // std::Debug("XYZ"); // std::Trace("Trace Deez"); - let ADDR = 0xFFFF_FFFF_8100_0000; - let ADDR_PLUS_ONE = ADDR + 1; - let ADDR_PLUS_NINE = ADDR + 9; + // let ADDR = 0xFFFF_FFFF_8100_0000; + // let ADDR_PLUS_ONE = ADDR + 1; + // let ADDR_PLUS_NINE = ADDR + 9; - li64(r25, 1); - st(r25, r0, ADDR, 1); + // li64(r25, 1); + // st(r25, r0, ADDR, 1); - li64(r25, 0); - st(r25, r0, ADDR_PLUS_ONE, 8); + // li64(r25, 0); + // st(r25, r0, ADDR_PLUS_ONE, 8); - li64(r25, 17); - st(r25, r0, ADDR_PLUS_NINE, 1); + // li64(r25, 17); + // st(r25, r0, ADDR_PLUS_NINE, 1); - li64(r1, 3); - li64(r2, 2); - li64(r3, ADDR); - li64(r4, 0); + // li64(r1, 3); + // li64(r2, 2); + // li64(r3, ADDR); + // li64(r4, 0); eca(); From a5cab167c5e9473ff24c5b50bf23fae4aa1d3e2b Mon Sep 17 00:00:00 2001 From: Christian Westrom Date: Mon, 6 May 2024 00:48:37 +0900 Subject: [PATCH 2/2] load the modules programmatically instead of manually --- repbuild/src/main.rs | 81 +++++++++++++++++++++++++++----------------- 1 file changed, 50 insertions(+), 31 deletions(-) diff --git a/repbuild/src/main.rs b/repbuild/src/main.rs index dfc601612..d9752f358 100644 --- a/repbuild/src/main.rs +++ b/repbuild/src/main.rs @@ -124,6 +124,18 @@ fn assemble() -> Result<(), Error> { fn get_fs() -> Result, io::Error> { let filename = "sysdata/system_config.toml"; + let mut img = File::options() + .read(true) + .write(true) + .create(true) + .open(Path::new("target/disk.img"))?; + + img.set_len(1024 * 1024 * 64)?; + + fatfs::format_volume(&mut img, FormatVolumeOptions::new())?; + + let fs = FileSystem::new(img, FsOptions::new())?; + // Read the contents of the file using a `match` block // to return the `data: Ok(c)` as a `String` // or handle any `errors: Err(_)`. @@ -175,6 +187,16 @@ TERM_BACKDROP={} term_wallpaper.as_str().unwrap(), term_background ); + + // Copy the term_wallpaper to the image + let term_wallpaper_path = term_wallpaper + .as_str() + .unwrap() + .split("boot:///") + .last() + .unwrap(); + copy_file_to_img(&format!("sysdata/{}", term_wallpaper_path), &fs); + limine_str.push_str(&base); let boot_entries = limine_table.as_table_mut().unwrap(); @@ -230,18 +252,23 @@ TERM_BACKDROP={} limine_str.push_str(&a); } } + + // Copy modules into the test_programs directory + modules.into_iter().for_each(|(key, value)| { + if value.is_table() { + let path = value + .get("path") + .expect("You must have a `path` as a value") + .as_str() + .unwrap() + .split("boot:///") + .last() + .unwrap(); + let fpath = format!("target/test-programs/{}", path); + copy_file_to_img(&fpath, &fs); + } + }); } - let mut img = File::options() - .read(true) - .write(true) - .create(true) - .open(Path::new("target/disk.img"))?; - - img.set_len(1024 * 1024 * 64)?; - - fatfs::format_volume(&mut img, FormatVolumeOptions::new())?; - - let fs = FileSystem::new(img, FsOptions::new())?; let bootdir = fs.root_dir().create_dir("efi")?.create_dir("boot")?; @@ -262,31 +289,23 @@ TERM_BACKDROP={} .attach_printable("Copying Limine (ARM): have you pulled the submodule?")?, &mut bootdir.create_file("bootaa64.efi")?, )?; - // TODO: Remove this and replace it with pulling executables from the system_config - for fpath in [ - "sysdata/background.bmp", - "target/test-programs/failure.hbf", - "target/test-programs/ecall.hbf", - "target/test-programs/main.hbf", - "target/test-programs/serial_driver.hbf", - "target/test-programs/vfs_test.hbf", - "target/test-programs/sds_test.hbf", - "target/test-programs/limine_framebuffer_driver.hbf", - "target/test-programs/keyboard_driver.hbf", - ] { - let path = Path::new(fpath); - io::copy( - &mut File::open(path)?, - &mut fs - .root_dir() - .create_file(&path.file_name().unwrap().to_string_lossy())?, - )?; - } drop(bootdir); Ok(fs) } +fn copy_file_to_img(fpath: &str, fs: &FileSystem) { + let path = Path::new(fpath); + io::copy( + &mut File::open(path).expect(&format!("Could not open file {fpath}")), + &mut fs + .root_dir() + .create_file(&path.file_name().unwrap().to_string_lossy()) + .expect("Unable to create file"), + ) + .expect("Copy failed"); +} + fn build(release: bool, target: Target) -> Result<(), Error> { let fs = get_fs().change_context(Error::Io)?; let mut com = Command::new("cargo");