|
384 | 384 |
|
385 | 385 | extern crate r0;
|
386 | 386 |
|
| 387 | +use core::fmt; |
| 388 | + |
387 | 389 | /// Registers stacked (pushed into the stack) during an exception
|
388 |
| -#[derive(Clone, Copy, Debug)] |
| 390 | +#[derive(Clone, Copy)] |
389 | 391 | #[repr(C)]
|
390 | 392 | pub struct ExceptionFrame {
|
391 | 393 | /// (General purpose) Register 0
|
392 | 394 | pub r0: u32,
|
| 395 | + |
393 | 396 | /// (General purpose) Register 1
|
394 | 397 | pub r1: u32,
|
| 398 | + |
395 | 399 | /// (General purpose) Register 2
|
396 | 400 | pub r2: u32,
|
| 401 | + |
397 | 402 | /// (General purpose) Register 3
|
398 | 403 | pub r3: u32,
|
| 404 | + |
399 | 405 | /// (General purpose) Register 12
|
400 | 406 | pub r12: u32,
|
| 407 | + |
401 | 408 | /// Linker Register
|
402 | 409 | pub lr: u32,
|
| 410 | + |
403 | 411 | /// Program Counter
|
404 | 412 | pub pc: u32,
|
| 413 | + |
405 | 414 | /// Program Status Register
|
406 | 415 | pub xpsr: u32,
|
407 | 416 | }
|
408 | 417 |
|
| 418 | +impl fmt::Debug for ExceptionFrame { |
| 419 | + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { |
| 420 | + struct Hex(u32); |
| 421 | + impl fmt::Debug for Hex { |
| 422 | + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { |
| 423 | + write!(f, "0x{:08x}", self.0) |
| 424 | + } |
| 425 | + } |
| 426 | + f.debug_struct("ExceptionFrame") |
| 427 | + .field("r0", &Hex(self.r0)) |
| 428 | + .field("r1", &Hex(self.r1)) |
| 429 | + .field("r2", &Hex(self.r2)) |
| 430 | + .field("r3", &Hex(self.r3)) |
| 431 | + .field("r12", &Hex(self.r12)) |
| 432 | + .field("lr", &Hex(self.lr)) |
| 433 | + .field("pc", &Hex(self.pc)) |
| 434 | + .field("xpsr", &Hex(self.xpsr)) |
| 435 | + .finish() |
| 436 | + } |
| 437 | +} |
| 438 | + |
409 | 439 | /// Returns a pointer into which the heap can be placed
|
410 | 440 | ///
|
411 | 441 | /// The start of the heap is guaranteed to be 4-byte aligned; that is the pointer returned by this
|
|
0 commit comments