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 #define MAX_NUM_CONFIGS 16
35 
36 /*
37  * Imports
38  */
39 extern char *iComments2;
40 
41 /* memRange - a structure to define a range of valid memory addresses
42  *
43  * The Memory of most PICs (and other micros) is a collection of
44  * disjoint chunks. The memRange structure will define the start
45  * and end address of one of these chunks. The memory map of a
46  * particular device is a collection of memRange struct's.
47  */
48 
49 typedef struct memRange {
50 	int start_address;      /* first address in range */
51 	int end_address;        /* last */
52 	int alias;              /* bit mask defining how/if memory range is aliased
53 	                         * e.g. alias = 0x80 means start_address is identical
54 	                         * to the memory location at (0x80 | start_address) */
55 	int bank;               /* PIC memory bank this range occupies */
56 	struct memRange *next;	/* linked list */
57 
58 } memRange;
59 
60 /* Processor unique attributes */
61 typedef struct PIC_device {
62 	char *name;                 /* the processor name */
63 
64 	memRange *ram;              /* RAM memory map */
65 	memRange *sfr;              /* SFR memory map */
66 
67 	int maxRAMaddress;          /* maximum value for a data address */
68 	int defMaxRAMaddrs;         /* default maximum value for a data address */
69 	int bankMask;               /* Bitmask that is ANDed with address to extract banking bits */
70 	//  int hasAliasedRAM:1;        /* True if there are bank independent registers */
71 	int num_configs;                /* number of config words for this device */
72 	int config[MAX_NUM_CONFIGS];    /* addresses of config word(s) */
73 
74 	int programMemSize;         /* program memory size in words - for device listing only */
75 	int dataMemSize;            /* data (RAM) memory size in bytes - for device listing only */
76 	int eepromMemSize;          /* EEPROM memory size in bytes - for device listing only */
77 	int ioPins;                 /* number of I/O pins - for device listing only */
78         int isEnhancedCore;         /* enhanced cores (19f1934) feature automatic context saving */
79 
80 } PIC_device;
81 
82 
83 PIC_device *init_pic(char *pic_type);
84 int picIsInitialized(void);
85 char *processor_base_name(void);
86 int IS_CONFIG_ADDRESS(int addr);
87 void pic14_assignConfigWordValue(int address, int value);
88 int pic14_emitConfigWord(FILE *vFile);
89 
90 int pic14_allRAMShared(void);
91 int pic14_getSharedStack(int *low, int *high, int *size);
92 PIC_device * pic14_getPIC(void);
93 
94 #endif  /* __DEVICE_H__ */
95