Hello :-)

I have created Interface Feature API and tested it on my fork with
OpenOCD+LibSWD integration. It works pretty well and really makes
Interface API small, simple and elegant, while it allows new features
to be added info Interface easily or expose interface specific
features at runtime...

typedef struct oocd_feature {
        /** Feature name. */
        char name[OOCD_FEATURE_NAME_MAXLEN];

        /** Description is a one line feature summary. */
        char description[OOCD_FEATURE_DESCRIPTION_MAXLEN];

        /** Body points to feature contents. */
        void *body;

        /** Next points to next feature on the list. */
        struct oocd_feature *next;
} oocd_feature_t;

Features is a part of interface structure. Structure can simply have
its own unique name, human readable description and void *body that
can hold virtually anything, and the pointer to next feature.

Why it was created? To keep things simple and elegant. Let us take SWD
implementation as an example. If we want to have two transports JTAG
and SWD and separate transport from an interface and target, we need
some additional abstraction. Otherwise each interface would need its
own transport. When Features are in place, intelligent interface can
define its own features that are done by the hardware, generic
interfaces will use features provided by external library (libswd in
this case). When transport is being setup, code will check if driver
already has features defined, if so transport will use these features,
if not transport will try to add generic features to the interface.

This way we have clean and elegant solution, that have simple
interface api, simple transports organization, clean target, and lots
of possibilities to add in a well organized manner :-)

Feel free to see the code / commit:

http://repo.or.cz/w/openocd/libswd.git/commit/bdd0f7924a21b84ce731d2dfb333b01b4e370f6e

At this point I had to modify existing Transport infrastructure, so
further code changes in OpenOCD+LibSWD integration will probably break
existing code. I was trying to avoid that at all cost but there is no
sense to develop bad code. The transport now have only setup() and
quit() methods, all other target specific operations are moved into
arm_dap_feature (as it regards to the arm_dap). Anyway - I have things
working and bits jumping on the target again with the new openocd
head, so the integration is very near :-)

% ./openocd -f stm32swd.cfg
Open On-Chip Debugger 0.7.0-dev-gc1e217b-dirty (2012-11-15-21:21)
Licensed under GNU GPL v2
For bug reports, read
       http://openocd.sourceforge.net/doc/doxygen/bugs.html
Info : only one transport option; autoselect 'swd'
Info : Selected LibSWD as SWD transport mechanism, adding driver features...
Info : Interface signal - 'RnW' added.
Info : Interface signal - 'LED' added.
Info : Interface signal - 'SRST' added.
Info : Interface signal - 'SRSTin' added.
Info : Interface signal - 'CLK' added.
Info : Interface signal - 'MOSI' added.
Info : Interface signal - 'MISO' added.
Info : Interface signal - 'nSWDsel' added.
adapter speed: 1000 kHz
adapter_nsrst_delay: 100
Info : KT-LINK SWD-Mode initialization complete...
Info : max TCK change to: 30000 kHz
Info : clock speed 1000 kHz
LIBSWD_N: Using libswd master-GIT-devel (http://libswd.sf.net)
LIBSWD_N: (c) Tomasz Boleslaw CEDRO (http://www.tomek.cedro.info)
Info : New SWD context initialized at 0x0x801423340
LIBSWD_I: Executing libswd_dap_activate(libswdctx=@0x801423340,
operation=LIBSWD_OPERATION_EXECUTE)
LIBSWD_I: Executing libswd_dap_reset(libswdctx=@0x801423340,
operation=LIBSWD_OPERATION_EXECUTE)
LIBSWD_I: Executing libswd_dp_read_idcode(libswdctx=@0x801423340,
operation=LIBSWD_OPERATION_EXECUTE)
LIBSWD_I: libswd_dp_read_idcode(libswdctx=@0x801423340,
operation=LIBSWD_OPERATION_EXECUTE,
**idcode=0x1BA01477/00011011101000000001010001110111).
Info : SWD transport initialization complete. Found IDCODE=0x1BA01477.

Best regards :-)
Tomek Cedro

-- 
CeDeROM, SQ7MHZ, http://www.tomek.cedro.info

------------------------------------------------------------------------------
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov
_______________________________________________
OpenOCD-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openocd-devel

Reply via email to