@@ -18,6 +18,8 @@ mod fs;
1818mod program;
1919mod vgaconsole;
2020
21+ pub use config:: Config as OsConfig ;
22+
2123// ===========================================================================
2224// Global Variables
2325// ===========================================================================
@@ -188,7 +190,7 @@ impl core::fmt::Write for Ctx {
188190
189191/// Initialise our global variables - the BIOS will not have done this for us
190192/// (as it doesn't know where they are).
191- #[ cfg( target_os = "none" ) ]
193+ #[ cfg( all ( target_os = "none" , not ( feature = "lib-mode" ) ) ) ]
192194unsafe fn start_up_init ( ) {
193195 extern "C" {
194196
@@ -205,7 +207,7 @@ unsafe fn start_up_init() {
205207 r0:: init_data ( & mut __sdata, & mut __edata, & __sidata) ;
206208}
207209
208- #[ cfg( not( target_os = "none" ) ) ]
210+ #[ cfg( any ( not( target_os = "none" ) , feature = "lib-mode ") ) ]
209211unsafe fn start_up_init ( ) {
210212 // Nothing to do
211213}
@@ -217,7 +219,7 @@ unsafe fn start_up_init() {
217219/// This is the function the BIOS calls. This is because we store the address
218220/// of this function in the ENTRY_POINT_ADDR variable.
219221#[ no_mangle]
220- pub extern "C" fn main ( api : & bios:: Api ) -> ! {
222+ pub extern "C" fn os_main ( api : & bios:: Api ) -> ! {
221223 unsafe {
222224 start_up_init ( ) ;
223225 API . store ( api) ;
@@ -344,13 +346,33 @@ pub extern "C" fn main(api: &bios::Api) -> ! {
344346 println ! ( "Failed to get HID events: {:?}" , e) ;
345347 }
346348 }
349+ if let Some ( ( uart_dev, _serial_conf) ) = menu. context . config . get_serial_console ( ) {
350+ loop {
351+ let mut buffer = [ 0u8 ; 8 ] ;
352+ let wrapper = neotron_common_bios:: ApiBuffer :: new ( & mut buffer) ;
353+ match ( api. serial_read ) ( uart_dev, wrapper, neotron_common_bios:: Option :: None ) {
354+ neotron_common_bios:: Result :: Ok ( n) if n == 0 => {
355+ break ;
356+ }
357+ neotron_common_bios:: Result :: Ok ( n) => {
358+ for b in & buffer[ 0 ..n] {
359+ menu. input_byte ( * b) ;
360+ }
361+ }
362+ _ => {
363+ break ;
364+ }
365+ }
366+ }
367+ }
347368 ( api. power_idle ) ( ) ;
348369 }
349370}
350371
351372/// Called when we have a panic.
352373#[ inline( never) ]
353374#[ panic_handler]
375+ #[ cfg( not( feature = "lib-mode" ) ) ]
354376fn panic ( info : & core:: panic:: PanicInfo ) -> ! {
355377 IS_PANIC . store ( true , Ordering :: SeqCst ) ;
356378 println ! ( "PANIC!\n {:#?}" , info) ;
0 commit comments