avr-arch.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. /* Definitions of types that are used to store AVR architecture and
  2. device information.
  3. Copyright (C) 2012-2015 Free Software Foundation, Inc.
  4. Contributed by Georg-Johann Lay (avr@gjlay.de)
  5. This file is part of GCC.
  6. GCC is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 3, or (at your option)
  9. any later version.
  10. GCC is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with GCC; see the file COPYING3. If not see
  16. <http://www.gnu.org/licenses/>. */
  17. #ifndef AVR_ARCH_H
  18. #define AVR_ARCH_H
  19. #define AVR_MMCU_DEFAULT "avr2"
  20. /* This enum supplies indices into the avr_arch_types[] table below. */
  21. enum avr_arch_id
  22. {
  23. ARCH_UNKNOWN,
  24. ARCH_AVR1,
  25. ARCH_AVR2,
  26. ARCH_AVR25,
  27. ARCH_AVR3,
  28. ARCH_AVR31,
  29. ARCH_AVR35,
  30. ARCH_AVR4,
  31. ARCH_AVR5,
  32. ARCH_AVR51,
  33. ARCH_AVR6,
  34. ARCH_AVRTINY,
  35. ARCH_AVRXMEGA2,
  36. ARCH_AVRXMEGA4,
  37. ARCH_AVRXMEGA5,
  38. ARCH_AVRXMEGA6,
  39. ARCH_AVRXMEGA7
  40. };
  41. /* Architecture-specific properties. */
  42. typedef struct
  43. {
  44. /* Assembler only. */
  45. int asm_only;
  46. /* Core have 'MUL*' instructions. */
  47. int have_mul;
  48. /* Core have 'CALL' and 'JMP' instructions. */
  49. int have_jmp_call;
  50. /* Core have 'MOVW' and 'LPM Rx,Z' instructions. */
  51. int have_movw_lpmx;
  52. /* Core have 'ELPM' instructions. */
  53. int have_elpm;
  54. /* Core have 'ELPM Rx,Z' instructions. */
  55. int have_elpmx;
  56. /* Core have 'EICALL' and 'EIJMP' instructions. */
  57. int have_eijmp_eicall;
  58. /* This is an XMEGA core. */
  59. int xmega_p;
  60. /* This core has the RAMPD special function register
  61. and thus also the RAMPX, RAMPY and RAMPZ registers. */
  62. int have_rampd;
  63. /* This is a TINY core. */
  64. int tiny_p;
  65. /* Default start of data section address for architecture. */
  66. int default_data_section_start;
  67. /* Offset between SFR address and RAM address:
  68. SFR-address = RAM-address - sfr_offset */
  69. int sfr_offset;
  70. /* Architecture id to built-in define __AVR_ARCH__ (NULL -> no macro) */
  71. const char *const macro;
  72. /* Architecture name. */
  73. const char *const name;
  74. } avr_arch_t;
  75. /* Device-specific properties. */
  76. typedef struct
  77. {
  78. /* Device name. */
  79. const char *const name;
  80. /* Index in avr_arch_types[]. */
  81. enum avr_arch_id arch_id;
  82. /* device specific feature */
  83. int dev_attribute;
  84. /* Must lie outside user's namespace. NULL == no macro. */
  85. const char *const macro;
  86. /* Start of data section. */
  87. int data_section_start;
  88. /* Start of text section. */
  89. int text_section_start;
  90. /* Number of 64k segments in the flash. */
  91. int n_flash;
  92. } avr_mcu_t;
  93. /* AVR device specific features.
  94. AVR_ISA_RMW
  95. Only few avr devices have Read-Modify-Write (RMW) instructions
  96. (XCH, LAC, LAS and LAT)
  97. AVR_SHORT_SP
  98. Stack Pointer has only 8 bit width.
  99. The device / multilib has an 8-bit stack pointer (no SPH).
  100. AVR_ERRATA_SKIP
  101. Some AVR devices have a core erratum when skipping a 2-word instruction.
  102. Skip instructions are: SBRC, SBRS, SBIC, SBIS, CPSE.
  103. Problems will occur with return address is IRQ executes during the
  104. skip sequence.
  105. A support ticket from Atmel returned the following information:
  106. Subject: (ATTicket:644469) On AVR skip-bug core Erratum
  107. From: avr@atmel.com Date: 2011-07-27
  108. (Please keep the subject when replying to this mail)
  109. This errata exists only in AT90S8515 and ATmega103 devices.
  110. For information please refer the following respective errata links
  111. http://www.atmel.com/dyn/resources/prod_documents/doc2494.pdf
  112. http://www.atmel.com/dyn/resources/prod_documents/doc1436.pdf */
  113. enum avr_device_specific_features
  114. {
  115. AVR_ISA_NONE,
  116. AVR_ISA_RMW = 0x1, /* device has RMW instructions. */
  117. AVR_SHORT_SP = 0x2, /* Stack Pointer has 8 bits width. */
  118. AVR_ERRATA_SKIP = 0x4 /* device has a core erratum. */
  119. };
  120. /* Map architecture to its texinfo string. */
  121. typedef struct
  122. {
  123. /* Architecture ID. */
  124. enum avr_arch_id arch_id;
  125. /* textinfo source to describe the archtiecture. */
  126. const char *texinfo;
  127. } avr_arch_info_t;
  128. /* Preprocessor macros to define depending on MCU type. */
  129. extern const avr_arch_t avr_arch_types[];
  130. extern const avr_arch_t *avr_arch;
  131. extern const avr_mcu_t avr_mcu_types[];
  132. extern void avr_inform_devices (void);
  133. extern void avr_inform_core_architectures (void);
  134. #endif /* AVR_ARCH_H */