1 /* FreeEMS - the open source engine management system
3 * Copyright 2008-2012 Fred Cooke
5 * This file is part of the FreeEMS project.
7 * FreeEMS software 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 of the License, or
10 * (at your option) any later version.
12 * FreeEMS software 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.
17 * You should have received a copy of the GNU General Public License
18 * along with any FreeEMS software. If not, see http://www.gnu.org/licenses/
20 * We ask that if you make any changes to this file you email them upstream to
21 * us at admin(at)diyefi(dot)org or, even better, fork the code on github.com!
23 * Thank you for choosing FreeEMS to run your engine!
30 * @ingroup globalHeaders
32 * @brief Memory usage directives
34 * This file is solely for the definition of compiler memory usage directives.
35 * Each one is just a short form of the larger statements DFAR and FFAR found
36 * near the top of this file.
40 /* Header file multiple inclusion protection courtesy eclipse Header Template */
41 /* and http://gcc.gnu.org/onlinedocs/gcc-3.1.1/cpp/ C pre processor manual */
42 #ifndef FILE_MEMORY_H_SEEN
43 #define FILE_MEMORY_H_SEEN
46 #define flashSectorSize 1024
47 #define flashSectorSizeInWords 512 /* 512 words to a 1k flash sector */
50 /* Valid RPAGE values :
60 /* The reset value of RPAGE is 0xFD */
61 /* The other 8k of linear RAM space is accessible */
62 /* through the RPAGE window with 0xFE and 0xFF */
63 /* 0xFE refers to the 0x2000 to 0x3000 region */
64 /* 0xFF refers to the 0x3000 to 0x4000 region */
65 #define RPAGE_TUNE_ONE 0xF8
66 #define RPAGE_TUNE_TWO 0xF9
67 #define RPAGE_FUEL_ONE 0xFA
68 #define RPAGE_FUEL_TWO 0xFB
69 #define RPAGE_TIME_ONE 0xFC
70 #define RPAGE_TIME_TWO 0xFD
71 #define RPAGE_LINEAR 0xFD
72 #define RPAGE_MIN 0xF8
73 #define PPAGE_MIN 0xE0
74 #define EPAGE_MIN 0x?? // TODO
77 /* http://gcc.gnu.org/onlinedocs/gcc-4.0.0/gcc/Variable-Attributes.html */
80 //#define EEPROM __attribute__ ((section (".eeprom")))
81 /* EEPROM would appear to not be loadable by hcs12mem */
82 /* Furthermore it isn't really needed except in code anyway */
84 /* RAM divided up into special purpose blocks */
85 #define RWINDOW __attribute__ ((section (".rpage"))) /* ~4k paged RAM window */
86 #define RXBUF __attribute__ ((section (".rxbuf"))) /* ~2k block of RAM for receive buffer */
87 #define TXBUF __attribute__ ((section (".txbuf"))) /* ~2k block of RAM for transmit buffer */
88 // 4k of RAM for general variable and stack use, need to put some aside for xgate!!
90 /* Direct flash blocks */
91 #define FIXEDCONF1 __attribute__ ((section (".fixedconf1"))) /* 1k unpaged block, primary static configuration. */
92 #define FIXEDCONF2 __attribute__ ((section (".fixedconf2"))) /* 1k unpaged block, secondary static configuration. */
93 #define TEXT1 __attribute__ ((section (".text1"))) /* 14k unpaged block, must be explicitly used. */
94 #define TEXT __attribute__ ((section (".text"))) /* 14k unpaged block, code defaults to being stored here. */
95 /*define SERMON __attribute__ ((section (".sermon"))) 2k unpaged block, occupied by AN2548 serial monitor. */
98 /* far shortcut for data */
99 #define DFAR(label) __attribute__ ((section (label)))
100 /* far shortcut for functions */
101 #define FFAR(label) __attribute__ ((far)) __attribute__ ((section (label)))
104 /* Paged flash blocks for functions */
105 #define FPPAGE_E0X FFAR(".ppageE0X")
106 #define FPPAGE_E0S FFAR(".ppageE0S")
107 #define FPPAGE_E1 FFAR(".ppageE1")
108 #define FPPAGE_E2 FFAR(".ppageE2")
109 #define FPPAGE_E3 FFAR(".ppageE3")
110 #define FPPAGE_E4 FFAR(".ppageE4")
111 #define FPPAGE_E5 FFAR(".ppageE5")
112 #define FPPAGE_E6 FFAR(".ppageE6")
113 #define FPPAGE_E7 FFAR(".ppageE7")
114 #define FPPAGE_E8 FFAR(".ppageE8")
115 #define FPPAGE_E9 FFAR(".ppageE9")
116 #define FPPAGE_EA FFAR(".ppageEA")
117 #define FPPAGE_EB FFAR(".ppageEB")
118 #define FPPAGE_EC FFAR(".ppageEC")
119 #define FPPAGE_ED FFAR(".ppageED")
120 #define FPPAGE_EE FFAR(".ppageEE")
121 #define FPPAGE_EF FFAR(".ppageEF")
122 #define FPPAGE_F0 FFAR(".ppageF0")
123 #define FPPAGE_F1 FFAR(".ppageF1")
124 #define FPPAGE_F2 FFAR(".ppageF2")
125 #define FPPAGE_F3 FFAR(".ppageF3")
126 #define FPPAGE_F4 FFAR(".ppageF4")
127 #define FPPAGE_F5 FFAR(".ppageF5")
128 #define FPPAGE_F6 FFAR(".ppageF6")
129 #define FPPAGE_F7 FFAR(".ppageF7")
131 /* Paged flash blocks for data */
132 #define PPAGE_E0S DFAR(".ppageE0S")
133 #define PPAGE_E0X DFAR(".ppageE0X")
134 #define PPAGE_E1 DFAR(".ppageE1")
135 #define PPAGE_E2 DFAR(".ppageE2")
136 #define PPAGE_E3 DFAR(".ppageE3")
137 #define PPAGE_E4 DFAR(".ppageE4")
138 #define PPAGE_E5 DFAR(".ppageE5")
139 #define PPAGE_E6 DFAR(".ppageE6")
140 #define PPAGE_E7 DFAR(".ppageE7")
141 #define PPAGE_E8 DFAR(".ppageE8")
142 #define PPAGE_E9 DFAR(".ppageE9")
143 #define PPAGE_EA DFAR(".ppageEA")
144 #define PPAGE_EB DFAR(".ppageEB")
145 #define PPAGE_EC DFAR(".ppageEC")
146 #define PPAGE_ED DFAR(".ppageED")
147 #define PPAGE_EE DFAR(".ppageEE")
148 #define PPAGE_EF DFAR(".ppageEF")
149 #define PPAGE_F0 DFAR(".ppageF0")
150 #define PPAGE_F1 DFAR(".ppageF1")
151 #define PPAGE_F2 DFAR(".ppageF2")
152 #define PPAGE_F3 DFAR(".ppageF3")
153 #define PPAGE_F4 DFAR(".ppageF4")
154 #define PPAGE_F5 DFAR(".ppageF5")
155 #define PPAGE_F6 DFAR(".ppageF6")
156 #define PPAGE_F7 DFAR(".ppageF7")
158 /* ONLY use the pages below this line for now (Or you won't be able to load them...) */
160 /* General Purpose Page with PPAGE = 0xF8 */
161 #define FPAGE_F8 FFAR(".fpageF8")
162 #define DPAGE_F8 DFAR(".dpageF8")
163 #define PAGE_F8_PPAGE 0xF8
165 /* Function and large lookup tables for ADC to value mapping */
166 #define LOOKUPF FFAR(".fpageF9")
167 #define LOOKUPD DFAR(".dpageF9")
168 #define LOOKUP_PPAGE 0xF9
170 /* Fuel tables and the function for copying it up to RAM */
171 #define FUELTABLESF FFAR(".fpageFA")
172 #define FUELTABLESD DFAR(".dpageFA")
173 #define FUELTABLES_PPAGE 0xFA
175 /* Tunable tables etc and the function for copying them up to RAM */
176 #define TUNETABLESF FFAR(".fpageFB")
177 #define TUNETABLESD1 DFAR(".dpageFB1")
178 #define TUNETABLESD2 DFAR(".dpageFB2")
179 #define TUNETABLESD3 DFAR(".dpageFB3")
180 #define TUNETABLESD4 DFAR(".dpageFB4")
181 #define TUNETABLESD5 DFAR(".dpageFB5")
182 #define TUNETABLESD6 DFAR(".dpageFB6")
183 #define TUNETABLESD7 DFAR(".dpageFB7")
184 #define TUNETABLESD8 DFAR(".dpageFB8")
185 #define TUNETABLES_PPAGE 0xFB
187 /* Timing tables and the function for copying them up to RAM */
188 #define TIMETABLESF FFAR(".fpageFC")
189 #define TIMETABLESD DFAR(".dpageFC")
190 #define TIMETABLES_PPAGE 0xFC
192 /* General Purpose Page with PPAGE = 0xFE */
193 #define FPAGE_FE FFAR(".ppageFE") /* This is the block that is present in the page window using linear addressing, represents 0x8000 - 0xBFFF ("text2" paged) */
194 #define DPAGE_FE DFAR(".ppageFE") /* This is the block that is present in the page window using linear addressing, represents 0x8000 - 0xBFFF ("text2" paged) */
195 //#define FPAGE_FD FFAR(".ppageFD") /* Represents 0x4000 - 0x7FFF ("text1" paged) */
196 //#define DPAGE_FD DFAR(".ppageFD") /* Represents 0x4000 - 0x7FFF ("text1" paged) */
197 //#define FPAGE_FF FFAR(".ppageFF") /* Represents 0xC000 - 0xFFFF ("text" paged) */
198 //#define DPAGE_FF DFAR(".ppageFF") /* Represents 0xC000 - 0xFFFF ("text" paged) */
199 /* The previous four lines are included for clarity only. */
200 /* Changes to the memory layout should be reflected in memory.x and Makefile also */
204 /* let us know if we are being untidy with headers */
205 #warning "Header file MEMORY_H seen before, sort it out!"
206 /* end of the wrapper ifdef from the very top */