Skip to content

Commit

Permalink
Handle AVRMEM_ALIAS
Browse files Browse the repository at this point in the history
Aliases are interesting for generic vs. datasheet names of
avrX fuses
  • Loading branch information
dl8dtl committed Apr 5, 2024
1 parent 306d948 commit 69672a8
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/libavrdude.i
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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*);

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions src/python/swigtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 69672a8

Please sign in to comment.