Skip to content

Commit

Permalink
fix: fix mount module
Browse files Browse the repository at this point in the history
  • Loading branch information
yfblock committed Apr 19, 2024
1 parent 8213aa1 commit 24b03b4
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 84 deletions.
12 changes: 2 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions byteos.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ run = "make ARCH=x86_64 justrun"
board = "qemu"
driver = "kvirtio,kgoldfish-rtc,ns16550a"

[bin.x86_64-qemu.env]
HEAP_SIZE = "0x0200_0000"

# build for aarch64-qemu
[bin.aarch64-qemu]
target = "aarch64-unknown-none-softfloat"
Expand Down
12 changes: 0 additions & 12 deletions crates/allocator/Cargo.toml

This file was deleted.

14 changes: 0 additions & 14 deletions crates/allocator/build.rs

This file was deleted.

36 changes: 0 additions & 36 deletions crates/allocator/src/lib.rs

This file was deleted.

22 changes: 22 additions & 0 deletions crates/kramdisk/build.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,35 @@
#![feature(lazy_cell)]

use std::{env, fs, path::PathBuf};

#[allow(unused_macros)]
macro_rules! display {
($fmt:expr) => (println!("cargo:warning={}", format!($fmt)));
($fmt:expr, $($arg:tt)*) => (println!(concat!("cargo:warning=", $fmt), $($arg)*));
}

fn main() {
let out_dir = PathBuf::from(env::var("OUT_DIR").expect("can't find manifest dir"));
let img_path = env::var("MOUNT_IMG_PATH").unwrap_or("mount.img".into());

fs::write(
out_dir.join("inc.S"),
format!(
".section .data
.global ramdisk_start
.global ramdisk_end
.align 16
ramdisk_start:
.incbin \"{img_path}\"
ramdisk_end:"
),
)
.expect("can't write ram file to out_dir");

// fs::write(path, contents)

// write module configuration to OUT_PATH, then it will be included in the main.rs
println!("cargo:rerun-if-env-changed=MOUNT_IMG_PATH");
println!("cargo:rerun-if-changed=mount.img");
println!("cargo:rerun-if-changed=build.rs");
}
12 changes: 1 addition & 11 deletions crates/kramdisk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,7 @@ impl BlkDriver for RamDiskBlock {
}
}

global_asm!(
"
.section .data
.global ramdisk_start
.global ramdisk_end
.align 16
ramdisk_start:
.incbin \"./mount.img\"
ramdisk_end:
"
);
global_asm!(include_str!(concat!(env!("OUT_DIR"), "/inc.S")));

driver_define!({
extern "C" {
Expand Down
2 changes: 1 addition & 1 deletion kernel/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ serde = "1.0.136"
serde_derive = "1.0.136"

[dependencies]
allocator = { git = "https://github.com/Byte-OS/allocator.git" }
allocator = { git = "https://github.com/Byte-OS/allocator.git", rev = "c6ce949146d5feab1d406502b19b035f5d392c35"}
crate_interface = { git = "https://github.com/Byte-OS/crate_interface.git" }
frame_allocator = { git = "https://github.com/Byte-OS/bit_frame_allocator.git" }
logging = { git = "https://github.com/Byte-OS/logging.git" }
Expand Down
2 changes: 2 additions & 0 deletions kernel/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ impl ArchInterface for ArchInterfaceImpl {
fn end();
}

println!("HEAP_SIZE: {:#x}", allocator::HEAP_SIZE);

println!("run kernel @ hart {}", hart_id);

info!("program size: {}KB", (end as usize - start as usize) / 1024);
Expand Down

0 comments on commit 24b03b4

Please sign in to comment.