cpuinfo.pas 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. {
  2. Copyright (c) 2008 by the Free Pascal development team
  3. Basic Processor information for the AVR
  4. See the file COPYING.FPC, included in this distribution,
  5. for details about the copyright.
  6. This program is distributed in the hope that it will be useful,
  7. but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  9. **********************************************************************}
  10. Unit CPUInfo;
  11. Interface
  12. uses
  13. globtype;
  14. Type
  15. bestreal = double;
  16. {$if FPC_FULLVERSION>20700}
  17. bestrealrec = TDoubleRec;
  18. {$endif FPC_FULLVERSION>20700}
  19. ts32real = single;
  20. ts64real = double;
  21. ts80real = type extended;
  22. ts128real = type extended;
  23. ts64comp = comp;
  24. pbestreal=^bestreal;
  25. { possible supported processors for this target }
  26. tcputype =
  27. (cpu_none,
  28. cpu_avr1,
  29. cpu_avr2,
  30. cpu_avr25,
  31. cpu_avr3,
  32. cpu_avr31,
  33. cpu_avr35,
  34. cpu_avr4,
  35. cpu_avr5,
  36. cpu_avr51,
  37. cpu_avr6
  38. );
  39. tfputype =
  40. (fpu_none,
  41. fpu_soft,
  42. fp_libgcc
  43. );
  44. tcontrollertype =
  45. (ct_none,
  46. ct_avrsim,
  47. ct_atmega8,
  48. ct_atmega16,
  49. ct_atmega32,
  50. ct_atmega48,
  51. ct_atmega64,
  52. ct_atmega128
  53. );
  54. Const
  55. { Is there support for dealing with multiple microcontrollers available }
  56. { for this platform? }
  57. ControllerSupport = true;
  58. {# Size of native extended floating point type }
  59. extended_size = 12;
  60. {# Size of a multimedia register }
  61. mmreg_size = 16;
  62. { target cpu string (used by compiler options) }
  63. target_cpu_string = 'avr';
  64. { calling conventions supported by the code generator }
  65. supported_calling_conventions : tproccalloptions = [
  66. pocall_internproc,
  67. pocall_safecall,
  68. pocall_stdcall,
  69. { same as stdcall only different name mangling }
  70. pocall_cdecl,
  71. { same as stdcall only different name mangling }
  72. pocall_cppdecl,
  73. { same as stdcall but floating point numbers are handled like equal sized integers }
  74. pocall_softfloat
  75. ];
  76. cputypestr : array[tcputype] of string[5] = ('',
  77. 'AVR1',
  78. 'AVR2',
  79. 'AVR25',
  80. 'AVR3',
  81. 'AVR31',
  82. 'AVR35',
  83. 'AVR4',
  84. 'AVR5',
  85. 'AVR51',
  86. 'AVR6'
  87. );
  88. fputypestr : array[tfputype] of string[6] = (
  89. 'NONE',
  90. 'SOFT',
  91. 'LIBGCC'
  92. );
  93. { We know that there are fields after sramsize
  94. but we don't care about this warning }
  95. {$WARN 3177 OFF}
  96. embedded_controllers : array [tcontrollertype] of tcontrollerdatatype =
  97. ((
  98. controllertypestr:'';
  99. controllerunitstr:'';
  100. flashbase:0;
  101. flashsize:0;
  102. srambase:0;
  103. sramsize:0;
  104. eeprombase:0;
  105. eepromsize:0
  106. ),
  107. (
  108. controllertypestr:'AVRSIM';
  109. controllerunitstr:'AVRSIM';
  110. flashbase:0;
  111. flashsize:$20000;
  112. srambase:0;
  113. sramsize:4096;
  114. eeprombase:0;
  115. eepromsize:4096;
  116. ),
  117. (
  118. controllertypestr:'ATMEGA8';
  119. controllerunitstr:'ATMEGA8';
  120. flashbase:0;
  121. flashsize:$2000;
  122. srambase:0;
  123. sramsize:1024;
  124. eeprombase:0;
  125. eepromsize:512
  126. ),
  127. (
  128. controllertypestr:'ATMEGA16';
  129. controllerunitstr:'ATMEGA16';
  130. flashbase:0;
  131. flashsize:$4000;
  132. srambase:0;
  133. sramsize:1024;
  134. eeprombase:0;
  135. eepromsize:512
  136. ),
  137. (
  138. controllertypestr:'ATMEGA32';
  139. controllerunitstr:'ATMEGA32';
  140. flashbase:0;
  141. flashsize:$8000;
  142. srambase:0;
  143. sramsize:1024;
  144. eeprombase:0;
  145. eepromsize:512
  146. ),
  147. (
  148. controllertypestr:'ATMEGA48';
  149. controllerunitstr:'ATMEGA48';
  150. flashbase:0;
  151. flashsize:$1000;
  152. srambase:0;
  153. sramsize:512;
  154. eeprombase:0;
  155. eepromsize:256;
  156. ),
  157. (
  158. controllertypestr:'ATMEGA64';
  159. controllerunitstr:'ATMEGA64';
  160. flashbase:0;
  161. flashsize:$10000;
  162. srambase:0;
  163. sramsize:4096;
  164. eeprombase:0;
  165. eepromsize:2048;
  166. ),
  167. (
  168. controllertypestr:'ATMEGA128';
  169. controllerunitstr:'ATMEGA128';
  170. flashbase:0;
  171. flashsize:$20000;
  172. srambase:0;
  173. sramsize:4096;
  174. eeprombase:0;
  175. eepromsize:4096;
  176. )
  177. );
  178. { Supported optimizations, only used for information }
  179. supported_optimizerswitches = genericlevel1optimizerswitches+
  180. genericlevel2optimizerswitches+
  181. genericlevel3optimizerswitches-
  182. { no need to write info about those }
  183. [cs_opt_level1,cs_opt_level2,cs_opt_level3]+
  184. [cs_opt_regvar,cs_opt_loopunroll,cs_opt_tailrecursion,
  185. cs_opt_stackframe,cs_opt_nodecse,cs_opt_reorder_fields,cs_opt_fastmath];
  186. level1optimizerswitches = genericlevel1optimizerswitches;
  187. level2optimizerswitches = genericlevel2optimizerswitches + level1optimizerswitches +
  188. [cs_opt_regvar,cs_opt_stackframe,cs_opt_tailrecursion];
  189. level3optimizerswitches = genericlevel3optimizerswitches + level2optimizerswitches + [{,cs_opt_loopunroll}];
  190. level4optimizerswitches = genericlevel4optimizerswitches + level3optimizerswitches + [];
  191. type
  192. tcpuflags =
  193. (CPUAVR_HAS_JMP_CALL,
  194. CPUAVR_HAS_MOVW,
  195. CPUAVR_HAS_LPMX,
  196. CPUAVR_HAS_MUL,
  197. CPUAVR_HAS_RAMPZ,
  198. CPUAVR_HAS_ELPM,
  199. CPUAVR_HAS_ELPMX,
  200. CPUAVR_2_BYTE_PC,
  201. CPUAVR_3_BYTE_PC
  202. );
  203. const
  204. cpu_capabilities : array[tcputype] of set of tcpuflags =
  205. ( { cpu_none } [],
  206. { cpu_avr1 } [CPUAVR_2_BYTE_PC],
  207. { cpu_avr2 } [CPUAVR_2_BYTE_PC],
  208. { cpu_avr25 } [CPUAVR_HAS_MOVW,CPUAVR_HAS_LPMX,CPUAVR_2_BYTE_PC],
  209. { cpu_avr3 } [CPUAVR_HAS_JMP_CALL,CPUAVR_2_BYTE_PC],
  210. { cpu_avr31 } [CPUAVR_HAS_JMP_CALL,CPUAVR_HAS_RAMPZ,CPUAVR_HAS_ELPM,CPUAVR_2_BYTE_PC],
  211. { cpu_avr35 } [CPUAVR_HAS_JMP_CALL,CPUAVR_HAS_MOVW,CPUAVR_HAS_LPMX,CPUAVR_2_BYTE_PC],
  212. { cpu_avr4 } [CPUAVR_HAS_MOVW,CPUAVR_HAS_LPMX,CPUAVR_HAS_MUL,CPUAVR_2_BYTE_PC],
  213. { cpu_avr5 } [CPUAVR_HAS_JMP_CALL,CPUAVR_HAS_MOVW,CPUAVR_HAS_LPMX,CPUAVR_HAS_MUL,CPUAVR_2_BYTE_PC],
  214. { cpu_avr51 } [CPUAVR_HAS_JMP_CALL,CPUAVR_HAS_MOVW,CPUAVR_HAS_LPMX,CPUAVR_HAS_MUL,CPUAVR_HAS_RAMPZ,CPUAVR_HAS_ELPM,CPUAVR_HAS_ELPMX,CPUAVR_2_BYTE_PC],
  215. { cpu_avr6 } [CPUAVR_HAS_JMP_CALL,CPUAVR_HAS_MOVW,CPUAVR_HAS_LPMX,CPUAVR_HAS_MUL,CPUAVR_HAS_RAMPZ,CPUAVR_HAS_ELPM,CPUAVR_HAS_ELPMX,CPUAVR_3_BYTE_PC]
  216. );
  217. Implementation
  218. end.