Imported Upstream version 2.9.0
[debian/cc1111] / 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   unsigned int mask;
38   int emit;
39   unsigned int value;
40   unsigned int andmask;
41 } configRegInfo_t;
42
43 typedef struct {
44   int confAddrStart;      /* starting address */
45   int confAddrEnd;        /* ending address */
46   configRegInfo_t crInfo[ CONFIGURATION_WORDS ];
47 } configWordsInfo_t;
48
49 typedef struct {
50   unsigned char emit;
51   unsigned char value;
52 } idRegInfo_t;
53
54 typedef struct {
55   int idAddrStart;        /* starting ID address */
56   int idAddrEnd;          /* ending ID address */
57   idRegInfo_t irInfo[ IDLOCATION_BYTES ];
58 } idBytesInfo_t;
59
60
61 #define PROCESSOR_NAMES    4
62 /* Processor unique attributes */
63 typedef struct PIC16_device {
64   char *name[PROCESSOR_NAMES];  /* aliases for the processor name */
65   /* RAMsize *must* be the first item to copy for 'using' */
66   int RAMsize;                  /* size of Data RAM - VR 031120 */
67   int acsSplitOfs;              /* access bank split offset */
68   configWordsInfo_t cwInfo;     /* configuration words info */
69   idBytesInfo_t idInfo;         /* ID Locations info */
70   /* next *must* be the first field NOT being copied via 'using' */
71   struct PIC16_device *next;    /* linked list */
72 } PIC16_device;
73
74 extern PIC16_device *pic16;
75
76 /* Given a pointer to a register, this macro returns the bank that it is in */
77 #define REG_ADDR(r)        ((r)->isBitField ? (((r)->address)>>3) : (r)->address)
78
79 #define OF_LR_SUPPORT           0x00000001
80 #define OF_NO_OPTIMIZE_GOTO     0x00000002
81 #define OF_OPTIMIZE_CMP         0x00000004
82 #define OF_OPTIMIZE_DF          0x00000008
83
84 typedef struct {
85   int no_banksel;
86   int opt_banksel;
87   int omit_configw;
88   int omit_ivt;
89   int leave_reset;
90   int stack_model;
91   int ivt_loc;
92   int nodefaultlibs;
93   int dumpcalltree;
94   char *crt_name;
95   int no_crt;
96   int ip_stack;
97   unsigned long opt_flags;
98   int gstack;
99   unsigned int debgen;
100   int xinst;
101 } pic16_options_t;
102
103 extern pic16_options_t pic16_options;
104
105 #define STACK_MODEL_SMALL       (pic16_options.stack_model == 0)
106 #define STACK_MODEL_LARGE       (pic16_options.stack_model == 1)
107
108 extern set *fix_idataSymSet;
109 extern set *rel_idataSymSet;
110
111 #if 0
112 /* This is an experimental code for #pragma inline
113    and is temporarily disabled for 2.5.0 release */
114 extern set *asmInlineMap;
115 #endif  /* 0 */
116
117 typedef struct {
118   unsigned long isize;
119   unsigned long adsize;
120   unsigned long udsize;
121   unsigned long idsize;
122   unsigned long intsize;
123 } stats_t;
124
125 extern stats_t statistics;
126
127 /****************************************/
128 void pic16_assignConfigWordValue(int address, unsigned int value);
129 void pic16_assignIdByteValue(int address, char value);
130 int pic16_isREGinBank(regs *reg, int bank);
131 int pic16_REGallBanks(regs *reg);
132
133 int checkAddReg(set **set, regs *reg);
134 int checkAddSym(set **set, symbol *reg);
135 int checkSym(set *set, symbol *reg);
136
137 #endif  /* __DEVICE_H__ */
138