Imported Upstream version 2.9.0
[debian/cc1111] / src / pic / device.h
1 /*-------------------------------------------------------------------------
2
3    device.c - Accomodates subtle variations in PIC devices
4    Written By -  Scott Dattalo scott@dattalo.com
5
6    This program is free software; you can redistribute it and/or modify it
7    under the terms of the GNU General Public License as published by the
8    Free Software Foundation; either version 2, or (at your option) any
9    later version.
10    
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15    
16    You should have received a copy of the GNU General Public License
17    along with this program; if not, write to the Free Software
18    Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 -------------------------------------------------------------------------*/
20
21 /*
22   PIC device abstraction
23
24   There are dozens of variations of PIC microcontrollers. This include
25   file attempts to abstract those differences so that SDCC can easily
26   deal with them.
27 */
28
29 #ifndef  __DEVICE_H__
30 #define  __DEVICE_H__
31
32 #include "common.h"
33
34 /*
35  * Imports
36  */
37 extern char *iComments2;
38
39 /* memRange - a structure to define a range of valid memory addresses 
40  * 
41  * The Memory of most PICs (and other micros) is a collection of
42  * disjoint chunks. The memRange structure will define the start
43  * and end address of one of these chunks. The memory map of a
44  * particular device is a collection of memRange struct's.
45  */
46
47 typedef struct memRange {
48         int start_address;      /* first address in range */
49         int end_address;        /* last */
50         int alias;              /* bit mask defining how/if memory range is aliased 
51                                  * e.g. alias = 0x80 means start_address is identical
52                                  * to the memory location at (0x80 | start_address) */
53         int bank;               /* PIC memory bank this range occupies */
54         struct memRange *next;  /* linked list */
55
56 } memRange;
57
58 /* Processor unique attributes */
59 typedef struct PIC_device {
60         char *name;                 /* the processor name */
61
62         memRange *ram;              /* RAM memory map */
63         memRange *sfr;              /* SFR memory map */
64
65         int maxRAMaddress;          /* maximum value for a data address */
66         int defMaxRAMaddrs;         /* default maximum value for a data address */
67         int bankMask;               /* Bitmask that is ANDed with address to extract banking bits */
68         //  int hasAliasedRAM:1;        /* True if there are bank independent registers */
69         int hasSecondConfigReg;     /* True if there is a second configuration register */
70         
71         int programMemSize;         /* program memory size in words - for device listing only */
72         int dataMemSize;            /* data (RAM) memory size in bytes - for device listing only */
73         int eepromMemSize;          /* EEPROM memory size in bytes - for device listing only */
74         int ioPins;                 /* number of I/O pins - for device listing only */
75
76 } PIC_device;
77
78
79 PIC_device *init_pic(char *pic_type);
80 int picIsInitialized(void);
81 char *processor_base_name(void);
82 int IS_CONFIG_ADDRESS(int addr);
83 void pic14_assignConfigWordValue(int address, int value);
84 int pic14_emitConfigWord(FILE *vFile);
85
86 int pic14_allRAMShared(void);
87 int pic14_getSharedStack(int *low, int *high, int *size);
88 PIC_device * pic14_getPIC(void);
89
90 #endif  /* __DEVICE_H__ */