Cumulative patch for pic16 port
[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 #if defined(__BORLANDC__) || defined(_MSC_VER)
34 #define STRCASECMP stricmp
35 #else
36 #define STRCASECMP strcasecmp
37 #endif
38
39 #define CONFIGURATION_WORDS     20
40
41 typedef struct {
42         int sfrLoAddr;
43         int sfrHiAddr;
44 } sfrRangeInfo_t;
45         
46
47 typedef struct {
48         int mask;
49         int emit;
50         int value;
51 } configRegInfo_t;
52
53 typedef struct {
54         int confAddrStart;      /* starting address */
55         int confAddrEnd;        /* ending address */
56         configRegInfo_t crInfo[ CONFIGURATION_WORDS ];
57 } configWordsInfo_t;
58
59
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
65   int maxRAMaddress;            /* maximum value for a data address */
66   int RAMsize;                  /* size of Data RAM - VR 031120 */
67   int acsSplitOfs;              /* access bank split offset */
68   int extMIface;                /* device has external memory interface */
69   sfrRangeInfo_t sfrRange;      /* SFR range */
70   configWordsInfo_t cwInfo;     /* configuration words info */
71 } PIC16_device;
72
73 /* Given a pointer to a register, this macro returns the bank that it is in */
74 #define REG_ADDR(r)        ((r)->isBitField ? (((r)->address)>>3) : (r)->address)
75 //#define REG_BANK(r)        (pic16_finalMapping[REG_ADDR(r)].bank)
76 //#define REG_isALIASED(r)   (pic16_finalMapping[REG_ADDR(r)].alias != 0)
77 //#define REG_isVALID(r)     (pic16_finalMapping[REG_ADDR(r)].isValid)
78
79
80 typedef struct {
81         int no_banksel;
82         int opt_banksel;
83         int omit_configw;
84         int omit_ivt;
85         int leave_reset;
86         int stack_model;
87 } pic16_options_t;
88
89 #define STACK_MODEL_SMALL       (pic16_options.stack_model == 0)
90 #define STACK_MODEL_LARGE       (pic16_options.stack_model == 1)
91
92 extern set *fix_idataSymSet;
93 extern set *rel_idataSymSet;
94
95 extern pic16_options_t pic16_options;
96 extern PIC16_device *pic16;
97
98 /****************************************/
99 void pic16_assignConfigWordValue(int address, int value);
100 int pic16_getConfigWord(int address);
101 int pic16_isREGinBank(regs *reg, int bank);
102 int pic16_REGallBanks(regs *reg);
103 void pic16_setMaxRAM(int size);
104 int PIC16_IS_CONFIG_ADDRESS(int address);
105
106 int checkAddReg(set **set, regs *reg);
107 int checkAddSym(set **set, symbol *reg);
108
109 #endif  /* __DEVICE_H__ */