2014-06-17 20:08:28 +00:00
|
|
|
/*
|
|
|
|
* avrdude - A Downloader/Uploader for AVR device programmers
|
|
|
|
* Copyright (C) 2000-2004 Brian S. Dean <bsd@bsdhome.com>
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* $Id$ */
|
|
|
|
|
|
|
|
/* These are the internal definitions needed for config parsing */
|
|
|
|
|
|
|
|
#ifndef config_h
|
|
|
|
#define config_h
|
|
|
|
|
|
|
|
#include "libavrdude.h"
|
|
|
|
|
2022-07-19 07:05:42 +00:00
|
|
|
#if defined(WIN32) || defined(_MSC_VER) || defined(__MINGW32__)
|
|
|
|
#define realpath(N,R) _fullpath((R), (N), PATH_MAX)
|
|
|
|
#endif
|
|
|
|
|
2014-06-17 20:08:28 +00:00
|
|
|
|
2022-08-11 23:28:54 +00:00
|
|
|
typedef struct {
|
|
|
|
char *kw; // Keyword near the comments
|
|
|
|
LISTID comms; // Chained list of comments
|
|
|
|
int rhs; // Comments to print rhs of keyword line
|
|
|
|
} COMMENT;
|
|
|
|
|
|
|
|
|
Prepare for new components in avrdude.conf incl prog_modes
- Add prog_modes to part and programmer definitions; prog_mode is a bitwise
or of programming modes
+ PM_SPM: Bootloaders, self-programming with SPM/NVM Controllers
+ PM_TPI: t4, t5, t9, t10, t20, t40, t102, t104
+ PM_ISP: SPI programming for In-System Programming (typ classic parts)
+ PM_PDI: Program and Debug Interface (xmega parts)
+ PM_UPDI: Unified Program and Debug Interface
+ PM_HVSP: High Voltage Serial Programming (some classic parts)
+ PM_HVPP: High Voltage Parallel Programming (most non-HVSP classic parts)
+ PM_debugWIRE: Simpler alternative to JTAG (a subset of HVPP/HVSP parts)
+ PM_JTAG: some classic parts, some xmega
+ PM_aWire: AVR32 parts
- Add mcuid, a unique id in 0..2039, to part definition for urclock programmer
- Add n_interrupts, the number of interrupts, to part definition
- Add n_page_erase to part definition (# of pages erased during NVM erase)
- Implement a simple calculator in config_gram.y so numeric values can be
expressed as simple expressions such as PM_SPM | PM_UPDI
- Introduce a new method of assigning simple components to the grammar without
touching config_gram.y via an eligible-component list in config.c; numeric
expressions on the rhs of an assignment resolve to integer values
- Update documentation in avrdude.conf.in and avrdude.texi
2022-08-30 01:08:15 +00:00
|
|
|
enum { // Which structures a component can occur in
|
|
|
|
COMP_CONFIG_MAIN,
|
|
|
|
COMP_PROGRAMMER,
|
|
|
|
COMP_AVRPART,
|
|
|
|
COMP_AVRMEM,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum { // Component types in structure
|
|
|
|
COMP_INT,
|
|
|
|
COMP_SHORT,
|
|
|
|
COMP_CHAR,
|
|
|
|
COMP_STRING,
|
|
|
|
COMP_CHAR_ARRAY, // This and below are not yet implemented
|
|
|
|
COMP_INT_LISTID,
|
|
|
|
COMP_STRING_LISTID,
|
|
|
|
COMP_OPCODE,
|
|
|
|
COMP_PIN, // Pins may never be implemented
|
|
|
|
COMP_PIN_LIST
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct { // Description of a component in a structure
|
|
|
|
const char *name; // Component name
|
|
|
|
int strct; // Structure, eg, COMP_AVRPART
|
|
|
|
int offset, size, type; // Location, size and type within structure
|
|
|
|
} Component_t;
|
|
|
|
|
|
|
|
|
|
|
|
enum { // Value types for VALUE struct
|
|
|
|
V_NONE,
|
|
|
|
V_NUM,
|
|
|
|
V_NUM_REAL,
|
|
|
|
V_STR,
|
|
|
|
V_COMPONENT,
|
|
|
|
};
|
|
|
|
|
2014-06-17 20:08:28 +00:00
|
|
|
typedef struct value_t {
|
|
|
|
int type;
|
2022-08-09 20:20:44 +00:00
|
|
|
union {
|
2014-06-17 20:08:28 +00:00
|
|
|
int number;
|
|
|
|
double number_real;
|
|
|
|
char * string;
|
Prepare for new components in avrdude.conf incl prog_modes
- Add prog_modes to part and programmer definitions; prog_mode is a bitwise
or of programming modes
+ PM_SPM: Bootloaders, self-programming with SPM/NVM Controllers
+ PM_TPI: t4, t5, t9, t10, t20, t40, t102, t104
+ PM_ISP: SPI programming for In-System Programming (typ classic parts)
+ PM_PDI: Program and Debug Interface (xmega parts)
+ PM_UPDI: Unified Program and Debug Interface
+ PM_HVSP: High Voltage Serial Programming (some classic parts)
+ PM_HVPP: High Voltage Parallel Programming (most non-HVSP classic parts)
+ PM_debugWIRE: Simpler alternative to JTAG (a subset of HVPP/HVSP parts)
+ PM_JTAG: some classic parts, some xmega
+ PM_aWire: AVR32 parts
- Add mcuid, a unique id in 0..2039, to part definition for urclock programmer
- Add n_interrupts, the number of interrupts, to part definition
- Add n_page_erase to part definition (# of pages erased during NVM erase)
- Implement a simple calculator in config_gram.y so numeric values can be
expressed as simple expressions such as PM_SPM | PM_UPDI
- Introduce a new method of assigning simple components to the grammar without
touching config_gram.y via an eligible-component list in config.c; numeric
expressions on the rhs of an assignment resolve to integer values
- Update documentation in avrdude.conf.in and avrdude.texi
2022-08-30 01:08:15 +00:00
|
|
|
Component_t *comp;
|
2022-08-09 20:20:44 +00:00
|
|
|
};
|
2014-06-17 20:08:28 +00:00
|
|
|
} VALUE;
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct token_t {
|
|
|
|
int primary;
|
|
|
|
VALUE value;
|
|
|
|
} TOKEN;
|
|
|
|
typedef struct token_t *token_p;
|
|
|
|
|
|
|
|
|
|
|
|
extern FILE * yyin;
|
|
|
|
extern PROGRAMMER * current_prog;
|
|
|
|
extern AVRPART * current_part;
|
|
|
|
extern AVRMEM * current_mem;
|
2022-08-30 01:49:37 +00:00
|
|
|
extern int current_strct;
|
2022-07-18 17:10:09 +00:00
|
|
|
extern int cfg_lineno;
|
|
|
|
extern char * cfg_infile;
|
2014-06-17 20:08:28 +00:00
|
|
|
extern LISTID string_list;
|
|
|
|
extern LISTID number_list;
|
Alias keyword (#868)
Implementation for an "alias" keyword.
By now, only applied inside memory descriptions.
* Make "mem_alias" a separate nonterminal.
The previous implementation attempt caused a syntax error in
yacc code, and separating mem_alias on the same level as
mem_spec appears to be the cleaner solution anyway.
* Maintain real memory aliases.
Instead of duplicating the aliased memory with a new name, maintain a
second list of memory aliases (per device) that contains a pointer to
the memory area it is aliased to. That way, a memory name can be
clearly distinguished between the canonical one and any aliases.
* Check p->mem_alias != NULL before touching it
* Add avr_find_memalias()
This takes a memory region as input, and searches whether an
alias can be found for it.
* We need to add a list structure for the mem_alias list, always.
By that means, mem_alias won't ever be NULL, so no need to check
later.
Also, in avr_dup_part(), duplicate the alias list.
* In a memory alias, actually remember the current name.
* In avr_dup_part(), adjust pointers of aliased memories
While walking the list of memories, for each entry, see if there is an
alias pointing to it. If so, allocate a duplicated one, and fix its
aliased_mem pointer to point to the duplicated memory region instead
of the original one.
* Add avr_locate_mem_noalias()
When looking whether any memory region has already been defined for
the current part while parsing the config file, only non-aliased names
must be considered. Otherwise, a newly defined alias would kick out
the memory definition it is being aliased to.
* When defining a mem_alias, drop any existing one of that name.
* Actually use avr_find_memalias() to find aliases
* Add declaration for avr_find_memalias()
* When defining a memory, also search for an existing alias
If the newly defined name has the same as an existing alias, the alias
can be removed.
Note that we do explicitly *not* remove any memory by the same name of
a later defined alias, as this might invalidate another alias'es
pointer. If someone defines that, the alias name just won't ever be
found by avr_locate_mem().
2022-02-10 19:39:19 +00:00
|
|
|
extern bool is_alias; // current entry is alias
|
2014-06-17 20:08:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
#if !defined(HAS_YYSTYPE)
|
|
|
|
#define YYSTYPE token_p
|
|
|
|
#endif
|
|
|
|
extern YYSTYPE yylval;
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
int yyparse(void);
|
|
|
|
|
2022-08-09 20:20:44 +00:00
|
|
|
int yyerror(char *errmsg, ...);
|
2014-06-17 20:08:28 +00:00
|
|
|
|
2022-08-09 20:20:44 +00:00
|
|
|
int yywarning(char *errmsg, ...);
|
2014-06-17 20:08:28 +00:00
|
|
|
|
2022-08-09 20:20:44 +00:00
|
|
|
TOKEN *new_token(int primary);
|
2014-06-17 20:08:28 +00:00
|
|
|
|
2022-08-09 20:20:44 +00:00
|
|
|
void free_token(TOKEN *tkn);
|
2014-06-17 20:08:28 +00:00
|
|
|
|
|
|
|
void free_tokens(int n, ...);
|
|
|
|
|
Prepare for new components in avrdude.conf incl prog_modes
- Add prog_modes to part and programmer definitions; prog_mode is a bitwise
or of programming modes
+ PM_SPM: Bootloaders, self-programming with SPM/NVM Controllers
+ PM_TPI: t4, t5, t9, t10, t20, t40, t102, t104
+ PM_ISP: SPI programming for In-System Programming (typ classic parts)
+ PM_PDI: Program and Debug Interface (xmega parts)
+ PM_UPDI: Unified Program and Debug Interface
+ PM_HVSP: High Voltage Serial Programming (some classic parts)
+ PM_HVPP: High Voltage Parallel Programming (most non-HVSP classic parts)
+ PM_debugWIRE: Simpler alternative to JTAG (a subset of HVPP/HVSP parts)
+ PM_JTAG: some classic parts, some xmega
+ PM_aWire: AVR32 parts
- Add mcuid, a unique id in 0..2039, to part definition for urclock programmer
- Add n_interrupts, the number of interrupts, to part definition
- Add n_page_erase to part definition (# of pages erased during NVM erase)
- Implement a simple calculator in config_gram.y so numeric values can be
expressed as simple expressions such as PM_SPM | PM_UPDI
- Introduce a new method of assigning simple components to the grammar without
touching config_gram.y via an eligible-component list in config.c; numeric
expressions on the rhs of an assignment resolve to integer values
- Update documentation in avrdude.conf.in and avrdude.texi
2022-08-30 01:08:15 +00:00
|
|
|
TOKEN *new_number(const char *text);
|
|
|
|
|
|
|
|
TOKEN *new_number_real(const char *text);
|
2014-06-17 20:08:28 +00:00
|
|
|
|
Prepare for new components in avrdude.conf incl prog_modes
- Add prog_modes to part and programmer definitions; prog_mode is a bitwise
or of programming modes
+ PM_SPM: Bootloaders, self-programming with SPM/NVM Controllers
+ PM_TPI: t4, t5, t9, t10, t20, t40, t102, t104
+ PM_ISP: SPI programming for In-System Programming (typ classic parts)
+ PM_PDI: Program and Debug Interface (xmega parts)
+ PM_UPDI: Unified Program and Debug Interface
+ PM_HVSP: High Voltage Serial Programming (some classic parts)
+ PM_HVPP: High Voltage Parallel Programming (most non-HVSP classic parts)
+ PM_debugWIRE: Simpler alternative to JTAG (a subset of HVPP/HVSP parts)
+ PM_JTAG: some classic parts, some xmega
+ PM_aWire: AVR32 parts
- Add mcuid, a unique id in 0..2039, to part definition for urclock programmer
- Add n_interrupts, the number of interrupts, to part definition
- Add n_page_erase to part definition (# of pages erased during NVM erase)
- Implement a simple calculator in config_gram.y so numeric values can be
expressed as simple expressions such as PM_SPM | PM_UPDI
- Introduce a new method of assigning simple components to the grammar without
touching config_gram.y via an eligible-component list in config.c; numeric
expressions on the rhs of an assignment resolve to integer values
- Update documentation in avrdude.conf.in and avrdude.texi
2022-08-30 01:08:15 +00:00
|
|
|
TOKEN *new_hexnumber(const char *text);
|
2014-06-17 20:08:28 +00:00
|
|
|
|
Prepare for new components in avrdude.conf incl prog_modes
- Add prog_modes to part and programmer definitions; prog_mode is a bitwise
or of programming modes
+ PM_SPM: Bootloaders, self-programming with SPM/NVM Controllers
+ PM_TPI: t4, t5, t9, t10, t20, t40, t102, t104
+ PM_ISP: SPI programming for In-System Programming (typ classic parts)
+ PM_PDI: Program and Debug Interface (xmega parts)
+ PM_UPDI: Unified Program and Debug Interface
+ PM_HVSP: High Voltage Serial Programming (some classic parts)
+ PM_HVPP: High Voltage Parallel Programming (most non-HVSP classic parts)
+ PM_debugWIRE: Simpler alternative to JTAG (a subset of HVPP/HVSP parts)
+ PM_JTAG: some classic parts, some xmega
+ PM_aWire: AVR32 parts
- Add mcuid, a unique id in 0..2039, to part definition for urclock programmer
- Add n_interrupts, the number of interrupts, to part definition
- Add n_page_erase to part definition (# of pages erased during NVM erase)
- Implement a simple calculator in config_gram.y so numeric values can be
expressed as simple expressions such as PM_SPM | PM_UPDI
- Introduce a new method of assigning simple components to the grammar without
touching config_gram.y via an eligible-component list in config.c; numeric
expressions on the rhs of an assignment resolve to integer values
- Update documentation in avrdude.conf.in and avrdude.texi
2022-08-30 01:08:15 +00:00
|
|
|
TOKEN *new_constant(const char *text);
|
2014-06-17 20:08:28 +00:00
|
|
|
|
Prepare for new components in avrdude.conf incl prog_modes
- Add prog_modes to part and programmer definitions; prog_mode is a bitwise
or of programming modes
+ PM_SPM: Bootloaders, self-programming with SPM/NVM Controllers
+ PM_TPI: t4, t5, t9, t10, t20, t40, t102, t104
+ PM_ISP: SPI programming for In-System Programming (typ classic parts)
+ PM_PDI: Program and Debug Interface (xmega parts)
+ PM_UPDI: Unified Program and Debug Interface
+ PM_HVSP: High Voltage Serial Programming (some classic parts)
+ PM_HVPP: High Voltage Parallel Programming (most non-HVSP classic parts)
+ PM_debugWIRE: Simpler alternative to JTAG (a subset of HVPP/HVSP parts)
+ PM_JTAG: some classic parts, some xmega
+ PM_aWire: AVR32 parts
- Add mcuid, a unique id in 0..2039, to part definition for urclock programmer
- Add n_interrupts, the number of interrupts, to part definition
- Add n_page_erase to part definition (# of pages erased during NVM erase)
- Implement a simple calculator in config_gram.y so numeric values can be
expressed as simple expressions such as PM_SPM | PM_UPDI
- Introduce a new method of assigning simple components to the grammar without
touching config_gram.y via an eligible-component list in config.c; numeric
expressions on the rhs of an assignment resolve to integer values
- Update documentation in avrdude.conf.in and avrdude.texi
2022-08-30 01:08:15 +00:00
|
|
|
TOKEN *new_string(const char *text);
|
2014-06-17 20:08:28 +00:00
|
|
|
|
Prepare for new components in avrdude.conf incl prog_modes
- Add prog_modes to part and programmer definitions; prog_mode is a bitwise
or of programming modes
+ PM_SPM: Bootloaders, self-programming with SPM/NVM Controllers
+ PM_TPI: t4, t5, t9, t10, t20, t40, t102, t104
+ PM_ISP: SPI programming for In-System Programming (typ classic parts)
+ PM_PDI: Program and Debug Interface (xmega parts)
+ PM_UPDI: Unified Program and Debug Interface
+ PM_HVSP: High Voltage Serial Programming (some classic parts)
+ PM_HVPP: High Voltage Parallel Programming (most non-HVSP classic parts)
+ PM_debugWIRE: Simpler alternative to JTAG (a subset of HVPP/HVSP parts)
+ PM_JTAG: some classic parts, some xmega
+ PM_aWire: AVR32 parts
- Add mcuid, a unique id in 0..2039, to part definition for urclock programmer
- Add n_interrupts, the number of interrupts, to part definition
- Add n_page_erase to part definition (# of pages erased during NVM erase)
- Implement a simple calculator in config_gram.y so numeric values can be
expressed as simple expressions such as PM_SPM | PM_UPDI
- Introduce a new method of assigning simple components to the grammar without
touching config_gram.y via an eligible-component list in config.c; numeric
expressions on the rhs of an assignment resolve to integer values
- Update documentation in avrdude.conf.in and avrdude.texi
2022-08-30 01:08:15 +00:00
|
|
|
TOKEN *new_keyword(int primary);
|
2014-06-17 20:08:28 +00:00
|
|
|
|
2022-08-09 20:20:44 +00:00
|
|
|
void print_token(TOKEN *tkn);
|
2014-06-17 20:08:28 +00:00
|
|
|
|
|
|
|
void pyytext(void);
|
|
|
|
|
2022-08-11 23:28:54 +00:00
|
|
|
COMMENT *locate_comment(const LISTID comments, const char *where, int rhs);
|
|
|
|
|
|
|
|
void cfg_capture_prologue(void);
|
|
|
|
|
|
|
|
LISTID cfg_get_prologue(void);
|
|
|
|
|
|
|
|
void capture_comment_str(const char *com, int lineno);
|
|
|
|
|
|
|
|
void capture_lvalue_kw(const char *kw, int lineno);
|
|
|
|
|
|
|
|
LISTID cfg_move_comments(void);
|
|
|
|
|
|
|
|
void cfg_pop_comms(void);
|
2022-08-08 15:52:09 +00:00
|
|
|
|
Prepare for new components in avrdude.conf incl prog_modes
- Add prog_modes to part and programmer definitions; prog_mode is a bitwise
or of programming modes
+ PM_SPM: Bootloaders, self-programming with SPM/NVM Controllers
+ PM_TPI: t4, t5, t9, t10, t20, t40, t102, t104
+ PM_ISP: SPI programming for In-System Programming (typ classic parts)
+ PM_PDI: Program and Debug Interface (xmega parts)
+ PM_UPDI: Unified Program and Debug Interface
+ PM_HVSP: High Voltage Serial Programming (some classic parts)
+ PM_HVPP: High Voltage Parallel Programming (most non-HVSP classic parts)
+ PM_debugWIRE: Simpler alternative to JTAG (a subset of HVPP/HVSP parts)
+ PM_JTAG: some classic parts, some xmega
+ PM_aWire: AVR32 parts
- Add mcuid, a unique id in 0..2039, to part definition for urclock programmer
- Add n_interrupts, the number of interrupts, to part definition
- Add n_page_erase to part definition (# of pages erased during NVM erase)
- Implement a simple calculator in config_gram.y so numeric values can be
expressed as simple expressions such as PM_SPM | PM_UPDI
- Introduce a new method of assigning simple components to the grammar without
touching config_gram.y via an eligible-component list in config.c; numeric
expressions on the rhs of an assignment resolve to integer values
- Update documentation in avrdude.conf.in and avrdude.texi
2022-08-30 01:08:15 +00:00
|
|
|
Component_t *cfg_comp_search(const char *name, int strct);
|
|
|
|
|
|
|
|
const char *cfg_v_type(int type);
|
|
|
|
|
|
|
|
const char *cfg_strct_name(int strct);
|
|
|
|
|
|
|
|
void cfg_assign(char *sp, int strct, Component_t *cp, VALUE *v);
|
|
|
|
|
2022-08-30 18:48:17 +00:00
|
|
|
void cfg_update_mcuid(AVRPART *part);
|
Prepare for new components in avrdude.conf incl prog_modes
- Add prog_modes to part and programmer definitions; prog_mode is a bitwise
or of programming modes
+ PM_SPM: Bootloaders, self-programming with SPM/NVM Controllers
+ PM_TPI: t4, t5, t9, t10, t20, t40, t102, t104
+ PM_ISP: SPI programming for In-System Programming (typ classic parts)
+ PM_PDI: Program and Debug Interface (xmega parts)
+ PM_UPDI: Unified Program and Debug Interface
+ PM_HVSP: High Voltage Serial Programming (some classic parts)
+ PM_HVPP: High Voltage Parallel Programming (most non-HVSP classic parts)
+ PM_debugWIRE: Simpler alternative to JTAG (a subset of HVPP/HVSP parts)
+ PM_JTAG: some classic parts, some xmega
+ PM_aWire: AVR32 parts
- Add mcuid, a unique id in 0..2039, to part definition for urclock programmer
- Add n_interrupts, the number of interrupts, to part definition
- Add n_page_erase to part definition (# of pages erased during NVM erase)
- Implement a simple calculator in config_gram.y so numeric values can be
expressed as simple expressions such as PM_SPM | PM_UPDI
- Introduce a new method of assigning simple components to the grammar without
touching config_gram.y via an eligible-component list in config.c; numeric
expressions on the rhs of an assignment resolve to integer values
- Update documentation in avrdude.conf.in and avrdude.texi
2022-08-30 01:08:15 +00:00
|
|
|
|
2014-06-17 20:08:28 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|