Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/86Box/86Box
Browse files Browse the repository at this point in the history
  • Loading branch information
OBattler committed Jun 1, 2024
2 parents ab137e9 + 9b4846d commit 86b9ccc
Show file tree
Hide file tree
Showing 7 changed files with 231 additions and 54 deletions.
154 changes: 149 additions & 5 deletions src/device/isamem.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@
*
*
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
* Jasmine Iwanek <jriwanek@gmail.com>
*
* Copyright 2018 Fred N. van Kempen.
* Copyright 2018 Fred N. van Kempen.
* Copyright 2022-2024 Jasmine Iwanek.
*
* Redistribution and use in source and binary forms, with
* or without modification, are permitted provided that the
Expand Down Expand Up @@ -98,14 +100,15 @@
#define ISAMEM_ABOVEBOARD_CARD 12
#define ISAMEM_BRAT_CARD 13
#define ISAMEM_EV165A_CARD 14
#define ISAMEM_LOTECH_CARD 15

#define ISAMEM_DEBUG 0

#define RAM_TOPMEM (640 << 10) /* end of low memory */
#define RAM_UMAMEM (384 << 10) /* upper memory block */
#define RAM_EXTMEM (1024 << 10) /* start of high memory */

#define EMS_MAXSIZE (2048 << 10) /* max EMS memory size */
#define EMS_MAXSIZE (4096 << 10) /* max EMS memory size */
#define EMS_PGSIZE (16 << 10) /* one page is this big */
#define EMS_MAXPAGE 4 /* number of viewport pages */

Expand Down Expand Up @@ -318,6 +321,26 @@ ems_read(uint16_t port, void *priv)
return ret;
}

/* Handle a READ operation from one of our registers. */
static uint8_t
consecutive_ems_read(uint16_t port, void *priv)
{
const memdev_t *dev = (memdev_t *) priv;
uint8_t ret = 0xff;
int vpage;

/* Get the viewport page number. */
vpage = (port - dev->base_addr);

isamem_log("ISAMEM: read(%04x) = %02x) page=%d\n", port, ret, vpage);

ret = dev->ems[vpage].page;
if (dev->ems[vpage].enabled)
ret |= 0x80;

return ret;
}

/* Handle a WRITE operation to one of our registers. */
static void
ems_write(uint16_t port, uint8_t val, void *priv)
Expand Down Expand Up @@ -393,6 +416,47 @@ ems_write(uint16_t port, uint8_t val, void *priv)
}
}

/* Handle a WRITE operation to one of our registers. */
static void
consecutive_ems_write(uint16_t port, uint8_t val, void *priv)
{
memdev_t *dev = (memdev_t *) priv;
int vpage;

/* Get the viewport page number. */
vpage = (port - dev->base_addr);

isamem_log("ISAMEM: write(%04x, %02x) page=%d\n", port, val, vpage);

isamem_log("EMS: write(%02x) to register 0! (%02x)\n", val);
/* Set the page number. */
dev->ems[vpage].enabled = (val & 0xff);
dev->ems[vpage].page = (val & 0xff);

/* Make sure we can do that.. */
if (dev->flags & FLAG_CONFIG) {
if (dev->ems[vpage].page < dev->ems_pages) {
/* Pre-calculate the page address in EMS RAM. */
dev->ems[vpage].addr = dev->ram + dev->ems_start + ((val & 0xff) * EMS_PGSIZE);
} else {
/* That page does not exist. */
dev->ems[vpage].enabled = 0;
}

if (dev->ems[vpage].enabled) {
/* Update the EMS RAM address for this page. */
mem_mapping_set_exec(&dev->ems[vpage].mapping,
dev->ems[vpage].addr);

/* Enable this page. */
mem_mapping_enable(&dev->ems[vpage].mapping);
} else {
/* Disable this page. */
mem_mapping_disable(&dev->ems[vpage].mapping);
}
}
}

