This most definitely requires a make clean and then make, due to all the header files edited.
I can't seem to build a314.device, so it's not included yet.
EXEPATH = ./
.CFILES = $(MAINFILES) $(MUSASHIFILES) $(MUSASHIGENCFILES)
EXEPATH = ./
.CFILES = $(MAINFILES) $(MUSASHIFILES) $(MUSASHIGENCFILES)
-.OFILES = $(.CFILES:%.c=%.o)
+.OFILES = $(.CFILES:%.c=%.o) a314/a314.o
WARNINGS = -Wall -Wextra -pedantic
# Pi3 CFLAGS
WARNINGS = -Wall -Wextra -pedantic
# Pi3 CFLAGS
-CFLAGS = $(WARNINGS) -I. -I./raylib -I./raylib/external -march=armv8-a -mfloat-abi=hard -mfpu=neon-fp-armv8 -O3 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE
+CFLAGS = $(WARNINGS) -I. -I./raylib -I./raylib/external -march=armv8-a -mfloat-abi=hard -mfpu=neon-fp-armv8 -O3 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -lstdc++
# Pi4 CFLAGS
#CFLAGS = $(WARNINGS) -I. -I./raylib_pi4_test -I./raylib_pi4_test/external -march=armv8-a -mfloat-abi=hard -mfpu=neon-fp-armv8 -O3 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE
# Pi4 CFLAGS
#CFLAGS = $(WARNINGS) -I. -I./raylib_pi4_test -I./raylib_pi4_test/external -march=armv8-a -mfloat-abi=hard -mfpu=neon-fp-armv8 -O3 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE
#LFLAGS = $(WARNINGS) `sdl2-config --libs`
# Pi3 standard raylib stuff
#LFLAGS = $(WARNINGS) `sdl2-config --libs`
# Pi3 standard raylib stuff
-LFLAGS = $(WARNINGS) -L/opt/vc/lib -L./raylib -lraylib -lbrcmGLESv2 -lbrcmEGL -lbcm_host
+LFLAGS = $(WARNINGS) -L/opt/vc/lib -L./raylib -lraylib -lbrcmGLESv2 -lbrcmEGL -lbcm_host -lstdc++
# Pi4 experimental crap
# Graphics output on the Pi4 sort of REQUIRES X11 to be running, otherwise it is insanely slow and useless.
#LFLAGS = $(WARNINGS) -L/usr/local/lib -L./raylib_pi4_test -lraylib -lGL -ldl -lrt -lX11 -DPLATFORM_DESKTOP
# Pi4 experimental crap
# Graphics output on the Pi4 sort of REQUIRES X11 to be running, otherwise it is insanely slow and useless.
#LFLAGS = $(WARNINGS) -L/usr/local/lib -L./raylib_pi4_test -lraylib -lGL -ldl -lrt -lX11 -DPLATFORM_DESKTOP
$(TARGET): $(MUSASHIGENHFILES) $(.OFILES) Makefile
$(TARGET): $(MUSASHIGENHFILES) $(.OFILES) Makefile
- $(CC) -o $@ $(.OFILES) -O3 -pthread $(LFLAGS) -lm
+ $(CC) -o $@ $(.OFILES) -O3 -pthread $(LFLAGS) -lm -lstdc++
+
+a314/a314.o: a314/a314.cc a314/a314.h
+ $(CXX) -c -o a314/a314.o -O3 a314/a314.cc -march=armv8-a -mfloat-abi=hard -mfpu=neon-fp-armv8 -O3 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -I. -I..
$(MUSASHIGENCFILES) $(MUSASHIGENHFILES): $(MUSASHIGENERATOR)$(EXE)
$(EXEPATH)$(MUSASHIGENERATOR)$(EXE)
$(MUSASHIGENCFILES) $(MUSASHIGENHFILES): $(MUSASHIGENERATOR)$(EXE)
$(EXEPATH)$(MUSASHIGENERATOR)$(EXE)
#include <vector>
#include "a314.h"
#include <vector>
#include "a314.h"
+// Silence stupid warning
+#undef _GNU_SOURCE
+#include "config_file/config_file.h"
+
+extern "C" emulator_config *cfg;
#define LOGGER_TRACE 1
#define LOGGER_DEBUG 2
#define LOGGER_TRACE 1
#define LOGGER_DEBUG 2
static int epfd = -1;
static int irq_fds[2];
static int epfd = -1;
static int irq_fds[2];
-extern "C" unsigned char fast_ram_array[];
-extern "C" void write16(unsigned int address, unsigned int value);
+extern "C" void ps_write_16(unsigned int address, unsigned int value);
unsigned int a314_base;
int a314_base_configured;
unsigned int a314_base;
int a314_base_configured;
std::vector<OnDemandStart> on_demand_services;
std::vector<OnDemandStart> on_demand_services;
+std::string a314_config_file = "/etc/opt/a314/a314d.conf";
+std::string home_env = "HOME=/home/pi";
+
static void load_config_file(const char *filename)
{
FILE *f = fopen(filename, "rt");
static void load_config_file(const char *filename)
{
FILE *f = fopen(filename, "rt");
uint32_t address = *(uint32_t *)&(cc->payload[0]);
uint32_t length = *(uint32_t *)&(cc->payload[4]);
uint32_t address = *(uint32_t *)&(cc->payload[0]);
uint32_t length = *(uint32_t *)&(cc->payload[4]);
- create_and_send_msg(cc, MSG_READ_MEM_RES, 0, &fast_ram_array[address], length);
+ if (get_mapped_item_by_address(cfg, address) != -1) {
+ int32_t index = get_mapped_item_by_address(cfg, address);
+ uint8_t *map = &cfg->map_data[index][address - cfg->map_offset[index]];
+ create_and_send_msg(cc, MSG_READ_MEM_RES, 0, map, length);
+ }
+ else // FIXME
+ printf("help.\n");
}
static void handle_msg_write_mem_req(ClientConnection *cc)
}
static void handle_msg_write_mem_req(ClientConnection *cc)
uint32_t address = *(uint32_t *)&(cc->payload[0]);
uint32_t length = cc->payload.size() - 4;
uint32_t address = *(uint32_t *)&(cc->payload[0]);
uint32_t length = cc->payload.size() - 4;
- memcpy(&fast_ram_array[address], &(cc->payload[4]), length);
+
+ if (get_mapped_item_by_address(cfg, address) != -1) {
+ int32_t index = get_mapped_item_by_address(cfg, address);
+ uint8_t *map = &cfg->map_data[index][address - cfg->map_offset[index]];
+ memcpy(map, &(cc->payload[4]), length);
+ }
+ else // FIXME
+ printf("help 2.\n");
create_and_send_msg(cc, MSG_WRITE_MEM_RES, 0, nullptr, 0);
}
create_and_send_msg(cc, MSG_WRITE_MEM_RES, 0, nullptr, 0);
}
// FIXE: The user should be configurable.
setgid(1000);
setuid(1000);
// FIXE: The user should be configurable.
setgid(1000);
setuid(1000);
- putenv("HOME=/home/pi");
+ putenv((char *)home_env.c_str());
std::vector<std::string> args(on_demand.arguments);
args.push_back("-ondemand");
std::vector<std::string> args(on_demand.arguments);
args.push_back("-ondemand");
-static void sigterm_handler(int signo)
-{
-}
-
-static void init_sigterm()
-{
- /*
- sigset_t ss;
- sigemptyset(&ss);
- sigaddset(&ss, SIGTERM);
- sigprocmask(SIG_BLOCK, &ss, &original_sigset);
-
- struct sigaction sa;
- sa.sa_handler = sigterm_handler;
- sigemptyset(&sa.sa_mask);
- sa.sa_flags = 0;
- sigaction(SIGTERM, &sa, NULL);
- */
-}
-
static int init_driver()
{
static int init_driver()
{
if (init_server_socket() != 0)
return -1;
if (init_server_socket() != 0)
return -1;
- std::string conf_filename("/etc/opt/a314/a314d.conf");
-
- load_config_file(conf_filename.c_str());
+ load_config_file(a314_config_file.c_str());
int err = init_driver();
if (err < 0)
int err = init_driver();
if (err < 0)
{
if (ca.a_events & ca.a_enable)
{
{
if (ca.a_events & ca.a_enable)
{
- write16(0xdff09c, 0x8008);
+ ps_write_16(0xdff09c, 0x8008);
+
+void a314_set_config_file(char *filename)
+{
+ printf ("[A314] Set A314 config filename to %s.\n", filename);
+ a314_config_file = std::string(filename);
+}
int a314_init();
void a314_set_mem_base_size(unsigned int base, unsigned int size);
void a314_process_events();
int a314_init();
void a314_set_mem_base_size(unsigned int base, unsigned int size);
void a314_process_events();
+void a314_set_config_file(char *filename);
unsigned int a314_read_memory_8(unsigned int address);
unsigned int a314_read_memory_16(unsigned int address);
unsigned int a314_read_memory_8(unsigned int address);
unsigned int a314_read_memory_16(unsigned int address);
void (*setvar)(struct emulator_config *cfg, char *var, char *val);
};
void (*setvar)(struct emulator_config *cfg, char *var, char *val);
};
+#ifdef __cplusplus
+extern "C" int get_mapped_item_by_address(struct emulator_config *cfg, uint32_t address);
+#else
unsigned int get_m68k_cpu_type(char *name);
struct emulator_config *load_config_file(char *filename);
void free_config_file(struct emulator_config *cfg);
unsigned int get_m68k_cpu_type(char *name);
struct emulator_config *load_config_file(char *filename);
void free_config_file(struct emulator_config *cfg);
int get_mapped_item_by_address(struct emulator_config *cfg, uint32_t address);
void add_mapping(struct emulator_config *cfg, unsigned int type, unsigned int addr, unsigned int size, int mirr_addr, char *filename, char *map_id);
unsigned int get_int(char *str);
int get_mapped_item_by_address(struct emulator_config *cfg, uint32_t address);
void add_mapping(struct emulator_config *cfg, unsigned int type, unsigned int addr, unsigned int size, int mirr_addr, char *filename, char *map_id);
unsigned int get_int(char *str);
#endif /* _CONFIG_FILE_H */
#endif /* _CONFIG_FILE_H */
#setvar enable_rtc_emulation 0
# Uncomment to enable RTG
#setvar rtg
#setvar enable_rtc_emulation 0
# Uncomment to enable RTG
#setvar rtg
# Uncomment to enable CDTV mode (not working, requires Kickstart 1.3+CDTV extended ROM)
#setvar cdtv
# Uncomment this line to enable the PiSCSI interface
# Uncomment to enable CDTV mode (not working, requires Kickstart 1.3+CDTV extended ROM)
#setvar cdtv
# Uncomment this line to enable the PiSCSI interface
# Uncomment this line to enable the (currently non-working) Pi-Net interface.
#setvar pi-net
# Uncomment this line to enable the (currently non-working) Pi-Net interface.
#setvar pi-net
+# Uncomment and edit to set a custom config filename for the A314 emulation
+#setvar a314_conf /etc/opt/a314/a314d.conf
+# Uncomment to enable A314 emulation
+#setvar a314
+
# Forward keyboard events to host system, defaults to off unless toggle key is pressed, toggled off using F12.
# Syntax: keyboard [grab key] [grab|nograb] [autoconnect|noautoconnect]
# "grab" steals the keyboard from the Pi so Amiga/etc. input is not sent to the Pi
# Forward keyboard events to host system, defaults to off unless toggle key is pressed, toggled off using F12.
# Syntax: keyboard [grab key] [grab|nograb] [autoconnect|noautoconnect]
# "grab" steals the keyboard from the Pi so Amiga/etc. input is not sent to the Pi
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define Z2_Z2 0xC
#define Z2_FAST 0x2
#define Z2_Z2 0xC
#define Z2_FAST 0x2
0x4, 0x0, 0x0, 0x0, // Optional BOOT ROM vector
};
0x4, 0x0, 0x0, 0x0, // Optional BOOT ROM vector
};
-// A314 Emulation ROM (currently unused)
static unsigned char ac_a314_rom[] = {
0xc, AC_MEM_SIZE_64KB, // 00/02, 64 kB
0xa, 0x3, // 04/06, product id
static unsigned char ac_a314_rom[] = {
0xc, AC_MEM_SIZE_64KB, // 00/02, 64 kB
0xa, 0x3, // 04/06, product id
0x0, 0x0, 0x0, 0x0, // Optional BOOT ROM vector
};
0x0, 0x0, 0x0, 0x0, // Optional BOOT ROM vector
};
+extern unsigned int a314_base;
+
int ac_z2_current_pic = 0;
int ac_z2_pic_count = 0;
int ac_z2_done = 0;
int ac_z2_current_pic = 0;
int ac_z2_pic_count = 0;
int ac_z2_done = 0;
base = &ac_base[ac_z2_current_pic];
break;
case ACTYPE_A314:
base = &ac_base[ac_z2_current_pic];
break;
case ACTYPE_A314:
break;
case ACTYPE_PISCSI:
base = &piscsi_base;
break;
case ACTYPE_PISCSI:
base = &piscsi_base;
*base &= 0xff0fffff;
*base |= (value & 0xf0) << (20 - 4);
*base &= 0xff0fffff;
*base |= (value & 0xf0) << (20 - 4);
- if (ac_z2_type[ac_z2_current_pic] == ACTYPE_MAPFAST_Z2) { // fast ram
+ if (ac_z2_type[ac_z2_current_pic] == ACTYPE_A314) {
//a314_set_mem_base_size(*base, cfg->map_size[ac_index[ac_z2_current_pic]]);
}
done = 1;
//a314_set_mem_base_size(*base, cfg->map_size[ac_index[ac_z2_current_pic]]);
}
done = 1;
printf("[AUTOCONF] PiSCSI Z2 device assigned to $%.8X\n", piscsi_base);
//m68k_add_rom_range(piscsi_base + (16 * SIZE_KILO), piscsi_base + (32 * SIZE_KILO), piscsi_rom_ptr);
break;
printf("[AUTOCONF] PiSCSI Z2 device assigned to $%.8X\n", piscsi_base);
//m68k_add_rom_range(piscsi_base + (16 * SIZE_KILO), piscsi_base + (32 * SIZE_KILO), piscsi_rom_ptr);
break;
+ case ACTYPE_A314:
+ printf("[AUTOCONF] A314 emulation device assigned to $%.8X\n", a314_base);
+ break;
- printf("[AUTOCONF] PiStorm Interaction Z2 Device assigned to $%.8X\n", pistorm_dev_base);
+ printf("[AUTOCONF] PiStorm Interaction Z2 device assigned to $%.8X\n", pistorm_dev_base);
+ printf("[!!!AUTOCONF] Some strange unknown Z2 device has been assigned to $%.8X?", *base);
break;
}
ac_z2_current_pic++;
break;
}
ac_z2_current_pic++;
#include "platforms/platforms.h"
#include "platforms/shared/rtc.h"
#include "rtg/rtg.h"
#include "platforms/platforms.h"
#include "platforms/shared/rtc.h"
#include "rtg/rtg.h"
//#define DEBUG_AMIGA_PLATFORM
//#define DEBUG_AMIGA_PLATFORM
extern uint8_t cdtv_mode;
extern uint8_t rtc_type;
extern unsigned char cdtv_sram[32 * SIZE_KILO];
extern uint8_t cdtv_mode;
extern uint8_t rtc_type;
extern unsigned char cdtv_sram[32 * SIZE_KILO];
+extern unsigned int a314_base;
#define min(a, b) (a < b) ? a : b
#define max(a, b) (a > b) ? a : b
uint8_t rtg_enabled = 0, piscsi_enabled = 0, pinet_enabled = 0, kick13_mode = 0, pistorm_dev_enabled = 1;
#define min(a, b) (a < b) ? a : b
#define max(a, b) (a > b) ? a : b
uint8_t rtg_enabled = 0, piscsi_enabled = 0, pinet_enabled = 0, kick13_mode = 0, pistorm_dev_enabled = 1;
+uint8_t a314_emulation_enabled = 0;
extern uint32_t piscsi_base, pistorm_dev_base;
extern uint32_t piscsi_base, pistorm_dev_base;
+ if (a314_emulation_enabled && addr >= a314_base && addr < a314_base + (64 * SIZE_KILO)) {
+ switch (type) {
+ case OP_TYPE_BYTE:
+ *val = a314_read_memory_8(addr);
+ return 1;
+ break;
+ case OP_TYPE_WORD:
+ *val = a314_read_memory_16(addr);
+ return 1;
+ break;
+ case OP_TYPE_LONGWORD:
+ *val = a314_read_memory_32(addr);
+ return 1;
+ break;
+ default:
+ break;
+ }
+ return 1;
+ }
+
+ if (a314_emulation_enabled && addr >= a314_base && addr < a314_base + (64 * SIZE_KILO)) {
+ switch (type) {
+ case OP_TYPE_BYTE:
+ a314_write_memory_8(addr, val);
+ return 1;
+ break;
+ case OP_TYPE_WORD:
+ // Not implemented in a314.cc
+ //a314_write_memory_16(addr, val);
+ return -1;
+ break;
+ case OP_TYPE_LONGWORD:
+ // Not implemented in a314.cc
+ // a314_write_memory_32(addr, val);
+ return -1;
+ break;
+ default:
+ break;
+ }
+ }
+
+#define CHKVAR(a) (strcmp(var, a) == 0)
+
void setvar_amiga(struct emulator_config *cfg, char *var, char *val) {
if (!var)
return;
void setvar_amiga(struct emulator_config *cfg, char *var, char *val) {
if (!var)
return;
- if (strcmp(var, "enable_rtc_emulation") == 0) {
+ if CHKVAR("enable_rtc_emulation") {
int8_t rtc_enabled = 0;
if (!val || strlen(val) == 0)
rtc_enabled = 1;
int8_t rtc_enabled = 0;
if (!val || strlen(val) == 0)
rtc_enabled = 1;
configure_rtc_emulation_amiga(rtc_enabled);
}
}
configure_rtc_emulation_amiga(rtc_enabled);
}
}
- if (strcmp(var, "hdd0") == 0) {
if (val && strlen(val) != 0)
set_hard_drive_image_file_amiga(0, val);
}
if (val && strlen(val) != 0)
set_hard_drive_image_file_amiga(0, val);
}
- if (strcmp(var, "hdd1") == 0) {
if (val && strlen(val) != 0)
set_hard_drive_image_file_amiga(1, val);
}
if (val && strlen(val) != 0)
set_hard_drive_image_file_amiga(1, val);
}
- if (strcmp(var, "cdtv") == 0) {
printf("[AMIGA] CDTV mode enabled.\n");
cdtv_mode = 1;
}
printf("[AMIGA] CDTV mode enabled.\n");
cdtv_mode = 1;
}
- if (strcmp(var, "rtg") == 0 && !rtg_enabled) {
+ if (CHKVAR("rtg") && !rtg_enabled) {
if (init_rtg_data(cfg)) {
printf("[AMIGA] RTG Enabled.\n");
rtg_enabled = 1;
if (init_rtg_data(cfg)) {
printf("[AMIGA] RTG Enabled.\n");
rtg_enabled = 1;
else
printf("[AMIGA} Failed to enable RTG.\n");
}
else
printf("[AMIGA} Failed to enable RTG.\n");
}
- if (strcmp(var, "kick13") == 0) {
printf("[AMIGA] Kickstart 1.3 mode enabled, Z3 PICs will not be enumerated.\n");
kick13_mode = 1;
}
printf("[AMIGA] Kickstart 1.3 mode enabled, Z3 PICs will not be enumerated.\n");
kick13_mode = 1;
}
+ if CHKVAR("a314") {
+ int32_t res = a314_init();
+ if (res != 0) {
+ printf("[AMIGA] Failed to enable A314 emulation, error return code: %d.\n", res);
+ } else {
+ printf("[AMIGA] A314 emulation enabled.\n");
+ add_z2_pic(ACTYPE_A314, 0);
+ a314_emulation_enabled = 1;
+ }
+ }
+ if CHKVAR("a314conf") {
+ if (val && strlen(val) != 0) {
+ a314_set_config_file(val);
+ }
+ }
- if (strcmp(var, "piscsi") == 0 && !piscsi_enabled) {
+ if (CHKVAR("piscsi") && !piscsi_enabled) {
printf("[AMIGA] PISCSI Interface Enabled.\n");
piscsi_enabled = 1;
piscsi_init();
add_z2_pic(ACTYPE_PISCSI, 0);
printf("[AMIGA] PISCSI Interface Enabled.\n");
piscsi_enabled = 1;
piscsi_init();
add_z2_pic(ACTYPE_PISCSI, 0);
- //ac_z2_type[ac_z2_pic_count] = ACTYPE_PISCSI;
- //ac_z2_pic_count++;
adjust_ranges_amiga(cfg);
}
if (piscsi_enabled) {
adjust_ranges_amiga(cfg);
}
if (piscsi_enabled) {
- if (strcmp(var, "piscsi0") == 0) {
piscsi_map_drive(val, 0);
}
piscsi_map_drive(val, 0);
}
- if (strcmp(var, "piscsi1") == 0) {
piscsi_map_drive(val, 1);
}
piscsi_map_drive(val, 1);
}
- if (strcmp(var, "piscsi2") == 0) {
piscsi_map_drive(val, 2);
}
piscsi_map_drive(val, 2);
}
- if (strcmp(var, "piscsi3") == 0) {
piscsi_map_drive(val, 3);
}
piscsi_map_drive(val, 3);
}
- if (strcmp(var, "piscsi4") == 0) {
piscsi_map_drive(val, 4);
}
piscsi_map_drive(val, 4);
}
- if (strcmp(var, "piscsi5") == 0) {
piscsi_map_drive(val, 5);
}
piscsi_map_drive(val, 5);
}
- if (strcmp(var, "piscsi6") == 0) {
piscsi_map_drive(val, 6);
}
}
// Pi-Net stuff
piscsi_map_drive(val, 6);
}
}
// Pi-Net stuff
- if (strcmp(var, "pi-net") == 0 && !pinet_enabled) {
+ if (CHKVAR("pi-net")&& !pinet_enabled) {
printf("[AMIGA] PI-NET Interface Enabled.\n");
pinet_enabled = 1;
pinet_init(val);
adjust_ranges_amiga(cfg);
}
printf("[AMIGA] PI-NET Interface Enabled.\n");
pinet_enabled = 1;
pinet_init(val);
adjust_ranges_amiga(cfg);
}
- if (strcmp(var, "no-pistorm-dev") == 0) {
+ if CHKVAR("no-pistorm-dev") {
pistorm_dev_enabled = 0;
printf("[AMIGA] Disabling PiStorm interaction device.\n");
}
// RTC stuff
pistorm_dev_enabled = 0;
printf("[AMIGA] Disabling PiStorm interaction device.\n");
}
// RTC stuff
- if (strcmp(var, "rtc_type") == 0) {
+ if CHKVAR("rtc_type") {
if (val && strlen(val) != 0) {
if (strcmp(val, "msm") == 0) {
printf("[AMIGA] RTC type set to MSM.\n");
if (val && strlen(val) != 0) {
if (strcmp(val, "msm") == 0) {
printf("[AMIGA] RTC type set to MSM.\n");
if (pinet_enabled) {
pinet_enabled = 0;
}
if (pinet_enabled) {
pinet_enabled = 0;
}
+ if (a314_emulation_enabled) {
+ a314_emulation_enabled = 0;
+ }