File tree Expand file tree Collapse file tree 3 files changed +21
-5
lines changed Expand file tree Collapse file tree 3 files changed +21
-5
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,15 @@ lto = true
1414panic = " abort"
1515lto = true
1616
17+ [features ]
18+ default = [" log-serial" , " log-panic" ]
19+ # Have the log! macro write to serial output. Disabling this significantly
20+ # reduces code size, but makes debugging essentially impossible
21+ log-serial = []
22+ # Log panics to serial output. Disabling this (without disabling log-serial)
23+ # gets you most of the code size reduction, without losing _all_ debugging.
24+ log-panic = [" log-serial" ]
25+
1726[dependencies ]
1827cpuio = " *"
1928spin = " 0.4.9"
Original file line number Diff line number Diff line change @@ -54,9 +54,9 @@ impl fmt::Write for Logger {
5454macro_rules! log {
5555 ( $( $arg: tt) * ) => { {
5656 use core:: fmt:: Write ;
57- #[ cfg( not( test) ) ]
57+ #[ cfg( all ( feature = "log-serial" , not( test) ) ) ]
5858 writeln!( & mut crate :: logger:: LOGGER . lock( ) , $( $arg) * ) . unwrap( ) ;
59- #[ cfg( test) ]
59+ #[ cfg( all ( feature = "log-serial" , test) ) ]
6060 println!( $( $arg) * ) ;
6161 } } ;
6262}
Original file line number Diff line number Diff line change 1515#![ feature( global_asm) ]
1616#![ cfg_attr( not( test) , no_std) ]
1717#![ cfg_attr( not( test) , no_main) ]
18- #![ cfg_attr( test, allow( unused_imports) ) ]
19- #![ cfg_attr( test , allow( dead_code ) ) ]
18+ #![ cfg_attr( test, allow( unused_imports, dead_code ) ) ]
19+ #![ cfg_attr( not ( feature = "log-serial" ) , allow( unused_variables , unused_imports ) ) ]
2020
2121#[ macro_use]
2222mod logger;
@@ -45,12 +45,19 @@ extern "C" {
4545 fn halt_loop ( ) -> !;
4646}
4747
48- #[ cfg_attr( not( test) , panic_handler) ]
48+ #[ cfg( all( not( test) , feature = "log-panic" ) ) ]
49+ #[ panic_handler]
4950fn panic ( info : & PanicInfo ) -> ! {
5051 log ! ( "PANIC: {}" , info) ;
5152 unsafe { halt_loop ( ) }
5253}
5354
55+ #[ cfg( all( not( test) , not( feature = "log-panic" ) ) ) ]
56+ #[ panic_handler]
57+ fn panic ( _: & PanicInfo ) -> ! {
58+ loop { }
59+ }
60+
5461/// Setup page tables to provide an identity mapping over the full 4GiB range
5562fn setup_pagetables ( ) {
5663 type PageTable = [ u64 ; 512 ] ;
You can’t perform that action at this time.
0 commit comments