]> git.sesse.net Git - pistorm/blob - platforms/amiga/amiga-platform.c
Fix config reload?
[pistorm] / platforms / amiga / amiga-platform.c
1 // SPDX-License-Identifier: MIT
2
3 #include <stdio.h>
4 #include <stdlib.h>
5 #include <string.h>
6 #include <ctype.h>
7 #include "amiga-autoconf.h"
8 #include "amiga-registers.h"
9 #include "hunk-reloc.h"
10 #include "net/pi-net-enums.h"
11 #include "net/pi-net.h"
12 #include "piscsi/piscsi-enums.h"
13 #include "piscsi/piscsi.h"
14 #include "pistorm-dev/pistorm-dev-enums.h"
15 #include "pistorm-dev/pistorm-dev.h"
16 #include "platforms/platforms.h"
17 #include "platforms/shared/rtc.h"
18 #include "rtg/rtg.h"
19 #include "a314/a314.h"
20
21 //#define DEBUG_AMIGA_PLATFORM
22
23 #ifdef DEBUG_AMIGA_PLATFORM
24 #define DEBUG printf
25 #else
26 #define DEBUG(...)
27 #endif
28
29 int handle_register_read_amiga(unsigned int addr, unsigned char type, unsigned int *val);
30 int handle_register_write_amiga(unsigned int addr, unsigned int value, unsigned char type);
31
32 extern int ac_z2_current_pic;
33 extern int ac_z2_done;
34 extern int ac_z2_pic_count;
35 extern int ac_z2_type[AC_PIC_LIMIT];
36 extern int ac_z2_index[AC_PIC_LIMIT];
37
38 extern int ac_z3_current_pic;
39 extern int ac_z3_pic_count;
40 extern int ac_z3_done;
41 extern int ac_z3_type[AC_PIC_LIMIT];
42 extern int ac_z3_index[AC_PIC_LIMIT];
43 extern uint8_t gayle_emulation_enabled;
44
45 char *z2_autoconf_id = "z2_autoconf_fast";
46 char *z2_autoconf_zap_id = "^2_autoconf_fast";
47 char *z3_autoconf_id = "z3_autoconf_fast";
48 char *z3_autoconf_zap_id = "^3_autoconf_fast";
49
50 extern const char *op_type_names[OP_TYPE_NUM];
51 extern uint8_t cdtv_mode;
52 extern uint8_t rtc_type;
53 extern unsigned char cdtv_sram[32 * SIZE_KILO];
54 extern unsigned int a314_base;
55
56 #define min(a, b) (a < b) ? a : b
57 #define max(a, b) (a > b) ? a : b
58
59 uint8_t rtg_enabled = 0, piscsi_enabled = 0, pinet_enabled = 0, kick13_mode = 0, pistorm_dev_enabled = 1;
60 uint8_t a314_emulation_enabled = 0, a314_initialized = 0;
61
62 extern uint32_t piscsi_base, pistorm_dev_base;
63
64 extern void stop_cpu_emulation(uint8_t disasm_cur);
65
66 inline int custom_read_amiga(struct emulator_config *cfg, unsigned int addr, unsigned int *val, unsigned char type) {
67     if (kick13_mode)
68         ac_z3_done = 1;
69
70     if ((!ac_z2_done || !ac_z3_done) && addr >= AC_Z2_BASE && addr < AC_Z2_BASE + AC_SIZE) {
71         if (!ac_z2_done && ac_z2_current_pic < ac_z2_pic_count) {
72             if (type == OP_TYPE_BYTE) {
73                 *val = autoconfig_read_memory_8(cfg, addr - AC_Z2_BASE);
74                 return 1;
75             }
76             printf("Unexpected %s read from Z2 autoconf addr %.X\n", op_type_names[type], addr - AC_Z2_BASE);
77             return -1;
78         }
79         if (!ac_z3_done && ac_z3_current_pic < ac_z3_pic_count) {
80             uint32_t addr_ = addr - AC_Z2_BASE;
81             if (addr_ & 0x02) {
82                 addr_ = (addr_ - 2) + 0x100;
83             }
84             if (type == OP_TYPE_BYTE) {
85                 *val = autoconfig_read_memory_z3_8(cfg, addr_ - AC_Z2_BASE);
86                 return 1;
87             }
88             printf("Unexpected %s read from Z3 autoconf addr %.X\n", op_type_names[type], addr - AC_Z2_BASE);
89             return -1;
90         }
91     }
92     if (!ac_z3_done && addr >= AC_Z3_BASE && addr < AC_Z3_BASE + AC_SIZE) {
93         if (ac_z3_pic_count == 0) {
94             ac_z3_done = 1;
95             return -1;
96         }
97
98         if (type == OP_TYPE_BYTE) {
99             *val = autoconfig_read_memory_z3_8(cfg, addr - AC_Z3_BASE);
100             return 1;
101         }
102         printf("Unexpected %s read from Z3 autoconf addr %.X\n", op_type_names[type], addr - AC_Z3_BASE);
103         return -1;
104     }
105
106     if (pistorm_dev_enabled && addr >= pistorm_dev_base && addr < pistorm_dev_base + (64 * SIZE_KILO)) {
107         *val = handle_pistorm_dev_read(addr, type);
108         return 1;
109     }
110
111     if (piscsi_enabled && addr >= piscsi_base && addr < piscsi_base + (64 * SIZE_KILO)) {
112         //printf("[Amiga-Custom] %s read from PISCSI base @$%.8X.\n", op_type_names[type], addr);
113         //stop_cpu_emulation(1);
114         *val = handle_piscsi_read(addr, type);
115         return 1;
116     }
117
118     if (a314_emulation_enabled && addr >= a314_base && addr < a314_base + (64 * SIZE_KILO)) {
119         //printf("%s read from A314 @$%.8X\n", op_type_names[type], addr);
120         switch (type) {
121             case OP_TYPE_BYTE:
122                 *val = a314_read_memory_8(addr - a314_base);
123                 return 1;
124                 break;
125             case OP_TYPE_WORD:
126                 *val = a314_read_memory_16(addr - a314_base);
127                 return 1;                
128                 break;
129             case OP_TYPE_LONGWORD:
130                 *val = a314_read_memory_32(addr - a314_base);
131                 return 1;
132                 break;
133             default:
134                 break;
135         }
136         return 1;
137     }
138
139     return -1;
140 }
141
142 inline int custom_write_amiga(struct emulator_config *cfg, unsigned int addr, unsigned int val, unsigned char type) {
143     if (kick13_mode)
144         ac_z3_done = 1;
145
146     if ((!ac_z2_done || !ac_z3_done) && addr >= AC_Z2_BASE && addr < AC_Z2_BASE + AC_SIZE) {
147         if (!ac_z2_done && ac_z2_current_pic < ac_z2_pic_count) {
148             if (type == OP_TYPE_BYTE) {
149                 autoconfig_write_memory_8(cfg, addr - AC_Z2_BASE, val);
150                 return 1;
151             }
152             printf("Unexpected %s write to Z2 autoconf addr %.X\n", op_type_names[type], addr - AC_Z2_BASE);
153             return -1;
154         }
155         if (!ac_z3_done && ac_z3_current_pic < ac_z3_pic_count) {
156             uint32_t addr_ = addr - AC_Z2_BASE;
157             if (addr_ & 0x02) {
158                 addr_ = (addr_ - 2) + 0x100;
159             }
160             if (type == OP_TYPE_BYTE) {
161                 autoconfig_write_memory_z3_8(cfg, addr_ - AC_Z2_BASE, val);
162                 return 1;
163             }
164             else if (type == OP_TYPE_WORD) {
165                 autoconfig_write_memory_z3_16(cfg, addr_ - AC_Z2_BASE, val);
166                 return 1;
167             }
168             printf("Unexpected %s write to Z3 autoconf addr %.X\n", op_type_names[type], addr - AC_Z2_BASE);
169             return -1;
170         }
171     }
172
173     if (!ac_z3_done && addr >= AC_Z3_BASE && addr < AC_Z3_BASE + AC_SIZE) {
174         if (type == OP_TYPE_BYTE) {
175             if (ac_z3_pic_count == 0) {
176                 ac_z3_done = 1;
177                 return -1;
178             }
179
180             //printf("Write to autoconf area.\n");
181             autoconfig_write_memory_z3_8(cfg, addr - AC_Z3_BASE, val);
182             return 1;
183         }
184         else if (type == OP_TYPE_WORD) {
185             autoconfig_write_memory_z3_16(cfg, addr - AC_Z3_BASE, val);
186             return 1;
187         }
188         else {
189             printf("Unexpected %s write to Z3 autoconf addr %.X\n", op_type_names[type], addr - AC_Z3_BASE);
190             //stop_emulation();
191         }
192     }
193
194     if (pistorm_dev_enabled && addr >= pistorm_dev_base && addr < pistorm_dev_base + (64 * SIZE_KILO)) {
195         handle_pistorm_dev_write(addr, val, type);
196         return 1;
197     }
198
199     if (piscsi_enabled && addr >= piscsi_base && addr < piscsi_base + (64 * SIZE_KILO)) {
200         //printf("[Amiga-Custom] %s write to PISCSI base @$%.8x: %.8X\n", op_type_names[type], addr, val);
201         handle_piscsi_write(addr, val, type);
202         return 1;
203     }
204
205     if (a314_emulation_enabled && addr >= a314_base && addr < a314_base + (64 * SIZE_KILO)) {
206         //printf("%s write to A314 @$%.8X: %d\n", op_type_names[type], addr, val);
207         switch (type) {
208             case OP_TYPE_BYTE:
209                 a314_write_memory_8(addr - a314_base, val);
210                 return 1;
211                 break;
212             case OP_TYPE_WORD:
213                 // Not implemented in a314.cc
214                 //a314_write_memory_16(addr, val);
215                 return -1;
216                 break;
217             case OP_TYPE_LONGWORD:
218                 // Not implemented in a314.cc
219                 // a314_write_memory_32(addr, val);
220                 return -1;
221                 break;
222             default:
223                 break;
224         }
225     }
226
227     return -1;
228 }
229
230 void adjust_ranges_amiga(struct emulator_config *cfg) {
231     cfg->mapped_high = 0;
232     cfg->mapped_low = 0;
233     cfg->custom_high = 0;
234     cfg->custom_low = 0;
235
236     // Set up the min/max ranges for mapped reads/writes
237     for (int i = 0; i < MAX_NUM_MAPPED_ITEMS; i++) {
238         if (cfg->map_type[i] != MAPTYPE_NONE) {
239             if ((cfg->map_offset[i] != 0 && cfg->map_offset[i] < cfg->mapped_low) || cfg->mapped_low == 0)
240                 cfg->mapped_low = cfg->map_offset[i];
241             if (cfg->map_offset[i] + cfg->map_size[i] > cfg->mapped_high)
242                 cfg->mapped_high = cfg->map_offset[i] + cfg->map_size[i];
243         }
244     }
245
246     if ((ac_z2_pic_count || ac_z3_pic_count) && (!ac_z2_done || !ac_z3_done)) {
247         if (cfg->custom_low == 0)
248             cfg->custom_low = AC_Z2_BASE;
249         else
250             cfg->custom_low = min(cfg->custom_low, AC_Z2_BASE);
251         cfg->custom_high = max(cfg->custom_high, AC_Z2_BASE + AC_SIZE);
252     }
253     /*if (ac_z3_pic_count && !ac_z3_done) {
254         if (cfg->custom_low == 0)
255             cfg->custom_low = AC_Z3_BASE;
256         else
257             cfg->custom_low = min(cfg->custom_low, AC_Z3_BASE);
258         cfg->custom_high = max(cfg->custom_high, AC_Z3_BASE + AC_SIZE);
259     }*/
260     if (rtg_enabled) {
261         if (cfg->custom_low == 0)
262             cfg->custom_low = PIGFX_RTG_BASE;
263         else
264             cfg->custom_low = min(cfg->custom_low, PIGFX_RTG_BASE);
265         cfg->custom_high = max(cfg->custom_high, PIGFX_UPPER);
266     }
267     if (piscsi_enabled) {
268         if (cfg->custom_low == 0)
269             cfg->custom_low = PISCSI_OFFSET;
270         else
271             cfg->custom_low = min(cfg->custom_low, PISCSI_OFFSET);
272         cfg->custom_high = max(cfg->custom_high, PISCSI_UPPER);
273         if (piscsi_base != 0) {
274             cfg->custom_low = min(cfg->custom_low, piscsi_base);
275         }
276     }
277     if (pinet_enabled) {
278         if (cfg->custom_low == 0)
279             cfg->custom_low = PINET_OFFSET;
280         else
281             cfg->custom_low = min(cfg->custom_low, PINET_OFFSET);
282         cfg->custom_high = max(cfg->custom_high, PINET_UPPER);
283     }
284
285     printf("Platform custom range: %.8X-%.8X\n", cfg->custom_low, cfg->custom_high);
286     printf("Platform mapped range: %.8X-%.8X\n", cfg->mapped_low, cfg->mapped_high);
287 }
288
289 int setup_platform_amiga(struct emulator_config *cfg) {
290     printf("Performing setup for Amiga platform.\n");
291
292     if (strlen(cfg->platform->subsys)) {
293         printf("Subsystem is [%s]\n", cfg->platform->subsys);
294         if (strcmp(cfg->platform->subsys, "4000") == 0 || strcmp(cfg->platform->subsys, "3000") == 0) {
295             printf("Adjusting Gayle accesses for A3000/4000 Kickstart.\n");
296             adjust_gayle_4000();
297         }
298         else if (strcmp(cfg->platform->subsys, "1200") == 0 || strcmp(cfg->platform->subsys, "cd32") == 0) {
299             printf("Adjusting Gayle accesses for A1200/CD32 Kickstart.\n");
300             adjust_gayle_1200();
301         }
302         else if (strcmp(cfg->platform->subsys, "cdtv") == 0) {
303             printf("Configuring platform for CDTV emulation.\n");
304             cdtv_mode = 1;
305             rtc_type = RTC_TYPE_MSM;
306         }
307     }
308     else
309         printf("No sub system specified.\n");
310
311     // Look for Z2 autoconf Fast RAM by id
312     int index = get_named_mapped_item(cfg, z2_autoconf_id);
313     more_z2_fast:;
314     if (index != -1) {
315         // "Zap" config items as they are processed.
316         cfg->map_id[index][0] = '^';
317         int resize_data = 0;
318         if (cfg->map_size[index] > 8 * SIZE_MEGA) {
319             printf("Attempted to configure more than 8MB of Z2 Fast RAM, downsizing to 8MB.\n");
320             resize_data = 8 * SIZE_MEGA;
321         }
322         else if(cfg->map_size[index] != 2 * SIZE_MEGA && cfg->map_size[index] != 4 * SIZE_MEGA && cfg->map_size[index] != 8 * SIZE_MEGA) {
323             printf("Z2 Fast RAM may only provision 2, 4 or 8MB of memory, resizing to ");
324             if (cfg->map_size[index] > 8 * SIZE_MEGA)
325                 resize_data = 8 * SIZE_MEGA;
326             else if (cfg->map_size[index] > 4 * SIZE_MEGA)
327                 resize_data = 4 * SIZE_MEGA;
328             else
329                 resize_data = 2 * SIZE_MEGA;
330             printf("%dMB.\n", resize_data / SIZE_MEGA);
331         }
332         if (resize_data) {
333             free(cfg->map_data[index]);
334             cfg->map_size[index] = resize_data;
335             cfg->map_data[index] = (unsigned char *)malloc(cfg->map_size[index]);
336         }
337         printf("%dMB of Z2 Fast RAM configured at $%lx\n", cfg->map_size[index] / SIZE_MEGA, cfg->map_offset[index]);
338         add_z2_pic(ACTYPE_MAPFAST_Z2, index);
339         //ac_z2_type[ac_z2_pic_count] = ACTYPE_MAPFAST_Z2;
340         //ac_z2_index[ac_z2_pic_count] = index;
341         //ac_z2_pic_count++;
342     }
343     else
344         printf("No Z2 Fast RAM configured.\n");
345
346     index = get_named_mapped_item(cfg, z2_autoconf_id);
347     if (index != -1)
348         goto more_z2_fast;
349
350     for (int i = 0; i < MAX_NUM_MAPPED_ITEMS; i ++) {
351         // Restore any "zapped" autoconf items so they can be reinitialized if needed.
352         if (cfg->map_id[i] && strcmp(cfg->map_id[i], z2_autoconf_zap_id) == 0) {
353             cfg->map_id[i][0] = z2_autoconf_id[0];
354         }
355     }
356
357     index = get_named_mapped_item(cfg, z3_autoconf_id);
358     more_z3_fast:;
359     if (index != -1) {
360         cfg->map_id[index][0] = '^';
361         printf("%dMB of Z3 Fast RAM configured at $%lx\n", cfg->map_size[index] / SIZE_MEGA, cfg->map_offset[index]);
362         ac_z3_type[ac_z3_pic_count] = ACTYPE_MAPFAST_Z3;
363         ac_z3_index[ac_z3_pic_count] = index;
364         ac_z3_pic_count++;
365     }
366     else
367         printf("No Z3 Fast RAM configured.\n");
368     index = get_named_mapped_item(cfg, z3_autoconf_id);
369     if (index != -1)
370         goto more_z3_fast;
371     for (int i = 0; i < MAX_NUM_MAPPED_ITEMS; i++) {
372         if (cfg->map_id[i] && strcmp(cfg->map_id[i], z3_autoconf_zap_id) == 0) {
373             cfg->map_id[i][0] = z3_autoconf_id[0];
374         }
375     }
376
377     index = get_named_mapped_item(cfg, "cpu_slot_ram");
378     if (index != -1) {
379         m68k_add_ram_range((uint32_t)cfg->map_offset[index], (uint32_t)cfg->map_high[index], cfg->map_data[index]);
380     }
381
382     adjust_ranges_amiga(cfg);
383
384     if (cdtv_mode) {
385         FILE *in = fopen("data/cdtv.sram", "rb");
386         if (in != NULL) {
387             printf("Loaded CDTV SRAM.\n");
388             fread(cdtv_sram, 32 * SIZE_KILO, 1, in);
389             fclose(in);
390         }
391     }
392
393     if (pistorm_dev_enabled) {
394         add_z2_pic(ACTYPE_PISTORM_DEV, 0);
395     }
396
397     return 0;
398 }
399
400 #define CHKVAR(a) (strcmp(var, a) == 0)
401
402 void setvar_amiga(struct emulator_config *cfg, char *var, char *val) {
403     if (!var)
404         return;
405
406     if CHKVAR("enable_rtc_emulation") {
407         int8_t rtc_enabled = 0;
408         if (!val || strlen(val) == 0)
409             rtc_enabled = 1;
410         else {
411             rtc_enabled = get_int(val);
412         }
413         if (rtc_enabled != -1) {
414             configure_rtc_emulation_amiga(rtc_enabled);
415         }
416     }
417     if CHKVAR("hdd0") {
418         if (val && strlen(val) != 0)
419             set_hard_drive_image_file_amiga(0, val);
420     }
421     if CHKVAR("hdd1") {
422         if (val && strlen(val) != 0)
423             set_hard_drive_image_file_amiga(1, val);
424     }
425     if CHKVAR("cdtv") {
426         printf("[AMIGA] CDTV mode enabled.\n");
427         cdtv_mode = 1;
428     }
429     if (CHKVAR("rtg") && !rtg_enabled) {
430         if (init_rtg_data(cfg)) {
431             printf("[AMIGA] RTG Enabled.\n");
432             rtg_enabled = 1;
433             adjust_ranges_amiga(cfg);
434         }
435         else
436             printf("[AMIGA} Failed to enable RTG.\n");
437     }
438     if CHKVAR("kick13") {
439         printf("[AMIGA] Kickstart 1.3 mode enabled, Z3 PICs will not be enumerated.\n");
440         kick13_mode = 1;
441     }
442     if CHKVAR("a314") {
443         if (!a314_initialized) {
444             int32_t res = a314_init();
445             if (res != 0) {
446                 printf("[AMIGA] Failed to enable A314 emulation, error return code: %d.\n", res);
447             } else {
448                 printf("[AMIGA] A314 emulation enabled.\n");
449                 add_z2_pic(ACTYPE_A314, 0);
450                 a314_emulation_enabled = 1;
451                 a314_initialized = 1;
452             }
453         } else {
454             add_z2_pic(ACTYPE_A314, 0);
455             a314_emulation_enabled = 1;
456         }
457     }
458     if CHKVAR("a314_conf") {
459         if (val && strlen(val) != 0) {
460             a314_set_config_file(val);
461         }
462     }
463
464     // PiSCSI stuff
465     if (CHKVAR("piscsi") && !piscsi_enabled) {
466         printf("[AMIGA] PISCSI Interface Enabled.\n");
467         piscsi_enabled = 1;
468         piscsi_init();
469         add_z2_pic(ACTYPE_PISCSI, 0);
470         adjust_ranges_amiga(cfg);
471     }
472     if (piscsi_enabled) {
473         if CHKVAR("piscsi0") {
474             piscsi_map_drive(val, 0);
475         }
476         if CHKVAR("piscsi1") {
477             piscsi_map_drive(val, 1);
478         }
479         if CHKVAR("piscsi2") {
480             piscsi_map_drive(val, 2);
481         }
482         if CHKVAR("piscsi3") {
483             piscsi_map_drive(val, 3);
484         }
485         if CHKVAR("piscsi4") {
486             piscsi_map_drive(val, 4);
487         }
488         if CHKVAR("piscsi5") {
489             piscsi_map_drive(val, 5);
490         }
491         if CHKVAR("piscsi6") {
492             piscsi_map_drive(val, 6);
493         }
494     }
495
496     // Pi-Net stuff
497     if (CHKVAR("pi-net")&& !pinet_enabled) {
498         printf("[AMIGA] PI-NET Interface Enabled.\n");
499         pinet_enabled = 1;
500         pinet_init(val);
501         adjust_ranges_amiga(cfg);
502     }
503
504     if CHKVAR("no-pistorm-dev") {
505         pistorm_dev_enabled = 0;
506         printf("[AMIGA] Disabling PiStorm interaction device.\n");
507     }
508
509     // RTC stuff
510     if CHKVAR("rtc_type") {
511         if (val && strlen(val) != 0) {
512             if (strcmp(val, "msm") == 0) {
513                 printf("[AMIGA] RTC type set to MSM.\n");
514                 rtc_type = RTC_TYPE_MSM;
515             }
516             else {
517                 printf("[AMIGA] RTC type set to Ricoh.\n");
518                 rtc_type = RTC_TYPE_RICOH;
519             }
520         }
521     }
522 }
523
524 void handle_reset_amiga(struct emulator_config *cfg) {
525     ac_z2_done = (ac_z2_pic_count == 0);
526     ac_z3_done = (ac_z3_pic_count == 0);
527     ac_z2_current_pic = 0;
528     ac_z3_current_pic = 0;
529
530     DEBUG("[AMIGA] Reset handler.\n");
531     DEBUG("[AMIGA] AC done - Z2: %d Z3: %d.\n", ac_z2_done, ac_z3_done);
532
533     if (piscsi_enabled)
534         piscsi_refresh_drives();
535
536     adjust_ranges_amiga(cfg);
537 }
538
539 void shutdown_platform_amiga(struct emulator_config *cfg) {
540     printf("[AMIGA] Performing Amiga platform shutdown.\n");
541     if (cfg) {}
542     if (cdtv_mode) {
543         FILE *out = fopen("data/cdtv.sram", "wb+");
544         if (out != NULL) {
545             printf("Saving CDTV SRAM.\n");
546             fwrite(cdtv_sram, 32 * SIZE_KILO, 1, out);
547             fclose(out);
548         }
549         else {
550             printf("Failed to write CDTV SRAM to disk.\n");
551         }
552     }
553     if (cfg->platform->subsys) {
554         free(cfg->platform->subsys);
555         cfg->platform->subsys = NULL;
556     }
557     if (piscsi_enabled) {
558         piscsi_shutdown();
559         piscsi_enabled = 0;
560     }
561     if (rtg_enabled) {
562         shutdown_rtg();
563         rtg_enabled = 0;
564     }
565     if (pinet_enabled) {
566         pinet_enabled = 0;
567     }
568     if (a314_emulation_enabled) {
569         a314_emulation_enabled = 0;
570     }
571
572     cdtv_mode = 0;
573
574     autoconfig_reset_all();
575     printf("[AMIGA] Platform shutdown completed.\n");
576 }
577
578 void create_platform_amiga(struct platform_config *cfg, char *subsys) {
579     cfg->register_read = handle_register_read_amiga;
580     cfg->register_write = handle_register_write_amiga;
581     cfg->custom_read = custom_read_amiga;
582     cfg->custom_write = custom_write_amiga;
583     cfg->platform_initial_setup = setup_platform_amiga;
584     cfg->handle_reset = handle_reset_amiga;
585     cfg->shutdown = shutdown_platform_amiga;
586
587     cfg->setvar = setvar_amiga;
588     cfg->id = PLATFORM_AMIGA;
589
590     if (subsys) {
591         cfg->subsys = malloc(strlen(subsys) + 1);
592         strcpy(cfg->subsys, subsys);
593         for (unsigned int i = 0; i < strlen(cfg->subsys); i++) {
594             cfg->subsys[i] = tolower(cfg->subsys[i]);
595         }
596     }
597 }