summaryrefslogtreecommitdiff
path: root/src/pic16/device.h
blob: cdfbba09b304a1f3552e7b68b72f82ea91aaa099 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
/*-------------------------------------------------------------------------

  device.c - Accomodates subtle variations in PIC16 devices

   Written By -  Scott Dattalo scott@dattalo.com

   This program is free software; you can redistribute it and/or modify it
   under the terms of the GNU General Public License as published by the
   Free Software Foundation; either version 2, or (at your option) any
   later version.
   
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.
   
   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-------------------------------------------------------------------------*/

/*
  PIC device abstraction

  There are dozens of variations of PIC microcontrollers. This include
  file attempts to abstract those differences so that SDCC can easily
  deal with them.
*/

#ifndef  __DEVICE_H__
#define  __DEVICE_H__

#define CONFIGURATION_WORDS     20
#define IDLOCATION_BYTES        20

typedef struct {
  unsigned int mask;
  int emit;
  unsigned int value;
  unsigned int andmask;
} configRegInfo_t;

typedef struct {
  int confAddrStart;      /* starting address */
  int confAddrEnd;        /* ending address */
  configRegInfo_t crInfo[ CONFIGURATION_WORDS ];
} configWordsInfo_t;

typedef struct {
  unsigned char emit;
  unsigned char value;
} idRegInfo_t;

typedef struct {
  int idAddrStart;        /* starting ID address */
  int idAddrEnd;          /* ending ID address */
  idRegInfo_t irInfo[ IDLOCATION_BYTES ];
} idBytesInfo_t;


#define PROCESSOR_NAMES    4
/* Processor unique attributes */
typedef struct PIC16_device {
  char *name[PROCESSOR_NAMES];  /* aliases for the processor name */
  /* RAMsize *must* be the first item to copy for 'using' */
  unsigned int RAMsize;         /* size of Data RAM - VR 031120 */
  unsigned int acsSplitOfs;     /* access bank split offset */
  configWordsInfo_t cwInfo;     /* configuration words info */
  idBytesInfo_t idInfo;         /* ID Locations info */
  int xinst;                    /* device supports XINST */
  /* next *must* be the first field NOT being copied via 'using' */
  struct PIC16_device *next;    /* linked list */
} PIC16_device;

extern PIC16_device *pic16;

/* Given a pointer to a register, this macro returns the bank that it is in */
#define REG_ADDR(r)        ((r)->isBitField ? (((r)->address)>>3) : (r)->address)

#define OF_LR_SUPPORT           0x00000001
#define OF_NO_OPTIMIZE_GOTO     0x00000002
#define OF_OPTIMIZE_CMP         0x00000004
#define OF_OPTIMIZE_DF          0x00000008

typedef struct {
  int no_banksel;
  int opt_banksel;
  int omit_configw;
  int omit_ivt;
  int leave_reset;
  int stack_model;
  int ivt_loc;
  int nodefaultlibs;
  int dumpcalltree;
  char *crt_name;
  int no_crt;
  int ip_stack;
  unsigned long opt_flags;
  int gstack;
  unsigned int debgen;
  int xinst;
  int no_warn_non_free;
} pic16_options_t;

extern pic16_options_t pic16_options;

#define STACK_MODEL_SMALL       (pic16_options.stack_model == 0)
#define STACK_MODEL_LARGE       (pic16_options.stack_model == 1)

extern set *fix_idataSymSet;
extern set *rel_idataSymSet;

#if 0
/* This is an experimental code for #pragma inline
   and is temporarily disabled for 2.5.0 release */
extern set *asmInlineMap;
#endif  /* 0 */

typedef struct {
  unsigned long isize;
  unsigned long adsize;
  unsigned long udsize;
  unsigned long idsize;
  unsigned long intsize;
} stats_t;

extern stats_t statistics;

typedef struct pic16_config_options_s {
  char *config_str;
  struct pic16_config_options_s *next;
} pic16_config_options_t;

extern pic16_config_options_t *pic16_config_options;

/****************************************/
const char *pic16_processor_base_name(void);
void pic16_assignConfigWordValue(int address, unsigned int value);
void pic16_assignIdByteValue(int address, char value);
int pic16_isREGinBank(reg_info *reg, int bank);
int pic16_REGallBanks(reg_info *reg);

int checkAddReg(set **set, reg_info *reg);
int checkAddSym(set **set, symbol *reg);
int checkSym(set *set, symbol *reg);

#endif  /* __DEVICE_H__ */