Skip to content

Commit 87c04a7

Browse files
mkroeningstlankes
authored andcommitted
fix(fd_write): don't use system call
- remove obsolete wasm file
1 parent 8328585 commit 87c04a7

File tree

7 files changed

+59
-211
lines changed

7 files changed

+59
-211
lines changed

src/arch/aarch64/kernel/mod.rs

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -36,50 +36,6 @@ const SERIAL_PORT_BAUDRATE: u32 = 115_200;
3636
global_asm!(include_str!("setjmp.s"));
3737
global_asm!(include_str!("longjmp.s"));
3838

39-
pub(crate) struct Console {
40-
serial_port: SerialPort,
41-
}
42-
43-
impl Console {
44-
pub fn new() -> Self {
45-
CoreLocal::install();
46-
47-
let base = env::boot_info()
48-
.hardware_info
49-
.serial_port_base
50-
.map(|uartport| uartport.get())
51-
.unwrap_or_default()
52-
.try_into()
53-
.unwrap();
54-
55-
let serial_port = SerialPort::new(base);
56-
57-
serial_port.init(SERIAL_PORT_BAUDRATE);
58-
59-
Self { serial_port }
60-
}
61-
62-
pub fn write(&mut self, buf: &[u8]) {
63-
self.serial_port.write_buf(buf);
64-
}
65-
66-
pub fn read(&mut self) -> Option<u8> {
67-
None
68-
}
69-
70-
pub fn is_empty(&self) -> bool {
71-
true
72-
}
73-
74-
pub fn register_waker(&mut self, _waker: &Waker) {}
75-
}
76-
77-
impl Default for Console {
78-
fn default() -> Self {
79-
Self::new()
80-
}
81-
}
82-
8339
#[repr(align(8))]
8440
pub(crate) struct AlignedAtomicU32(AtomicU32);
8541

src/arch/riscv64/kernel/mod.rs

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -36,38 +36,6 @@ use crate::env;
3636
use crate::init_cell::InitCell;
3737
use crate::mm::physicalmem::PHYSICAL_FREE_LIST;
3838

39-
pub(crate) struct Console {}
40-
41-
impl Console {
42-
pub fn new() -> Self {
43-
CoreLocal::install();
44-
45-
Self {}
46-
}
47-
48-
pub fn write(&mut self, buf: &[u8]) {
49-
for byte in buf {
50-
sbi_rt::console_write_byte(*byte);
51-
}
52-
}
53-
54-
pub fn read(&mut self) -> Option<u8> {
55-
None
56-
}
57-
58-
pub fn is_empty(&self) -> bool {
59-
true
60-
}
61-
62-
pub fn register_waker(&mut self, _waker: &Waker) {}
63-
}
64-
65-
impl Default for Console {
66-
fn default() -> Self {
67-
Self::new()
68-
}
69-
}
70-
7139
global_asm!(include_str!("setjmp.s"));
7240
global_asm!(include_str!("longjmp.s"));
7341

src/arch/x86_64/kernel/mod.rs

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -46,57 +46,6 @@ pub mod vga;
4646
global_asm!(include_str!("setjmp.s"));
4747
global_asm!(include_str!("longjmp.s"));
4848

49-
pub(crate) struct Console {
50-
serial_port: SerialPort,
51-
}
52-
53-
impl Console {
54-
pub fn new() -> Self {
55-
CoreLocal::install();
56-
57-
let base = env::boot_info()
58-
.hardware_info
59-
.serial_port_base
60-
.unwrap()
61-
.get();
62-
let serial_port = unsafe { SerialPort::new(base) };
63-
Self { serial_port }
64-
}
65-
66-
pub fn write(&mut self, buf: &[u8]) {
67-
self.serial_port.send(buf);
68-
69-
#[cfg(feature = "vga")]
70-
for &byte in buf {
71-
// vga::write_byte() checks if VGA support has been initialized,
72-
// so we don't need any additional if clause around it.
73-
vga::write_byte(byte);
74-
}
75-
}
76-
77-
pub fn buffer_input(&mut self) {
78-
self.serial_port.buffer_input();
79-
}
80-
81-
pub fn read(&mut self) -> Option<u8> {
82-
self.serial_port.read()
83-
}
84-
85-
pub fn is_empty(&self) -> bool {
86-
self.serial_port.is_empty()
87-
}
88-
89-
pub fn register_waker(&mut self, waker: &Waker) {
90-
self.serial_port.register_waker(waker);
91-
}
92-
}
93-
94-
impl Default for Console {
95-
fn default() -> Self {
96-
Self::new()
97-
}
98-
}
99-
10049
pub fn get_ram_address() -> PhysAddr {
10150
PhysAddr::new(env::boot_info().hardware_info.phys_addr_range.start)
10251
}

src/arch/x86_64/mm/paging.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ pub fn map<S>(
173173
if let Ok((_frame, flush)) = unmap {
174174
unmapped = true;
175175
flush.flush();
176-
debug!("Had to unmap page {page:?} before mapping.");
176+
trace!("Had to unmap page {page:?} before mapping.");
177177
}
178178
let map = unsafe { mapper.map_to(page, frame, flags, &mut *frame_allocator) };
179179
match map {
@@ -267,7 +267,7 @@ where
267267
// FIXME: Some sentinel pages around stacks are supposed to be unmapped.
268268
// We should handle this case there instead of here.
269269
Err(UnmapError::PageNotMapped) => {
270-
debug!("Tried to unmap {page:?}, which was not mapped.");
270+
trace!("Tried to unmap {page:?}, which was not mapped.");
271271
}
272272
Err(err) => panic!("{err:?}"),
273273
}

src/wasm/capi.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
use core::cell::UnsafeCell;
2-
31
use align_address::Align;
2+
use hermit_sync::InterruptTicketMutex;
43
use memory_addresses::VirtAddr;
54

65
use crate::arch;
@@ -55,26 +54,24 @@ pub type wasmtime_trap_handler_t =
5554
#[allow(non_camel_case_types)]
5655
pub enum wasmtime_memory_image {}
5756

58-
#[thread_local]
59-
static TLS: UnsafeCell<*mut u8> = UnsafeCell::new(core::ptr::null_mut());
57+
/// We support only single threaded application and use lock to get access to the TLS variable.
58+
static TLS: InterruptTicketMutex<usize> = InterruptTicketMutex::new(0);
6059

6160
/// Wasmtime requires a single pointer's space of TLS to be used at runtime,
6261
/// and this function returns the current value of the TLS variable.
6362
///
6463
/// This value should default to `NULL`.
6564
#[unsafe(no_mangle)]
6665
pub extern "C" fn wasmtime_tls_get() -> *mut u8 {
67-
unsafe { TLS.get().read() }
66+
*TLS.lock() as *mut u8
6867
}
6968

7069
// Sets the current TLS value for Wasmtime to the provided value.
7170
///
7271
/// This value should be returned when later calling `wasmtime_tls_get`.
7372
#[unsafe(no_mangle)]
7473
pub extern "C" fn wasmtime_tls_set(ptr: *mut u8) {
75-
unsafe {
76-
TLS.get().write(ptr);
77-
}
74+
*TLS.lock() = ptr as usize;
7875
}
7976

8077
/// Returns the page size, in bytes, of the current system.

src/wasm/fib.wasm

-444 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)