/* Initialize the device for use. */
static void *
isamem_init(const device_t *info)
Expand Down Expand Up @@ -435,6 +499,7 @@ isamem_init(const device_t *info)
case ISAMEM_EMS5150_CARD: /* Micro Mainframe EMS-5150(T) */
dev->base_addr = device_get_config_hex16("base");
dev->total_size = device_get_config_int("size");
dev->start_addr = 0;
dev->frame_addr = 0xD0000;
dev->flags |= (FLAG_EMS | FLAG_CONFIG);
break;
Expand Down Expand Up @@ -476,6 +541,13 @@ isamem_init(const device_t *info)
dev->flags |= FLAG_FAST;
break;

case ISAMEM_LOTECH_CARD:
dev->base_addr = device_get_config_hex16("base");
dev->total_size = device_get_config_int("size");
dev->start_addr = 0;
dev->frame_addr = device_get_config_hex20("frame");
dev->flags |= (FLAG_EMS | FLAG_CONFIG);

default:
break;
}
Expand Down Expand Up @@ -625,7 +697,7 @@ isamem_init(const device_t *info)

/* If EMS is enabled, use the remainder for EMS. */
if (dev->flags & FLAG_EMS) {
/* EMS 3.2 cannot have more than 2048KB per board. */
/* EMS 3.2 cannot have more than 4096KB per board. */
t = k;
if (t > EMS_MAXSIZE)
t = EMS_MAXSIZE;
Expand Down Expand Up @@ -663,9 +735,14 @@ isamem_init(const device_t *info)
mem_mapping_disable(&dev->ems[i].mapping);

/* Set up an I/O port handler. */
io_sethandler(dev->base_addr + (EMS_PGSIZE * i), 2,
ems_read, NULL, NULL, ems_write, NULL, NULL, dev);
if (dev->board != ISAMEM_LOTECH_CARD)
io_sethandler(dev->base_addr + (EMS_PGSIZE * i), 2,
ems_read, NULL, NULL, ems_write, NULL, NULL, dev);
}

if (dev->board == ISAMEM_LOTECH_CARD)
io_sethandler(dev->base_addr, 4,
consecutive_ems_read, NULL, NULL, consecutive_ems_write, NULL, NULL, dev);
}

/* Let them know our device instance. */
Expand Down Expand Up @@ -1439,6 +1516,72 @@ static const device_t brat_device = {
};
#endif

static const device_config_t lotech_config[] = {
// clang-format off
{
.name = "base",
.description = "Address",
.type = CONFIG_HEX16,
.default_string = "",
.default_int = 0x0260,
.file_filter = "",
.spinner = { 0 },
.selection = {
{ .description = "260H", .value = 0x0260 },
{ .description = "264H", .value = 0x0264 },
{ .description = "268H", .value = 0x0268 },
{ .description = "26CH", .value = 0x026C },
{ .description = "" }
},
},
{
.name = "frame",
.description = "Frame Address",
.type = CONFIG_HEX20,
.default_string = "",
.default_int = 0xe0000,
.file_filter = "",
.spinner = { 0 },
.selection = {
{ .description = "Disabled", .value = 0x00000 },
{ .description = "C000H", .value = 0xC0000 },
{ .description = "D000H", .value = 0xD0000 },
{ .description = "E000H", .value = 0xE0000 },
{ .description = "" }
},
},
{
.name = "size",
.description = "Memory Size",
.type = CONFIG_SPINNER,
.default_string = "",
.default_int = 2048,
.file_filter = "",
.spinner = {
.min = 512,
.max = 4096,
.step = 512
},
.selection = { { 0 } }
},
{ .name = "", .description = "", .type = CONFIG_END }
// clang-format on
};

static const device_t lotech_device = {
.name = "Lo-tech EMS Board",
.internal_name = "lotechems",
.flags = DEVICE_ISA,
.local = ISAMEM_LOTECH_CARD,
.init = isamem_init,
.close = isamem_close,
.reset = NULL,
{ .available = NULL },
.speed_changed = NULL,
.force_redraw = NULL,
.config = lotech_config
};

