|
|
1.1 root 1: /*
2: * UAE - The Un*x Amiga Emulator
3: *
4: * Expansion Slots
5: *
6: * (c) 1996 Stefan Reinauer
7: */
8:
9: #include "sysconfig.h"
10: #include "sysdeps.h"
11:
12: #include "config.h"
13: #include "options.h"
14: #include "memory.h"
15: #include "custom.h"
16: #include "newcpu.h"
17:
18: /* 00 / 02 */
19:
20: #define MEM_8MB 0x00 /* Size of Memory Block */
21: #define MEM_4MB 0x07
22: #define MEM_2MB 0x06
23: #define MEM_1MB 0x05
24: #define MEM_512KB 0x04
25: #define MEM_256KB 0x03
26: #define MEM_128KB 0x02
27: #define MEM_64KB 0x01
28:
29: #define same_slot 0x08 /* Next card is in the same Slot */
30: #define rom_card 0x10 /* Card has valid ROM */
31: #define add_memory 0x20 /* Add Memory to List of Free Ram */
32:
33: #define generic 0xc0 /* Type of Expansion Card */
34: #define future1 0x00
35: #define future2 0x40
36: #define future3 0x80
37:
38: /* ********************************************************** */
39:
40: /* Card Data - Where can I get a complete List of these ???? */
41:
42: /* 04 - 06 & 10-16 */
43: #define commodore_g 513 /* Commodore Braunschweig (Germany) */
44: #define commodore 514 /* Commodore West Chester */
45: #define gvp 2017 /* GVP */
46:
47: #define commodore_a2091 3 /* A2091 / A590 Card from C= */
48: #define commodore_a2091_ram 10 /* A2091 / A590 Ram on HD-Card */
49: #define commodore_a2232 70 /* A2232 Multiport Expansion */
50:
51: #define gvp_series_2_scsi 11
52: #define gvp_iv_24_gfx 32
53:
54: /* ********************************************************** */
55: /* 08-0A */
56:
57: #define no_shutup 64 /* Card cannot receive Shut_up_forever */
58: #define care_addr 128 /* Adress HAS to be $200000-$9fffff */
59:
60: /* ********************************************************** */
61:
62: /* 40-42 */
63: #define enable_irq 1 /* enable Interrupt */
64: #define reset_card 4 /* Reset of Expansion Card */
65: #define card_int2 16 /* READ ONLY: IRQ 2 occured */
66: #define card_irq6 32 /* READ ONLY: IRQ 6 occured */
67: #define card_irq7 64 /* READ ONLY: IRQ 7 occured */
68: #define does_irq 128 /* READ ONLY: Karte loest ger. IRQ aus*/
69:
70: /* ********************************************************** */
71:
72: /* ROM defines */
73:
74: #define rom_4bit (0x00<<14) /* ROM width */
75: #define rom_8bit (0x01<<14)
76: #define rom_16bit (0x02<<14)
77:
78: #define rom_never (0x00<<12) /* Never run Boot Code */
79: #define rom_install (0x01<<12) /* run code at install time */
80: #define rom_binddrv (0x02<<12) /* run code with binddrivers */
81:
82: /* ********************************************************** */
83:
84: static void expamem_init_clear(void);
85: static void expamem_init_fastcard(void);
86: static void expamem_map_clear(void);
87: static void expamem_map_fastcard(void);
88:
89: void (*card_init[5])(void) = {
90: expamem_init_fastcard,
91: expamem_init_clear,
92: expamem_init_clear,
93: expamem_init_clear,
94: expamem_init_clear
95: };
96:
97: void (*card_map[5])(void) = {
98: expamem_map_fastcard,
99: expamem_map_clear,
100: expamem_map_clear,
101: expamem_map_clear,
102: expamem_map_clear
103: };
104:
105: int card = 0;
106:
107: /* **********************************************************
108: * Fast Memory
109: * ********************************************************** */
110:
111: static ULONG fastmem_start; /* Determined by the OS */
112: static UWORD *fastmemory = NULL;
113:
114: static ULONG fastmem_lget(CPTR) REGPARAM;
115: static UWORD fastmem_wget(CPTR) REGPARAM;
116: static UBYTE fastmem_bget(CPTR) REGPARAM;
117: static void fastmem_lput(CPTR, ULONG) REGPARAM;
118: static void fastmem_wput(CPTR, UWORD) REGPARAM;
119: static void fastmem_bput(CPTR, UBYTE) REGPARAM;
120: static int fastmem_check(CPTR addr, ULONG size) REGPARAM;
121: static UWORD *fastmem_xlate(CPTR addr) REGPARAM;
122:
123: addrbank fastmem_bank = {
124: fastmem_lget, fastmem_wget, fastmem_bget,
125: fastmem_lput, fastmem_wput, fastmem_bput,
126: fastmem_xlate, fastmem_check
127: };
128:
129: static ULONG fastmem_lget(CPTR addr)
130: {
131: addr -= fastmem_start & (fastmem_size-1);
132: addr &= fastmem_size-1;
133: return ((ULONG)fastmemory[addr >> 1] << 16) | fastmemory[(addr >> 1)+1];
134: }
135:
136: static UWORD fastmem_wget(CPTR addr)
137: {
138: addr -= fastmem_start & (fastmem_size-1);
139: addr &= fastmem_size-1;
140: return fastmemory[addr >> 1];
141: }
142:
143: static UBYTE fastmem_bget(CPTR addr)
144: {
145: UWORD data;
146: addr -= fastmem_start & (fastmem_size-1);
147:
148: addr &= fastmem_size-1;
149: data = fastmemory[addr >> 1];
150: return addr & 1 ? data : data >> 8;
151: }
152:
153: static void fastmem_lput(CPTR addr, ULONG l)
154: {
155: addr -= fastmem_start & (fastmem_size-1);
156: addr &= fastmem_size-1;
157: fastmemory[addr >> 1] = l >> 16;
158: fastmemory[(addr >> 1)+1] = (UWORD)l;
159: }
160:
161: static void fastmem_wput(CPTR addr, UWORD w)
162: {
163: addr -= fastmem_start & (fastmem_size-1);
164: addr &= fastmem_size-1;
165: fastmemory[addr >> 1] = w;
166:
167: }
168:
169: static void fastmem_bput(CPTR addr, UBYTE b)
170: {
171: addr -= fastmem_start & (fastmem_size-1);
172: addr &= fastmem_size-1;
173: if (!(addr & 1)) {
174: fastmemory[addr>>1] = (fastmemory[addr>>1] & 0xff) | (((UWORD)b) << 8);
175: } else {
176: fastmemory[addr>>1] = (fastmemory[addr>>1] & 0xff00) | b;
177: }
178:
179: }
180:
181: static int fastmem_check(CPTR addr, ULONG size)
182: {
183: addr -= fastmem_start & (fastmem_size-1);
184: addr &= fastmem_size-1;
185: return (addr + size) < fastmem_size;
186: }
187:
188: static UWORD *fastmem_xlate(CPTR addr)
189: {
190: addr -= fastmem_start & (fastmem_size-1);
191: addr &= fastmem_size-1;
192: return fastmemory + (addr >> 1);
193: }
194: /* ******************************************************* */
195:
196: /* Autoconfig address space at 0xE80000 */
197: static UWORD expamem[0x8000];
198:
199: static UBYTE expamem_lo;
200: static UBYTE expamem_hi;
201:
202: static ULONG expamem_lget(CPTR) REGPARAM;
203: static UWORD expamem_wget(CPTR) REGPARAM;
204: static UBYTE expamem_bget(CPTR) REGPARAM;
205: static void expamem_lput(CPTR, ULONG) REGPARAM;
206: static void expamem_wput(CPTR, UWORD) REGPARAM;
207: static void expamem_bput(CPTR, UBYTE) REGPARAM;
208:
209: static void expamem_write(CPTR addr, UBYTE value)
210: {
211: addr &= 0xffff;
212: expamem[(addr >> 1)] = (value & 0xf0) << 8;
213: expamem[(addr >> 1)+1] = (value & 0x0f) << 12;
214: }
215:
216: addrbank expamem_bank = {
217: expamem_lget, expamem_wget, expamem_bget,
218: expamem_lput, expamem_wput, expamem_bput,
219: default_xlate, default_check
220: };
221:
222: static ULONG expamem_lget(CPTR addr)
223: {
224: fprintf(stderr,"warning: READ.L from address $%lx \n",addr);
225: return 0xffffffff;
226: }
227:
228: static UWORD expamem_wget(CPTR addr)
229: {
230: fprintf(stderr,"warning: READ.W from address $%lx \n",addr);
231: return 0xffff;
232: }
233:
234: static UBYTE expamem_bget(CPTR addr)
235: {
236: UBYTE value;
237: addr &= 0xFFFF;
238: value = (expamem[addr >> 1] >> (addr & 1 ? 0 : 8));
239: if (addr==00 || addr==02 || addr==0x40 || addr==0x42)
240: return value;
241: return ~value;
242: }
243:
244: static void expamem_lput(CPTR addr, ULONG value)
245: {
246: fprintf(stderr,"warning: WRITE.L to address $%lx : value $%lx\n",addr,value);
247: }
248:
249: static void expamem_wput(CPTR addr, UWORD value)
250: {
251: fprintf(stderr,"warning: WRITE.W to address $%lx : value $%x\n",addr,value);
252: }
253:
254: static void expamem_bput(CPTR addr, UBYTE value)
255: {
256: switch (addr&0xff) {
257: case 0x30:
258: case 0x32:
259: expamem_hi = 0;
260: expamem_lo = 0;
261: expamem_write (0x48, 0x00);
262: break;
263:
264: case 0x48:
265: expamem_hi = value;
266: (*card_map[card])();
267: fprintf (stderr," Card %d done.\n",card+1);
268: ++card;
269: if (card<=5) (*card_init[card])();
270: else expamem_init_clear();
271: break;
272:
273: case 0x4a:
274: expamem_lo = value;
275: break;
276:
277: case 0x4c:
278: fprintf (stderr," Card %d had no success.\n",card+1);
279: ++card;
280: if (card<=5) (*card_init[card])();
281: else expamem_init_clear();
282: break;
283: }
284: }
285:
286: void expamem_reset()
287: {
288: card = 0;
289: (*card_init[card])();
290: }
291:
292: /* ***************************************************************
293: * Expansion Card (ZORRO II) for 1/2/4/8 MB of Fast Memory
294: * *************************************************************** */
295:
296: void expamem_map_fastcard()
297: {
298: if (fastmemory == NULL)
299: fastmemory = (UWORD *)malloc(fastmem_size);
300: fastmem_start=((expamem_hi|(expamem_lo>>4))<<16);
301: map_banks(fastmem_bank,fastmem_start>>16,fastmem_size>>16);
302: fprintf (stderr,"Fastcard: mapped @$%lx: %dMB fast memory\n",fastmem_start, fastmem_size >>20);
303: }
304:
305: void expamem_init_fastcard()
306: {
307: if (fastmem_size == 0) {
308: ++card;
309: if (card<=5) (*card_init[card])();
310: else expamem_init_clear();
311: return;
312: }
313: expamem_init_clear();
314: if (fastmem_size==0x100000)
315: expamem_write (0x00, MEM_1MB+add_memory+generic);
316: else if (fastmem_size==0x200000)
317: expamem_write (0x00, MEM_2MB+add_memory+generic);
318: else if (fastmem_size==0x400000)
319: expamem_write (0x00, MEM_4MB+add_memory+generic);
320: else if (fastmem_size==0x800000)
321: expamem_write (0x00, MEM_8MB+add_memory+generic);
322:
323: expamem_write (0x08, care_addr);
324:
325: expamem_write (0x04, commodore_a2091_ram);
326: expamem_write (0x10, commodore>>8);
327: expamem_write (0x14, commodore & 0x0f);
328:
329: expamem_write (0x18, 0x00); /* ser.no. Byte 0 */
330: expamem_write (0x1c, 0x00); /* ser.no. Byte 1 */
331: expamem_write (0x20, 0x00); /* ser.no. Byte 2 */
332: expamem_write (0x24, 0x01); /* ser.no. Byte 3 */
333:
334: expamem_write (0x28, 0x00); /* Rom-Offset hi */
335: expamem_write (0x2c, 0x00); /* ROM-Offset lo */
336:
337: expamem_write (0x40, 0x00); /* Ctrl/Statusreg.*/
338: }
339:
340: /* *********************************************************
341: * Dummy Entries to show that there's no card in a slot
342: * ********************************************************* */
343:
344: void expamem_map_clear()
345: {
346: /* nothing to do here */
347: }
348:
349: void expamem_init_clear()
350: {
351: memset (expamem,0,sizeof expamem);
352: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.