Debian Codegraph @

gcc/config/avr/avr-arch.h

raw
1 /* Device information for AVR 8-bit microcontrollers.
2 Copyright (C) 2012-2025 Free Software Foundation, Inc.
3 Contributed by Georg-Johann Lay ([email protected])
4
5 This file is part of GCC.
6
7 GCC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3, or (at your option)
10 any later version.
11
12 GCC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
20
21 #ifndef AVR_ARCH_H
22 #define AVR_ARCH_H
23
24 #define AVR_MMCU_DEFAULT "avr2"
25
26 /* This enum supplies indices into the avr_arch_types[] table below. */
27
28 enum avr_arch_id
29 {
30 ARCH_UNKNOWN,
31 ARCH_AVR1,
32 ARCH_AVR2,
33 ARCH_AVR25,
34 ARCH_AVR3,
35 ARCH_AVR31,
36 ARCH_AVR35,
37 ARCH_AVR4,
38 ARCH_AVR5,
39 ARCH_AVR51,
40 ARCH_AVR6,
41 ARCH_AVRTINY,
42 ARCH_AVRXMEGA2,
43 ARCH_AVRXMEGA3,
44 ARCH_AVRXMEGA4,
45 ARCH_AVRXMEGA5,
46 ARCH_AVRXMEGA6,
47 ARCH_AVRXMEGA7
48 };
49
50
51 /* Architecture-specific properties. */
52
53 typedef struct
54 {
55 /* Assembler only. */
56 int asm_only;
57
58 /* Core have 'MUL*' instructions. */
59 int have_mul;
60
61 /* Core have 'CALL' and 'JMP' instructions. */
62 int have_jmp_call;
63
64 /* Core have 'MOVW' and 'LPM Rx,Z' instructions. */
65 int have_movw_lpmx;
66
67 /* Core have 'ELPM' instructions. */
68 int have_elpm;
69
70 /* Core have 'ELPM Rx,Z' instructions. */
71 int have_elpmx;
72
73 /* Core have 'EICALL' and 'EIJMP' instructions. */
74 int have_eijmp_eicall;
75
76 /* This is an XMEGA core. */
77 int xmega_p;
78
79 /* This core has the RAMPD special function register
80 and thus also the RAMPX, RAMPY and RAMPZ registers. */
81 int have_rampd;
82
83 /* This is a TINY core. */
84 int tiny_p;
85
86 /* Default start of data section address for architecture. */
87 int default_data_section_start;
88
89 /* Offset where flash memory is seen in RAM address range or 0. */
90 int flash_pm_offset;
91
92 /* Offset between SFR address and RAM address:
93 SFR-address = RAM-address - sfr_offset */
94 int sfr_offset;
95
96 /* Architecture id to built-in define __AVR_ARCH__ (NULL -> no macro) */
97 const char *const macro;
98
99 /* Architecture name. */
100 const char *const name;
101 } avr_arch_t;
102
103
104 /* Device-specific properties. */
105
106 typedef struct
107 {
108 /* Device name. */
109 const char *const name;
110
111 /* Index in avr_arch_types[]. */
112 enum avr_arch_id arch_id;
113
114 /* device specific feature */
115 int dev_attribute;
116
117 /* Must lie outside user's namespace. NULL == no macro. */
118 const char *const macro;
119
120 /* Start of data section. */
121 int data_section_start;
122
123 /* Start of text section. */
124 int text_section_start;
125
126 /* Flash size in bytes. */
127 int flash_size;
128
129 /* Offset where flash is seen in the RAM address space. */
130 int flash_pm_offset;
131 } avr_mcu_t;
132
133 /* AVR device specific features.
134
135 AVR_ISA_RMW
136 Only few avr devices have Read-Modify-Write (RMW) instructions
137 (XCH, LAC, LAS and LAT)
138
139 AVR_SHORT_SP
140 Stack Pointer has only 8 bit width.
141 The device / multilib has an 8-bit stack pointer (no SPH).
142
143 AVR_ERRATA_SKIP
144 Some AVR devices have a core erratum when skipping a 2-word instruction.
145 Skip instructions are: SBRC, SBRS, SBIC, SBIS, CPSE.
146 Problems will occur with return address is IRQ executes during the
147 skip sequence.
148
149 A support ticket from Atmel returned the following information:
150
151 Subject: (ATTicket:644469) On AVR skip-bug core Erratum
152 From: [email protected] Date: 2011-07-27
153 (Please keep the subject when replying to this mail)
154
155 This errata exists only in AT90S8515 and ATmega103 devices.
156
157 For information please refer the following respective errata links
158 http://www.atmel.com/dyn/resources/prod_documents/doc2494.pdf
159 http://www.atmel.com/dyn/resources/prod_documents/doc1436.pdf
160
161 AVR_CVT
162 The device supports a CVT (Compact Vector Table) which can be selected
163 with -mcvt, which links startup-code crt<mcu>-cvt.o instead of the
164 usual crt<mcu>.o. This assumes that AVR-LibC implements Issue #1010.
165 https://github.com/avrdudes/avr-libc/issues/1010
166 crt<mcu>-cvt.o also pulls in __do_cvt_init from lib<mcu>.a which sets
167 bit CPUINT_CTRLA.CPUINT_CVT in order to activate the CVT.
168
169 AVR_ISA_RCALL
170 Always use RJMP / RCALL and assume JMP / CALL are not available.
171 This affects multilib selection via specs generation and -mshort-calls.
172 Even if a device like ATtiny417 from avrxmega3 supports JMP / CALL, we
173 assume these instructions are not available and we set the built-in
174 macro __AVR_HAVE_JMP_CALL__ accordingly. This macro is used to
175 determine a rough estimate of flash size in libgcc, and AVR-LibC uses
176 this macro to determine vector sizes.
177
178 AVR_ISA_FLMAP
179 The device has the NVMCTRL_CTRLB.FLMAP bitfield. The value of FLMAP
180 determines which 32 KiB segment of the program memory (flash) is visible
181 in the RAM address space at 0x8000.
182
183 If Binutils support emulations avrxmega2_flmap resp. avrxmega4_flmap
184 (PR31124), then the location of the .rodata section can be determined
185 by means of option -m[no-]rodata-in-ram. If .rodata is located in flash,
186 the user can chose which 32 KiB flash block is visible in RAM space by
187 means of defining symbol __flmap.
188
189 The startup code from AVR-LibC initializes FLMAP according to __flmap
190 provided one of the avrxmega*_flmap emulations is used. If avrxmega2/4
191 is used, then the startup code does not initialize FLMAP.
192
193 __AVR_HAVE_FLMAP__ is a macro defined in device-specs and supposed to be
194 consumed by code that sets FLMAP, like the startup code for example.
195 The macro is defined when all of the following conditions are met:
196 * The device is AVR_ISA_FLMAP.
197 * It's not known at compile time / assembler time whether or not .rodata
198 will be located in flash or in RAM. This implies Binutils PR31124.
199 * The definition of the macro is independent of -m[no-]rodata-in-ram.
200
201 AVR_ISA_FLMAP does not affect multilib layout or selection in any way.
202
203 For details on which symbols are defined in which way depending on the
204 emulation, see <Binutils>/ld/scripttempl/avr.sc. */
205
206 enum avr_device_specific_features
207 {
208 AVR_ISA_NONE,
209 AVR_CVT = 0x1, /* Device supports a "Compact Vector Table" (-mcvt)
210 as configured in field CPUINT_CTRLA.CPUINT_CVT. */
211 AVR_SHORT_SP = 0x2, /* Stack Pointer has 8 bits width. */
212 AVR_ERRATA_SKIP = 0x4, /* Device has a core erratum. */
213 AVR_ISA_RMW = 0x8, /* Device has RMW instructions. */
214 AVR_ISA_LDS = 0x10, /* Whether LDS / STS is valid for all data in static
215 storage. Only useful for reduced Tiny. */
216 AVR_ISA_RCALL = 0x20, /* Use RJMP / RCALL even though JMP / CALL
217 are available (-mshort-calls). */
218 AVR_ISA_FLMAP = 0x40 /* Has NVMCTRL_CTRLB.FLMAP to select which 32 KiB
219 block of program memory is visible in the RAM
220 address space. */
221 };
222
223 /* Map architecture to its texinfo string. */
224
225 typedef struct
226 {
227 /* Architecture ID. */
228 enum avr_arch_id arch_id;
229
230 /* textinfo source to describe the architecture. */
231 const char *texinfo;
232 } avr_arch_info_t;
233
234 /* Preprocessor macros to define depending on MCU type. */
235
236 extern const avr_arch_t avr_arch_types[];
237 extern const avr_arch_t *avr_arch;
238 extern const avr_arch_t *avr_get_parch (const char *mcu);
239
240 extern const avr_mcu_t avr_mcu_types[];
241
242 extern void avr_inform_core_architectures (void);
243
244 #endif /* AVR_ARCH_H */