mirror of
https://github.com/stnolting/neorv32.git
synced 2025-04-23 21:57:33 -04:00
[sw/ocd-firmware] optimize park-loop
faster debugging response
This commit is contained in:
parent
ba2fc9701f
commit
5095a0072a
3 changed files with 29 additions and 51 deletions
|
@ -1,18 +1,20 @@
|
|||
# NEORV32 On-Chip Debugger (OCD) - "Park Loop" Code
|
||||
# NEORV32 On-Chip Debugger (OCD) - "Park Loop" Code (Firmware)
|
||||
|
||||
This folder contains the ASM sources for the *execution-based* debugger code ROM.
|
||||
`park_loop.S` contains the "park loop" that is executed when the CPU is in debug mode. This code is used to communicate
|
||||
with the *debug module (DM)* and is responsible for:
|
||||
This folder contains the source code for the *execution-based* debugger code ROM (firmware).
|
||||
`park_loop.S` contains the "park loop" that is executed when the CPU is in debug mode. This code
|
||||
is used to communicate with the *debug module (DM)* and is responsible for:
|
||||
|
||||
* acknowledging halt requests
|
||||
* processing and acknowledging resume requests
|
||||
* processing and acknowledging "execute program buffer" requests
|
||||
* executing the program buffer (provided by the DM)
|
||||
* catching exceptions while in debug mode
|
||||
* catching and acknowledging exceptions while in debug mode
|
||||
|
||||
The park loop code is implemented as endless loop that polls the status register of the *debug memory (DBMEM)* module
|
||||
to check for requests from the DM and sets according flags in the status register to acknowledge these requests.
|
||||
The park loop code is implemented as endless loop that polls the status register of
|
||||
the _debug memory (DM)_ module to check for requests from the DM and sets according flags in the
|
||||
status register to acknowledge these requests.
|
||||
|
||||
:warning: Executing `make clean_all all` will **NOT** update the actual debugger code ROM that will be synthesized.
|
||||
The interface with the DM will break if there are any bugs in this code. However, if you wish to update the code ROM,
|
||||
copy the array content from `neorv32_debug_mem.code.vhd` to the `code_rom_file` constant in `rtl/core/neorv32_debug_dbmem.vhd`.
|
||||
:warning: Executing `make clean_all all` will **NOT** update the actual debugger code ROM that
|
||||
will be synthesized. The interface with the DM will break if there are any bugs in this code.
|
||||
However, if you wish to update the code ROM, copy the array content from `neorv32_debug_mem.code.vhd`
|
||||
to the `code_rom_file` constant in `rtl/core/neorv32_debug_dm.vhd`.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* ################################################################################################# */
|
||||
/* # << NEORV32 - RISC-V GCC Linker Script >> # */
|
||||
/* # ********************************************************************************************* # */
|
||||
/* # For the execution based on-chip debugger code memory (/ROM() - "park loop" code # */
|
||||
/* # For the execution-based on-chip debugger code memory (/ROM() - "park loop" code (firmware) # */
|
||||
/* # ********************************************************************************************* # */
|
||||
/* # BSD 3-Clause License # */
|
||||
/* # # */
|
||||
|
@ -34,37 +34,19 @@
|
|||
/* # The NEORV32 Processor - https://github.com/stnolting/neorv32 (c) Stephan Nolting # */
|
||||
/* ################################################################################################# */
|
||||
|
||||
/* Default linker script, for normal executables */
|
||||
/* Copyright (C) 2014-2020 Free Software Foundation, Inc.
|
||||
Copying and distribution of this script, with or without modification,
|
||||
are permitted in any medium without royalty provided the copyright
|
||||
notice and this notice are preserved. */
|
||||
|
||||
/* modified for the NEORV32 processor by Stephan Nolting */
|
||||
|
||||
|
||||
OUTPUT_FORMAT("elf32-littleriscv")
|
||||
OUTPUT_ARCH(riscv)
|
||||
ENTRY(_start)
|
||||
SEARCH_DIR("/opt/riscv/riscv32-unknown-elf/lib")
|
||||
SEARCH_DIR("=/usr/local/lib")
|
||||
SEARCH_DIR("=/lib")
|
||||
SEARCH_DIR("=/usr/lib")
|
||||
ENTRY(__start)
|
||||
|
||||
MEMORY
|
||||
{
|
||||
debug_mem (rx) : ORIGIN = 0xFFFFF800, LENGTH = 128
|
||||
debug_mem (rx) : ORIGIN = 0xFFFFF800, LENGTH = 128
|
||||
}
|
||||
/* ************************************************************************* */
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
|
||||
/* Actual instructions */
|
||||
.text :
|
||||
{
|
||||
KEEP(*(.text));
|
||||
|
||||
} > debug_mem
|
||||
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/* ################################################################################################# */
|
||||
/* # << NEORV32 - park_loop.S - Execution-Based On-Chip Debugger - Park Loop Code >> # */
|
||||
/* # << NEORV32 - park_loop.S - Execution-Based On-Chip Debugger Firmware - Park Loop Code >> # */
|
||||
/* # ********************************************************************************************* # */
|
||||
/* # BSD 3-Clause License # */
|
||||
/* # # */
|
||||
/* # Copyright (c) 2021, Stephan Nolting. All rights reserved. # */
|
||||
/* # Copyright (c) 2022, Stephan Nolting. All rights reserved. # */
|
||||
/* # # */
|
||||
/* # Redistribution and use in source and binary forms, with or without modification, are # */
|
||||
/* # permitted provided that the following conditions are met: # */
|
||||
|
@ -50,42 +50,36 @@
|
|||
.section .text
|
||||
.balign 4
|
||||
.option norvc
|
||||
.global _start
|
||||
.global entry_normal
|
||||
.global __start
|
||||
.global entry_exception
|
||||
.global entry_normal
|
||||
|
||||
__start:
|
||||
|
||||
_start:
|
||||
|
||||
// BASE + 0: entry for ebreak in debug-mode, halt request or return from single-stepped instruction
|
||||
entry_normal:
|
||||
jal zero, parking_loop_start
|
||||
|
||||
// BASE + 4: entry for exceptions - signal EXCEPTION to DM and restart parking loop
|
||||
// BASE + 0: entry for exceptions - signal EXCEPTION to DM and restart parking loop
|
||||
entry_exception:
|
||||
csrw dscratch0, s0 // save s0 to dscratch0 so we have a general purpose register available
|
||||
addi s0, zero, SREG_EXCEPTION_ACK // mask exception acknowledge flag
|
||||
addi s0, zero, SREG_EXCEPTION_ACK // set exception acknowledge flag
|
||||
sw s0, DBMEM_SREG_BASE(zero) // trigger exception acknowledge to inform DM
|
||||
csrr s0, dscratch0 // restore s0 from dscratch0
|
||||
ebreak // restart parking loop
|
||||
jal zero, parking_loop_halt // start parking loop
|
||||
|
||||
// BASE + 16: entry for ebreak in debug-mode, halt request or return from single-stepped instruction
|
||||
// "parking loop": endless loop that polls the status register to check if the DM
|
||||
// wants to execute code from the program buffer or to resume normal CPU/application operation
|
||||
parking_loop_start:
|
||||
entry_normal:
|
||||
csrw dscratch0, s0 // save s0 to dscratch0 so we have a general purpose register available
|
||||
parking_loop_halt:
|
||||
addi s0, zero, SREG_HALTED_ACK
|
||||
sw s0, DBMEM_SREG_BASE(zero) // ACK that CPU has halted
|
||||
|
||||
parking_loop:
|
||||
lw s0, DBMEM_SREG_BASE(zero) // get status register
|
||||
andi s0, s0, SREG_EXECUTE_REQ // request to execute program buffer?
|
||||
bnez s0, execute_progbuf // execute program buffer
|
||||
bnez s0, execute // execute program buffer
|
||||
|
||||
lw s0, DBMEM_SREG_BASE(zero) // get status register
|
||||
andi s0, s0, SREG_RESUME_REQ // request to resume?
|
||||
bnez s0, resume // resume normal operation
|
||||
|
||||
jal zero, parking_loop // restart parking loop polling
|
||||
beqz s0, parking_loop // no: restart parking loop; yes: resume normal operation
|
||||
|
||||
// resume normal operation
|
||||
resume:
|
||||
|
@ -95,7 +89,7 @@ resume:
|
|||
dret // end debug mode
|
||||
|
||||
// execute program buffer
|
||||
execute_progbuf:
|
||||
execute:
|
||||
addi s0, zero, SREG_EXECUTE_ACK
|
||||
sw s0, DBMEM_SREG_BASE(zero) // ACK that execution is about to start
|
||||
csrr s0, dscratch0 // restore s0 from dscratch0
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue