11//! Block Device related commands for Neotron OS
22
3- use crate :: { bios, print , println , Ctx , API } ;
3+ use crate :: { bios, osprint , osprintln , Ctx , API } ;
44
55pub static LSBLK_ITEM : menu:: Item < Ctx > = menu:: Item {
66 item_type : menu:: ItemType :: Callback {
@@ -34,7 +34,7 @@ fn lsblk(_menu: &menu::Menu<Ctx>, _item: &menu::Item<Ctx>, _args: &[&str], _ctx:
3434 let api = API . get ( ) ;
3535 let mut found = false ;
3636
37- println ! ( "Block Devices:" ) ;
37+ osprintln ! ( "Block Devices:" ) ;
3838 for dev_idx in 0 ..=255u8 {
3939 if let bios:: FfiOption :: Some ( device_info) = ( api. block_dev_get_info ) ( dev_idx) {
4040 let ( bsize, bunits, dsize, dunits) =
@@ -48,12 +48,12 @@ fn lsblk(_menu: &menu::Menu<Ctx>, _item: &menu::Item<Ctx>, _args: &[&str], _ctx:
4848 ( 10 * x / ( 1024 * 1024 * 1024 ) , "GiB" , x / 100_000_000 , "GB" )
4949 }
5050 } ;
51- println ! ( "Device {}:" , dev_idx) ;
52- println ! ( " Name: {}" , device_info. name) ;
53- println ! ( " Type: {:?}" , device_info. device_type) ;
54- println ! ( " Block size: {}" , device_info. block_size) ;
55- println ! ( " Num Blocks: {}" , device_info. num_blocks) ;
56- println ! (
51+ osprintln ! ( "Device {}:" , dev_idx) ;
52+ osprintln ! ( " Name: {}" , device_info. name) ;
53+ osprintln ! ( " Type: {:?}" , device_info. device_type) ;
54+ osprintln ! ( " Block size: {}" , device_info. block_size) ;
55+ osprintln ! ( " Num Blocks: {}" , device_info. num_blocks) ;
56+ osprintln ! (
5757 " Card Size: {}.{} {} ({}.{} {})" ,
5858 bsize / 10 ,
5959 bsize % 10 ,
@@ -62,30 +62,30 @@ fn lsblk(_menu: &menu::Menu<Ctx>, _item: &menu::Item<Ctx>, _args: &[&str], _ctx:
6262 dsize % 10 ,
6363 dunits
6464 ) ;
65- println ! ( " Ejectable: {}" , device_info. ejectable) ;
66- println ! ( " Removable: {}" , device_info. removable) ;
67- println ! ( " Media Present: {}" , device_info. media_present) ;
68- println ! ( " Read Only: {}" , device_info. read_only) ;
65+ osprintln ! ( " Ejectable: {}" , device_info. ejectable) ;
66+ osprintln ! ( " Removable: {}" , device_info. removable) ;
67+ osprintln ! ( " Media Present: {}" , device_info. media_present) ;
68+ osprintln ! ( " Read Only: {}" , device_info. read_only) ;
6969 found = true ;
7070 }
7171 }
7272 if !found {
73- println ! ( " None" ) ;
73+ osprintln ! ( " None" ) ;
7474 }
7575}
7676
7777/// Called when the "read_block" command is executed.
7878fn read_block ( _menu : & menu:: Menu < Ctx > , _item : & menu:: Item < Ctx > , args : & [ & str ] , _ctx : & mut Ctx ) {
7979 let api = API . get ( ) ;
8080 let Ok ( dev_idx) = args[ 0 ] . parse :: < u8 > ( ) else {
81- println ! ( "Couldn't parse {:?}" , args[ 0 ] ) ;
81+ osprintln ! ( "Couldn't parse {:?}" , args[ 0 ] ) ;
8282 return ;
8383 } ;
8484 let Ok ( block_idx) = args[ 1 ] . parse :: < u64 > ( ) else {
85- println ! ( "Couldn't parse {:?}" , args[ 1 ] ) ;
85+ osprintln ! ( "Couldn't parse {:?}" , args[ 1 ] ) ;
8686 return ;
8787 } ;
88- println ! ( "Reading block {}:" , block_idx) ;
88+ osprintln ! ( "Reading block {}:" , block_idx) ;
8989 let mut buffer = [ 0u8 ; 512 ] ;
9090 match ( api. block_read ) (
9191 dev_idx,
@@ -97,16 +97,16 @@ fn read_block(_menu: &menu::Menu<Ctx>, _item: &menu::Item<Ctx>, args: &[&str], _
9797 // Carry on
9898 let mut count = 0 ;
9999 for chunk in buffer. chunks ( 32 ) {
100- print ! ( "{:03x}: " , count) ;
100+ osprint ! ( "{:03x}: " , count) ;
101101 for b in chunk {
102- print ! ( "{:02x}" , * b) ;
102+ osprint ! ( "{:02x}" , * b) ;
103103 }
104104 count += chunk. len ( ) ;
105- println ! ( ) ;
105+ osprintln ! ( ) ;
106106 }
107107 }
108108 bios:: ApiResult :: Err ( e) => {
109- println ! ( "Failed to read: {:?}" , e) ;
109+ osprintln ! ( "Failed to read: {:?}" , e) ;
110110 }
111111 }
112112}
0 commit comments