Add parent id output for developer options -p*/s for parts

This commit is contained in:
Stefan Rueger 2022-07-26 23:43:56 +01:00
parent 1549273529
commit 78754b8ccc
5 changed files with 28 additions and 25 deletions

View File

@ -354,7 +354,6 @@ AVRMEM_ALIAS * avr_dup_memalias(AVRMEM_ALIAS * m)
void avr_free_mem(AVRMEM * m) void avr_free_mem(AVRMEM * m)
{ {
int i;
if (m->buf != NULL) { if (m->buf != NULL) {
free(m->buf); free(m->buf);
m->buf = NULL; m->buf = NULL;
@ -363,7 +362,7 @@ void avr_free_mem(AVRMEM * m)
free(m->tags); free(m->tags);
m->tags = NULL; m->tags = NULL;
} }
for(i=0;i<sizeof(m->op)/sizeof(m->op[0]);i++) for(size_t i=0; i<sizeof(m->op)/sizeof(m->op[0]); i++)
{ {
if (m->op[i] != NULL) if (m->op[i] != NULL)
{ {
@ -487,7 +486,8 @@ AVRMEM_ALIAS * avr_find_memalias(AVRPART * p, AVRMEM * m_orig)
void avr_mem_display(const char * prefix, FILE * f, AVRMEM * m, AVRPART * p, void avr_mem_display(const char * prefix, FILE * f, AVRMEM * m, AVRPART * p,
int type, int verbose) int type, int verbose)
{ {
static unsigned int prev_mem_offset, prev_mem_size; static unsigned int prev_mem_offset;
static int prev_mem_size;
int i, j; int i, j;
char * optr; char * optr;
@ -579,6 +579,7 @@ AVRPART * avr_new_part(void)
p->reset_disposition = RESET_DEDICATED; p->reset_disposition = RESET_DEDICATED;
p->retry_pulse = PIN_AVR_SCK; p->retry_pulse = PIN_AVR_SCK;
p->flags = AVRPART_SERIALOK | AVRPART_PARALLELOK | AVRPART_ENABLEPAGEPROGRAMMING; p->flags = AVRPART_SERIALOK | AVRPART_PARALLELOK | AVRPART_ENABLEPAGEPROGRAMMING;
p->parent_id = NULL;
p->config_file = NULL; p->config_file = NULL;
p->lineno = 0; p->lineno = 0;
memset(p->signature, 0xFF, 3); memset(p->signature, 0xFF, 3);
@ -608,7 +609,6 @@ AVRPART * avr_dup_part(AVRPART * d)
p->mem = save; p->mem = save;
p->mem_alias = save2; p->mem_alias = save2;
for (ln=lfirst(d->mem); ln; ln=lnext(ln)) { for (ln=lfirst(d->mem); ln; ln=lnext(ln)) {
AVRMEM *m = ldata(ln); AVRMEM *m = ldata(ln);
AVRMEM *m2 = avr_dup_mem(m); AVRMEM *m2 = avr_dup_mem(m);
@ -636,20 +636,18 @@ AVRPART * avr_dup_part(AVRPART * d)
void avr_free_part(AVRPART * d) void avr_free_part(AVRPART * d)
{ {
int i; ldestroy_cb(d->mem, (void(*)(void *))avr_free_mem);
ldestroy_cb(d->mem, (void(*)(void *))avr_free_mem); d->mem = NULL;
d->mem = NULL; ldestroy_cb(d->mem_alias, (void(*)(void *))avr_free_memalias);
ldestroy_cb(d->mem_alias, (void(*)(void *))avr_free_memalias); d->mem_alias = NULL;
d->mem_alias = NULL; /* do not free d->parent_id and d->config_file */
for(i=0;i<sizeof(d->op)/sizeof(d->op[0]);i++) for(size_t i=0; i<sizeof(d->op)/sizeof(d->op[0]); i++) {
{ if (d->op[i] != NULL) {
if (d->op[i] != NULL) avr_free_opcode(d->op[i]);
{ d->op[i] = NULL;
avr_free_opcode(d->op[i]);
d->op[i] = NULL;
}
} }
free(d); }
free(d);
} }
AVRPART * locate_part(LISTID parts, const char * partdesc) AVRPART * locate_part(LISTID parts, const char * partdesc)

View File

@ -334,6 +334,7 @@ prog_decl :
free_token($3); free_token($3);
YYABORT; YYABORT;
} }
current_prog->parent_id = cache_string($3->value.string);
current_prog->config_file = cache_string(cfg_infile); current_prog->config_file = cache_string(cfg_infile);
current_prog->lineno = cfg_lineno; current_prog->lineno = cfg_lineno;
free_token($3); free_token($3);
@ -425,6 +426,7 @@ part_decl :
free_token($3); free_token($3);
YYABORT; YYABORT;
} }
current_part->parent_id = cache_string($3->value.string);
current_part->config_file = cache_string(cfg_infile); current_part->config_file = cache_string(cfg_infile);
current_part->lineno = cfg_lineno; current_part->lineno = cfg_lineno;

View File

@ -592,6 +592,7 @@ static int avrpart_deep_copy(AVRPARTdeep *d, AVRPART *p) {
d->base = *p; d->base = *p;
d->base.parent_id = NULL;
d->base.config_file = NULL; d->base.config_file = NULL;
d->base.lineno = 0; d->base.lineno = 0;
@ -678,7 +679,10 @@ static void dev_part_strct(AVRPART *p, bool tsv, AVRPART *base) {
dev_info("#------------------------------------------------------------\n"); dev_info("#------------------------------------------------------------\n");
dev_info("# %s\n", p->desc); dev_info("# %s\n", p->desc);
dev_info("#------------------------------------------------------------\n"); dev_info("#------------------------------------------------------------\n");
dev_info("\npart\n"); if(p->parent_id)
dev_info("\npart parent \"%s\"\n", p->parent_id);
else
dev_info("\npart\n");
} }
_if_partout(strcmp, "\"%s\"", desc); _if_partout(strcmp, "\"%s\"", desc);
@ -1047,7 +1051,7 @@ void dev_output_part_defs(char *partdesc) {
continue; continue;
if(strct || cmpst) if(strct || cmpst)
dev_part_strct(p, tsv, cmpst? nullpart: NULL); dev_part_strct(p, tsv, !cmpst? NULL: p->parent_id? locate_part(part_list, p->parent_id): nullpart);
if(raw) if(raw)
dev_part_raw(p); dev_part_raw(p);

View File

@ -217,6 +217,7 @@ typedef struct opcode {
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 */
char * parent_id; /* parent id if set, for -p.../s */
char family_id[AVR_FAMILYIDLEN+1]; /* family id in the SIB (avr8x) */ char family_id[AVR_FAMILYIDLEN+1]; /* family id in the SIB (avr8x) */
int hvupdi_variant; /* HV pulse on UPDI pin, no pin or RESET pin */ int hvupdi_variant; /* HV pulse on UPDI pin, no pin or RESET pin */
int stk500_devcode; /* stk500 device code */ int stk500_devcode; /* stk500 device code */
@ -661,6 +662,7 @@ typedef struct programmer_t {
char desc[PGM_DESCLEN]; char desc[PGM_DESCLEN];
char type[PGM_TYPELEN]; char type[PGM_TYPELEN];
char port[PGM_PORTLEN]; char port[PGM_PORTLEN];
char *parent_id;
void (*initpgm)(struct programmer_t * pgm); void (*initpgm)(struct programmer_t * pgm);
unsigned int pinno[N_PINS]; unsigned int pinno[N_PINS];
struct pindef_t pin[N_PINS]; struct pindef_t pin[N_PINS];

View File

@ -79,6 +79,7 @@ PROGRAMMER * pgm_new(void)
pgm->usbpid = lcreat(NULL, 0); pgm->usbpid = lcreat(NULL, 0);
pgm->desc[0] = 0; pgm->desc[0] = 0;
pgm->type[0] = 0; pgm->type[0] = 0;
pgm->parent_id = NULL;
pgm->config_file = NULL; pgm->config_file = NULL;
pgm->lineno = 0; pgm->lineno = 0;
pgm->baudrate = 0; pgm->baudrate = 0;
@ -145,11 +146,8 @@ void pgm_free(PROGRAMMER * const p)
ldestroy_cb(p->usbpid, free); ldestroy_cb(p->usbpid, free);
p->id = NULL; p->id = NULL;
p->usbpid = NULL; p->usbpid = NULL;
/* this is done by pgm_teardown, but usually cookie is not set to NULL */ /* do not free p->parent_id nor p->config_file */
/* if (p->cookie !=NULL) { /* p->cookie is freed by pgm_teardown */
free(p->cookie);
p->cookie = NULL;
}*/
free(p); free(p);
} }
@ -169,7 +167,6 @@ PROGRAMMER * pgm_dup(const PROGRAMMER * const src)
pgm->id = lcreat(NULL, 0); pgm->id = lcreat(NULL, 0);
pgm->usbpid = lcreat(NULL, 0); pgm->usbpid = lcreat(NULL, 0);
for (ln = lfirst(src->usbpid); ln; ln = lnext(ln)) { for (ln = lfirst(src->usbpid); ln; ln = lnext(ln)) {
int *ip = malloc(sizeof(int)); int *ip = malloc(sizeof(int));
if (ip == NULL) { if (ip == NULL) {