Skip to content

Commit

Permalink
Cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
dbittman committed Sep 5, 2024
1 parent 3502a4f commit 2106783
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 375 deletions.
2 changes: 1 addition & 1 deletion src/kernel/src/initrd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ pub fn init(modules: &[BootModule]) {
}
let obj = Arc::new(obj);
obj::register_object(obj.clone());
if e.filename().as_str() == "bootstrap" {
if e.filename().as_str() == "init" {
boot_objects.init = Some(obj.clone());
}
boot_objects
Expand Down
15 changes: 0 additions & 15 deletions src/runtime/monitor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ use twz_rt::{set_upcall_handler, OUR_RUNTIME};
mod compartment;
mod init;
mod object;
//mod runtime;
pub mod secgate_test;
//mod state;
//mod thread;
mod upcall;

mod api;
Expand Down Expand Up @@ -72,18 +69,6 @@ pub fn main() {
fn monitor_init() -> miette::Result<()> {
info!("monitor early init completed, starting init");

let cur = monitor_api::CompartmentHandle::current();
let info = cur.info();
info!("current compartment info: {:?}", info);

for lib in cur.libs() {
info!("lh: {:?}", lib);
let info = lib.info();
info!("library: {:?}", info);
}

panic!("test panic");

Ok(())
}

Expand Down
25 changes: 18 additions & 7 deletions src/runtime/monitor/src/mon/compartment/runcomp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,32 +47,43 @@ pub struct RunComp {
per_thread: HashMap<ObjID, PerThread>,
}

/// Per-thread data in a compartment.
pub struct PerThread {
simple_buffer: (SimpleBuffer, MapHandle),
simple_buffer: Option<(SimpleBuffer, MapHandle)>,
}

impl PerThread {
/// Create a new PerThread. Note that this must succeed, so any allocation failures must be
/// handled gracefully. This means that if the thread fails to allocate a simple buffer, it
/// will just forego having one. This may cause a failure down the line, but it's the best we
/// can do without panicing.
fn new(instance: ObjID, th: ObjID, space: &mut Space) -> Self {
// TODO: unwrap
let handle = space
.safe_create_and_map_runtime_object(instance, MapFlags::READ | MapFlags::WRITE)
.unwrap();
.ok();

Self {
simple_buffer: (SimpleBuffer::new(unsafe { handle.object_handle() }), handle),
simple_buffer: handle
.map(|handle| (SimpleBuffer::new(unsafe { handle.object_handle() }), handle)),
}
}

/// Write bytes into this compartment-thread's simple buffer.
pub fn write_bytes(&mut self, bytes: &[u8]) -> usize {
self.simple_buffer.0.write(bytes)
self.simple_buffer
.as_mut()
.map(|sb| sb.0.write(bytes))
.unwrap_or(0)
}

pub fn simple_buffer_id(&self) -> ObjID {
self.simple_buffer.0.handle().id
/// Get the Object ID of this compartment thread's simple buffer.
pub fn simple_buffer_id(&self) -> Option<ObjID> {
Some(self.simple_buffer.as_ref()?.0.handle().id)
}
}

impl RunComp {
/// Build a new runtime compartment.
pub fn new(
sctx: ObjID,
instance: ObjID,
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/monitor/src/mon/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ impl Monitor {
let (ref mut space, _, ref mut comps, _, _, _) = *locks;
let rc = comps.get_mut(sctx)?;
let pt = rc.get_per_thread(thread, &mut *space);
Some(pt.simple_buffer_id())
pt.simple_buffer_id()
}
}

Expand Down
85 changes: 0 additions & 85 deletions src/runtime/monitor/src/runtime.rs

This file was deleted.

155 changes: 0 additions & 155 deletions src/runtime/monitor/src/state.rs

This file was deleted.

Loading

0 comments on commit 2106783

Please sign in to comment.