1 /* Error handling
2    Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
3    James Bowman, Craig Franklin
4    Copyright (C) 2012 Borut Razem
5 
6     Copyright (C) 2015-2016 Molnar Karoly
7 
8 This file is part of gputils.
9 
10 gputils is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2, or (at your option)
13 any later version.
14 
15 gputils is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 GNU General Public License for more details.
19 
20 You should have received a copy of the GNU General Public License
21 along with gputils; see the file COPYING.  If not, write to
22 the Free Software Foundation, 59 Temple Place - Suite 330,
23 Boston, MA 02111-1307, USA.  */
24 
25 #ifndef __GPMSG_H__
26 #define __GPMSG_H__
27 
28 /* Error codes
29  *
30  * The error codes gpasm defines here are identical to MPASM's
31  * definitions. Additional gpasm definitions follow the last
32  * MPASM definition.
33  *
34  */
35 enum GPE_codes {
36   GPE_USER             = 101,
37   GPE_NOMEM            = 102,
38   GPE_SYMFULL          = 103,
39   GPE_TEMPFILE         = 104,
40   GPE_NOENT            = 105,  /* File or directory not found */
41   GPE_STRCPLX          = 106,
42   GPE_BADDIGIT         = 107,
43   GPE_BADCHAR          = 108,
44   GPE_OPENPAR          = 109,  /* Mis-matched open parenthesis */
45   GPE_CLOSEPAR         = 110,  /* Mis-matched closed parenthesis */
46   GPE_MISSYM           = 111,  /* No symbol in an EQU or SET */
47   GPE_NOOP             = 112,  /* Missing an arithmetic operator */
48   GPE_SYM_NOT_DEFINED  = 113,  /* Symbol has not been defined */
49   GPE_DIVBY0           = 114,
50   GPE_DUPLAB           = 115,
51   GPE_DIFFLAB          = 116,
52   GPE_ADDROVF          = 117,  /* address overflow */
53   GPE_ADDROVR          = 118,  /* overwriting a previously written address */
54   GPE_BAD_CALL_ADDR    = 120,
55   GPE_ILLEGAL_LABEL    = 121,
56   GPE_ILLEGAL_DIR      = 123,
57   GPE_ILLEGAL_ARGU     = 124,
58   GPE_ILLEGAL_COND     = 125,
59   GPE_OUT_OF_RANGE     = 126,  /* Argument out of range */
60   GPE_TOO_MANY_ARGU    = 127,
61   GPE_MISSING_ARGU     = 128,
62   GPE_EXPECTED         = 129,
63   GPE_EXTRA_PROC       = 130,
64   GPE_UNDEF_PROC       = 131,
65   GPE_UNKNOWN_PROC     = 132,
66   GPE_IHEX             = 133,  /* Hex file format is too small for code */
67   GPE_NO_MACRO_NAME    = 135,
68   GPE_DUPLICATE_MACRO  = 136,
69   GPE_BAD_WHILE_LOOP   = 140,
70   GPE_ILLEGAL_NESTING  = 143,
71   GPE_UNMATCHED_ENDM   = 145,
72   GPE_OBJECT_ONLY      = 149,
73   GPE_LABEL_IN_SECTION = 150,
74   GPE_UNRESOLVABLE     = 151,
75   GPE_WRONG_SECTION    = 152,
76   GPE_CONTIG_SECTION   = 154,
77   GPE_MUST_BE_LABEL    = 156,
78   GPE_ORG_ODD          = 157,
79   GPE_FILL_ODD         = 159,
80   GPE_CONTIG_CONFIG    = 163,
81   GPE_CONTIG_IDLOC     = 164,
82   GPE_NO_EXTENDED_MODE = 165,  /*  Extended mode not available for this device */
83   GPE_MISSING_BRACKET  = 168,
84   GPE_CONSTANT         = 170,  /* Expression within brackets must be constant */
85   GPE_IDLOCS_ORDER     = 175,
86   GPE_CONFIG_UNKNOWN   = 176,
87   GPE_CONFIG_usCONFIG  = 177,
88   GPE_RES_ODD_PIC16EA  = 180,
89   GPE_UNKNOWN          = 181,
90 
91   /* gputils special errors */
92   GPE_INTERNAL         = 1101,  /* Internal error */
93   GPE_PARSER           = 1102,  /* Parser error */
94   GPE_SCANNER          = 1103,  /* Scanner error */
95 
96   GPE_IDLOCS_P16E      = 1501,  /* IDLOCS directive use solely to the PIC16E family. */
97   GPE_NO_DEST          = 1502,  /* The destination of the storage is not selected. */
98   GPE_NO_ACC           = 1503,  /* The access of RAM is not selected. */
99   GPE_TOO_LONG         = 1504,  /* A string too long. */
100   GPE_IN_OF_ACCRAM     = 1505,  /* A register is located on the Access RAM. */
101   GPE_OUT_OF_ACCRAM    = 1506,  /* A register is not located on the Access RAM. */
102   GPE_OUT_OF_BANK      = 1507,
103   GPE_INVALID_RAM      = 1508,
104   GPE_INVALID_ROM      = 1509,
105   GPE_EXCEED_ROM       = 1510,
106   GPE_SYM_NO_VALUE     = 1511
107 };
108 
109 #define GMSG_ERR_LEVEL0_MIN     GPE_USER
110 #define GMSG_ERR_LEVEL0_MAX     GPE_UNKNOWN
111 
112 #define GMSG_ERR_LEVEL1_MIN     GPE_IDLOCS_P16E
113 #define GMSG_ERR_LEVEL1_MAX     GPE_INVALID_ROM
114 
115 /* Warning codes
116  *
117  * The warning codes gpasm defines here are identical to MPASM's
118  * definitions. Additional gpasm definitions follow the last
119  * MPASM definition.
120  *
121  */
122 enum GPW_codes {
123   GPW_SYM_NOT_DEFINED  = 201,
124   GPW_OUT_OF_RANGE     = 202,  /* Argument out of range */
125   GPW_OP_COLUMN_ONE    = 203,
126   GPW_DIR_COLUMN_ONE   = 205,
127   GPW_MACRO_COLUMN_ONE = 206,
128   GPW_LABEL_COLUMN     = 207,
129   GPW_MISSING_QUOTE    = 209,
130   GPW_EXTRANEOUS       = 211,
131   GPW_EXPECTED         = 212,
132   GPW_CMDLINE_PROC     = 215,
133   GPW_CMDLINE_RADIX    = 216,
134   GPW_CMDLINE_HEXFMT   = 217,
135   GPW_RADIX            = 218,
136   GPW_INVALID_RAM      = 219,
137   GPW_EXCEED_ROM       = 220,
138   GPW_DISABLE_ERROR    = 222,
139   GPW_REDEFINING_PROC  = 223,
140   GPW_NOT_RECOMMENDED  = 224,
141   GPW_WORD_ALIGNED     = 226,
142   GPW_INVALID_ROM      = 228,
143   GPW_UNKNOWN          = 231,
144 
145   /* gputils special warnings */
146   GPW_BANK_PAGE_SEL_AFTER_SKIP = 1201, /* %s after skip instruction. I this really what you intended? */
147   GPW_UNDEF_PROC       = 1202,
148   GPW_IN_OF_ACCRAM     = 1203, /* A register is located on the Access RAM. */
149   GPW_OUT_OF_ACCRAM    = 1204, /* A register is not located on the Access RAM. */
150   GPW_NO_DEST          = 1205, /* The destination of the storage is not selected. */
151   GPW_OUT_OF_BANK      = 1206,
152   GPW_STRING_TRUNCATE  = 1207,
153   GPW_SYM_NO_VALUE     = 1208,
154   GPW_USER             = 1299
155 };
156 
157 #define GMSG_WARN_LEVEL0_MIN    GPW_NOT_DEFINED
158 #define GMSG_WARN_LEVEL0_MAX    GPW_UNKNOWN
159 
160 #define GMSG_WARN_LEVEL1_MIN    GPW_BANK_PAGE_SEL_AFTER_SKIP
161 #define GMSG_WARN_LEVEL1_MAX    GPW_USER
162 
163 /* Message codes
164  *
165  * The message codes gpasm defines here are identical to MPASM's
166  * definitions. Additional gpasm definitions follow the last
167  * MPASM definition.
168  *
169  */
170 enum GPM_codes {
171   GPM_USER             = 301,  /* User supplied message */
172   GPM_OUT_OF_BANK      = 302,
173   GPM_OUT_OF_RANGE     = 303,
174   GPM_IDLOC            = 304,
175   GPM_NO_DEST          = 305,
176   GPM_PAGE_BOUNDARY    = 306,
177   GPM_PAGEBITS         = 307,
178   GPM_SUPVAL           = 308,
179   GPM_SUPLIN           = 309,
180   GPM_SUPRAM           = 310,
181   GPM_EXT_BANK_OR_PAGE = 312,
182   GPM_CBLOCK           = 313,
183   GPM_W_MODIFIED       = 316,
184   GPM_SPECIAL_MNEMONIC = 318,
185   GPM_UNKNOWN          = 319,
186 
187   /* gputils special messages */
188   GPM_ACC_DEF          = 1301,
189   GPM_NO_BANK          = 1302,
190   GPM_EXT_BANK         = 1303,
191   GPM_EXT_PAGE         = 1304
192 };
193 
194 #define GMSG_MSG_LEVEL0_MIN     GPM_USER
195 #define GMSG_MSG_LEVEL0_MAX     GPM_UNKNOWN
196 
197 #define GMSG_MSG_LEVEL1_MIN     GPM_ACC_DEF
198 #define GMSG_MSG_LEVEL1_MAX     GPM_EXT_PAGE2
199 
200 extern void gpmsg_init(void);
201 extern void gpmsg_close(void);
202 
203 extern void gpmsg_add_code(int Code);
204 extern void gpmsg_add_code_range(int Code0, int Code1);
205 
206 extern void gpmsg_error(int Code, const char *Message);
207 extern void gpmsg_warning(int Code, const char *Message);
208 extern void gpmsg_message(int Code, const char *Message);
209 
210 extern void gpmsg_verror(int Code, const char *Message, ...);
211 extern void gpmsg_vwarning(int Code, const char *Message, ...);
212 extern void gpmsg_vmessage(int Code, const char *Message, ...);
213 
214 /* Alternate message functions. Only the prototypes are provided, the user
215    must link their own function into gpasm. */
216 extern void gpmsg_user_error(int Code, const char *Message);
217 extern void gpmsg_user_warning(int Code, const char *Message);
218 extern void gpmsg_user_message(int Code, const char *Message);
219 
220 #endif /* __GPMSG_H__ */
221