1 /*-------------------------------------------------------------------------
3 device.c - Accomodates subtle variations in PIC16 devices
5 Written By - Scott Dattalo scott@dattalo.com
7 This program is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 2, or (at your option) any
12 This program 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 this program; if not, write to the Free Software
19 Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 -------------------------------------------------------------------------*/
23 PIC device abstraction
25 There are dozens of variations of PIC microcontrollers. This include
26 file attempts to abstract those differences so that SDCC can easily
33 #define CONFIGURATION_WORDS 20
34 #define IDLOCATION_BYTES 20
43 int confAddrStart; /* starting address */
44 int confAddrEnd; /* ending address */
45 configRegInfo_t crInfo[ CONFIGURATION_WORDS ];
54 int idAddrStart; /* starting ID address */
55 int idAddrEnd; /* ending ID address */
56 idRegInfo_t irInfo[ IDLOCATION_BYTES ];
60 #define PROCESSOR_NAMES 4
61 /* Processor unique attributes */
62 typedef struct PIC16_device {
63 char *name[PROCESSOR_NAMES]; /* aliases for the processor name */
64 /* RAMsize *must* be the first item to copy for 'using' */
65 int RAMsize; /* size of Data RAM - VR 031120 */
66 int acsSplitOfs; /* access bank split offset */
67 configWordsInfo_t cwInfo; /* configuration words info */
68 idBytesInfo_t idInfo; /* ID Locations info */
69 /* next *must* be the first field NOT being copied via 'using' */
70 struct PIC16_device *next; /* linked list */
73 extern PIC16_device *pic16;
75 /* Given a pointer to a register, this macro returns the bank that it is in */
76 #define REG_ADDR(r) ((r)->isBitField ? (((r)->address)>>3) : (r)->address)
78 #define OF_LR_SUPPORT 0x00000001
79 #define OF_NO_OPTIMIZE_GOTO 0x00000002
80 #define OF_OPTIMIZE_CMP 0x00000004
81 #define OF_OPTIMIZE_DF 0x00000008
96 unsigned long opt_flags;
102 extern pic16_options_t pic16_options;
104 #define STACK_MODEL_SMALL (pic16_options.stack_model == 0)
105 #define STACK_MODEL_LARGE (pic16_options.stack_model == 1)
107 extern set *fix_idataSymSet;
108 extern set *rel_idataSymSet;
111 /* This is an experimental code for #pragma inline
112 and is temporarily disabled for 2.5.0 release */
113 extern set *asmInlineMap;
118 unsigned long adsize;
119 unsigned long udsize;
120 unsigned long idsize;
121 unsigned long intsize;
124 extern stats_t statistics;
126 /****************************************/
127 void pic16_assignConfigWordValue(int address, unsigned int value);
128 void pic16_assignIdByteValue(int address, char value);
129 int pic16_isREGinBank(regs *reg, int bank);
130 int pic16_REGallBanks(regs *reg);
132 int checkAddReg(set **set, regs *reg);
133 int checkAddSym(set **set, symbol *reg);
134 int checkSym(set *set, symbol *reg);
136 #endif /* __DEVICE_H__ */