* sim/ucsim/cmd.src/cmdutil.cc: NUL device is detected as CG_FILE type
[fw/sdcc] / src / pic16 / device.h
1 /*-------------------------------------------------------------------------
2
3   device.c - Accomodates subtle variations in PIC16 devices
4
5    Written By -  Scott Dattalo scott@dattalo.com
6
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
10    later version.
11    
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.
16    
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 -------------------------------------------------------------------------*/
21
22 /*
23   PIC device abstraction
24
25   There are dozens of variations of PIC microcontrollers. This include
26   file attempts to abstract those differences so that SDCC can easily
27   deal with them.
28 */
29
30 #ifndef  __DEVICE_H__
31 #define  __DEVICE_H__
32
33 #define CONFIGURATION_WORDS     20
34 #define IDLOCATION_BYTES        20
35
36 typedef struct {
37         int sfrLoAddr;
38         int sfrHiAddr;
39 } sfrRangeInfo_t;
40         
41
42 typedef struct {
43         unsigned int mask;
44         int emit;
45         unsigned int value;
46 } configRegInfo_t;
47
48 typedef struct {
49         int confAddrStart;      /* starting address */
50         int confAddrEnd;        /* ending address */
51         configRegInfo_t crInfo[ CONFIGURATION_WORDS ];
52 } configWordsInfo_t;
53
54 typedef struct {
55         unsigned char emit;
56         unsigned char value;
57 } idRegInfo_t;
58
59 typedef struct {
60         int idAddrStart;        /* starting ID address */
61         int idAddrEnd;          /* ending ID address */
62         idRegInfo_t irInfo[ IDLOCATION_BYTES ];
63 } idBytesInfo_t;
64
65
66 #define PROCESSOR_NAMES    4
67 /* Processor unique attributes */
68 typedef struct PIC16_device {
69   char *name[PROCESSOR_NAMES];/* aliases for the processor name */
70
71   int maxRAMaddress;            /* maximum value for a data address */
72   int RAMsize;                  /* size of Data RAM - VR 031120 */
73   int acsSplitOfs;              /* access bank split offset */
74   int extMIface;                /* device has external memory interface */
75   sfrRangeInfo_t sfrRange;      /* SFR range */
76   configWordsInfo_t cwInfo;     /* configuration words info */
77   idBytesInfo_t idInfo;         /* ID Locations info */
78 } PIC16_device;
79
80 /* Given a pointer to a register, this macro returns the bank that it is in */
81 #define REG_ADDR(r)        ((r)->isBitField ? (((r)->address)>>3) : (r)->address)
82
83 #define OF_LR_SUPPORT           0x00000001
84 #define OF_OPTIMIZE_GOTO        0x00000002
85 #define OF_OPTIMIZE_CMP         0x00000004
86 #define OF_OPTIMIZE_DF          0x00000008
87
88 typedef struct {
89   int no_banksel;
90   int opt_banksel;
91   int omit_configw;
92   int omit_ivt;
93   int leave_reset;
94   int stack_model;
95   int ivt_loc;
96   int nodefaultlibs;
97   int dumpcalltree;
98   char *crt_name;
99   int no_crt;
100   int ip_stack;
101   unsigned long opt_flags;
102   int gstack;
103   unsigned int debgen;
104   int CATregs;
105 } pic16_options_t;
106
107 extern int xinst;
108
109 #define STACK_MODEL_SMALL       (pic16_options.stack_model == 0)
110 #define STACK_MODEL_LARGE       (pic16_options.stack_model == 1)
111
112 extern set *fix_idataSymSet;
113 extern set *rel_idataSymSet;
114
115 #if 0
116 /* This is an experimental code for #pragma inline
117    and is temporarily disabled for 2.5.0 release */
118 extern set *asmInlineMap;
119 #endif  /* 0 */
120
121 typedef struct {
122   unsigned long isize;
123   unsigned long adsize;
124   unsigned long udsize;
125   unsigned long idsize;
126   unsigned long intsize;
127 } stats_t;
128
129 extern stats_t statistics;
130
131 extern pic16_options_t pic16_options;
132 extern PIC16_device *pic16;
133
134 /****************************************/
135 void pic16_assignConfigWordValue(int address, unsigned int value);
136 void pic16_assignIdByteValue(int address, char value);
137 int pic16_isREGinBank(regs *reg, int bank);
138 int pic16_REGallBanks(regs *reg);
139 void pic16_setMaxRAM(int size);
140 int PIC16_IS_CONFIG_ADDRESS(int address);
141 int PIC16_IS_IDLOC_ADDRESS(int address);
142 int PIC16_IS_HWREG_ADDRESS(int address);
143
144 int checkAddReg(set **set, regs *reg);
145 int checkAddSym(set **set, symbol *reg);
146 int checkSym(set *set, symbol *reg);
147
148 #endif  /* __DEVICE_H__ */