ISA ROM system cleanups
This commit is contained in:
@@ -26,9 +26,11 @@
|
|||||||
#include <86box/nvr.h>
|
#include <86box/nvr.h>
|
||||||
#include <86box/isarom.h>
|
#include <86box/isarom.h>
|
||||||
|
|
||||||
#define ISAROM_CARD 0
|
enum {
|
||||||
#define ISAROM_CARD_DUAL 1
|
ISAROM_CARD = 0,
|
||||||
#define ISAROM_CARD_QUAD 2
|
ISAROM_CARD_DUAL,
|
||||||
|
ISAROM_CARD_QUAD
|
||||||
|
};
|
||||||
|
|
||||||
#ifdef ENABLE_ISAROM_LOG
|
#ifdef ENABLE_ISAROM_LOG
|
||||||
int isarom_do_log = ENABLE_ISAROM_LOG;
|
int isarom_do_log = ENABLE_ISAROM_LOG;
|
||||||
@@ -56,7 +58,7 @@ typedef struct isarom_t {
|
|||||||
uint32_t size;
|
uint32_t size;
|
||||||
uint32_t len;
|
uint32_t len;
|
||||||
char nvr_path[64];
|
char nvr_path[64];
|
||||||
uint8_t wp;
|
uint8_t writable;
|
||||||
} socket[4];
|
} socket[4];
|
||||||
uint8_t inst;
|
uint8_t inst;
|
||||||
uint8_t type;
|
uint8_t type;
|
||||||
@@ -65,11 +67,14 @@ typedef struct isarom_t {
|
|||||||
static inline uint8_t
|
static inline uint8_t
|
||||||
get_limit(uint8_t type)
|
get_limit(uint8_t type)
|
||||||
{
|
{
|
||||||
if (type == ISAROM_CARD_DUAL)
|
switch (type) {
|
||||||
return 2;
|
case ISAROM_CARD_DUAL:
|
||||||
if (type == ISAROM_CARD_QUAD)
|
return 2;
|
||||||
return 4;
|
case ISAROM_CARD_QUAD:
|
||||||
return 1;
|
return 4;
|
||||||
|
default:
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
@@ -92,12 +97,13 @@ isarom_close(void *priv)
|
|||||||
if (!priv)
|
if (!priv)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (uint8_t i = 0; i < get_limit(dev->type); i++)
|
for (uint8_t i = 0; i < get_limit(dev->type); i++) {
|
||||||
if (dev->socket[i].rom.rom) {
|
if (dev->socket[i].writable) {
|
||||||
isarom_log("isarom[%u]: saving NVR for socket %u -> %s (%u bytes)\n",
|
isarom_log("isarom[%u]: saving NVR for socket %u -> %s (%u bytes)\n",
|
||||||
dev->inst, i, dev->socket[i].nvr_path, dev->socket[i].size);
|
dev->inst, i, dev->socket[i].nvr_path, dev->socket[i].size);
|
||||||
isarom_save_nvr(dev->socket[i].nvr_path, dev->socket[i].rom.rom, dev->socket[i].size);
|
isarom_save_nvr(dev->socket[i].nvr_path, dev->socket[i].rom.rom, dev->socket[i].size);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
free(dev);
|
free(dev);
|
||||||
}
|
}
|
||||||
@@ -115,32 +121,37 @@ isarom_init(const device_t *info)
|
|||||||
isarom_log("isarom[%u]: initializing device (type=%u)\n", dev->inst, dev->type);
|
isarom_log("isarom[%u]: initializing device (type=%u)\n", dev->inst, dev->type);
|
||||||
|
|
||||||
for (uint8_t i = 0; i < get_limit(dev->type); i++) {
|
for (uint8_t i = 0; i < get_limit(dev->type); i++) {
|
||||||
char key_fn[12];
|
char s[22];
|
||||||
char key_addr[14];
|
|
||||||
char key_size[14];
|
|
||||||
char key_writes[22];
|
|
||||||
char suffix[4] = "";
|
char suffix[4] = "";
|
||||||
if (i > 0)
|
if (i > 0)
|
||||||
snprintf(suffix, sizeof(suffix), "%d", i + 1);
|
snprintf(suffix, sizeof(suffix), "%d", i + 1);
|
||||||
|
|
||||||
snprintf(key_fn, sizeof(key_fn), "bios_fn%s", suffix);
|
snprintf(s, sizeof(s), "bios_addr%s", suffix);
|
||||||
snprintf(key_addr, sizeof(key_addr), "bios_addr%s", suffix);
|
dev->socket[i].addr = device_get_config_hex20(s);
|
||||||
snprintf(key_size, sizeof(key_size), "bios_size%s", suffix);
|
|
||||||
snprintf(key_writes, sizeof(key_writes), "rom_writes_enabled%s", suffix);
|
|
||||||
|
|
||||||
dev->socket[i].fn = device_get_config_string(key_fn);
|
switch (dev->type) {
|
||||||
dev->socket[i].addr = device_get_config_hex20(key_addr);
|
default:
|
||||||
dev->socket[i].size = device_get_config_int(key_size);
|
snprintf(s, sizeof(s), "bios_fn%s", suffix);
|
||||||
// Note: 2K is the smallest ROM I've found, but 86box's memory granularity is 4k, the number below is fine
|
dev->socket[i].fn = device_get_config_string(s);
|
||||||
// as we'll end up allocating no less than 4k due to the device config limits.
|
|
||||||
dev->socket[i].len = (dev->socket[i].size > 2048) ? dev->socket[i].size - 1 : 0;
|
|
||||||
dev->socket[i].wp = (uint8_t) device_get_config_int(key_writes) ? 1 : 0;
|
|
||||||
|
|
||||||
isarom_log("isarom[%u]: socket %u: addr=0x%05X size=%u wp=%u fn=%s\n",
|
snprintf(s, sizeof(s), "bios_size%s", suffix);
|
||||||
|
dev->socket[i].size = device_get_config_int(s);
|
||||||
|
|
||||||
|
snprintf(s, sizeof(s), "rom_writes_enabled%s", suffix);
|
||||||
|
if (device_get_config_int(s))
|
||||||
|
dev->socket[i].writable = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Note: 2K is the smallest ROM I've found, but 86Box's memory granularity is 4K, the number
|
||||||
|
below is fine as we'll end up allocating no less than 4K due to the device config limits. */
|
||||||
|
dev->socket[i].len = (dev->socket[i].size > 0) ? ((dev->socket[i].size - 1) | MEM_GRANULARITY_MASK) : 0;
|
||||||
|
|
||||||
|
isarom_log("isarom[%u]: socket %u: addr=0x%05X size=%u writable=%u fn=%s\n",
|
||||||
dev->inst, i, dev->socket[i].addr, dev->socket[i].size,
|
dev->inst, i, dev->socket[i].addr, dev->socket[i].size,
|
||||||
dev->socket[i].wp, dev->socket[i].fn ? dev->socket[i].fn : "(null)");
|
dev->socket[i].writable, dev->socket[i].fn ? dev->socket[i].fn : "(null)");
|
||||||
|
|
||||||
if (dev->socket[i].addr != 0 && dev->socket[i].fn != NULL) {
|
if ((dev->socket[i].addr != 0) && (dev->socket[i].fn != NULL)) {
|
||||||
rom_init(&dev->socket[i].rom,
|
rom_init(&dev->socket[i].rom,
|
||||||
dev->socket[i].fn,
|
dev->socket[i].fn,
|
||||||
dev->socket[i].addr,
|
dev->socket[i].addr,
|
||||||
@@ -151,7 +162,7 @@ isarom_init(const device_t *info)
|
|||||||
|
|
||||||
isarom_log("isarom[%u]: ROM initialized for socket %u\n", dev->inst, i);
|
isarom_log("isarom[%u]: ROM initialized for socket %u\n", dev->inst, i);
|
||||||
|
|
||||||
if (dev->socket[i].wp) {
|
if (dev->socket[i].writable) {
|
||||||
mem_mapping_set_write_handler(&dev->socket[i].rom.mapping, rom_write, rom_writew, rom_writel);
|
mem_mapping_set_write_handler(&dev->socket[i].rom.mapping, rom_write, rom_writew, rom_writel);
|
||||||
snprintf(dev->socket[i].nvr_path, sizeof(dev->socket[i].nvr_path), "isarom_%i_%i.nvr", dev->inst, i + 1);
|
snprintf(dev->socket[i].nvr_path, sizeof(dev->socket[i].nvr_path), "isarom_%i_%i.nvr", dev->inst, i + 1);
|
||||||
FILE *fp = nvr_fopen(dev->socket[i].nvr_path, "rb");
|
FILE *fp = nvr_fopen(dev->socket[i].nvr_path, "rb");
|
||||||
|
|||||||
Reference in New Issue
Block a user