Skip to content
Snippets Groups Projects
Commit d6b9768d authored by Jeremy Soller's avatar Jeremy Soller
Browse files

More efficient live filesystem method

Reduce kernel heap to 64 MB
Fix issue in build.rs
parent 1f81866a
No related branches found
No related tags found
No related merge requests found
......@@ -87,6 +87,8 @@ fn fill_from_location(f: &mut fs::File, loc: &Path ) -> Result<(), (Error)> {
}
fn main() {
println!("cargo:rustc-env=TARGET={}", env::var("TARGET").unwrap());
let out_dir = env::var("OUT_DIR").unwrap();
let dest_path = Path::new(&out_dir).join("gen.rs");
let mut f = fs::File::create(&dest_path).unwrap();
......@@ -114,8 +116,4 @@ b" files.clear();" // Silence mutability warning
}
}
").unwrap();
fn main() {
println!("cargo:rustc-env=TARGET={}", env::var("TARGET").unwrap());
}
}
......@@ -15,10 +15,7 @@
/// Offset to kernel heap
pub const KERNEL_HEAP_OFFSET: usize = KERNEL_OFFSET + PML4_SIZE/2;
/// Size of kernel heap
#[cfg(not(feature = "live"))]
pub const KERNEL_HEAP_SIZE: usize = 128 * 1024 * 1024; // 128 MB
#[cfg(feature = "live")]
pub const KERNEL_HEAP_SIZE: usize = 640 * 1024 * 1024; // 640 MB - 128 default + 512 for the live disk
pub const KERNEL_HEAP_SIZE: usize = 64 * 1024 * 1024; // 64 MB
/// Offset to kernel percpu variables
//TODO: Use 64-bit fs offset to enable this pub const KERNEL_PERCPU_OFFSET: usize = KERNEL_HEAP_OFFSET - PML4_SIZE;
......
/// Disk scheme replacement when making live disk
use alloc::arc::Arc;
use collections::{BTreeMap, Vec};
use core::cmp;
use collections::BTreeMap;
use core::{cmp, slice};
use core::sync::atomic::{AtomicUsize, Ordering};
use spin::RwLock;
......@@ -11,26 +11,41 @@ use syscall::error::*;
use syscall::flag::{MODE_FILE, SEEK_SET, SEEK_CUR, SEEK_END};
use syscall::scheme::Scheme;
static FILESYSTEM: &'static [u8] = include_bytes!(env!("FILESYSTEM"));
struct Handle {
path: &'static [u8],
data: Arc<RwLock<Vec<u8>>>,
data: Arc<RwLock<&'static mut [u8]>>,
mode: u16,
seek: usize
}
pub struct DiskScheme {
next_id: AtomicUsize,
data: Arc<RwLock<Vec<u8>>>,
data: Arc<RwLock<&'static mut [u8]>>,
handles: RwLock<BTreeMap<usize, Handle>>
}
impl DiskScheme {
pub fn new() -> DiskScheme {
let data;
unsafe {
extern {
static mut __live_start: u8;
static mut __live_end: u8;
}
let start = &mut __live_start as *mut u8;
let end = &mut __live_end as *mut u8;
if end as usize >= start as usize {
data = slice::from_raw_parts_mut(start, end as usize - start as usize);
} else {
data = &mut [];
};
}
DiskScheme {
next_id: AtomicUsize::new(0),
data: Arc::new(RwLock::new(FILESYSTEM.to_vec())),
data: Arc::new(RwLock::new(data)),
handles: RwLock::new(BTreeMap::new())
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment