cpuinfo.pas 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  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_atmega16,
  47. ct_atmega32,
  48. ct_atmega48,
  49. ct_atmega64,
  50. ct_atmega128
  51. );
  52. Const
  53. { Is there support for dealing with multiple microcontrollers available }
  54. { for this platform? }
  55. ControllerSupport = true;
  56. {# Size of native extended floating point type }
  57. extended_size = 12;
  58. {# Size of a multimedia register }
  59. mmreg_size = 16;
  60. { target cpu string (used by compiler options) }
  61. target_cpu_string = 'avr';
  62. { calling conventions supported by the code generator }
  63. supported_calling_conventions : tproccalloptions = [
  64. pocall_internproc,
  65. pocall_safecall,
  66. pocall_stdcall,
  67. { same as stdcall only different name mangling }
  68. pocall_cdecl,
  69. { same as stdcall only different name mangling }
  70. pocall_cppdecl,
  71. { same as stdcall but floating point numbers are handled like equal sized integers }
  72. pocall_softfloat
  73. ];
  74. cputypestr : array[tcputype] of string[5] = ('',
  75. 'AVR1',
  76. 'AVR2',
  77. 'AVR25',
  78. 'AVR3',
  79. 'AVR31',
  80. 'AVR35',
  81. 'AVR4',
  82. 'AVR5',
  83. 'AVR51',
  84. 'AVR6'
  85. );
  86. fputypestr : array[tfputype] of string[6] = (
  87. 'NONE',
  88. 'SOFT',
  89. 'LIBGCC'
  90. );
  91. { We know that there are fields after sramsize
  92. but we don't care about this warning }
  93. {$WARN 3177 OFF}
  94. embedded_controllers : array [tcontrollertype] of tcontrollerdatatype =
  95. ((
  96. controllertypestr:'';
  97. controllerunitstr:'';
  98. flashbase:0;
  99. flashsize:0;
  100. srambase:0;
  101. sramsize:0;
  102. eeprombase:0;
  103. eepromsize:0
  104. ),
  105. (
  106. controllertypestr:'ATMEGA16';
  107. controllerunitstr:'ATMEGA16';
  108. flashbase:0;
  109. flashsize:$4000;
  110. srambase:0;
  111. sramsize:1024;
  112. eeprombase:0;
  113. eepromsize:512
  114. ),
  115. (
  116. controllertypestr:'ATMEGA32';
  117. controllerunitstr:'ATMEGA32';
  118. flashbase:0;
  119. flashsize:$8000;
  120. srambase:0;
  121. sramsize:1024;
  122. eeprombase:0;
  123. eepromsize:512
  124. ),
  125. (
  126. controllertypestr:'ATMEGA48';
  127. controllerunitstr:'ATMEGA48';
  128. flashbase:0;
  129. flashsize:$1000;
  130. srambase:0;
  131. sramsize:512;
  132. eeprombase:0;
  133. eepromsize:256;
  134. ),
  135. (
  136. controllertypestr:'ATMEGA64';
  137. controllerunitstr:'ATMEGA64';
  138. flashbase:0;
  139. flashsize:$10000;
  140. srambase:0;
  141. sramsize:4096;
  142. eeprombase:0;
  143. eepromsize:2048;
  144. ),
  145. (
  146. controllertypestr:'ATMEGA128';
  147. controllerunitstr:'ATMEGA128';
  148. flashbase:0;
  149. flashsize:$20000;
  150. srambase:0;
  151. sramsize:4096;
  152. eeprombase:0;
  153. eepromsize:4096;
  154. )
  155. );
  156. { Supported optimizations, only used for information }
  157. supported_optimizerswitches = genericlevel1optimizerswitches+
  158. genericlevel2optimizerswitches+
  159. genericlevel3optimizerswitches-
  160. { no need to write info about those }
  161. [cs_opt_level1,cs_opt_level2,cs_opt_level3]+
  162. [cs_opt_regvar,cs_opt_loopunroll,cs_opt_tailrecursion,
  163. cs_opt_stackframe,cs_opt_nodecse,cs_opt_reorder_fields,cs_opt_fastmath];
  164. level1optimizerswitches = genericlevel1optimizerswitches;
  165. level2optimizerswitches = genericlevel2optimizerswitches + level1optimizerswitches +
  166. [cs_opt_regvar,cs_opt_stackframe,cs_opt_tailrecursion];
  167. level3optimizerswitches = genericlevel3optimizerswitches + level2optimizerswitches + [{,cs_opt_loopunroll}];
  168. level4optimizerswitches = genericlevel4optimizerswitches + level3optimizerswitches + [];
  169. type
  170. tcpuflags =
  171. (CPUAVR_HAS_JMP_CALL,
  172. CPUAVR_HAS_MOVW,
  173. CPUAVR_HAS_LPMX,
  174. CPUAVR_HAS_MUL,
  175. CPUAVR_HAS_RAMPZ,
  176. CPUAVR_HAS_ELPM,
  177. CPUAVR_HAS_ELPMX,
  178. CPUAVR_2_BYTE_PC,
  179. CPUAVR_3_BYTE_PC
  180. );
  181. const
  182. cpu_capabilities : array[tcputype] of set of tcpuflags =
  183. ( { cpu_none } [],
  184. { cpu_avr1 } [CPUAVR_2_BYTE_PC],
  185. { cpu_avr2 } [CPUAVR_2_BYTE_PC],
  186. { cpu_avr25 } [CPUAVR_HAS_MOVW,CPUAVR_HAS_LPMX,CPUAVR_2_BYTE_PC],
  187. { cpu_avr3 } [CPUAVR_HAS_JMP_CALL,CPUAVR_2_BYTE_PC],
  188. { cpu_avr31 } [CPUAVR_HAS_JMP_CALL,CPUAVR_HAS_RAMPZ,CPUAVR_HAS_ELPM,CPUAVR_2_BYTE_PC],
  189. { cpu_avr35 } [CPUAVR_HAS_JMP_CALL,CPUAVR_HAS_MOVW,CPUAVR_HAS_LPMX,CPUAVR_2_BYTE_PC],
  190. { cpu_avr4 } [CPUAVR_HAS_MOVW,CPUAVR_HAS_LPMX,CPUAVR_HAS_MUL,CPUAVR_2_BYTE_PC],
  191. { cpu_avr5 } [CPUAVR_HAS_JMP_CALL,CPUAVR_HAS_MOVW,CPUAVR_HAS_LPMX,CPUAVR_HAS_MUL,CPUAVR_2_BYTE_PC],
  192. { 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],
  193. { 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]
  194. );
  195. Implementation
  196. end.