Handle AVRMEM_ALIAS

Aliases are interesting for generic vs. datasheet names of
avrX fuses
This commit is contained in:
Joerg Wunsch
2024-04-05 19:42:08 +02:00
parent 306d948bc5
commit 69672a8470
2 changed files with 24 additions and 0 deletions

View File

@@ -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

View File

@@ -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