forked from AbleOS/ableos
Merge pull request 'Repbuild will add files to the disk image programmatically' (#13) from wildwestrom/ableos:master into master
Reviewed-on: https://git.ablecorp.us/AbleOS/ableos/pulls/13
This commit is contained in:
commit
bbe29d54ab
|
@ -124,6 +124,18 @@ fn assemble() -> Result<(), Error> {
|
||||||
fn get_fs() -> Result<FileSystem<impl ReadWriteSeek>, io::Error> {
|
fn get_fs() -> Result<FileSystem<impl ReadWriteSeek>, io::Error> {
|
||||||
let filename = "sysdata/system_config.toml";
|
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
|
// Read the contents of the file using a `match` block
|
||||||
// to return the `data: Ok(c)` as a `String`
|
// to return the `data: Ok(c)` as a `String`
|
||||||
// or handle any `errors: Err(_)`.
|
// or handle any `errors: Err(_)`.
|
||||||
|
@ -175,6 +187,16 @@ TERM_BACKDROP={}
|
||||||
term_wallpaper.as_str().unwrap(),
|
term_wallpaper.as_str().unwrap(),
|
||||||
term_background
|
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);
|
limine_str.push_str(&base);
|
||||||
|
|
||||||
let boot_entries = limine_table.as_table_mut().unwrap();
|
let boot_entries = limine_table.as_table_mut().unwrap();
|
||||||
|
@ -230,18 +252,23 @@ TERM_BACKDROP={}
|
||||||
limine_str.push_str(&a);
|
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")?;
|
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?")?,
|
.attach_printable("Copying Limine (ARM): have you pulled the submodule?")?,
|
||||||
&mut bootdir.create_file("bootaa64.efi")?,
|
&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);
|
drop(bootdir);
|
||||||
Ok(fs)
|
Ok(fs)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn copy_file_to_img(fpath: &str, fs: &FileSystem<File>) {
|
||||||
|
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> {
|
fn build(release: bool, target: Target) -> Result<(), Error> {
|
||||||
let fs = get_fs().change_context(Error::Io)?;
|
let fs = get_fs().change_context(Error::Io)?;
|
||||||
let mut com = Command::new("cargo");
|
let mut com = Command::new("cargo");
|
||||||
|
|
|
@ -7,23 +7,23 @@ fn main(){
|
||||||
// std::Debug("XYZ");
|
// std::Debug("XYZ");
|
||||||
// std::Trace("Trace Deez");
|
// std::Trace("Trace Deez");
|
||||||
|
|
||||||
let ADDR = 0xFFFF_FFFF_8100_0000;
|
// let ADDR = 0xFFFF_FFFF_8100_0000;
|
||||||
let ADDR_PLUS_ONE = ADDR + 1;
|
// let ADDR_PLUS_ONE = ADDR + 1;
|
||||||
let ADDR_PLUS_NINE = ADDR + 9;
|
// let ADDR_PLUS_NINE = ADDR + 9;
|
||||||
|
|
||||||
li64(r25, 1);
|
// li64(r25, 1);
|
||||||
st(r25, r0, ADDR, 1);
|
// st(r25, r0, ADDR, 1);
|
||||||
|
|
||||||
li64(r25, 0);
|
// li64(r25, 0);
|
||||||
st(r25, r0, ADDR_PLUS_ONE, 8);
|
// st(r25, r0, ADDR_PLUS_ONE, 8);
|
||||||
|
|
||||||
li64(r25, 17);
|
// li64(r25, 17);
|
||||||
st(r25, r0, ADDR_PLUS_NINE, 1);
|
// st(r25, r0, ADDR_PLUS_NINE, 1);
|
||||||
|
|
||||||
li64(r1, 3);
|
// li64(r1, 3);
|
||||||
li64(r2, 2);
|
// li64(r2, 2);
|
||||||
li64(r3, ADDR);
|
// li64(r3, ADDR);
|
||||||
li64(r4, 0);
|
// li64(r4, 0);
|
||||||
|
|
||||||
eca();
|
eca();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue