From 69672a8470396dad09f46d74a354fe7b467ffe8c Mon Sep 17 00:00:00 2001 From: Joerg Wunsch Date: Fri, 5 Apr 2024 19:42:08 +0200 Subject: [PATCH] Handle AVRMEM_ALIAS Aliases are interesting for generic vs. datasheet names of avrX fuses --- src/libavrdude.i | 17 +++++++++++++++++ src/python/swigtest.py | 7 +++++++ 2 files changed, 24 insertions(+) diff --git a/src/libavrdude.i b/src/libavrdude.i index aa150f609..3c1813d45 100644 --- a/src/libavrdude.i +++ b/src/libavrdude.i @@ -159,6 +159,10 @@ AVRMEM *ldata_avrmem(LNODEID p) { return (AVRMEM *)ldata(p); } +AVRMEM_ALIAS *ldata_avrmem_alias(LNODEID p) { + return (AVRMEM_ALIAS *)ldata(p); +} + const char *ldata_string(LNODEID p) { return (const char *)ldata(p); } @@ -249,6 +253,7 @@ const char *pgmid; typedef void * LNODEID; typedef void * LISTID; typedef struct avrmem AVRMEM; +typedef struct avrmem_alias AVRMEM_ALIAS; typedef struct programmer_t PROGRAMMER; typedef void pgm_initpgm(PROGRAMMER*); @@ -328,6 +333,13 @@ typedef struct avrmem { unsigned char * buf; /* pointer to memory buffer */ } AVRMEM; +%immutable; +typedef struct avrmem_alias { + const char *desc; /* alias name ("syscfg0" etc.) */ + AVRMEM *aliased_mem; +} AVRMEM_ALIAS; +%mutable; + %extend avrmem { %feature("autodoc", "m.get(len: int, offset: int = 0) => return bytes; Read from memory buffer") get; PyObject *get(unsigned int len, unsigned int offset = 0) { @@ -604,12 +616,17 @@ AVRPART *ldata_avrpart(LNODEID); %feature("autodoc", "LNODEID -> AVRMEM*") ldata_avrmem; AVRMEM *ldata_avrmem(LNODEID); +%feature("autodoc", "LNODEID -> AVRMEM_ALIAS*") ldata_avrmem_alias; +AVRMEM_ALIAS *ldata_avrmem_alias(LNODEID); + %feature("autodoc", "LNODEID -> str") ldata_string; const char *ldata_string(LNODEID); // AVRMEM and AVRPART handling AVRMEM * avr_locate_mem(const AVRPART *p, const char *desc); AVRPART * locate_part(const LISTID parts, const char *partdesc); +AVRMEM_ALIAS * avr_locate_memalias(const AVRPART *p, const char *desc); +AVRMEM_ALIAS * avr_find_memalias(const AVRPART *p, const AVRMEM *m_orig); // Programming modes for parts and programmers: reflect changes in lexer.l, developer_opts.c and config.c #define PM_SPM 1 // Bootloaders, self-programming with SPM opcodes or NVM Controllers diff --git a/src/python/swigtest.py b/src/python/swigtest.py index a12924184..d0e9a0823 100644 --- a/src/python/swigtest.py +++ b/src/python/swigtest.py @@ -27,6 +27,13 @@ # l=dissect_fuse(cfg, 'lfuse', 0xe0) # hex(synthesize_fuse(cfg, 'lfuse', l)) +# for AVR parts with aliased mem (avrX): +# ad.avr_locate_memalias(p, 'wdtcfg').aliased_mem.desc +# alist = ad.lfirst(p.mem_alias) +# ad.ldata_avrmem_alias(alist).desc +# ad.ldata_avrmem_alias(alist).aliased_mem.desc +# alist = ad.lnext(alist) # ... + # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or