Imported Upstream version 2.9.0
[debian/cc1111] / sim / ucsim / stypes.h
1 /*
2  * Simulator of microcontrollers (stypes.h)
3  *
4  * Copyright (C) 1999,99 Drotos Daniel, Talker Bt.
5  * 
6  * To contact author send email to drdani@mazsola.iit.uni-miskolc.hu
7  *
8  */
9
10 /* This file is part of microcontroller simulator: ucsim.
11
12 UCSIM is free software; you can redistribute it and/or modify
13 it under the terms of the GNU General Public License as published by
14 the Free Software Foundation; either version 2 of the License, or
15 (at your option) any later version.
16
17 UCSIM is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20 GNU General Public License for more details.
21
22 You should have received a copy of the GNU General Public License
23 along with UCSIM; see the file COPYING.  If not, write to the Free
24 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
25 02111-1307, USA. */
26 /*@1@*/
27
28 #ifndef STYPES_HEADER
29 #define STYPES_HEADER
30
31 #include "ddconfig.h"
32
33
34 typedef unsigned char   uchar;
35 typedef unsigned int    uint;
36 typedef unsigned long   ulong;
37 typedef TYPE_DWORD      t_addr;         /* 32 bit max */
38 typedef TYPE_UWORD      t_mem;          /* 16 bit max */
39 typedef TYPE_WORD       t_smem;         /* signed 16 bit memory */
40
41 struct id_element
42 {
43   int id;
44   const char *id_string;
45 };
46
47 enum error_type {
48   err_unknown  = 0x01,
49   err_error    = 0x02,
50   err_warning  = 0x04
51 };
52
53 // table of dissassembled instructions
54 struct dis_entry
55 {
56   uint  code, mask;
57   char  branch;
58   uchar length;
59   const char *mnemonic;
60 };
61
62 // table entry of SFR and BIT names
63 struct name_entry
64 {
65   int cpu_type;
66   t_addr addr;
67   const char *name;
68 };
69
70
71 struct cpu_entry
72 {
73   const char *type_str;
74   int  type;
75   int  technology;
76 };
77
78 #define CPU_51          0x0001
79 #define CPU_31          0x0002
80 #define CPU_52          0x0004
81 #define CPU_32          0x0008
82 #define CPU_51R         0x0010
83 #define CPU_89C51R      0x0020
84 #define CPU_251         0x0040
85 #define CPU_DS390       0x0080
86 #define CPU_DS390F      0x0100
87 #define CPU_ALL_51      (CPU_51|CPU_31)
88 #define CPU_ALL_52      (CPU_52|CPU_32|CPU_51R|CPU_89C51R|CPU_251|CPU_DS390|CPU_DS390F)
89
90 #define CPU_AVR         0x0001
91 #define CPU_ALL_AVR     (CPU_AVR)
92
93 #define CPU_Z80         0x0001
94 #define CPU_ALL_Z80     (CPU_Z80)
95
96 #define CPU_XA          0x0001
97 #define CPU_ALL_XA      (CPU_XA)
98
99 #define CPU_HC08       0x0001
100 #define CPU_ALL_HC08   (CPU_HC08)
101
102 #define CPU_CMOS        0x0001
103 #define CPU_HMOS        0x0002
104
105 /* Classes of memories, this is index on the list */
106 enum mem_class
107 {
108   MEM_ROM= 0,
109   MEM_XRAM,
110   MEM_IRAM,
111   MEM_SFR,
112   MEM_DUMMY,
113   MEM_IXRAM,
114   MEM_TYPES
115 };
116
117 #define MEM_ROM_ID      "rom"
118 #define MEM_SFR_ID      "sfr"
119 #define MEM_XRAM_ID     "xram"
120 #define MEM_IXRAM_ID    "ixram"
121 #define MEM_IRAM_ID     "iram"
122
123 // States of simulator
124 #define SIM_NONE        0
125 #define SIM_GO          0x01    // Processor is running
126 #define SIM_QUIT        0x02    // Program must exit
127
128 /* States of CPU */
129 #define stGO            0       /* Normal state */
130 #define stIDLE          1       /* Idle mode is active */
131 #define stPD            2       /* Power Down mode is active */
132
133 /* Result of instruction simulation */
134 #define resGO           0       /* OK, go on */
135 #define resWDTRESET     1       /* Reseted by WDT */
136 #define resINTERRUPT    2       /* Interrupt accepted */
137 #define resSTOP         100     /* Stop if result greather then this */
138 #define resHALT         101     /* Serious error, halt CPU */
139 #define resINV_ADDR     102     /* Invalid indirect address */
140 #define resSTACK_OV     103     /* Stack overflow */
141 #define resBREAKPOINT   104     /* Breakpoint */
142 #define resUSER         105     /* Stopped by user */
143 #define resINV_INST     106     /* Invalid instruction */
144 #define resBITADDR      107     /* Bit address is uninterpretable */
145 #define resERROR        108     /* Error happened during instruction exec */
146
147 #define BIT_MASK(bitaddr) (1 << (bitaddr & 0x07))
148
149 //#define IRAM_SIZE 256   /* Size of Internal RAM */
150 //#define SFR_SIZE  256     /* Size of SFR area */
151 //#define SFR_START 128     /* Start address of SFR area */
152 //#define ERAM_SIZE 256     /* Size of ERAM in 51R */
153 //#define XRAM_SIZE 0x10000 /* Size of External RAM */
154 //#define IROM_SIZE 0x1000  /* Size of Internal ROM */
155 //#define EROM_SIZE 0x10000 /* Size of External ROM */
156
157
158 /* Type of breakpoints */
159 enum brk_perm
160 {
161   brkFIX,       /* f */
162   brkDYNAMIC    /* d */
163 };
164
165 enum brk_type
166 {
167   brkFETCH,     /* f */
168   brkEVENT      /* e */
169 };
170
171 enum brk_event
172 {
173   brkNONE,
174   brkWXRAM,     /* wx */
175   brkRXRAM,     /* rx */
176   brkRCODE,     /* rc */
177   brkWIRAM,     /* wi */
178   brkRIRAM,     /* ri */
179   brkWSFR,      /* ws */
180   brkRSFR,      /* rs */
181   brkREAD,
182   brkWRITE,
183   brkACCESS
184 };
185
186 //struct event_rec
187 //{
188 //  t_addr wx; /* write to XRAM at this address, else -1 */
189 //  t_addr rx; /* read from XRAM at this address, else -1 */
190 //  t_addr wi; /* write to IRAM at this address, else -1 */
191 //  t_addr ri; /* read from IRAM at this address, else -1 */
192 //  t_addr ws; /* write to SFR at this address, else -1 */
193 //  t_addr rs; /* read from SFR at this address, else -1 */
194 //  t_addr rc; /* read from ROM at this address, else -1 */
195 //};
196
197 /* Interrupt levels */
198 //#define IT_NO         -1 /* not in interroupt service */
199 #define IT_LOW          1 /* low level interrupt service */
200 #define IT_HIGH         2 /* service of high priority interrupt */
201
202 /* cathegories of hw elements (peripherials) */
203 enum hw_cath {
204   HW_DUMMY      = 0x0000,
205   HW_TIMER      = 0x0002,
206   HW_UART       = 0x0004,
207   HW_PORT       = 0x0008,
208   HW_PCA        = 0x0010,
209   HW_INTERRUPT  = 0x0020,
210   HW_WDT        = 0x0040
211 };
212
213 // Events that can happen in peripherals
214 enum hw_event {
215   EV_OVERFLOW,
216   EV_PORT_CHANGED,
217   EV_T2_MODE_CHANGED
218 };
219
220 // flags of hw units
221 #define HWF_NONE        0
222 #define HWF_INSIDE      0x0001
223 #define HWF_OUTSIDE     0x0002
224 #define HWF_MISC        0x0004
225
226
227 /* Letter cases */
228 enum letter_case {
229   case_upper,  /* all is upper case */
230   case_lower,  /* all is lower case */
231   case_case    /* first letter is upper, others are lower case */
232 };
233
234
235 #endif
236
237 /* End of stypes.h */