#if defined(DEV_BRANCH) && defined(USE_ISAMEM_RAMPAGE)
static const device_config_t rampage_config[] = {
// clang-format off
Expand Down Expand Up @@ -1676,6 +1819,7 @@ static const struct {
#if defined(DEV_BRANCH) && defined(USE_ISAMEM_IAB)
{ &iab_device },
#endif
{ &lotech_device },
{ NULL }
// clang-format on
};
Expand Down
1 change: 1 addition & 0 deletions src/include/86box/video.h
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,7 @@ extern const device_t s3_diamond_stealth_2000_pci_device;
extern const device_t s3_diamond_stealth_3000_pci_device;
extern const device_t s3_stb_velocity_3d_pci_device;
extern const device_t s3_virge_375_pci_device;
extern const device_t s3_virge_375_onboard_pci_device;
extern const device_t s3_diamond_stealth_2000pro_pci_device;
extern const device_t s3_virge_385_pci_device;
extern const device_t s3_virge_357_pci_device;
Expand Down
7 changes: 7 additions & 0 deletions src/machine/m_at_socket8.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include <86box/timer.h>
#include <86box/nvr.h>
#include <86box/sio.h>
#include <86box/sound.h>
#include <86box/hwm.h>
#include <86box/spd.h>
#include <86box/video.h>
Expand Down Expand Up @@ -322,6 +323,12 @@ machine_at_ap440fx_init(const machine_t *model)
device_add(&pc87307_device);
device_add(&intel_flash_bxt_ami_device);

if (sound_card_current[0] == SOUND_INTERNAL)
device_add(&cs4236b_device);

if (gfxcard[0] == VID_INTERNAL)
device_add(&s3_virge_375_onboard_pci_device);

return ret;
}

Expand Down
58 changes: 29 additions & 29 deletions src/machine/machine_table.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,28 +58,28 @@ extern const device_t ps1_2011_device;

const machine_filter_t machine_types[] = {
{ "None", MACHINE_TYPE_NONE },
{ "8088", MACHINE_TYPE_8088 },
{ "8086", MACHINE_TYPE_8086 },
{ "80286", MACHINE_TYPE_286 },
{ "i386SX", MACHINE_TYPE_386SX },
{ "486SLC", MACHINE_TYPE_486SLC },
{ "i386DX", MACHINE_TYPE_386DX },
{ "i386DX/i486", MACHINE_TYPE_386DX_486 },
{ "i486 (Socket 168 and 1)", MACHINE_TYPE_486 },
{ "i486 (Socket 2)", MACHINE_TYPE_486_S2 },
{ "i486 (Socket 3)", MACHINE_TYPE_486_S3 },
{ "i486 (Miscellaneous)", MACHINE_TYPE_486_MISC },
{ "Socket 4", MACHINE_TYPE_SOCKET4 },
{ "Socket 5", MACHINE_TYPE_SOCKET5 },
{ "Socket 7 (Single Voltage)", MACHINE_TYPE_SOCKET7_3V },
{ "Socket 7 (Dual Voltage)", MACHINE_TYPE_SOCKET7 },
{ "Super Socket 7", MACHINE_TYPE_SOCKETS7 },
{ "Socket 8", MACHINE_TYPE_SOCKET8 },
{ "Slot 1", MACHINE_TYPE_SLOT1 },
{ "Slot 1/2", MACHINE_TYPE_SLOT1_2 },
{ "Slot 1/Socket 370", MACHINE_TYPE_SLOT1_370 },
{ "Slot 2", MACHINE_TYPE_SLOT2 },
{ "Socket 370", MACHINE_TYPE_SOCKET370 },
{ "[1979] 8088", MACHINE_TYPE_8088 },
{ "[1978] 8086", MACHINE_TYPE_8086 },
{ "[1982] 80286", MACHINE_TYPE_286 },
{ "[1988] i386SX", MACHINE_TYPE_386SX },
{ "[1992] 486SLC", MACHINE_TYPE_486SLC },
{ "[1985] i386DX", MACHINE_TYPE_386DX },
{ "[1989] i386DX/i486", MACHINE_TYPE_386DX_486 },
{ "[1992] i486 (Socket 168 and 1)", MACHINE_TYPE_486 },
{ "[1992] i486 (Socket 2)", MACHINE_TYPE_486_S2 },
{ "[1994] i486 (Socket 3)", MACHINE_TYPE_486_S3 },
{ "[1992] i486 (Miscellaneous)", MACHINE_TYPE_486_MISC },
{ "[1993] Socket 4", MACHINE_TYPE_SOCKET4 },
{ "[1994] Socket 5", MACHINE_TYPE_SOCKET5 },
{ "[1995] Socket 7 (Single Voltage)", MACHINE_TYPE_SOCKET7_3V },
{ "[1995] Socket 7 (Dual Voltage)", MACHINE_TYPE_SOCKET7 },
{ "[1998] Super Socket 7", MACHINE_TYPE_SOCKETS7 },
{ "[1995] Socket 8", MACHINE_TYPE_SOCKET8 },
{ "[1996] Slot 1", MACHINE_TYPE_SLOT1 },
{ "[1998] Slot 1/2", MACHINE_TYPE_SLOT1_2 },
{ "[1998] Slot 1/Socket 370", MACHINE_TYPE_SLOT1_370 },
{ "[1998] Slot 2", MACHINE_TYPE_SLOT2 },
{ "[1998] Socket 370", MACHINE_TYPE_SOCKET370 },
{ "Miscellaneous", MACHINE_TYPE_MISC }
};

