mirror of
https://github.com/captain-amygdala/pistorm.git
synced 2026-02-11 10:34:45 +00:00
The remainder of the initial PiStorm interaction stuff (I think)
This commit is contained in:
@@ -101,6 +101,7 @@ int handle_mapped_read(struct emulator_config *cfg, unsigned int addr, unsigned
|
||||
int handle_mapped_write(struct emulator_config *cfg, unsigned int addr, unsigned int value, unsigned char type);
|
||||
int get_named_mapped_item(struct emulator_config *cfg, char *name);
|
||||
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 */
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
# Sets CPU type. Valid types are (probably) 68000, 68010, 68020, 68EC020, 68030, 68EC030, 68040, 68EC040, 68LC040 and some STTTT thing.
|
||||
cpu 68020
|
||||
# Map 512KB kickstart ROM to default offset.
|
||||
map type=rom address=0xF80000 size=0x80000 file=kick.rom ovl=0
|
||||
map type=rom address=0xF80000 size=0x80000 file=kick.rom ovl=0 id=kickstart
|
||||
# Want to map an extended ROM, such as CDTV or CD32?
|
||||
#map type=rom address=0xF00000 size=0x80000 file=cdtv.rom
|
||||
#map type=rom address=0xF00000 size=0x80000 file=cdtv.rom id=extended
|
||||
|
||||
# Map 128MB of Fast RAM at 0x8000000, also known as 32-bit Fast RAM or CPU local Fast RAM.
|
||||
# Only supported properly on select Kickstarts, such as 3.1+ for Amiga 1200, 3000 and 4000.
|
||||
|
||||
41
emulator.c
41
emulator.c
@@ -14,6 +14,7 @@
|
||||
#include "platforms/amiga/net/pi-net.h"
|
||||
#include "platforms/amiga/net/pi-net-enums.h"
|
||||
#include "platforms/amiga/pistorm-dev/pistorm-dev.h"
|
||||
#include "platforms/amiga/pistorm-dev/pistorm-dev-enums.h"
|
||||
#include "gpio/ps_protocol.h"
|
||||
|
||||
#include <assert.h>
|
||||
@@ -456,6 +457,9 @@ int main(int argc, char *argv[]) {
|
||||
} else {
|
||||
g++;
|
||||
cfg = load_config_file(argv[g]);
|
||||
if (cfg) {
|
||||
set_pistorm_devcfg_filename(argv[g]);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (strcmp(argv[g], "--keyboard-file") == 0 || strcmp(argv[g], "--kbfile") == 0) {
|
||||
@@ -469,7 +473,8 @@ int main(int argc, char *argv[]) {
|
||||
}
|
||||
|
||||
switch_config:
|
||||
if (load_new_config) {
|
||||
if (load_new_config != 0) {
|
||||
uint8_t config_action = load_new_config - 1;
|
||||
load_new_config = 0;
|
||||
free_config_file(cfg);
|
||||
if (cfg) {
|
||||
@@ -477,7 +482,19 @@ switch_config:
|
||||
cfg = NULL;
|
||||
}
|
||||
|
||||
cfg = load_config_file(get_pistorm_devcfg_filename());
|
||||
for(int i = 0; i < 2 * SIZE_MEGA; i++) {
|
||||
write8(i, 0);
|
||||
}
|
||||
|
||||
switch(config_action) {
|
||||
case PICFG_LOAD:
|
||||
case PICFG_RELOAD:
|
||||
cfg = load_config_file(get_pistorm_devcfg_filename());
|
||||
break;
|
||||
case PICFG_DEFAULT:
|
||||
cfg = load_config_file("default.cfg");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!cfg) {
|
||||
@@ -587,14 +604,16 @@ switch_config:
|
||||
m68k_set_cpu_type(cpu_type);
|
||||
cpu_pulse_reset();
|
||||
|
||||
pthread_t ipl_tid, cpu_tid, kbd_tid;
|
||||
pthread_t ipl_tid = 0, cpu_tid, kbd_tid;
|
||||
int err;
|
||||
err = pthread_create(&ipl_tid, NULL, &ipl_task, NULL);
|
||||
if (err != 0)
|
||||
printf("[ERROR] Cannot create IPL thread: [%s]", strerror(err));
|
||||
else {
|
||||
pthread_setname_np(ipl_tid, "pistorm: ipl");
|
||||
printf("IPL thread created successfully\n");
|
||||
if (ipl_tid == 0) {
|
||||
err = pthread_create(&ipl_tid, NULL, &ipl_task, NULL);
|
||||
if (err != 0)
|
||||
printf("[ERROR] Cannot create IPL thread: [%s]", strerror(err));
|
||||
else {
|
||||
pthread_setname_np(ipl_tid, "pistorm: ipl");
|
||||
printf("IPL thread created successfully\n");
|
||||
}
|
||||
}
|
||||
|
||||
// create keyboard task
|
||||
@@ -618,7 +637,7 @@ switch_config:
|
||||
// wait for cpu task to end before closing up and finishing
|
||||
pthread_join(cpu_tid, NULL);
|
||||
|
||||
if (!load_new_config)
|
||||
if (load_new_config == 0)
|
||||
printf("[MAIN] All threads appear to have concluded; ending process\n");
|
||||
|
||||
if (mouse_fd != -1)
|
||||
@@ -626,7 +645,7 @@ switch_config:
|
||||
if (mem_fd)
|
||||
close(mem_fd);
|
||||
|
||||
if (load_new_config)
|
||||
if (load_new_config != 0)
|
||||
goto switch_config;
|
||||
|
||||
if (cfg->platform->shutdown) {
|
||||
|
||||
@@ -25,11 +25,8 @@
|
||||
#define DEBUG(...)
|
||||
#endif
|
||||
|
||||
|
||||
int handle_register_read_amiga(unsigned int addr, unsigned char type, unsigned int *val);
|
||||
int handle_register_write_amiga(unsigned int addr, unsigned int value, unsigned char type);
|
||||
int init_rtg_data();
|
||||
void shutdown_rtg();
|
||||
|
||||
extern int ac_z2_current_pic;
|
||||
extern int ac_z2_done;
|
||||
|
||||
@@ -23,6 +23,10 @@ void pinet_init(char *dev) {
|
||||
(void)dev;
|
||||
}
|
||||
|
||||
void pinet_shutdown() {
|
||||
// Aaahh!
|
||||
}
|
||||
|
||||
uint8_t PI_MAC[6] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
uint8_t PI_IP[4] = { 192, 168, 1, 9 };
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
void pinet_init(char *dev);
|
||||
void pinet_shutdown();
|
||||
void handle_pinet_write(uint32_t addr, uint32_t val, uint8_t type);
|
||||
uint32_t handle_pinet_read(uint32_t addr, uint8_t type);
|
||||
|
||||
@@ -308,6 +308,10 @@ fs_done:;
|
||||
free(fhb_block);
|
||||
}
|
||||
|
||||
struct piscsi_dev *piscsi_get_dev(uint8_t index) {
|
||||
return &devs[index];
|
||||
}
|
||||
|
||||
void piscsi_map_drive(char *filename, uint8_t index) {
|
||||
if (index > 7) {
|
||||
printf("[PISCSI] Drive index %d out of range.\nUnable to map file %s to drive.\n", index, filename);
|
||||
|
||||
@@ -257,6 +257,8 @@ struct FileSysHeaderBlock {
|
||||
void piscsi_init();
|
||||
void piscsi_shutdown();
|
||||
void piscsi_map_drive(char *filename, uint8_t index);
|
||||
void piscsi_unmap_drive(uint8_t index);
|
||||
struct piscsi_dev *piscsi_get_dev(uint8_t index);
|
||||
|
||||
void handle_piscsi_write(uint32_t addr, uint32_t val, uint8_t type);
|
||||
uint32_t handle_piscsi_read(uint32_t addr, uint8_t type);
|
||||
|
||||
@@ -63,12 +63,14 @@ enum pistorm_dev_cmds {
|
||||
PI_CMDRESULT = 0x2100, // [R] Check the result of any command that provides a "return value".
|
||||
};
|
||||
|
||||
enum pistorm_piscsi_ctrl_commands {
|
||||
enum pistorm_piscsi_commands {
|
||||
PISCSI_CTRL_NONE,
|
||||
PISCSI_CTRL_MAP, // For hard drives
|
||||
PISCSI_CTRL_UNMAP, //
|
||||
PISCSI_CTRL_EJECT, // For optical media, not yet implemented
|
||||
PISCSI_CTRL_INSERT, //
|
||||
PISCSI_CTRL_ENABLE, // Enable PiSCSI
|
||||
PISCSI_CTRL_DISABLE, // Disable PiSCSI
|
||||
PISCSI_CTRL_NUM,
|
||||
};
|
||||
|
||||
@@ -78,3 +80,13 @@ enum pistorm_config_commands {
|
||||
PICFG_DEFAULT, // Load default.cfg if it exists
|
||||
PICFG_NUM,
|
||||
};
|
||||
|
||||
enum pistorm_command_results {
|
||||
PI_RES_OK,
|
||||
PI_RES_FAILED,
|
||||
PI_RES_NOCHANGE,
|
||||
PI_RES_FILENOTFOUND,
|
||||
PI_RES_INVALIDVALUE,
|
||||
PI_RES_INVALIDCMD,
|
||||
PI_RES_NUM,
|
||||
};
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "pistorm-dev.h"
|
||||
#include "pistorm-dev-enums.h"
|
||||
#include "platforms/platforms.h"
|
||||
#include "gpio/ps_protocol.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "platforms/amiga/rtg/rtg.h"
|
||||
#include "platforms/amiga/piscsi/piscsi.h"
|
||||
#include "platforms/amiga/net/pi-net.h"
|
||||
|
||||
#define DEBUG_PISTORM_DEVICE
|
||||
|
||||
@@ -28,10 +32,12 @@ static const char *op_type_names[4] = {
|
||||
extern uint32_t pistorm_dev_base;
|
||||
extern uint32_t do_reset;
|
||||
|
||||
extern void adjust_ranges_amiga(struct emulator_config *cfg);
|
||||
extern uint8_t rtg_enabled, rtg_on, pinet_enabled, piscsi_enabled, load_new_config;
|
||||
extern struct emulator_config *cfg;
|
||||
|
||||
char cfg_filename[256];
|
||||
char cfg_filename[256] = "default.cfg";
|
||||
char tmp_string[256];
|
||||
|
||||
static uint8_t pi_byte[8];
|
||||
static uint16_t pi_word[4];
|
||||
@@ -73,6 +79,10 @@ char *get_pistorm_devcfg_filename() {
|
||||
return cfg_filename;
|
||||
}
|
||||
|
||||
void set_pistorm_devcfg_filename(char *filename) {
|
||||
strcpy(cfg_filename, filename);
|
||||
}
|
||||
|
||||
void handle_pistorm_dev_write(uint32_t addr_, uint32_t val, uint8_t type) {
|
||||
uint32_t addr = (addr_ & 0xFFFF);
|
||||
|
||||
@@ -108,6 +118,177 @@ void handle_pistorm_dev_write(uint32_t addr_, uint32_t val, uint8_t type) {
|
||||
pi_string[(addr - PI_STR1) / 4] = val;
|
||||
break;
|
||||
|
||||
case PI_CMD_RTGSTATUS:
|
||||
DEBUG("[PISTORM-DEV] Write to RTGSTATUS: %d\n", val);
|
||||
if (val == 1 && !rtg_enabled) {
|
||||
init_rtg_data();
|
||||
rtg_enabled = 1;
|
||||
pi_cmd_result = PI_RES_OK;
|
||||
} else if (val == 0 && rtg_enabled) {
|
||||
if (!rtg_on) {
|
||||
shutdown_rtg();
|
||||
rtg_enabled = 0;
|
||||
pi_cmd_result = PI_RES_OK;
|
||||
} else {
|
||||
// Refuse to disable RTG if it's currently in use.
|
||||
pi_cmd_result = PI_RES_FAILED;
|
||||
}
|
||||
} else {
|
||||
pi_cmd_result = PI_RES_NOCHANGE;
|
||||
}
|
||||
adjust_ranges_amiga(cfg);
|
||||
break;
|
||||
case PI_CMD_NETSTATUS:
|
||||
DEBUG("[PISTORM-DEV] Write to NETSTATUS: %d\n", val);
|
||||
if (val == 1 && !pinet_enabled) {
|
||||
pinet_init(NULL);
|
||||
pinet_enabled = 1;
|
||||
pi_cmd_result = PI_RES_OK;
|
||||
} else if (val == 0 && pinet_enabled) {
|
||||
pinet_shutdown();
|
||||
pinet_enabled = 0;
|
||||
pi_cmd_result = PI_RES_OK;
|
||||
} else {
|
||||
pi_cmd_result = PI_RES_NOCHANGE;
|
||||
}
|
||||
adjust_ranges_amiga(cfg);
|
||||
break;
|
||||
case PI_CMD_PISCSI_CTRL:
|
||||
DEBUG("[PISTORM-DEV] Write to PISCSI_CTRL: ");
|
||||
switch(val) {
|
||||
case PISCSI_CTRL_DISABLE:
|
||||
DEBUG("DISABLE\n");
|
||||
if (piscsi_enabled) {
|
||||
piscsi_shutdown();
|
||||
piscsi_enabled = 0;
|
||||
// Probably not OK... depends on if you booted from floppy, I guess.
|
||||
pi_cmd_result = PI_RES_OK;
|
||||
} else {
|
||||
pi_cmd_result = PI_RES_NOCHANGE;
|
||||
}
|
||||
break;
|
||||
case PISCSI_CTRL_ENABLE:
|
||||
DEBUG("ENABLE\n");
|
||||
if (!piscsi_enabled) {
|
||||
piscsi_init();
|
||||
piscsi_enabled = 1;
|
||||
piscsi_refresh_drives();
|
||||
pi_cmd_result = PI_RES_OK;
|
||||
} else {
|
||||
pi_cmd_result = PI_RES_NOCHANGE;
|
||||
}
|
||||
break;
|
||||
case PISCSI_CTRL_MAP:
|
||||
DEBUG("MAP\n");
|
||||
if (pi_string[0] == 0 || grab_amiga_string(pi_string[0], (uint8_t *)tmp_string, 255) == -1) {
|
||||
printf("[PISTORM-DEV] Failed to grab string for PISCSI drive filename. Aborting.\n");
|
||||
pi_cmd_result = PI_RES_FAILED;
|
||||
} else {
|
||||
FILE *tmp = fopen(tmp_string, "rb");
|
||||
if (tmp == NULL) {
|
||||
printf("[PISTORM-DEV] Failed to open file %s for PISCSI drive mapping. Aborting.\n", cfg_filename);
|
||||
pi_cmd_result = PI_RES_FILENOTFOUND;
|
||||
} else {
|
||||
fclose(tmp);
|
||||
printf("[PISTORM-DEV] Attempting to map file %s as PISCSI drive %d...\n", cfg_filename, pi_word[0]);
|
||||
piscsi_unmap_drive(pi_word[0]);
|
||||
piscsi_map_drive(tmp_string, pi_word[0]);
|
||||
pi_cmd_result = PI_RES_OK;
|
||||
}
|
||||
}
|
||||
pi_string[0] = 0;
|
||||
break;
|
||||
case PISCSI_CTRL_UNMAP:
|
||||
DEBUG("UNMAP\n");
|
||||
if (pi_word[0] > 7) {
|
||||
printf("[PISTORM-DEV] Invalid drive ID %d for PISCSI unmap command.", pi_word[0]);
|
||||
pi_cmd_result = PI_RES_INVALIDVALUE;
|
||||
} else {
|
||||
if (piscsi_get_dev(pi_word[0])->fd != -1) {
|
||||
piscsi_unmap_drive(pi_word[0]);
|
||||
pi_cmd_result = PI_RES_OK;
|
||||
} else {
|
||||
pi_cmd_result = PI_RES_NOCHANGE;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case PISCSI_CTRL_EJECT:
|
||||
DEBUG("EJECT (NYI)\n");
|
||||
pi_cmd_result = PI_RES_NOCHANGE;
|
||||
break;
|
||||
case PISCSI_CTRL_INSERT:
|
||||
DEBUG("INSERT (NYI)\n");
|
||||
pi_cmd_result = PI_RES_NOCHANGE;
|
||||
break;
|
||||
default:
|
||||
DEBUG("UNKNOWN/UNHANDLED. Aborting.\n");
|
||||
pi_cmd_result = PI_RES_INVALIDVALUE;
|
||||
break;
|
||||
}
|
||||
adjust_ranges_amiga(cfg);
|
||||
break;
|
||||
|
||||
case PI_CMD_KICKROM:
|
||||
DEBUG("[PISTORM-DEV] Write to KICKROM.\n");
|
||||
if (pi_string[0] == 0 || grab_amiga_string(pi_string[0], (uint8_t *)tmp_string, 255) == -1) {
|
||||
printf("[PISTORM-DEV] Failed to grab string KICKROM filename. Aborting.\n");
|
||||
pi_cmd_result = PI_RES_FAILED;
|
||||
} else {
|
||||
FILE *tmp = fopen(tmp_string, "rb");
|
||||
if (tmp == NULL) {
|
||||
printf("[PISTORM-DEV] Failed to open file %s for KICKROM mapping. Aborting.\n", cfg_filename);
|
||||
pi_cmd_result = PI_RES_FILENOTFOUND;
|
||||
} else {
|
||||
fclose(tmp);
|
||||
if (get_named_mapped_item(cfg, "kickstart") != -1) {
|
||||
uint32_t index = get_named_mapped_item(cfg, "kickstart");
|
||||
free(cfg->map_data[index]);
|
||||
free(cfg->map_id[index]);
|
||||
cfg->map_type[index] = MAPTYPE_NONE;
|
||||
// Dirty hack, I am sleepy and lazy.
|
||||
add_mapping(cfg, MAPTYPE_ROM, cfg->map_offset[index], cfg->map_size[index], 0, tmp_string, "kickstart");
|
||||
pi_cmd_result = PI_RES_OK;
|
||||
do_reset = 1;
|
||||
} else {
|
||||
printf ("[PISTORM-DEV] Could not find mapped range 'kickstart', cannot remap KICKROM.\n");
|
||||
pi_cmd_result = PI_RES_FAILED;
|
||||
}
|
||||
}
|
||||
}
|
||||
adjust_ranges_amiga(cfg);
|
||||
pi_string[0] = 0;
|
||||
break;
|
||||
case PI_CMD_EXTROM:
|
||||
DEBUG("[PISTORM-DEV] Write to EXTROM.\n");
|
||||
if (pi_string[0] == 0 || grab_amiga_string(pi_string[0], (uint8_t *)tmp_string, 255) == -1) {
|
||||
printf("[PISTORM-DEV] Failed to grab string EXTROM filename. Aborting.\n");
|
||||
pi_cmd_result = PI_RES_FAILED;
|
||||
} else {
|
||||
FILE *tmp = fopen(tmp_string, "rb");
|
||||
if (tmp == NULL) {
|
||||
printf("[PISTORM-DEV] Failed to open file %s for EXTROM mapping. Aborting.\n", cfg_filename);
|
||||
pi_cmd_result = PI_RES_FILENOTFOUND;
|
||||
} else {
|
||||
fclose(tmp);
|
||||
if (get_named_mapped_item(cfg, "extended") != -1) {
|
||||
uint32_t index = get_named_mapped_item(cfg, "extended");
|
||||
free(cfg->map_data[index]);
|
||||
free(cfg->map_id[index]);
|
||||
cfg->map_type[index] = MAPTYPE_NONE;
|
||||
// Dirty hack, I am tired and lazy.
|
||||
add_mapping(cfg, MAPTYPE_ROM, cfg->map_offset[index], cfg->map_size[index], 0, tmp_string, "extended");
|
||||
pi_cmd_result = PI_RES_OK;
|
||||
do_reset = 1;
|
||||
} else {
|
||||
printf ("[PISTORM-DEV] Could not find mapped range 'extrom', cannot remap EXTROM.\n");
|
||||
pi_cmd_result = PI_RES_FAILED;
|
||||
}
|
||||
}
|
||||
}
|
||||
adjust_ranges_amiga(cfg);
|
||||
pi_string[0] = 0;
|
||||
break;
|
||||
|
||||
case PI_CMD_RESET:
|
||||
DEBUG("[PISTORM-DEV] System reset called, code %d\n", (val & 0xFFFF));
|
||||
do_reset = 1;
|
||||
@@ -118,31 +299,41 @@ void handle_pistorm_dev_write(uint32_t addr_, uint32_t val, uint8_t type) {
|
||||
case PICFG_LOAD:
|
||||
DEBUG("LOAD\n");
|
||||
if (pi_string[0] == 0 || grab_amiga_string(pi_string[0], (uint8_t *)cfg_filename, 255) == -1) {
|
||||
printf("[PISTORM-DEV] Failed to grab string for config filename. Aborting.\n");
|
||||
printf("[PISTORM-DEV] Failed to grab string for CONFIG filename. Aborting.\n");
|
||||
pi_cmd_result = PI_RES_FAILED;
|
||||
} else {
|
||||
FILE *tmp = fopen(cfg_filename, "rb");
|
||||
if (tmp == NULL) {
|
||||
printf("[PISTORM-DEV] Failed to open config file %s for reading. Aborting.\n", cfg_filename);
|
||||
printf("[PISTORM-DEV] Failed to open CONFIG file %s for reading. Aborting.\n", cfg_filename);
|
||||
pi_cmd_result = PI_RES_FILENOTFOUND;
|
||||
} else {
|
||||
fclose(tmp);
|
||||
printf("[PISTORM-DEV] Attempting to load config file %s...\n", cfg_filename);
|
||||
load_new_config = 1;
|
||||
load_new_config = val + 1;
|
||||
pi_cmd_result = PI_RES_OK;
|
||||
}
|
||||
}
|
||||
pi_string[0] = 0;
|
||||
break;
|
||||
case PICFG_RELOAD:
|
||||
DEBUG("RELOAD\n");
|
||||
printf("[PISTORM-DEV] Reloading current config file (%s)...\n", cfg_filename);
|
||||
load_new_config = val + 1;
|
||||
break;
|
||||
case PICFG_DEFAULT:
|
||||
DEBUG("DEFAULT\n");
|
||||
printf("[PISTORM-DEV] Loading default.cfg...\n");
|
||||
load_new_config = val + 1;
|
||||
break;
|
||||
default:
|
||||
DEBUG("UNKNOWN. Command ignored.\n");
|
||||
DEBUG("UNKNOWN/UNHANDLED. Command ignored.\n");
|
||||
pi_cmd_result = PI_RES_INVALIDVALUE;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
DEBUG("[PISTORM-DEV] WARN: Unhandled %s register write to %.4X: %d\n", op_type_names[type], addr - pistorm_dev_base, val);
|
||||
pi_cmd_result = PI_RES_INVALIDCMD;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,3 +5,4 @@
|
||||
void handle_pistorm_dev_write(uint32_t addr, uint32_t val, uint8_t type);
|
||||
uint32_t handle_pistorm_dev_read(uint32_t addr, uint8_t type);
|
||||
char *get_pistorm_devcfg_filename();
|
||||
void set_pistorm_devcfg_filename(char *filename);
|
||||
|
||||
Binary file not shown.
@@ -1 +1 @@
|
||||
m68k-amigaos-gcc pistorm_dev.c simple_interact.c -mregparm -m68020 -O2 -o PiSimple -Wno-unused-parameter -noixemul -DHAS_STDLIB
|
||||
m68k-amigaos-gcc pistorm_dev.c simple_interact.c -mregparm -m68020 -O2 -o PiSimple -Wno-unused-parameter -noixemul -DHAS_STDLIB -Wall
|
||||
|
||||
@@ -37,6 +37,8 @@ unsigned int pistorm_base_addr = 0xFFFFFFFF;
|
||||
#define READLONG(cmd, var) var = *(volatile unsigned int *)(pistorm_base_addr + cmd);
|
||||
#define READBYTE(cmd, var) var = *(volatile unsigned short *)(pistorm_base_addr + cmd);
|
||||
|
||||
#define RETURN_CMDRES READSHORT(PI_CMDRESULT, short_val); return short_val;
|
||||
|
||||
unsigned short short_val;
|
||||
|
||||
unsigned int pi_find_pistorm() {
|
||||
@@ -62,17 +64,102 @@ void pi_reset_amiga(unsigned short reset_code) {
|
||||
WRITESHORT(PI_CMD_RESET, reset_code);
|
||||
}
|
||||
|
||||
void pi_handle_config(unsigned char cmd, char *str) {
|
||||
// Kickstart/Extended ROM stuff
|
||||
unsigned short pi_remap_kickrom(char *filename) {
|
||||
WRITELONG(PI_STR1, (unsigned int)filename);
|
||||
WRITESHORT(PI_CMD_KICKROM, 1);
|
||||
|
||||
RETURN_CMDRES;
|
||||
}
|
||||
|
||||
unsigned short pi_remap_extrom(char *filename) {
|
||||
WRITELONG(PI_STR1, (unsigned int)filename);
|
||||
WRITESHORT(PI_CMD_EXTROM, 1);
|
||||
|
||||
RETURN_CMDRES;
|
||||
}
|
||||
|
||||
// PiSCSI stuff
|
||||
// TODO: There's currently no way to read back what drives are mounted at which SCSI index.
|
||||
unsigned short pi_piscsi_map_drive(char *filename, unsigned char index) {
|
||||
WRITESHORT(PI_WORD1, index);
|
||||
WRITELONG(PI_STR1, (unsigned int)filename);
|
||||
WRITESHORT(PI_CMD_PISCSI_CTRL, PISCSI_CTRL_MAP);
|
||||
|
||||
RETURN_CMDRES;
|
||||
}
|
||||
|
||||
unsigned short pi_piscsi_unmap_drive(unsigned char index) {
|
||||
WRITESHORT(PI_WORD1, index);
|
||||
WRITESHORT(PI_CMD_PISCSI_CTRL, PISCSI_CTRL_UNMAP);
|
||||
|
||||
RETURN_CMDRES;
|
||||
}
|
||||
|
||||
// For virtual removable media. Not yet implemented.
|
||||
unsigned short pi_piscsi_insert_media(char *filename, unsigned char index) {
|
||||
WRITESHORT(PI_WORD1, index);
|
||||
WRITELONG(PI_STR1, (unsigned int)filename);
|
||||
WRITESHORT(PI_CMD_PISCSI_CTRL, PISCSI_CTRL_INSERT);
|
||||
|
||||
RETURN_CMDRES;
|
||||
}
|
||||
|
||||
unsigned short pi_piscsi_eject_media(unsigned char index) {
|
||||
WRITESHORT(PI_WORD1, index);
|
||||
WRITESHORT(PI_CMD_PISCSI_CTRL, PISCSI_CTRL_EJECT);
|
||||
|
||||
RETURN_CMDRES;
|
||||
}
|
||||
|
||||
// Config file stuff
|
||||
unsigned short pi_load_config(char *filename) {
|
||||
WRITELONG(PI_STR1, (unsigned int)filename);
|
||||
WRITESHORT(PI_CMD_SWITCHCONFIG, PICFG_LOAD);
|
||||
|
||||
RETURN_CMDRES;
|
||||
}
|
||||
|
||||
void pi_reload_config() {
|
||||
WRITESHORT(PI_CMD_SWITCHCONFIG, PICFG_RELOAD);
|
||||
}
|
||||
|
||||
void pi_load_default_config() {
|
||||
WRITESHORT(PI_CMD_SWITCHCONFIG, PICFG_DEFAULT);
|
||||
}
|
||||
|
||||
unsigned short pi_handle_config(unsigned char cmd, char *str) {
|
||||
if (cmd == PICFG_LOAD) {
|
||||
WRITELONG(PI_STR1, (unsigned int)str);
|
||||
}
|
||||
WRITESHORT(PI_CMD_SWITCHCONFIG, cmd);
|
||||
|
||||
RETURN_CMDRES;
|
||||
}
|
||||
|
||||
// Generic stuff
|
||||
#define SIMPLEWRITE_SHORT(a, b) \
|
||||
void a(unsigned short val) { WRITESHORT(b, val); }
|
||||
|
||||
// Simple feature status write functions
|
||||
SIMPLEWRITE_SHORT(pi_enable_rtg, PI_CMD_RTGSTATUS);
|
||||
SIMPLEWRITE_SHORT(pi_enable_net, PI_CMD_NETSTATUS);
|
||||
SIMPLEWRITE_SHORT(pi_enable_piscsi, PI_CMD_RTGSTATUS);
|
||||
|
||||
// Generic feature status setting function.
|
||||
// Example: pi_set_feature_status(PI_CMD_RTGSTATUS, 1) to enable RTG
|
||||
// pi_set_feature_status(PI_CMD_PISCSI_CTRL, PISCSI_CTRL_ENABLE) to enable PiSCSI
|
||||
void pi_set_feature_status(unsigned short cmd, unsigned char value) {
|
||||
WRITESHORT(cmd, value);
|
||||
}
|
||||
|
||||
#define SIMPLEREAD_SHORT(a, b) \
|
||||
unsigned short a() { READSHORT(b, short_val); return short_val; }
|
||||
|
||||
// Simple feature status read functions
|
||||
SIMPLEREAD_SHORT(pi_get_hw_rev, PI_CMD_HWREV);
|
||||
SIMPLEREAD_SHORT(pi_get_sw_rev, PI_CMD_SWREV);
|
||||
SIMPLEREAD_SHORT(pi_get_rtg_status, PI_CMD_RTGSTATUS);
|
||||
SIMPLEREAD_SHORT(pi_get_net_status, PI_CMD_NETSTATUS);
|
||||
SIMPLEREAD_SHORT(pi_get_piscsi_status, PI_CMD_PISCSI_CTRL);
|
||||
SIMPLEREAD_SHORT(pi_get_cmd_result, PI_CMDRESULT);
|
||||
|
||||
@@ -6,6 +6,25 @@ unsigned short pi_get_hw_rev();
|
||||
unsigned short pi_get_sw_rev();
|
||||
unsigned short pi_get_net_status();
|
||||
unsigned short pi_get_rtg_status();
|
||||
unsigned short pi_get_piscsi_status();
|
||||
|
||||
void enable_rtg(unsigned short val);
|
||||
void enable_net(unsigned short val);
|
||||
void enable_piscsi(unsigned short val);
|
||||
|
||||
void pi_reset_amiga(unsigned short reset_code);
|
||||
void pi_handle_config(unsigned char cmd, char *str);
|
||||
unsigned short pi_handle_config(unsigned char cmd, char *str);
|
||||
|
||||
void pi_set_feature_status(unsigned short cmd, unsigned char value);
|
||||
|
||||
unsigned short pi_piscsi_map_drive(char *filename, unsigned char index);
|
||||
unsigned short pi_piscsi_unmap_drive(unsigned char index);
|
||||
unsigned short pi_piscsi_insert_media(char *filename, unsigned char index);
|
||||
unsigned short pi_piscsi_eject_media(unsigned char index);
|
||||
|
||||
unsigned short pi_load_config(char *filename);
|
||||
void pi_reload_config();
|
||||
void pi_load_default_config();
|
||||
|
||||
unsigned short pi_remap_kickrom(char *filename);
|
||||
unsigned short pi_remap_extrom(char *filename);
|
||||
|
||||
@@ -79,6 +79,7 @@ int __stdargs main (int argc, char *argv[]) {
|
||||
printf ("Software revision: %d.%d\n", (pi_get_sw_rev() >> 8), (pi_get_sw_rev() & 0xFF));
|
||||
printf ("RTG: %s - %s\n", (pi_get_rtg_status() & 0x01) ? "Enabled" : "Disabled", (pi_get_rtg_status() & 0x02) ? "In use" : "Not in use");
|
||||
printf ("NET: %s\n", pi_get_net_status() ? "Enabled" : "Disabled");
|
||||
printf ("PiSCSI: %s\n", pi_get_piscsi_status() ? "Enabled" : "Disabled");
|
||||
break;
|
||||
case PI_CMD_SWITCHCONFIG:
|
||||
if (cmd_arg == PICFG_LOAD) {
|
||||
@@ -108,6 +109,14 @@ int get_command(char *cmd) {
|
||||
cmd_arg = PICFG_LOAD;
|
||||
return PI_CMD_SWITCHCONFIG;
|
||||
}
|
||||
if (strcmp(cmd, "--config-reload") == 0 || strcmp(cmd, "--reload-config") == 0 || strcmp(cmd, "--reloadcfg") == 0) {
|
||||
cmd_arg = PICFG_RELOAD;
|
||||
return PI_CMD_SWITCHCONFIG;
|
||||
}
|
||||
if (strcmp(cmd, "--config-default") == 0 || strcmp(cmd, "--default-config") == 0 || strcmp(cmd, "--defcfg") == 0) {
|
||||
cmd_arg = PICFG_DEFAULT;
|
||||
return PI_CMD_SWITCHCONFIG;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -17,6 +17,9 @@ void rtg_set_clut_entry(uint8_t index, uint32_t xrgb);
|
||||
void rtg_init_display();
|
||||
void rtg_shutdown_display();
|
||||
|
||||
int init_rtg_data();
|
||||
void shutdown_rtg();
|
||||
|
||||
void rtg_fillrect(uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint32_t color, uint16_t pitch, uint16_t format, uint8_t mask);
|
||||
void rtg_fillrect_solid(uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint32_t color, uint16_t pitch, uint16_t format);
|
||||
void rtg_invertrect(uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t pitch, uint16_t format, uint8_t mask);
|
||||
|
||||
Reference in New Issue
Block a user