Class: OrigenARM::Cores::CortexM::CM33Controller
- Inherits:
-
BaseController
- Object
- BaseController
- BaseController
- OrigenARM::Cores::CortexM::CM33Controller
- Defined in:
- lib/origen_arm/cores/cortexm/cm33/cm33_controller.rb
Instance Method Summary collapse
-
#enter_debug_mode(halt_core: true) ⇒ Object
Enters the core's debug mode.
-
#exit_debug_mode(release_core: true) ⇒ Object
Exits the core's debug mode.
-
#initialize(options = {}) ⇒ CM33Controller
constructor
A new instance of CM33Controller.
-
#initialize_core(pc:, sp:, release_core: false, sp_lower_limit: nil, sp_upper_limit: nil) ⇒ Object
(also: #initialize_for_lre)
Initializes the core, specifically geared towards LRE setup.
-
#set_pc(pc) ⇒ Object
Sets the program counter by writing the
debug_return_address
register. -
#set_sp(sp) ⇒ Object
Sets the current stack pointer.
Methods inherited from BaseController
#core_reg_to_dcrdr, #enter_debug_mode_delay!, #exit_debug_mode_delay!, #in_debug_mode, #read_register, #reg_wrapped_by_dcrsr?, #write_register
Constructor Details
#initialize(options = {}) ⇒ CM33Controller
Returns a new instance of CM33Controller
6 7 8 |
# File 'lib/origen_arm/cores/cortexm/cm33/cm33_controller.rb', line 6 def initialize(={}) super end |
Instance Method Details
#enter_debug_mode(halt_core: true) ⇒ Object
Enters the core's debug mode.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/origen_arm/cores/cortexm/cm33/cm33_controller.rb', line 31 def enter_debug_mode(halt_core: true) pp('Entering Debug Mode...') do reg(:dhcsr).bits(:dbgkey).write(OrigenARM::Cores::CortexM::CM33::Registers::DHCSR_DBGKEY) reg(:dhcsr).bits(:c_debugen).write(1) reg(:dhcsr).write! enter_debug_mode_delay! if halt_core reg(:dhcsr).bits(:dbgkey).write(OrigenARM::Cores::CortexM::CM33::Registers::DHCSR_DBGKEY) reg(:dhcsr).bits(:c_debugen).write(1) reg(:dhcsr).bits(:c_halt).write(1) reg(:dhcsr).write! enter_debug_mode_delay! end end end |
#exit_debug_mode(release_core: true) ⇒ Object
Exits the core's debug mode.
51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/origen_arm/cores/cortexm/cm33/cm33_controller.rb', line 51 def exit_debug_mode(release_core: true) pp('Exiting Debug Mode...') do reg(:dhcsr).bits(:dbgkey).write(OrigenARM::Cores::CortexM::CM33::Registers::DHCSR_DBGKEY) reg(:dhcsr).bits(:c_halt).write(0) if release_core reg(:dhcsr).bits(:c_debugen).write(0) reg(:dhcsr).write! cc 'Delay for the core to exit debug mode' exit_debug_mode_delay! end end |
#initialize_core(pc:, sp:, release_core: false, sp_lower_limit: nil, sp_upper_limit: nil) ⇒ Object Also known as: initialize_for_lre
Implement lower and upper stack pointer limit setting.
Initializes the core, specifically geared towards LRE setup.
18 19 20 21 22 23 24 |
# File 'lib/origen_arm/cores/cortexm/cm33/cm33_controller.rb', line 18 def initialize_core(pc:, sp:, release_core: false, sp_lower_limit: nil, sp_upper_limit: nil) enter_debug_mode set_sp(sp) set_pc(pc) # set_stack_limits(sp_lower_limit, sp_upper_limit) if (sp_lower_limit || sp_upper_limit) exit_debug_mode(release_core: release_core) end |
#set_pc(pc) ⇒ Object
This requires the core to be in debug mode, otherwise a bus error will occur.
This method will also force Thumb
mode.
Sets the program counter by writing the debug_return_address
register. The debug_return_address
will be loaded into the PC
following debug mode exit, effectively moving the PC.
80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/origen_arm/cores/cortexm/cm33/cm33_controller.rb', line 80 def set_pc(pc) pp('Patch the Program Counter') do # Force the thumb bit. Nothing will work otherwise as CM33 only support THUMB reg(:xpsr).bits(:t).write(1) reg(:xpsr).write! # Write the debug return address with the new PC # Add 1 to indicate thumb mode reg(:debug_return_address).write!(pc + 1) end end |
#set_sp(sp) ⇒ Object
This sets the current stack pointer. The stack pointer in question depends on the core's/device's mode and security settings.
This requires the core to be in debug mode, otherwise a bus error will occur.
Sets the current stack pointer.
68 69 70 71 72 |
# File 'lib/origen_arm/cores/cortexm/cm33/cm33_controller.rb', line 68 def set_sp(sp) pp('Patch the Stack Pointer') do reg(:sp).write!(sp) end end |