-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathautoconf.c
executable file
·232 lines (181 loc) · 4.51 KB
/
autoconf.c
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
/*
* UAE - The Un*x Amiga Emulator
*
* AutoConfig devices
*
* Copyright 1995, 1996 Bernd Schmidt
* Copyright 1996 Ed Hanway
*/
#include "sysconfig.h"
#include "sysdeps.h"
#include "options.h"
#include "uae.h"
#include "memory.h"
#include "custom.h"
#include "events.h"
#include "newcpu.h"
#include "autoconf.h"
#include "traps.h"
#include "version.h"
/* Commonly used autoconfig strings */
uaecptr EXPANSION_explibname, EXPANSION_doslibname, EXPANSION_uaeversion;
uaecptr EXPANSION_uaedevname, EXPANSION_explibbase = 0, EXPANSION_haveV36;
uaecptr EXPANSION_bootcode, EXPANSION_nullfunc;
uaecptr EXPANSION_cddevice;
/* ROM tag area memory access */
static uae_u8 *rtarea;
static uae_u32 rtarea_lget (uaecptr) REGPARAM;
static uae_u32 rtarea_wget (uaecptr) REGPARAM;
static uae_u32 rtarea_bget (uaecptr) REGPARAM;
static void rtarea_lput (uaecptr, uae_u32) REGPARAM;
static void rtarea_wput (uaecptr, uae_u32) REGPARAM;
static void rtarea_bput (uaecptr, uae_u32) REGPARAM;
static uae_u8 *rtarea_xlate (uaecptr) REGPARAM;
addrbank rtarea_bank = {
rtarea_lget, rtarea_wget, rtarea_bget,
rtarea_lput, rtarea_wput, rtarea_bput,
rtarea_xlate, default_check, NULL
};
uae_u8 REGPARAM2 *rtarea_xlate (uaecptr addr)
{
addr &= 0xFFFF;
return rtarea + addr;
}
uae_u32 REGPARAM2 rtarea_lget (uaecptr addr)
{
addr &= 0xFFFF;
return (uae_u32)(rtarea_wget (addr) << 16) + rtarea_wget (addr+2);
}
uae_u32 REGPARAM2 rtarea_wget (uaecptr addr)
{
addr &= 0xFFFF;
return (rtarea[addr]<<8) + rtarea[addr+1];
}
uae_u32 REGPARAM2 rtarea_bget (uaecptr addr)
{
addr &= 0xFFFF;
return rtarea[addr];
}
void REGPARAM2 rtarea_lput (uaecptr addr, uae_u32 value)
{
}
void REGPARAM2 rtarea_wput (uaecptr addr, uae_u32 value)
{
}
void REGPARAM2 rtarea_bput (uaecptr addr, uae_u32 value)
{
}
/* some quick & dirty code to fill in the rt area and save me a lot of
* scratch paper
*/
static int rt_addr;
static int rt_straddr;
uae_u32 addr (int ptr)
{
return (uae_u32)ptr + RTAREA_BASE;
}
void db (uae_u8 data)
{
rtarea[rt_addr++] = data;
}
void dw (uae_u16 data)
{
rtarea[rt_addr++] = (uae_u8)(data >> 8);
rtarea[rt_addr++] = (uae_u8)data;
}
void dl (uae_u32 data)
{
rtarea[rt_addr++] = data >> 24;
rtarea[rt_addr++] = data >> 16;
rtarea[rt_addr++] = data >> 8;
rtarea[rt_addr++] = data;
}
/* store strings starting at the end of the rt area and working
* backward. store pointer at current address
*/
uae_u32 ds (const char *str)
{
int len = strlen (str) + 1;
rt_straddr -= len;
strcpy ((char *)rtarea + rt_straddr, str);
return addr (rt_straddr);
}
void calltrap (uae_u32 n)
{
dw (0xA000 + n);
}
void org (uae_u32 a)
{
rt_addr = a - RTAREA_BASE;
}
uae_u32 here (void)
{
return addr (rt_addr);
}
void align (int b)
{
rt_addr = (rt_addr + b - 1) & ~(b - 1);
}
static uae_u32 REGPARAM2 nullfunc (TrapContext *context)
{
write_log ("Null function called\n");
return 0;
}
static uae_u32 REGPARAM2 getchipmemsize (TrapContext *context)
{
return allocated_chipmem;
}
static uae_u32 REGPARAM2 uae_puts (TrapContext *context)
{
puts ((char *)get_real_address (m68k_areg (&context->regs, 0)));
return 0;
}
static void rtarea_init_mem (void)
{
rtarea = mapped_malloc (0x10000, "rtarea");
if (!rtarea) {
write_log ("virtual memory exhausted (rtarea)!\n");
abort ();
}
rtarea_bank.baseaddr = rtarea;
}
void rtarea_init (void)
{
uae_u32 a;
char uaever[100];
rt_straddr = 0xFF00 - 2;
rt_addr = 0;
init_traps ();
rtarea_init_mem ();
sprintf (uaever, "uae-%d.%d.%d", UAEMAJOR, UAEMINOR, UAESUBREV);
EXPANSION_uaeversion = ds (uaever);
EXPANSION_explibname = ds ("expansion.library");
EXPANSION_doslibname = ds ("dos.library");
EXPANSION_uaedevname = ds ("uae.device");
deftrap (NULL); /* Generic emulator trap */
EXPANSION_nullfunc = here ();
calltrap (deftrap (nullfunc));
dw (RTS);
a = here();
/* Dummy trap - removing this breaks the filesys emulation. */
org (RTAREA_BASE + 0xFF00);
calltrap (deftrap2 (nullfunc, TRAPFLAG_NO_RETVAL, ""));
org (RTAREA_BASE + 0xFF80);
calltrap (deftrap2 (getchipmemsize, TRAPFLAG_DORET, ""));
org (RTAREA_BASE + 0xFF10);
calltrap (deftrap2 (uae_puts, TRAPFLAG_NO_RETVAL, ""));
dw (RTS);
org (a);
#ifdef FILESYS
filesys_install_code ();
#endif
init_extended_traps ();
}
volatile int uae_int_requested = 0;
void set_uae_int_flag (void)
{
rtarea[0xFFFB] = uae_int_requested;
}
void rtarea_setup (void)
{
}