@@ -71,15 +71,13 @@ impl<'a> PanicConsole<'a> {
7171 return ;
7272 }
7373 let glyph = FONT8X16 [ c as usize & 0x7F ] ;
74- for row in 0 ..16 {
75- for col in 0 ..8 {
76- let color = if glyph[ row] & ( 0x80 >> col) != 0 {
77- fg
78- } else {
79- bg
80- } ;
81- self . set_pixel ( self . x + col as u64 , self . y + row as u64 , color) ;
82- }
74+ for ( row, col) in glyph. iter ( ) . enumerate ( ) {
75+ let color = if glyph[ row] & ( 0x80 >> col) != 0 {
76+ fg
77+ } else {
78+ bg
79+ } ;
80+ self . set_pixel ( self . x + * col as u64 , self . y + row as u64 , color) ;
8381 }
8482 self . x += 8 ;
8583 if self . x + 8 > self . framebuffer . width ( ) - 20 {
@@ -92,9 +90,9 @@ impl<'a> PanicConsole<'a> {
9290impl < ' a > Write for PanicConsole < ' a > {
9391 fn write_str ( & mut self , s : & str ) -> core:: fmt:: Result {
9492 let fb = & self . framebuffer ;
95- let fg = ( ( 255 as u32 ) << fb. red_mask_shift ( ) )
96- | ( ( 255 as u32 ) << fb. green_mask_shift ( ) )
97- | ( ( 255 as u32 ) << fb. blue_mask_shift ( ) ) ;
93+ let fg = ( ( 255_u32 ) << fb. red_mask_shift ( ) )
94+ | ( ( 255_u32 ) << fb. green_mask_shift ( ) )
95+ | ( ( 255_u32 ) << fb. blue_mask_shift ( ) ) ;
9896 let bg = ( ( BG_COLOR . r as u32 ) << fb. red_mask_shift ( ) )
9997 | ( ( BG_COLOR . g as u32 ) << fb. green_mask_shift ( ) )
10098 | ( ( BG_COLOR . b as u32 ) << fb. blue_mask_shift ( ) ) ;
@@ -108,6 +106,7 @@ impl<'a> Write for PanicConsole<'a> {
108106
109107// This is the default panic handler
110108#[ cfg( not( test) ) ]
109+ #[ warn( unused_must_use) ]
111110#[ panic_handler]
112111pub fn panic ( info : & PanicInfo ) -> ! {
113112 let boot_time = crate :: libs:: time:: time_since_boot ( ) ;
@@ -179,48 +178,57 @@ pub fn panic(info: &PanicInfo) -> ! {
179178 let mut console = PanicConsole :: new ( framebuffer) ;
180179 console. clear ( bg) ;
181180
182- let _ = write ! ( console, "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n " ) ;
183- let _ = write ! ( console, "!! PROKA KERNEL PANIC !!\n " ) ;
184- let _ = write ! ( console, "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n " ) ;
185- let _ = write ! ( console, "\n " ) ;
186- let _ = write ! (
181+ let _ = writeln ! (
182+ console,
183+ "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
184+ ) ;
185+ let _ = writeln ! (
186+ console,
187+ "!! PROKA KERNEL PANIC !!"
188+ ) ;
189+ let _ = writeln ! (
190+ console,
191+ "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
192+ ) ;
193+ let _ = writeln ! ( console) ;
194+ let _ = writeln ! (
187195 console,
188- "A problem has been detected and the system has been halted to prevent damage.\n "
196+ "A problem has been detected and the system has been halted to prevent damage."
189197 ) ;
190- let _ = write ! ( console, " \n " ) ;
191- let _ = write ! ( console, "--- ERROR INFO ---\n " ) ;
192- let _ = write ! ( console, "Reason: {}\n " , info. message( ) ) ;
198+ let _ = writeln ! ( console) ;
199+ let _ = writeln ! ( console, "--- ERROR INFO ---" ) ;
200+ let _ = writeln ! ( console, "Reason: {}" , info. message( ) ) ;
193201 if is_exception {
194- let _ = write ! ( console, "Exception: {}\n " , exc_name) ;
202+ let _ = writeln ! ( console, "Exception: {}" , exc_name) ;
195203 if let Some ( err) = exc_error {
196- let _ = write ! ( console, "Error Code: {:#x}\n " , err) ;
204+ let _ = writeln ! ( console, "Error Code: {:#x}" , err) ;
197205 }
198206 }
199207 if let Some ( location) = info. location ( ) {
200- let _ = write ! (
208+ let _ = writeln ! (
201209 console,
202- "Location: {}, line {}\n " ,
210+ "Location: {}, line {}" ,
203211 location. file( ) ,
204212 location. line( )
205213 ) ;
206214 }
207- let _ = write ! ( console, " \n " ) ;
208- let _ = write ! ( console, "--- SYSTEM STATE ---\n " ) ;
209- let _ = write ! ( console, "Boot Time: {:.4}s\n " , boot_time) ;
210- let _ = write ! ( console, "RIP: {:#018x}\n " , rip) ;
211- let _ = write ! ( console, "RFLAGS: {:#018x}\n " , rflags) ;
212- let _ = write ! ( console, " \n " ) ;
213- let _ = write ! ( console, "--- REGISTERS ---\n " ) ;
214- let _ = write ! ( console, "RAX: {:#018x} RBX: {:#018x}\n " , rax, rbx) ;
215- let _ = write ! ( console, "RCX: {:#018x} RDX: {:#018x}\n " , rcx, rdx) ;
216- let _ = write ! ( console, "RSI: {:#018x} RDI: {:#018x}\n " , rsi, rdi) ;
217- let _ = write ! ( console, "RBP: {:#018x} RSP: {:#018x}\n " , rbp, rsp) ;
218- let _ = write ! ( console, "R8: {:#018x} R9: {:#018x}\n " , r8, r9) ;
219- let _ = write ! ( console, "R10: {:#018x} R11: {:#018x}\n " , r10, r11) ;
220- let _ = write ! ( console, "R12: {:#018x} R13: {:#018x}\n " , r12, r13) ;
221- let _ = write ! ( console, "R14: {:#018x} R15: {:#018x}\n " , r14, r15) ;
222- let _ = write ! ( console, " \n " ) ;
223- let _ = write ! ( console, "Please restart your computer.\n " ) ;
215+ let _ = writeln ! ( console) ;
216+ let _ = writeln ! ( console, "--- SYSTEM STATE ---" ) ;
217+ let _ = writeln ! ( console, "Boot Time: {:.4}s" , boot_time) ;
218+ let _ = writeln ! ( console, "RIP: {:#018x}" , rip) ;
219+ let _ = writeln ! ( console, "RFLAGS: {:#018x}" , rflags) ;
220+ let _ = writeln ! ( console) ;
221+ let _ = writeln ! ( console, "--- REGISTERS ---" ) ;
222+ let _ = writeln ! ( console, "RAX: {:#018x} RBX: {:#018x}" , rax, rbx) ;
223+ let _ = writeln ! ( console, "RCX: {:#018x} RDX: {:#018x}" , rcx, rdx) ;
224+ let _ = writeln ! ( console, "RSI: {:#018x} RDI: {:#018x}" , rsi, rdi) ;
225+ let _ = writeln ! ( console, "RBP: {:#018x} RSP: {:#018x}" , rbp, rsp) ;
226+ let _ = writeln ! ( console, "R8: {:#018x} R9: {:#018x}" , r8, r9) ;
227+ let _ = writeln ! ( console, "R10: {:#018x} R11: {:#018x}" , r10, r11) ;
228+ let _ = writeln ! ( console, "R12: {:#018x} R13: {:#018x}" , r12, r13) ;
229+ let _ = writeln ! ( console, "R14: {:#018x} R15: {:#018x}" , r14, r15) ;
230+ let _ = writeln ! ( console) ;
231+ let _ = writeln ! ( console, "Please restart your computer." ) ;
224232 }
225233 }
226234
@@ -239,6 +247,6 @@ pub fn panic(info: &PanicInfo) -> ! {
239247#[ cfg( test) ]
240248pub fn panic_for_test ( info : & PanicInfo ) -> ! {
241249 serial_println ! ( "[FAILED]" ) ;
242- serial_println ! ( "Caused by:\n \ t {}" , info) ;
250+ serial_println ! ( "Caused by:\t {}" , info) ;
243251 crate :: test:: long_jmp ( ) ;
244252}
0 commit comments