Add Generic MM58167 RTC

This commit is contained in:
Jasmine Iwanek
2024-05-06 06:40:57 -04:00
parent d8eb77849c
commit 3f3b921831

View File

@@ -76,17 +76,23 @@
#include <86box/machine.h>
#include <86box/io.h>
#include <86box/device.h>
#include <86box/mem.h>
#include <86box/nvr.h>
#include <86box/rom.h>
#include <86box/ui.h>
#include <86box/plat.h>
#include <86box/pic.h>
#include <86box/isartc.h>
#define ISARTC_EV170 0
#define ISARTC_DTK 1
#define ISARTC_P5PAK 2
#define ISARTC_A6PAK 3
#define ISARTC_VENDEX 4
#define ISARTC_EV170 0
#define ISARTC_DTK 1
#define ISARTC_P5PAK 2
#define ISARTC_A6PAK 3
#define ISARTC_VENDEX 4
#define ISARTC_MM58167 10
#define ISARTC_ROM_MM58167_1 "roms/rtc/glatick/GLaTICK_0.8.5_NS_RP.ROM"
#define ISARTC_ROM_MM58167_2 "roms/rtc/glatick/GLaTICK_0.8.5_86B.ROM"
#define ISARTC_DEBUG 0
@@ -101,6 +107,7 @@ typedef struct rtcdev_t {
int8_t irq; /* configured IRQ channel */
int8_t base_addrsz;
uint32_t base_addr; /* configured I/O address */
rom_t rom; /* BIOS ROM, If configured */
/* Fields for the specific driver. */
void (*f_wr)(uint16_t, uint8_t, void *);
@@ -524,6 +531,14 @@ isartc_init(const device_t *info)
/* Do per-board initialization. */
switch (dev->board) {
case ISARTC_MM58167: /* Generic MM58167 RTC */
{
int rom_addr = device_get_config_hex20("bios_addr");
if (rom_addr != -1)
rom_init(&dev->rom, ISARTC_ROM_MM58167_1,
rom_addr, 0x0800, 0x7ff, 0, MEM_MAPPING_EXTERNAL);
}
case ISARTC_EV170: /* Everex EV-170 Magic I/O */
dev->flags |= FLAG_YEAR80;
dev->base_addr = device_get_config_hex16("base");
@@ -738,6 +753,90 @@ static const device_t a6pak_device = {
.config = a6pak_config
};
static const device_config_t mm58167_config[] = {
// clang-format off
{
.name = "base",
.description = "Address",
.type = CONFIG_HEX16,
.default_string = "",
.default_int = 0x02C0,
.file_filter = "",
.spinner = { 0 },
.selection = {
{ "240H", 0x0240 },
{ "2C0H", 0x02c0 },
{ "340H", 0x0340 },
{ "" }
},
},
{
.name = "irq",
.description = "IRQ",
.type = CONFIG_SELECTION,
.default_string = "",
.default_int = -1,
.file_filter = "",
.spinner = { 0 },
.selection = {
{ "Disabled", -1 },
{ "IRQ2", 2 },
{ "IRQ5", 5 },
{ "IRQ7", 7 },
{ "" }
},
},
{
.name = "bios_addr",
.description = "BIOS Address",
.type = CONFIG_HEX20,
.default_string = "",
.default_int = 0xcc000,
.file_filter = "",
.spinner = { 0 },
.selection = {
{ .description = "Disabled", .value = -1 },
{ .description = "C800H", .value = 0xc8000 },
{ .description = "CA00H", .value = 0xca000 },
{ .description = "CC00H", .value = 0xcc000 },
{ .description = "CE00H", .value = 0xce000 },
{ .description = "D000H", .value = 0xd0000 },
{ .description = "D200H", .value = 0xd2000 },
{ .description = "D400H", .value = 0xd4000 },
{ .description = "D600H", .value = 0xd6000 },
{ .description = "D800H", .value = 0xd8000 },
{ .description = "DA00H", .value = 0xda000 },
{ .description = "DC00H", .value = 0xdc000 },
{ .description = "DE00H", .value = 0xde000 },
{ .description = "E000H", .value = 0xe0000 },
{ .description = "E200H", .value = 0xe2000 },
{ .description = "E400H", .value = 0xe4000 },
{ .description = "E600H", .value = 0xe6000 },
{ .description = "E800H", .value = 0xe8000 },
{ .description = "EA00H", .value = 0xea000 },
{ .description = "EC00H", .value = 0xec000 },
{ .description = "EE00H", .value = 0xee000 },
{ .description = "" }
},
},
{ .name = "", .description = "", .type = CONFIG_END }
// clang-format on
};
static const device_t mm58167_device = {
.name = "Generic MM58167 RTC",
.internal_name = "rtc_mm58167",
.flags = DEVICE_ISA,
.local = ISARTC_MM58167,
.init = isartc_init,
.close = isartc_close,
.reset = NULL,
.available = NULL,
.speed_changed = NULL,
.force_redraw = NULL,
.config = mm58167_config
};
/* Onboard RTC devices */
const device_t vendex_xt_rtc_onboard_device = {
.name = "National Semiconductor MM58167 (Vendex)",
@@ -757,12 +856,13 @@ static const struct {
const device_t *dev;
} boards[] = {
// clang-format off
{ &device_none },
{ &ev170_device },
{ &pii147_device },
{ &p5pak_device },
{ &a6pak_device },
{ NULL },
{ &device_none },
{ &ev170_device },
{ &pii147_device },
{ &p5pak_device },
{ &a6pak_device },
{ &mm58167_device },
{ NULL }
// clang-format on
};