Change macros __f() to _f() and adapt to config_file and hvupdi changes

This commit is contained in:
Stefan Rueger 2022-07-19 14:38:34 +01:00
parent 43e2955c61
commit 8989e6515b
3 changed files with 97 additions and 99 deletions

View File

@ -485,8 +485,7 @@ static int avrpart_deep_copy(AVRPARTdeep *d, AVRPART *p) {
d->base = *p; d->base = *p;
// remove location info d->base.config_file = NULL;
memset(d->base.config_file, 0, sizeof d->base.config_file);
d->base.lineno = 0; d->base.lineno = 0;
// zap all bytes beyond terminating nul of desc, id and family_id array // zap all bytes beyond terminating nul of desc, id and family_id array
@ -567,64 +566,60 @@ static void dev_part_raw(AVRPART *part) {
static void dev_part_strct(AVRPART *p, bool tsv, AVRPART *base) { static void dev_part_strct(AVRPART *p, bool tsv, AVRPART *base) {
char real_config_file[PATH_MAX]; dev_info("# %s %d\n", p->config_file, p->lineno);
if(!realpath(p->config_file, real_config_file))
memcpy(real_config_file, p->config_file, sizeof real_config_file);
dev_info("# %s %d\n", real_config_file, p->lineno);
if(!tsv) if(!tsv)
dev_info("part\n"); dev_info("part\n");
__if_partout(strcmp, "\"%s\"", desc); _if_partout(strcmp, "\"%s\"", desc);
__if_partout(strcmp, "\"%s\"", id); _if_partout(strcmp, "\"%s\"", id);
__if_partout(strcmp, "\"%s\"", family_id); _if_partout(strcmp, "\"%s\"", family_id);
__if_partout(intcmp, "0x%02x", stk500_devcode); _if_partout(intcmp, "%d", hvupdi_variant);
__if_partout(intcmp, "0x%02x", avr910_devcode); _if_partout(intcmp, "0x%02x", stk500_devcode);
__if_partout(intcmp, "%d", chip_erase_delay); _if_partout(intcmp, "0x%02x", avr910_devcode);
__if_partout(intcmp, "0x%02x", pagel); _if_partout(intcmp, "%d", chip_erase_delay);
__if_partout(intcmp, "0x%02x", bs2); _if_partout(intcmp, "0x%02x", pagel);
__if_n_partout_str(memcmp, sizeof p->signature, dev_sprintf("0x%02x 0x%02x 0x%02x", p->signature[0], p->signature[1], p->signature[2]), signature); _if_partout(intcmp, "0x%02x", bs2);
__if_partout(intcmp, "0x%04x", usbpid); _if_n_partout_str(memcmp, sizeof p->signature, dev_sprintf("0x%02x 0x%02x 0x%02x", p->signature[0], p->signature[1], p->signature[2]), signature);
_if_partout(intcmp, "0x%04x", usbpid);
if(!base || base->reset_disposition != p->reset_disposition) if(!base || base->reset_disposition != p->reset_disposition)
__partout_str(strdup(p->reset_disposition == RESET_DEDICATED? "dedicated": p->reset_disposition == RESET_IO? "io": "unknown"), reset); _partout_str(strdup(p->reset_disposition == RESET_DEDICATED? "dedicated": p->reset_disposition == RESET_IO? "io": "unknown"), reset);
__if_partout_str(intcmp, strdup(p->retry_pulse == PIN_AVR_RESET? "reset": p->retry_pulse == PIN_AVR_SCK? "sck": "unknown"), retry_pulse); _if_partout_str(intcmp, strdup(p->retry_pulse == PIN_AVR_RESET? "reset": p->retry_pulse == PIN_AVR_SCK? "sck": "unknown"), retry_pulse);
if(!base || base->flags != p->flags) { if(!base || base->flags != p->flags) {
if(tsv) { if(tsv) {
__partout("0x%04x", flags); _partout("0x%04x", flags);
} else { } else {
__if_flagout(AVRPART_HAS_JTAG, has_jtag); _if_flagout(AVRPART_HAS_JTAG, has_jtag);
__if_flagout(AVRPART_HAS_DW, has_debugwire); _if_flagout(AVRPART_HAS_DW, has_debugwire);
__if_flagout(AVRPART_HAS_PDI, has_pdi); _if_flagout(AVRPART_HAS_PDI, has_pdi);
__if_flagout(AVRPART_HAS_UPDI, has_updi); _if_flagout(AVRPART_HAS_UPDI, has_updi);
__if_flagout(AVRPART_HAS_TPI, has_tpi); _if_flagout(AVRPART_HAS_TPI, has_tpi);
__if_flagout(AVRPART_IS_AT90S1200, is_at90s1200); _if_flagout(AVRPART_IS_AT90S1200, is_at90s1200);
__if_flagout(AVRPART_AVR32, is_avr32); _if_flagout(AVRPART_AVR32, is_avr32);
__if_flagout(AVRPART_ALLOWFULLPAGEBITSTREAM, allowfullpagebitstream); _if_flagout(AVRPART_ALLOWFULLPAGEBITSTREAM, allowfullpagebitstream);
__if_flagout(AVRPART_ENABLEPAGEPROGRAMMING, enablepageprogramming); _if_flagout(AVRPART_ENABLEPAGEPROGRAMMING, enablepageprogramming);
__if_flagout(AVRPART_SERIALOK, serial); _if_flagout(AVRPART_SERIALOK, serial);
if(!base || (base->flags & (AVRPART_PARALLELOK | AVRPART_PSEUDOPARALLEL)) != (p->flags & (AVRPART_PARALLELOK | AVRPART_PSEUDOPARALLEL))) { if(!base || (base->flags & (AVRPART_PARALLELOK | AVRPART_PSEUDOPARALLEL)) != (p->flags & (AVRPART_PARALLELOK | AVRPART_PSEUDOPARALLEL))) {
int par = p->flags & (AVRPART_PARALLELOK | AVRPART_PSEUDOPARALLEL); int par = p->flags & (AVRPART_PARALLELOK | AVRPART_PSEUDOPARALLEL);
__partout_str(strdup(par == 0? "no": par == AVRPART_PSEUDOPARALLEL? "unknown": AVRPART_PARALLELOK? "yes": "pseudo"), parallel); _partout_str(strdup(par == 0? "no": par == AVRPART_PSEUDOPARALLEL? "unknown": AVRPART_PARALLELOK? "yes": "pseudo"), parallel);
} }
} }
} }
__if_partout(intcmp, "%d", timeout); _if_partout(intcmp, "%d", timeout);
__if_partout(intcmp, "%d", stabdelay); _if_partout(intcmp, "%d", stabdelay);
__if_partout(intcmp, "%d", cmdexedelay); _if_partout(intcmp, "%d", cmdexedelay);
__if_partout(intcmp, "%d", synchloops); _if_partout(intcmp, "%d", synchloops);
__if_partout(intcmp, "%d", bytedelay); _if_partout(intcmp, "%d", bytedelay);
__if_partout(intcmp, "%d", pollindex); _if_partout(intcmp, "%d", pollindex);
__if_partout(intcmp, "0x%02x", pollvalue); _if_partout(intcmp, "0x%02x", pollvalue);
__if_partout(intcmp, "%d", predelay); _if_partout(intcmp, "%d", predelay);
__if_partout(intcmp, "%d", postdelay); _if_partout(intcmp, "%d", postdelay);
__if_partout(intcmp, "%d", pollmethod); _if_partout(intcmp, "%d", pollmethod);
if(!base && p->ctl_stack_type != CTL_STACK_NONE) if(!base && p->ctl_stack_type != CTL_STACK_NONE)
dev_stack_out(tsv, p, dev_controlstack_name(p), p->controlstack, CTL_STACK_SIZE); dev_stack_out(tsv, p, dev_controlstack_name(p), p->controlstack, CTL_STACK_SIZE);
@ -639,32 +634,33 @@ static void dev_part_strct(AVRPART *p, bool tsv, AVRPART *base) {
if(!base || memcmp(base->eeprom_instr, p->eeprom_instr, sizeof base->eeprom_instr)) if(!base || memcmp(base->eeprom_instr, p->eeprom_instr, sizeof base->eeprom_instr))
dev_stack_out(tsv, p, "eeprom_instr", p->eeprom_instr, EEPROM_INSTR_SIZE); dev_stack_out(tsv, p, "eeprom_instr", p->eeprom_instr, EEPROM_INSTR_SIZE);
__if_partout(intcmp, "%d", hventerstabdelay); _if_partout(intcmp, "%d", hventerstabdelay);
__if_partout(intcmp, "%d", progmodedelay); _if_partout(intcmp, "%d", progmodedelay);
__if_partout(intcmp, "%d", latchcycles); _if_partout(intcmp, "%d", latchcycles);
__if_partout(intcmp, "%d", togglevtg); _if_partout(intcmp, "%d", togglevtg);
__if_partout(intcmp, "%d", poweroffdelay); _if_partout(intcmp, "%d", poweroffdelay);
__if_partout(intcmp, "%d", resetdelayms); _if_partout(intcmp, "%d", resetdelayms);
__if_partout(intcmp, "%d", resetdelayus); _if_partout(intcmp, "%d", resetdelayus);
__if_partout(intcmp, "%d", hvleavestabdelay); _if_partout(intcmp, "%d", hvleavestabdelay);
__if_partout(intcmp, "%d", resetdelay); _if_partout(intcmp, "%d", resetdelay);
__if_partout(intcmp, "%d", chiperasepulsewidth); _if_partout(intcmp, "%d", chiperasepulsewidth);
__if_partout(intcmp, "%d", chiperasepolltimeout); _if_partout(intcmp, "%d", chiperasepolltimeout);
__if_partout(intcmp, "%d", chiperasetime); _if_partout(intcmp, "%d", chiperasetime);
__if_partout(intcmp, "%d", programfusepulsewidth); _if_partout(intcmp, "%d", programfusepulsewidth);
__if_partout(intcmp, "%d", programfusepolltimeout); _if_partout(intcmp, "%d", programfusepolltimeout);
__if_partout(intcmp, "%d", programlockpulsewidth); _if_partout(intcmp, "%d", programlockpulsewidth);
__if_partout(intcmp, "%d", programlockpolltimeout); _if_partout(intcmp, "%d", programlockpolltimeout);
__if_partout(intcmp, "%d", synchcycles); _if_partout(intcmp, "%d", synchcycles);
__if_partout(intcmp, "%d", hvspcmdexedelay); _if_partout(intcmp, "%d", hvspcmdexedelay);
__if_partout(intcmp, "0x%02x", idr);
__if_partout(intcmp, "0x%02x", rampz); _if_partout(intcmp, "0x%02x", idr);
__if_partout(intcmp, "0x%02x", spmcr); _if_partout(intcmp, "0x%02x", rampz);
__if_partout(intcmp, "0x%02x", eecr); // why is eecr an unsigned short? _if_partout(intcmp, "0x%02x", spmcr);
__if_partout(intcmp, "0x%04x", mcu_base); _if_partout(intcmp, "0x%02x", eecr); // why is eecr an unsigned short?
__if_partout(intcmp, "0x%04x", nvm_base); _if_partout(intcmp, "0x%04x", mcu_base);
__if_partout(intcmp, "0x%04x", ocd_base); _if_partout(intcmp, "0x%04x", nvm_base);
__if_partout(intcmp, "%d", ocdrev); _if_partout(intcmp, "0x%04x", ocd_base);
_if_partout(intcmp, "%d", ocdrev);
for(int i=0; i < AVR_OP_MAX; i++) for(int i=0; i < AVR_OP_MAX; i++)
if(!base || opcodecmp(p->op[i], base->op[i])) if(!base || opcodecmp(p->op[i], base->op[i]))
@ -692,20 +688,20 @@ static void dev_part_strct(AVRPART *p, bool tsv, AVRPART *base) {
dev_info("\n memory \"%s\"\n", m->desc); dev_info("\n memory \"%s\"\n", m->desc);
} }
__if_memout_yn(paged); _if_memout_yn(paged);
__if_memout(intcmp, m->size > 8192? "0x%x": "%d", size); _if_memout(intcmp, m->size > 8192? "0x%x": "%d", size);
__if_memout(intcmp, "%d", page_size); _if_memout(intcmp, "%d", page_size);
__if_memout(intcmp, "%d", num_pages); // why can AVRDUDE not compute this? _if_memout(intcmp, "%d", num_pages); // why can AVRDUDE not compute this?
__if_memout(intcmp, "0x%x", offset); _if_memout(intcmp, "0x%x", offset);
__if_memout(intcmp, "%d", min_write_delay); _if_memout(intcmp, "%d", min_write_delay);
__if_memout(intcmp, "%d", max_write_delay); _if_memout(intcmp, "%d", max_write_delay);
__if_memout_yn(pwroff_after_write); _if_memout_yn(pwroff_after_write);
__if_n_memout_str(memcmp, 2, dev_sprintf("0x%02x 0x%02x", m->readback[0], m->readback[1]), readback); _if_n_memout_str(memcmp, 2, dev_sprintf("0x%02x 0x%02x", m->readback[0], m->readback[1]), readback);
__if_memout(intcmp, "%d", mode); _if_memout(intcmp, "%d", mode);
__if_memout(intcmp, "%d", delay); _if_memout(intcmp, "%d", delay);
__if_memout(intcmp, "%d", blocksize); _if_memout(intcmp, "%d", blocksize);
__if_memout(intcmp, "%d", readsize); _if_memout(intcmp, "%d", readsize);
__if_memout(intcmp, "%d", pollindex); _if_memout(intcmp, "%d", pollindex);
for(int i=0; i < AVR_OP_MAX; i++) for(int i=0; i < AVR_OP_MAX; i++)
if(!bm || opcodecmp(bm->op[i], m->op[i])) if(!bm || opcodecmp(bm->op[i], m->op[i]))

View File

@ -51,66 +51,66 @@ static int dev_message(int msglvl, const char *fmt, ...);
#define dev_notice(...) dev_message(DEV_NOTICE, __VA_ARGS__) #define dev_notice(...) dev_message(DEV_NOTICE, __VA_ARGS__)
#define dev_notice2(...) dev_message(DEV_NOTICE2, __VA_ARGS__) #define dev_notice2(...) dev_message(DEV_NOTICE2, __VA_ARGS__)
#define __partout(fmt, component) \ #define _partout(fmt, component) \
dev_part_strct_entry(tsv, ".pt", p->desc, NULL, #component, dev_sprintf(fmt, p->component)) dev_part_strct_entry(tsv, ".pt", p->desc, NULL, #component, dev_sprintf(fmt, p->component))
#define __if_partout(cmp, fmt, component) ({ \ #define _if_partout(cmp, fmt, component) ({ \
if(!base || cmp(base->component, p->component)) \ if(!base || cmp(base->component, p->component)) \
dev_part_strct_entry(tsv, ".pt", p->desc, NULL, #component, dev_sprintf(fmt, p->component)); \ dev_part_strct_entry(tsv, ".pt", p->desc, NULL, #component, dev_sprintf(fmt, p->component)); \
}) })
#define __if_n_partout(cmp, n, fmt, component) ({ \ #define _if_n_partout(cmp, n, fmt, component) ({ \
if(!base || cmp(base->component, p->component, n)) \ if(!base || cmp(base->component, p->component, n)) \
dev_part_strct_entry(tsv, ".pt", p->desc, NULL, #component, dev_sprintf(fmt, p->component)); \ dev_part_strct_entry(tsv, ".pt", p->desc, NULL, #component, dev_sprintf(fmt, p->component)); \
}) })
#define __partout_str(result, component) \ #define _partout_str(result, component) \
dev_part_strct_entry(tsv, ".pt", p->desc, NULL, #component, result) dev_part_strct_entry(tsv, ".pt", p->desc, NULL, #component, result)
#define __if_partout_str(cmp, result, component) ({ \ #define _if_partout_str(cmp, result, component) ({ \
if(!base || cmp(base->component, p->component)) \ if(!base || cmp(base->component, p->component)) \
dev_part_strct_entry(tsv, ".pt", p->desc, NULL, #component, result); \ dev_part_strct_entry(tsv, ".pt", p->desc, NULL, #component, result); \
}) })
#define __if_n_partout_str(cmp, n, result, component) ({ \ #define _if_n_partout_str(cmp, n, result, component) ({ \
if(!base || cmp(base->component, p->component, n)) \ if(!base || cmp(base->component, p->component, n)) \
dev_part_strct_entry(tsv, ".pt", p->desc, NULL, #component, result); \ dev_part_strct_entry(tsv, ".pt", p->desc, NULL, #component, result); \
}) })
#define __memout(fmt, component) \ #define _memout(fmt, component) \
dev_part_strct_entry(tsv, ".ptmm", p->desc, m->desc, #component, dev_sprintf(fmt, m->component)) dev_part_strct_entry(tsv, ".ptmm", p->desc, m->desc, #component, dev_sprintf(fmt, m->component))
#define __if_memout(cmp, fmt, component) ({ \ #define _if_memout(cmp, fmt, component) ({ \
if(!bm || cmp(bm->component, m->component)) \ if(!bm || cmp(bm->component, m->component)) \
dev_part_strct_entry(tsv, ".ptmm", p->desc, m->desc, #component, dev_sprintf(fmt, m->component)); \ dev_part_strct_entry(tsv, ".ptmm", p->desc, m->desc, #component, dev_sprintf(fmt, m->component)); \
}) })
#define __memout_str(result, component) \ #define _memout_str(result, component) \
dev_part_strct_entry(tsv, ".ptmm", p->desc, m->desc, #component, result) dev_part_strct_entry(tsv, ".ptmm", p->desc, m->desc, #component, result)
#define __if_n_memout_str(cmp, n, result, component) ({ \ #define _if_n_memout_str(cmp, n, result, component) ({ \
if(!bm || cmp(bm->component, m->component, n)) \ if(!bm || cmp(bm->component, m->component, n)) \
dev_part_strct_entry(tsv, ".ptmm", p->desc, m->desc, #component, result); \ dev_part_strct_entry(tsv, ".ptmm", p->desc, m->desc, #component, result); \
}) })
#define __memout_yn(component) \ #define _memout_yn(component) \
dev_part_strct_entry(tsv, ".ptmm", p->desc, m->desc, #component, strdup(m->component? "yes": "no")) dev_part_strct_entry(tsv, ".ptmm", p->desc, m->desc, #component, strdup(m->component? "yes": "no"))
#define __if_memout_yn(component) ({ \ #define _if_memout_yn(component) ({ \
if(!bm || bm->component != m->component) \ if(!bm || bm->component != m->component) \
dev_part_strct_entry(tsv, ".ptmm", p->desc, m->desc, #component, strdup(m->component? "yes": "no")); \ dev_part_strct_entry(tsv, ".ptmm", p->desc, m->desc, #component, strdup(m->component? "yes": "no")); \
}) })
#define __flagout(mask, name) \ #define _flagout(mask, name) \
__partout_str(strdup(p->flags & (mask)? "yes": "no"), name) _partout_str(strdup(p->flags & (mask)? "yes": "no"), name)
#define __if_flagout(mask, name) ({ \ #define _if_flagout(mask, name) ({ \
if(!base || (base->flags & (mask)) != (p->flags & (mask))) \ if(!base || (base->flags & (mask)) != (p->flags & (mask))) \
__partout_str(strdup(p->flags & (mask)? "yes": "no"), name); \ _partout_str(strdup(p->flags & (mask)? "yes": "no"), name); \
}) })
#define __cmderr(result, component) \ #define _cmderr(result, component) \
dev_part_strct_entry(tsv, ".cmderr", p->desc, m->desc, #component, result) dev_part_strct_entry(tsv, ".cmderr", p->desc, m->desc, #component, result)
#endif #endif

View File

@ -183,6 +183,7 @@ typedef struct opcode {
} OPCODE; } OPCODE;
/* Any changes here, please also reflect in dev_part_strct() of developer_opts.c */
#define AVRPART_SERIALOK 0x0001 /* part supports serial programming */ #define AVRPART_SERIALOK 0x0001 /* part supports serial programming */
#define AVRPART_PARALLELOK 0x0002 /* part supports parallel programming */ #define AVRPART_PARALLELOK 0x0002 /* part supports parallel programming */
#define AVRPART_PSEUDOPARALLEL 0x0004 /* part has pseudo parallel support */ #define AVRPART_PSEUDOPARALLEL 0x0004 /* part has pseudo parallel support */
@ -212,6 +213,7 @@ typedef struct opcode {
#define TAG_ALLOCATED 1 /* memory byte is allocated */ #define TAG_ALLOCATED 1 /* memory byte is allocated */
/* Any changes here, please also reflect in dev_part_strct() of developer_opts.c */
typedef struct avrpart { typedef struct avrpart {
char desc[AVR_DESCLEN]; /* long part name */ char desc[AVR_DESCLEN]; /* long part name */
char id[AVR_IDLEN]; /* short part name */ char id[AVR_IDLEN]; /* short part name */