foss-for-synopsys-dwc-arc-processors / openocd

The development tree for OpenOCD for the Synopsys DesignWare ARC processor family
Other
15 stars 12 forks source link

[Upstream port] Adding register types and registers #37

Open EvgeniiDidin opened 5 years ago

EvgeniiDidin commented 5 years ago

In case of ARC we have arch-specific registers like "STATUS32", "DEBUG", etc. We use one routine to add default GDB and ARC-specific register types.

In cpu/arc related .tcl script we describe register-types and registers, which are available on target. This requires jimctl command handlers.

anthony-kolesov commented 5 years ago

Note that today some registers which are essential for the debugging have hardcoded definitions. For example here https://github.com/foss-for-synopsys-dwc-arc-processors/openocd/blob/master/src/target/arc_ocd.c#L195 code uses hardcoded information for STATUS32. Or here https://github.com/foss-for-synopsys-dwc-arc-processors/openocd/blob/master/src/target/arc32.c#L530 code has hardcoded info on caches.

At the same time there is a more flexible code, like here: https://github.com/foss-for-synopsys-dwc-arc-processors/openocd/blob/master/src/target/arc32.c#L763, it refers to registers and their field by name, and I consider this code superior, because it doesn't duplicate information on which bit or register name has what meaning - connection through names is better. Although it is still not perfect, for example, in theory parameters of caches can be read and fully configured in TCL scripts as well, I think - that would be even better.

My opinion is that it would be better to replaces instances of code that use hardcoded register definitions with approach that relies on register/field names - it is something that I wanted to do after implementing registers in TCL, but never had the time to do. Though it is possible there could be some functions which are executed very early, before register definitions are read from TCL, so those functions would have to use hardcoded info, but that should use IDENTITY, DEBUG and STATUS32 at most, if at all. However, there is a concern that getting register by name is done by scanning linked list, so log(N), so in some cases you may need to either cache pointer to register object, or keep using the hardcoded definitions.

Also the more of this stuff you'd move to TCL, the more flexible it will be. For example, function https://github.com/foss-for-synopsys-dwc-arc-processors/openocd/blob/master/src/target/arc32.c#L751, that sets up CCM parameters - arc32_common fields can be exposed as TCL properties, then those checks, based on register field values can be done in TCL and then they would set arc32_common fields. Perhaps, this should be done only after the initial upstreaming, though.

EvgeniiDidin commented 5 years ago

Commits, related to adding reg_types: https://github.com/foss-for-synopsys-dwc-arc-processors/openocd/commit/8f734b077c49b26cd4a7c8ed406884aefd6ab9c9 https://github.com/foss-for-synopsys-dwc-arc-processors/openocd/commit/e12b5572880e53d5a51219c937332561c1f3f430

EvgeniiDidin commented 5 years ago

Commit, related to adding registers from tcl: ace638d3a32e9c9fea4e0e89dd8aa48e866aa722

EvgeniiDidin commented 5 years ago

Commit, adding building register caches function: 55d9df45f1072e165b95bfec7a3ef8ff113690cb

EvgeniiDidin commented 5 years ago

TODO after JTAG functionality introduction: 1) Introduce arc_regs_get(set)_core_reg functions 2) introduce get_register_value and register_get_by_name functions

EvgeniiDidin commented 5 years ago

Commit, introducing arc_regs_get(set)_core_reg functions: https://github.com/foss-for-synopsys-dwc-arc-processors/openocd/commit/2c1c26ee00e198ac453407ff455e5627a2285435 Commit, introducing arc_register_get_by_name: https://github.com/foss-for-synopsys-dwc-arc-processors/openocd/commit/e6f7cf6ee8fec8286b025c989064b09f3f90325b

EvgeniiDidin commented 5 years ago

Commits, introducing arc_get_register_field function: https://github.com/foss-for-synopsys-dwc-arc-processors/openocd/commit/0734496cf422744df09f7ca2ae09b970dfbf87af https://github.com/foss-for-synopsys-dwc-arc-processors/openocd/commit/c13bf9c56b98d03d00ac2745746d8fd26934b21c Commit, introducing arc_get/set_register_value functions: https://github.com/foss-for-synopsys-dwc-arc-processors/openocd/commit/3ad1583b828ff1db8d1572a37614c0847c9746f4