Skip to content

Commit 01d9d2b

Browse files
committed
Removing threading
1 parent 3434f0a commit 01d9d2b

File tree

5 files changed

+12
-76
lines changed

5 files changed

+12
-76
lines changed

Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,6 @@ authors = ["Lachlan Sneff <[email protected]>"]
77

88
[dependencies.nebulet_abi]
99
git = "https://github.com/nebulet/abi"
10+
11+
[profile.release]
12+
panic = "abort"

src/abi.rs

-5
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,4 @@ extern {
3838
// Pretty fast Exclusion
3939
pub fn pfex_acquire(state_ptr: *const u32);
4040
pub fn pfex_release(state_ptr: *const u32);
41-
42-
// threads
43-
pub fn thread_yield();
44-
pub fn thread_spawn(f: extern fn(u32), arg: u32, stack_ptr: *mut u8) -> AbiResult;
45-
pub fn thread_join(id: u32) -> AbiResult;
4641
}

src/driver.rs

+9-20
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,14 @@ impl<T> Dma<T> {
2121
}
2222

2323
pub unsafe fn zeroed() -> Result<Dma<T>> {
24-
// let (sip_addr, physical_addr) = physical_alloc::<T>()?;
24+
let (sip_addr, physical_addr) = physical_alloc::<T>()?;
2525

26-
// (sip_addr as *mut u8).write_bytes(0, mem::size_of::<T>());
27-
28-
// Ok(Dma {
29-
// physical_addr,
30-
// sip_addr,
31-
// })
32-
Dma::new(mem::zeroed())
26+
(sip_addr as *mut u8).write_bytes(0, mem::size_of::<T>());
3327

28+
Ok(Dma {
29+
physical_addr,
30+
sip_addr,
31+
})
3432
}
3533

3634
pub fn physical(&self) -> u64 {
@@ -54,17 +52,15 @@ impl<T> DerefMut for Dma<T> {
5452
impl<T> Drop for Dma<T> {
5553
fn drop(&mut self) {
5654
unsafe {
57-
self.sip_addr.drop_in_place();
55+
// self.sip_addr.drop_in_place();
5856

5957
// let _ = physical_unmap(self.sip_addr);
6058
}
6159
}
6260
}
6361

6462
pub unsafe fn physical_map<T: Sized>(phys_addr: u64) -> Result<*mut T> {
65-
let page_count = page_count::<T>();
66-
67-
let res: Result<u32> = abi::physical_map(phys_addr, page_count).into();
63+
let res: Result<u32> = abi::physical_map(phys_addr, mem::size_of::<T>()).into();
6864

6965
res.map(|offset| offset as _)
7066
}
@@ -79,16 +75,9 @@ pub unsafe fn physical_map<T: Sized>(phys_addr: u64) -> Result<*mut T> {
7975

8076
/// Allocate some physical memory and return the physical address.
8177
pub unsafe fn physical_alloc<T: Sized>() -> Result<(*mut T, u64)> {
82-
let page_count = page_count::<T>();
83-
8478
let mut physical_addr = 0;
8579

86-
let res: Result<u32> = abi::physical_alloc(page_count, &mut physical_addr as *mut _).into();
80+
let res: Result<u32> = abi::physical_alloc(mem::size_of::<T>(), &mut physical_addr as *mut _).into();
8781

8882
res.map(|sip_addr| (sip_addr as *mut T, physical_addr))
89-
}
90-
91-
fn page_count<T: Sized>() -> usize {
92-
let wasm_page_size = 1 << 16;
93-
(mem::size_of::<T>() + wasm_page_size - 1) / wasm_page_size
9483
}

src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ mod process;
1818
mod channel;
1919
mod event;
2020
mod mutex;
21-
pub mod thread;
2221
mod dlmalloc;
2322
pub mod interrupt;
2423
pub mod driver;

src/thread.rs

-50
This file was deleted.

0 commit comments

Comments
 (0)