Merge branch ucsim-034-pre3 to main trunk; new version 0.4
[fw/sdcc] / 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_UDWORD 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   char *id_string;
45 };
46
47 // table of dissassembled instructions
48 struct dis_entry
49 {
50   uint  code, mask;
51   char  branch;
52   uchar length;
53   char  *mnemonic;
54 };
55
56 // table entry of SFR and BIT names
57 struct name_entry
58 {
59   int  cpu_type;
60   uint addr;
61   char *name;
62 };
63
64
65 struct cpu_entry
66 {
67   char *type_str;
68   int  type;
69   int  technology;
70 };
71
72 #define CPU_51          0x0001
73 #define CPU_31          0x0002
74 #define CPU_52          0x0004
75 #define CPU_32          0x0008
76 #define CPU_51R         0x0010
77 #define CPU_89C51R      0x0020
78 #define CPU_251         0x0040
79 #define CPU_DS390       0x0080
80 #define CPU_DS390F      0x0100
81 #define CPU_ALL_51      (CPU_51|CPU_31)
82 #define CPU_ALL_52      (CPU_52|CPU_32|CPU_51R|CPU_89C51R|CPU_251|CPU_DS390|CPU_DS390F)
83
84 #define CPU_AVR         0x0001
85 #define CPU_ALL_AVR     (CPU_AVR)
86
87 #define CPU_Z80         0x0001
88 #define CPU_ALL_Z80     (CPU_Z80)
89
90 #define CPU_XA          0x0001
91 #define CPU_ALL_XA      (CPU_XA)
92
93 #define CPU_CMOS        0x0001
94 #define CPU_HMOS        0x0002
95
96 /* Classes of memories, this is index on the list */
97 enum mem_class
98 {
99   MEM_ROM= 0,
100   MEM_XRAM,
101   MEM_IRAM,
102   MEM_SFR,
103   MEM_DUMMY,
104   MEM_IXRAM,
105   MEM_TYPES
106 };
107
108 // Flags of consoles
109 #define CONS_NONE        0
110 #define CONS_DEBUG       0x01   // Print debug messages on this console
111 #define CONS_FROZEN      0x02   // Console is frozen (g command issued)
112 #define CONS_PROMPT      0x04   // Prompt is out, waiting for input
113 #define CONS_INTERACTIVE 0x08   // Interactive console
114
115 // States of simulator
116 #define SIM_NONE        0
117 #define SIM_GO          0x01    // Processor is running
118 #define SIM_QUIT        0x02    // Program must exit
119
120 /* States of CPU */
121 #define stGO            0       /* Normal state */
122 #define stIDLE          1       /* Idle mode is active */
123 #define stPD            2       /* Power Down mode is active */
124
125 /* Result of instruction simulation */
126 #define resGO           0       /* OK, go on */
127 #define resWDTRESET     1       /* Reseted by WDT */
128 #define resINTERRUPT    2       /* Interrupt accepted */
129 #define resSTOP         100     /* Stop if result greather then this */
130 #define resHALT         101     /* Serious error, halt CPU */
131 #define resINV_ADDR     102     /* Invalid indirect address */
132 #define resSTACK_OV     103     /* Stack overflow */
133 #define resBREAKPOINT   104     /* Breakpoint */
134 #define resUSER         105     /* Stopped by user */
135 #define resINV_INST     106     /* Invalid instruction */
136 #define resBITADDR      107     /* Bit address is uninterpretable */
137
138 #define BIT_MASK(bitaddr) (1 << (bitaddr & 0x07))
139
140 #define IRAM_SIZE 256     /* Size of Internal RAM */
141 #define SFR_SIZE  256     /* Size of SFR area */
142 #define SFR_START 128     /* Start address of SFR area */
143 #define ERAM_SIZE 256     /* Size of ERAM in 51R */
144 #define XRAM_SIZE 0x10000 /* Size of External RAM */
145 //#define IROM_SIZE 0x1000  /* Size of Internal ROM */
146 #define EROM_SIZE 0x10000 /* Size of External ROM */
147
148
149 /* Type of breakpoints */
150 enum brk_perm
151 {
152   brkFIX,       /* f */
153   brkDYNAMIC    /* d */
154 };
155
156 enum brk_type
157 {
158   brkFETCH,     /* f */
159   brkEVENT      /* e */
160 };
161
162 enum brk_event
163 {
164   brkNONE,
165   brkWXRAM,     /* wx */
166   brkRXRAM,     /* rx */
167   brkRCODE,     /* rc */
168   brkWIRAM,     /* wi */
169   brkRIRAM,     /* ri */
170   brkWSFR,      /* ws */
171   brkRSFR,      /* rs */
172   brkREAD,
173   brkWRITE,
174   brkACCESS
175 };
176
177 //struct event_rec
178 //{
179 //  t_addr wx; /* write to XRAM at this address, else -1 */
180 //  t_addr rx; /* read from XRAM at this address, else -1 */
181 //  t_addr wi; /* write to IRAM at this address, else -1 */
182 //  t_addr ri; /* read from IRAM at this address, else -1 */
183 //  t_addr ws; /* write to SFR at this address, else -1 */
184 //  t_addr rs; /* read from SFR at this address, else -1 */
185 //  t_addr rc; /* read from ROM at this address, else -1 */
186 //};
187
188 /* Interrupt levels */
189 //#define IT_NO         -1 /* not in interroupt service */
190 #define IT_LOW          1 /* low level interrupt service */
191 #define IT_HIGH         2 /* service of high priority interrupt */
192
193 /* cathegories of hw elements (peripherials) */
194 enum hw_cath {
195   HW_DUMMY      = 0x0000,
196   HW_TIMER      = 0x0002,
197   HW_UART       = 0x0004,
198   HW_PORT       = 0x0008,
199   HW_PCA        = 0x0010,
200   HW_INTERRUPT  = 0x0020,
201   HW_WDT        = 0x0040
202 };
203
204 // Events that can happen in peripherals
205 enum hw_event {
206   EV_OVERFLOW,
207   EV_PORT_CHANGED,
208   EV_T2_MODE_CHANGED
209 };
210
211 // flags of hw units
212 #define HWF_NONE        0
213 #define HWF_INSIDE      0x0001
214 #define HWF_OUTSIDE     0x0002
215 #define HWF_MISC        0x0004
216
217
218 #endif
219
220 /* End of stypes.h */