Expand Down Expand Up @@ -5182,7 +5182,7 @@ const machine_t machines[] = {
.snd_device = NULL,
.net_device = NULL
},
/* The board has a "ASII KB-100" which I was not able to find any information about,
/* The board has a "ASII KB-100" which I was not able to find any information about,
but the BIOS sends commands C9 without a parameter and D5, both of which are
Phoenix MultiKey commands. */
{
Expand Down Expand Up @@ -10606,7 +10606,7 @@ const machine_t machines[] = {
.snd_device = NULL,
.net_device = NULL
},
/* [TEST] The board doesn't seem to have a KBC at all, which probably means it's an on-chip one on the PC87306 SIO.
/* [TEST] The board doesn't seem to have a KBC at all, which probably means it's an on-chip one on the PC87306 SIO.
A list on a Danish site shows the BIOS as having a -0 string, indicating non-AMI KBC firmware. */
{
.name = "[i430HX] Supermicro P55T2S",
Expand Down Expand Up @@ -12658,7 +12658,7 @@ const machine_t machines[] = {
.snd_device = NULL,
.net_device = NULL
},

/* ALi ALADDiN IV+ */
/* Has the ALi M1543 southbridge with on-chip KBC. */
{
Expand Down Expand Up @@ -13051,7 +13051,7 @@ const machine_t machines[] = {
.max_multi = 5.5
},
.bus_flags = MACHINE_PS2_A97 | MACHINE_BUS_USB,
.flags = MACHINE_IDE_DUAL | MACHINE_SOUND | MACHINE_APM | MACHINE_ACPI | MACHINE_GAMEPORT | MACHINE_USB,
.flags = MACHINE_IDE_DUAL | MACHINE_SOUND | MACHINE_APM | MACHINE_ACPI | MACHINE_GAMEPORT | MACHINE_USB,
.ram = {
.min = 8192,
.max = 786432,
Expand Down Expand Up @@ -13462,7 +13462,7 @@ const machine_t machines[] = {
.max_multi = 3.5
},
.bus_flags = MACHINE_PS2_PCI | MACHINE_BUS_USB,
.flags = MACHINE_IDE_DUAL | MACHINE_APM | MACHINE_USB, /* Machine has internal video: S3 ViRGE/DX and sound: Crystal CS4236B */
.flags = MACHINE_IDE_DUAL | MACHINE_APM | MACHINE_SOUND | MACHINE_VIDEO | MACHINE_USB, /* Machine has internal video: S3 ViRGE/DX and sound: Crystal CS4236B */
.ram = {
.min = 8192,
.max = 131072,
Expand All @@ -13476,8 +13476,8 @@ const machine_t machines[] = {
.device = NULL,
.fdc_device = NULL,
.sio_device = NULL,
.vid_device = NULL,
.snd_device = NULL,
.vid_device = &s3_virge_375_onboard_pci_device,
.snd_device = &cs4236b_device,
.net_device = NULL
},
/* According to tests from real hardware: This has AMI MegaKey KBC firmware on the
Expand Down
Loading

0 comments on commit 86b9ccc

Please sign in to comment.