@@ -416,33 +416,156 @@ pub use macros::{entry, exception, pre_init};
416
416
#[ doc( hidden) ]
417
417
pub static __ONCE__: ( ) = ( ) ;
418
418
419
- /// Registers stacked (pushed into the stack) during an exception
419
+ /// Registers stacked (pushed onto the stack) during an exception.
420
420
#[ derive( Clone , Copy ) ]
421
421
#[ repr( C ) ]
422
422
pub struct ExceptionFrame {
423
- /// (General purpose) Register 0
424
- pub r0 : u32 ,
423
+ r0 : u32 ,
424
+ r1 : u32 ,
425
+ r2 : u32 ,
426
+ r3 : u32 ,
427
+ r12 : u32 ,
428
+ lr : u32 ,
429
+ pc : u32 ,
430
+ xpsr : u32 ,
431
+ }
432
+
433
+ impl ExceptionFrame {
434
+ /// Returns the value of (general purpose) register 0.
435
+ #[ inline( always) ]
436
+ pub fn r0 ( & self ) -> u32 {
437
+ self . r0
438
+ }
439
+
440
+ /// Returns the value of (general purpose) register 1.
441
+ #[ inline( always) ]
442
+ pub fn r1 ( & self ) -> u32 {
443
+ self . r1
444
+ }
445
+
446
+ /// Returns the value of (general purpose) register 2.
447
+ #[ inline( always) ]
448
+ pub fn r2 ( & self ) -> u32 {
449
+ self . r2
450
+ }
451
+
452
+ /// Returns the value of (general purpose) register 3.
453
+ #[ inline( always) ]
454
+ pub fn r3 ( & self ) -> u32 {
455
+ self . r3
456
+ }
457
+
458
+ /// Returns the value of (general purpose) register 12.
459
+ #[ inline( always) ]
460
+ pub fn r12 ( & self ) -> u32 {
461
+ self . r12
462
+ }
463
+
464
+ /// Returns the value of the Link Register.
465
+ #[ inline( always) ]
466
+ pub fn lr ( & self ) -> u32 {
467
+ self . lr
468
+ }
425
469
426
- /// (General purpose) Register 1
427
- pub r1 : u32 ,
470
+ /// Returns the value of the Program Counter.
471
+ #[ inline( always) ]
472
+ pub fn pc ( & self ) -> u32 {
473
+ self . pc
474
+ }
428
475
429
- /// (General purpose) Register 2
430
- pub r2 : u32 ,
476
+ /// Returns the value of the Program Status Register.
477
+ #[ inline( always) ]
478
+ pub fn xpsr ( & self ) -> u32 {
479
+ self . xpsr
480
+ }
431
481
432
- /// (General purpose) Register 3
433
- pub r3 : u32 ,
482
+ /// Sets the stacked value of (general purpose) register 0.
483
+ ///
484
+ /// # Safety
485
+ ///
486
+ /// This affects the `r0` register of the preempted code, which must not rely on it getting
487
+ /// restored to its previous value.
488
+ #[ inline( always) ]
489
+ pub unsafe fn set_r0 ( & mut self , value : u32 ) {
490
+ self . r0 = value;
491
+ }
434
492
435
- /// (General purpose) Register 12
436
- pub r12 : u32 ,
493
+ /// Sets the stacked value of (general purpose) register 1.
494
+ ///
495
+ /// # Safety
496
+ ///
497
+ /// This affects the `r1` register of the preempted code, which must not rely on it getting
498
+ /// restored to its previous value.
499
+ #[ inline( always) ]
500
+ pub unsafe fn set_r1 ( & mut self , value : u32 ) {
501
+ self . r1 = value;
502
+ }
437
503
438
- /// Linker Register
439
- pub lr : u32 ,
504
+ /// Sets the stacked value of (general purpose) register 2.
505
+ ///
506
+ /// # Safety
507
+ ///
508
+ /// This affects the `r2` register of the preempted code, which must not rely on it getting
509
+ /// restored to its previous value.
510
+ #[ inline( always) ]
511
+ pub unsafe fn set_r2 ( & mut self , value : u32 ) {
512
+ self . r2 = value;
513
+ }
440
514
441
- /// Program Counter
442
- pub pc : u32 ,
515
+ /// Sets the stacked value of (general purpose) register 3.
516
+ ///
517
+ /// # Safety
518
+ ///
519
+ /// This affects the `r3` register of the preempted code, which must not rely on it getting
520
+ /// restored to its previous value.
521
+ #[ inline( always) ]
522
+ pub unsafe fn set_r3 ( & mut self , value : u32 ) {
523
+ self . r3 = value;
524
+ }
443
525
444
- /// Program Status Register
445
- pub xpsr : u32 ,
526
+ /// Sets the stacked value of (general purpose) register 12.
527
+ ///
528
+ /// # Safety
529
+ ///
530
+ /// This affects the `r12` register of the preempted code, which must not rely on it getting
531
+ /// restored to its previous value.
532
+ #[ inline( always) ]
533
+ pub unsafe fn set_r12 ( & mut self , value : u32 ) {
534
+ self . r12 = value;
535
+ }
536
+
537
+ /// Sets the stacked value of the Link Register.
538
+ ///
539
+ /// # Safety
540
+ ///
541
+ /// This affects the `lr` register of the preempted code, which must not rely on it getting
542
+ /// restored to its previous value.
543
+ #[ inline( always) ]
544
+ pub unsafe fn set_lr ( & mut self , value : u32 ) {
545
+ self . lr = value;
546
+ }
547
+
548
+ /// Sets the stacked value of the Program Counter.
549
+ ///
550
+ /// # Safety
551
+ ///
552
+ /// This affects the `pc` register of the preempted code, which must not rely on it getting
553
+ /// restored to its previous value.
554
+ #[ inline( always) ]
555
+ pub unsafe fn set_pc ( & mut self , value : u32 ) {
556
+ self . pc = value;
557
+ }
558
+
559
+ /// Sets the stacked value of the Program Status Register.
560
+ ///
561
+ /// # Safety
562
+ ///
563
+ /// This affects the `xPSR` registers (`IPSR`, `APSR`, and `EPSR`) of the preempted code, which
564
+ /// must not rely on them getting restored to their previous value.
565
+ #[ inline( always) ]
566
+ pub unsafe fn set_xpsr ( & mut self , value : u32 ) {
567
+ self . xpsr = value;
568
+ }
446
569
}
447
570
448
571
impl fmt:: Debug for ExceptionFrame {
0 commit comments