2016-06-26 00:34:39 +02:00
|
|
|
/*
|
2017-05-30 03:38:38 +02:00
|
|
|
* 86Box A hypervisor and IBM PC system emulator that specializes in
|
|
|
|
|
* running old operating systems and software designed for IBM
|
|
|
|
|
* PC systems and compatibles from 1981 through fairly recent
|
|
|
|
|
* system designs based on the PCI bus.
|
|
|
|
|
*
|
|
|
|
|
* This file is part of the 86Box distribution.
|
|
|
|
|
*
|
|
|
|
|
* Emulation of the memory I/O scratch registers on ports 0xE1
|
|
|
|
|
* and 0xE2, used by just about any emulated machine.
|
|
|
|
|
*
|
2017-09-25 04:31:20 -04:00
|
|
|
* Version: @(#)memregs.c 1.0.2 2017/09/24
|
2017-05-30 03:38:38 +02:00
|
|
|
*
|
|
|
|
|
* Author: Miran Grca, <mgrca8@gmail.com>
|
|
|
|
|
* Copyright 2016-2017 Miran Grca.
|
|
|
|
|
*/
|
2017-09-25 04:31:20 -04:00
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <wchar.h>
|
2016-06-26 00:34:39 +02:00
|
|
|
#include "ibm.h"
|
|
|
|
|
#include "io.h"
|
|
|
|
|
#include "memregs.h"
|
|
|
|
|
|
2017-08-24 01:14:39 -04:00
|
|
|
|
2017-02-01 17:55:11 +01:00
|
|
|
static uint8_t mem_regs[16] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
|
2016-06-26 00:34:39 +02:00
|
|
|
|
2017-01-31 20:39:36 +01:00
|
|
|
static uint8_t mem_reg_ffff = 0;
|
|
|
|
|
|
2017-09-25 04:31:20 -04:00
|
|
|
|
2016-06-26 00:34:39 +02:00
|
|
|
void memregs_write(uint16_t port, uint8_t val, void *priv)
|
|
|
|
|
{
|
2017-01-31 20:39:36 +01:00
|
|
|
if (port == 0xffff)
|
|
|
|
|
{
|
|
|
|
|
mem_reg_ffff = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-01 17:55:11 +01:00
|
|
|
mem_regs[port & 0xf] = val;
|
2016-06-26 00:34:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uint8_t memregs_read(uint16_t port, void *priv)
|
|
|
|
|
{
|
2017-01-31 20:39:36 +01:00
|
|
|
if (port == 0xffff)
|
|
|
|
|
{
|
|
|
|
|
return mem_reg_ffff;
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-01 17:55:11 +01:00
|
|
|
return mem_regs[port & 0xf];
|
2016-06-26 00:34:39 +02:00
|
|
|
}
|
|
|
|
|
|
2017-08-24 01:14:39 -04:00
|
|
|
void memregs_init(void)
|
2016-06-26 00:34:39 +02:00
|
|
|
{
|
|
|
|
|
pclog("Memory Registers Init\n");
|
|
|
|
|
|
|
|
|
|
io_sethandler(0x00e1, 0x0002, memregs_read, NULL, NULL, memregs_write, NULL, NULL, NULL);
|
2017-01-31 20:39:36 +01:00
|
|
|
}
|
|
|
|
|
|
2017-08-24 01:14:39 -04:00
|
|
|
void powermate_memregs_init(void)
|
2017-01-31 20:39:36 +01:00
|
|
|
{
|
|
|
|
|
pclog("Memory Registers Init\n");
|
|
|
|
|
|
|
|
|
|
io_sethandler(0x00ed, 0x0002, memregs_read, NULL, NULL, memregs_write, NULL, NULL, NULL);
|
|
|
|
|
io_sethandler(0xffff, 0x0001, memregs_read, NULL, NULL, memregs_write, NULL, NULL, NULL);
|
|
|
|
|
}
|