File tree Expand file tree Collapse file tree 7 files changed +59
-211
lines changed
Expand file tree Collapse file tree 7 files changed +59
-211
lines changed Original file line number Diff line number Diff line change @@ -36,50 +36,6 @@ const SERIAL_PORT_BAUDRATE: u32 = 115_200;
3636global_asm ! ( include_str!( "setjmp.s" ) ) ;
3737global_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 ) ) ]
8440pub ( crate ) struct AlignedAtomicU32 ( AtomicU32 ) ;
8541
Original file line number Diff line number Diff line change @@ -36,38 +36,6 @@ use crate::env;
3636use crate :: init_cell:: InitCell ;
3737use 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-
7139global_asm ! ( include_str!( "setjmp.s" ) ) ;
7240global_asm ! ( include_str!( "longjmp.s" ) ) ;
7341
Original file line number Diff line number Diff line change @@ -46,57 +46,6 @@ pub mod vga;
4646global_asm ! ( include_str!( "setjmp.s" ) ) ;
4747global_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-
10049pub fn get_ram_address ( ) -> PhysAddr {
10150 PhysAddr :: new ( env:: boot_info ( ) . hardware_info . phys_addr_range . start )
10251}
Original file line number Diff line number Diff 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 }
Original file line number Diff line number Diff line change 1- use core:: cell:: UnsafeCell ;
2-
31use align_address:: Align ;
2+ use hermit_sync:: InterruptTicketMutex ;
43use memory_addresses:: VirtAddr ;
54
65use crate :: arch;
@@ -55,26 +54,24 @@ pub type wasmtime_trap_handler_t =
5554#[ allow( non_camel_case_types) ]
5655pub 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) ]
6665pub 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) ]
7473pub 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.
You can’t perform that action at this time.
0 commit comments