2005-07-02 16:31:34 +02:00
|
|
|
/*
|
|
|
|
* QEMU Sparc SLAVIO aux io port emulation
|
2007-09-16 23:08:06 +02:00
|
|
|
*
|
2005-07-02 16:31:34 +02:00
|
|
|
* Copyright (c) 2005 Fabrice Bellard
|
2007-09-16 23:08:06 +02:00
|
|
|
*
|
2005-07-02 16:31:34 +02:00
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
|
|
* in the Software without restriction, including without limitation the rights
|
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
* THE SOFTWARE.
|
|
|
|
*/
|
2009-07-13 18:51:27 +02:00
|
|
|
|
2016-01-26 19:17:17 +01:00
|
|
|
#include "qemu/osdep.h"
|
2012-12-17 18:20:04 +01:00
|
|
|
#include "sysemu/sysemu.h"
|
2013-02-04 15:40:22 +01:00
|
|
|
#include "hw/sysbus.h"
|
2010-10-31 10:24:14 +01:00
|
|
|
#include "trace.h"
|
2005-07-02 16:31:34 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* This is the auxio port, chip control and system control part of
|
|
|
|
* chip STP2001 (Slave I/O), also produced as NCR89C105. See
|
|
|
|
* http://www.ibiblio.org/pub/historic-linux/early-ports/Sparc/NCR/NCR89C105.txt
|
|
|
|
*
|
|
|
|
* This also includes the PMC CPU idle controller.
|
|
|
|
*/
|
|
|
|
|
2013-07-26 23:19:11 +02:00
|
|
|
#define TYPE_SLAVIO_MISC "slavio_misc"
|
|
|
|
#define SLAVIO_MISC(obj) OBJECT_CHECK(MiscState, (obj), TYPE_SLAVIO_MISC)
|
|
|
|
|
2005-07-02 16:31:34 +02:00
|
|
|
typedef struct MiscState {
|
2013-07-26 23:19:11 +02:00
|
|
|
SysBusDevice parent_obj;
|
|
|
|
|
2011-11-15 12:13:52 +01:00
|
|
|
MemoryRegion cfg_iomem;
|
2011-11-15 12:13:53 +01:00
|
|
|
MemoryRegion diag_iomem;
|
2011-11-15 12:13:54 +01:00
|
|
|
MemoryRegion mdm_iomem;
|
2011-11-15 12:13:55 +01:00
|
|
|
MemoryRegion led_iomem;
|
2011-11-15 12:13:56 +01:00
|
|
|
MemoryRegion sysctrl_iomem;
|
2011-11-15 12:13:57 +01:00
|
|
|
MemoryRegion aux1_iomem;
|
2011-11-15 12:13:58 +01:00
|
|
|
MemoryRegion aux2_iomem;
|
2007-04-07 20:14:41 +02:00
|
|
|
qemu_irq irq;
|
2011-08-07 21:03:18 +02:00
|
|
|
qemu_irq fdc_tc;
|
2009-08-29 15:37:09 +02:00
|
|
|
uint32_t dummy;
|
2005-07-02 16:31:34 +02:00
|
|
|
uint8_t config;
|
|
|
|
uint8_t aux1, aux2;
|
2007-11-04 18:27:07 +01:00
|
|
|
uint8_t diag, mctrl;
|
2009-08-29 15:37:09 +02:00
|
|
|
uint8_t sysctrl;
|
2007-11-11 18:56:38 +01:00
|
|
|
uint16_t leds;
|
2005-07-02 16:31:34 +02:00
|
|
|
} MiscState;
|
|
|
|
|
2013-07-26 23:21:50 +02:00
|
|
|
#define TYPE_APC "apc"
|
|
|
|
#define APC(obj) OBJECT_CHECK(APCState, (obj), TYPE_APC)
|
|
|
|
|
2009-07-13 18:51:27 +02:00
|
|
|
typedef struct APCState {
|
2013-07-26 23:21:50 +02:00
|
|
|
SysBusDevice parent_obj;
|
|
|
|
|
2011-11-15 12:13:51 +01:00
|
|
|
MemoryRegion iomem;
|
2009-07-13 18:51:27 +02:00
|
|
|
qemu_irq cpu_halt;
|
|
|
|
} APCState;
|
|
|
|
|
2007-05-26 19:39:43 +02:00
|
|
|
#define MISC_SIZE 1
|
2015-04-02 17:09:30 +02:00
|
|
|
#define LED_SIZE 2
|
2008-12-02 18:51:19 +01:00
|
|
|
#define SYSCTRL_SIZE 4
|
2005-07-02 16:31:34 +02:00
|
|
|
|
2008-03-21 19:05:23 +01:00
|
|
|
#define AUX1_TC 0x02
|
|
|
|
|
2007-12-01 15:53:22 +01:00
|
|
|
#define AUX2_PWROFF 0x01
|
|
|
|
#define AUX2_PWRINTCLR 0x02
|
|
|
|
#define AUX2_PWRFAIL 0x20
|
|
|
|
|
|
|
|
#define CFG_PWRINTEN 0x08
|
|
|
|
|
|
|
|
#define SYS_RESET 0x01
|
|
|
|
#define SYS_RESETSTAT 0x02
|
|
|
|
|
2005-07-02 16:31:34 +02:00
|
|
|
static void slavio_misc_update_irq(void *opaque)
|
|
|
|
{
|
|
|
|
MiscState *s = opaque;
|
|
|
|
|
2007-12-01 15:53:22 +01:00
|
|
|
if ((s->aux2 & AUX2_PWRFAIL) && (s->config & CFG_PWRINTEN)) {
|
2010-10-31 10:24:14 +01:00
|
|
|
trace_slavio_misc_update_irq_raise();
|
2007-04-07 20:14:41 +02:00
|
|
|
qemu_irq_raise(s->irq);
|
2005-07-02 16:31:34 +02:00
|
|
|
} else {
|
2010-10-31 10:24:14 +01:00
|
|
|
trace_slavio_misc_update_irq_lower();
|
2007-04-07 20:14:41 +02:00
|
|
|
qemu_irq_lower(s->irq);
|
2005-07-02 16:31:34 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-10-24 17:27:23 +02:00
|
|
|
static void slavio_misc_reset(DeviceState *d)
|
2005-07-02 16:31:34 +02:00
|
|
|
{
|
2013-07-26 23:19:11 +02:00
|
|
|
MiscState *s = SLAVIO_MISC(d);
|
2005-07-02 16:31:34 +02:00
|
|
|
|
2005-10-30 18:24:19 +01:00
|
|
|
// Diagnostic and system control registers not cleared in reset
|
2005-07-02 16:31:34 +02:00
|
|
|
s->config = s->aux1 = s->aux2 = s->mctrl = 0;
|
|
|
|
}
|
|
|
|
|
2009-08-09 09:27:29 +02:00
|
|
|
static void slavio_set_power_fail(void *opaque, int irq, int power_failing)
|
2005-07-02 16:31:34 +02:00
|
|
|
{
|
|
|
|
MiscState *s = opaque;
|
|
|
|
|
2010-10-31 10:24:14 +01:00
|
|
|
trace_slavio_set_power_fail(power_failing, s->config);
|
2007-12-01 15:53:22 +01:00
|
|
|
if (power_failing && (s->config & CFG_PWRINTEN)) {
|
|
|
|
s->aux2 |= AUX2_PWRFAIL;
|
2005-07-02 16:31:34 +02:00
|
|
|
} else {
|
2007-12-01 15:53:22 +01:00
|
|
|
s->aux2 &= ~AUX2_PWRFAIL;
|
2005-07-02 16:31:34 +02:00
|
|
|
}
|
|
|
|
slavio_misc_update_irq(s);
|
|
|
|
}
|
|
|
|
|
2012-10-23 12:30:10 +02:00
|
|
|
static void slavio_cfg_mem_writeb(void *opaque, hwaddr addr,
|
2011-11-15 12:13:52 +01:00
|
|
|
uint64_t val, unsigned size)
|
2008-12-02 18:51:19 +01:00
|
|
|
{
|
|
|
|
MiscState *s = opaque;
|
|
|
|
|
2010-10-31 10:24:14 +01:00
|
|
|
trace_slavio_cfg_mem_writeb(val & 0xff);
|
2008-12-02 18:51:19 +01:00
|
|
|
s->config = val & 0xff;
|
|
|
|
slavio_misc_update_irq(s);
|
|
|
|
}
|
|
|
|
|
2012-10-23 12:30:10 +02:00
|
|
|
static uint64_t slavio_cfg_mem_readb(void *opaque, hwaddr addr,
|
2011-11-15 12:13:52 +01:00
|
|
|
unsigned size)
|
2008-12-02 18:51:19 +01:00
|
|
|
{
|
|
|
|
MiscState *s = opaque;
|
|
|
|
uint32_t ret = 0;
|
|
|
|
|
|
|
|
ret = s->config;
|
2010-10-31 10:24:14 +01:00
|
|
|
trace_slavio_cfg_mem_readb(ret);
|
2008-12-02 18:51:19 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2011-11-15 12:13:52 +01:00
|
|
|
static const MemoryRegionOps slavio_cfg_mem_ops = {
|
|
|
|
.read = slavio_cfg_mem_readb,
|
|
|
|
.write = slavio_cfg_mem_writeb,
|
|
|
|
.endianness = DEVICE_NATIVE_ENDIAN,
|
|
|
|
.valid = {
|
|
|
|
.min_access_size = 1,
|
|
|
|
.max_access_size = 1,
|
|
|
|
},
|
2008-12-02 18:51:19 +01:00
|
|
|
};
|
|
|
|
|
2012-10-23 12:30:10 +02:00
|
|
|
static void slavio_diag_mem_writeb(void *opaque, hwaddr addr,
|
2011-11-15 12:13:53 +01:00
|
|
|
uint64_t val, unsigned size)
|
2005-07-02 16:31:34 +02:00
|
|
|
{
|
|
|
|
MiscState *s = opaque;
|
|
|
|
|
2010-10-31 10:24:14 +01:00
|
|
|
trace_slavio_diag_mem_writeb(val & 0xff);
|
2008-12-02 18:51:19 +01:00
|
|
|
s->diag = val & 0xff;
|
2005-07-02 16:31:34 +02:00
|
|
|
}
|
|
|
|
|
2012-10-23 12:30:10 +02:00
|
|
|
static uint64_t slavio_diag_mem_readb(void *opaque, hwaddr addr,
|
2011-11-15 12:13:53 +01:00
|
|
|
unsigned size)
|
2005-07-02 16:31:34 +02:00
|
|
|
{
|
|
|
|
MiscState *s = opaque;
|
|
|
|
uint32_t ret = 0;
|
|
|
|
|
2008-12-02 18:51:19 +01:00
|
|
|
ret = s->diag;
|
2010-10-31 10:24:14 +01:00
|
|
|
trace_slavio_diag_mem_readb(ret);
|
2008-12-02 18:51:19 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2011-11-15 12:13:53 +01:00
|
|
|
static const MemoryRegionOps slavio_diag_mem_ops = {
|
|
|
|
.read = slavio_diag_mem_readb,
|
|
|
|
.write = slavio_diag_mem_writeb,
|
|
|
|
.endianness = DEVICE_NATIVE_ENDIAN,
|
|
|
|
.valid = {
|
|
|
|
.min_access_size = 1,
|
|
|
|
.max_access_size = 1,
|
|
|
|
},
|
2008-12-02 18:51:19 +01:00
|
|
|
};
|
|
|
|
|
2012-10-23 12:30:10 +02:00
|
|
|
static void slavio_mdm_mem_writeb(void *opaque, hwaddr addr,
|
2011-11-15 12:13:54 +01:00
|
|
|
uint64_t val, unsigned size)
|
2008-12-02 18:51:19 +01:00
|
|
|
{
|
|
|
|
MiscState *s = opaque;
|
|
|
|
|
2010-10-31 10:24:14 +01:00
|
|
|
trace_slavio_mdm_mem_writeb(val & 0xff);
|
2008-12-02 18:51:19 +01:00
|
|
|
s->mctrl = val & 0xff;
|
|
|
|
}
|
|
|
|
|
2012-10-23 12:30:10 +02:00
|
|
|
static uint64_t slavio_mdm_mem_readb(void *opaque, hwaddr addr,
|
2011-11-15 12:13:54 +01:00
|
|
|
unsigned size)
|
2008-12-02 18:51:19 +01:00
|
|
|
{
|
|
|
|
MiscState *s = opaque;
|
|
|
|
uint32_t ret = 0;
|
|
|
|
|
|
|
|
ret = s->mctrl;
|
2010-10-31 10:24:14 +01:00
|
|
|
trace_slavio_mdm_mem_readb(ret);
|
2005-07-02 16:31:34 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2011-11-15 12:13:54 +01:00
|
|
|
static const MemoryRegionOps slavio_mdm_mem_ops = {
|
|
|
|
.read = slavio_mdm_mem_readb,
|
|
|
|
.write = slavio_mdm_mem_writeb,
|
|
|
|
.endianness = DEVICE_NATIVE_ENDIAN,
|
|
|
|
.valid = {
|
|
|
|
.min_access_size = 1,
|
|
|
|
.max_access_size = 1,
|
|
|
|
},
|
2005-07-02 16:31:34 +02:00
|
|
|
};
|
|
|
|
|
2012-10-23 12:30:10 +02:00
|
|
|
static void slavio_aux1_mem_writeb(void *opaque, hwaddr addr,
|
2011-11-15 12:13:57 +01:00
|
|
|
uint64_t val, unsigned size)
|
2008-01-27 10:49:28 +01:00
|
|
|
{
|
|
|
|
MiscState *s = opaque;
|
|
|
|
|
2010-10-31 10:24:14 +01:00
|
|
|
trace_slavio_aux1_mem_writeb(val & 0xff);
|
2008-03-21 19:05:23 +01:00
|
|
|
if (val & AUX1_TC) {
|
|
|
|
// Send a pulse to floppy terminal count line
|
|
|
|
if (s->fdc_tc) {
|
|
|
|
qemu_irq_raise(s->fdc_tc);
|
|
|
|
qemu_irq_lower(s->fdc_tc);
|
|
|
|
}
|
|
|
|
val &= ~AUX1_TC;
|
|
|
|
}
|
2008-01-27 10:49:28 +01:00
|
|
|
s->aux1 = val & 0xff;
|
|
|
|
}
|
|
|
|
|
2012-10-23 12:30:10 +02:00
|
|
|
static uint64_t slavio_aux1_mem_readb(void *opaque, hwaddr addr,
|
2011-11-15 12:13:57 +01:00
|
|
|
unsigned size)
|
2008-01-27 10:49:28 +01:00
|
|
|
{
|
|
|
|
MiscState *s = opaque;
|
|
|
|
uint32_t ret = 0;
|
|
|
|
|
|
|
|
ret = s->aux1;
|
2010-10-31 10:24:14 +01:00
|
|
|
trace_slavio_aux1_mem_readb(ret);
|
2008-01-27 10:49:28 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2011-11-15 12:13:57 +01:00
|
|
|
static const MemoryRegionOps slavio_aux1_mem_ops = {
|
|
|
|
.read = slavio_aux1_mem_readb,
|
|
|
|
.write = slavio_aux1_mem_writeb,
|
|
|
|
.endianness = DEVICE_NATIVE_ENDIAN,
|
|
|
|
.valid = {
|
|
|
|
.min_access_size = 1,
|
|
|
|
.max_access_size = 1,
|
|
|
|
},
|
2008-01-27 10:49:28 +01:00
|
|
|
};
|
|
|
|
|
2012-10-23 12:30:10 +02:00
|
|
|
static void slavio_aux2_mem_writeb(void *opaque, hwaddr addr,
|
2011-11-15 12:13:58 +01:00
|
|
|
uint64_t val, unsigned size)
|
2008-01-27 10:49:28 +01:00
|
|
|
{
|
|
|
|
MiscState *s = opaque;
|
|
|
|
|
|
|
|
val &= AUX2_PWRINTCLR | AUX2_PWROFF;
|
2010-10-31 10:24:14 +01:00
|
|
|
trace_slavio_aux2_mem_writeb(val & 0xff);
|
2008-01-27 10:49:28 +01:00
|
|
|
val |= s->aux2 & AUX2_PWRFAIL;
|
|
|
|
if (val & AUX2_PWRINTCLR) // Clear Power Fail int
|
|
|
|
val &= AUX2_PWROFF;
|
|
|
|
s->aux2 = val;
|
|
|
|
if (val & AUX2_PWROFF)
|
2017-05-15 23:41:13 +02:00
|
|
|
qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN);
|
2008-01-27 10:49:28 +01:00
|
|
|
slavio_misc_update_irq(s);
|
|
|
|
}
|
|
|
|
|
2012-10-23 12:30:10 +02:00
|
|
|
static uint64_t slavio_aux2_mem_readb(void *opaque, hwaddr addr,
|
2011-11-15 12:13:58 +01:00
|
|
|
unsigned size)
|
2008-01-27 10:49:28 +01:00
|
|
|
{
|
|
|
|
MiscState *s = opaque;
|
|
|
|
uint32_t ret = 0;
|
|
|
|
|
|
|
|
ret = s->aux2;
|
2010-10-31 10:24:14 +01:00
|
|
|
trace_slavio_aux2_mem_readb(ret);
|
2008-01-27 10:49:28 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2011-11-15 12:13:58 +01:00
|
|
|
static const MemoryRegionOps slavio_aux2_mem_ops = {
|
|
|
|
.read = slavio_aux2_mem_readb,
|
|
|
|
.write = slavio_aux2_mem_writeb,
|
|
|
|
.endianness = DEVICE_NATIVE_ENDIAN,
|
|
|
|
.valid = {
|
|
|
|
.min_access_size = 1,
|
|
|
|
.max_access_size = 1,
|
|
|
|
},
|
2008-01-27 10:49:28 +01:00
|
|
|
};
|
|
|
|
|
2012-10-23 12:30:10 +02:00
|
|
|
static void apc_mem_writeb(void *opaque, hwaddr addr,
|
2011-11-15 12:13:51 +01:00
|
|
|
uint64_t val, unsigned size)
|
2008-01-27 10:49:28 +01:00
|
|
|
{
|
2009-07-13 18:51:27 +02:00
|
|
|
APCState *s = opaque;
|
2008-01-27 10:49:28 +01:00
|
|
|
|
2010-10-31 10:24:14 +01:00
|
|
|
trace_apc_mem_writeb(val & 0xff);
|
2008-11-02 11:51:05 +01:00
|
|
|
qemu_irq_raise(s->cpu_halt);
|
2008-01-27 10:49:28 +01:00
|
|
|
}
|
|
|
|
|
2012-10-23 12:30:10 +02:00
|
|
|
static uint64_t apc_mem_readb(void *opaque, hwaddr addr,
|
2011-11-15 12:13:51 +01:00
|
|
|
unsigned size)
|
2008-01-27 10:49:28 +01:00
|
|
|
{
|
|
|
|
uint32_t ret = 0;
|
|
|
|
|
2010-10-31 10:24:14 +01:00
|
|
|
trace_apc_mem_readb(ret);
|
2008-01-27 10:49:28 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2011-11-15 12:13:51 +01:00
|
|
|
static const MemoryRegionOps apc_mem_ops = {
|
|
|
|
.read = apc_mem_readb,
|
|
|
|
.write = apc_mem_writeb,
|
|
|
|
.endianness = DEVICE_NATIVE_ENDIAN,
|
|
|
|
.valid = {
|
|
|
|
.min_access_size = 1,
|
|
|
|
.max_access_size = 1,
|
|
|
|
}
|
2008-01-27 10:49:28 +01:00
|
|
|
};
|
|
|
|
|
2012-10-23 12:30:10 +02:00
|
|
|
static uint64_t slavio_sysctrl_mem_readl(void *opaque, hwaddr addr,
|
2011-11-15 12:13:56 +01:00
|
|
|
unsigned size)
|
2007-11-04 18:27:07 +01:00
|
|
|
{
|
|
|
|
MiscState *s = opaque;
|
2008-12-02 18:51:19 +01:00
|
|
|
uint32_t ret = 0;
|
2007-11-04 18:27:07 +01:00
|
|
|
|
2008-12-02 18:51:19 +01:00
|
|
|
switch (addr) {
|
2007-11-04 18:27:07 +01:00
|
|
|
case 0:
|
|
|
|
ret = s->sysctrl;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2010-10-31 10:24:14 +01:00
|
|
|
trace_slavio_sysctrl_mem_readl(ret);
|
2007-11-04 18:27:07 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2012-10-23 12:30:10 +02:00
|
|
|
static void slavio_sysctrl_mem_writel(void *opaque, hwaddr addr,
|
2011-11-15 12:13:56 +01:00
|
|
|
uint64_t val, unsigned size)
|
2007-11-04 18:27:07 +01:00
|
|
|
{
|
|
|
|
MiscState *s = opaque;
|
|
|
|
|
2010-10-31 10:24:14 +01:00
|
|
|
trace_slavio_sysctrl_mem_writel(val);
|
2008-12-02 18:51:19 +01:00
|
|
|
switch (addr) {
|
2007-11-04 18:27:07 +01:00
|
|
|
case 0:
|
2007-12-01 15:53:22 +01:00
|
|
|
if (val & SYS_RESET) {
|
|
|
|
s->sysctrl = SYS_RESETSTAT;
|
2017-05-15 23:41:13 +02:00
|
|
|
qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET);
|
2007-11-04 18:27:07 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-15 12:13:56 +01:00
|
|
|
static const MemoryRegionOps slavio_sysctrl_mem_ops = {
|
|
|
|
.read = slavio_sysctrl_mem_readl,
|
|
|
|
.write = slavio_sysctrl_mem_writel,
|
|
|
|
.endianness = DEVICE_NATIVE_ENDIAN,
|
|
|
|
.valid = {
|
|
|
|
.min_access_size = 4,
|
|
|
|
.max_access_size = 4,
|
|
|
|
},
|
2007-11-04 18:27:07 +01:00
|
|
|
};
|
|
|
|
|
2012-10-23 12:30:10 +02:00
|
|
|
static uint64_t slavio_led_mem_readw(void *opaque, hwaddr addr,
|
2011-11-15 12:13:55 +01:00
|
|
|
unsigned size)
|
2007-11-11 18:56:38 +01:00
|
|
|
{
|
|
|
|
MiscState *s = opaque;
|
2008-12-02 18:51:19 +01:00
|
|
|
uint32_t ret = 0;
|
2007-11-11 18:56:38 +01:00
|
|
|
|
2008-12-02 18:51:19 +01:00
|
|
|
switch (addr) {
|
2007-11-11 18:56:38 +01:00
|
|
|
case 0:
|
|
|
|
ret = s->leds;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2010-10-31 10:24:14 +01:00
|
|
|
trace_slavio_led_mem_readw(ret);
|
2007-11-11 18:56:38 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2012-10-23 12:30:10 +02:00
|
|
|
static void slavio_led_mem_writew(void *opaque, hwaddr addr,
|
2011-11-15 12:13:55 +01:00
|
|
|
uint64_t val, unsigned size)
|
2007-11-11 18:56:38 +01:00
|
|
|
{
|
|
|
|
MiscState *s = opaque;
|
|
|
|
|
2013-06-07 12:59:18 +02:00
|
|
|
trace_slavio_led_mem_writew(val & 0xffff);
|
2008-12-02 18:51:19 +01:00
|
|
|
switch (addr) {
|
2007-11-11 18:56:38 +01:00
|
|
|
case 0:
|
2007-12-01 16:02:20 +01:00
|
|
|
s->leds = val;
|
2007-11-11 18:56:38 +01:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-15 12:13:55 +01:00
|
|
|
static const MemoryRegionOps slavio_led_mem_ops = {
|
|
|
|
.read = slavio_led_mem_readw,
|
|
|
|
.write = slavio_led_mem_writew,
|
|
|
|
.endianness = DEVICE_NATIVE_ENDIAN,
|
|
|
|
.valid = {
|
|
|
|
.min_access_size = 2,
|
|
|
|
.max_access_size = 2,
|
|
|
|
},
|
2007-11-11 18:56:38 +01:00
|
|
|
};
|
|
|
|
|
2009-08-29 15:37:09 +02:00
|
|
|
static const VMStateDescription vmstate_misc = {
|
|
|
|
.name ="slavio_misc",
|
|
|
|
.version_id = 1,
|
|
|
|
.minimum_version_id = 1,
|
2014-04-16 16:01:33 +02:00
|
|
|
.fields = (VMStateField[]) {
|
2009-08-29 15:37:09 +02:00
|
|
|
VMSTATE_UINT32(dummy, MiscState),
|
|
|
|
VMSTATE_UINT8(config, MiscState),
|
|
|
|
VMSTATE_UINT8(aux1, MiscState),
|
|
|
|
VMSTATE_UINT8(aux2, MiscState),
|
|
|
|
VMSTATE_UINT8(diag, MiscState),
|
|
|
|
VMSTATE_UINT8(mctrl, MiscState),
|
|
|
|
VMSTATE_UINT8(sysctrl, MiscState),
|
|
|
|
VMSTATE_END_OF_LIST()
|
|
|
|
}
|
|
|
|
};
|
2005-07-02 16:31:34 +02:00
|
|
|
|
2017-05-25 15:34:47 +02:00
|
|
|
static void apc_init(Object *obj)
|
2009-07-13 18:51:27 +02:00
|
|
|
{
|
2017-05-25 15:34:47 +02:00
|
|
|
APCState *s = APC(obj);
|
|
|
|
SysBusDevice *dev = SYS_BUS_DEVICE(obj);
|
2005-07-02 16:31:34 +02:00
|
|
|
|
2009-07-13 18:51:27 +02:00
|
|
|
sysbus_init_irq(dev, &s->cpu_halt);
|
|
|
|
|
|
|
|
/* Power management (APC) XXX: not a Slavio device */
|
2017-05-25 15:34:47 +02:00
|
|
|
memory_region_init_io(&s->iomem, obj, &apc_mem_ops, s,
|
2011-11-15 12:13:51 +01:00
|
|
|
"apc", MISC_SIZE);
|
2011-11-27 10:38:10 +01:00
|
|
|
sysbus_init_mmio(dev, &s->iomem);
|
2009-07-13 18:51:27 +02:00
|
|
|
}
|
|
|
|
|
2017-05-25 15:34:47 +02:00
|
|
|
static void slavio_misc_init(Object *obj)
|
2009-07-13 18:51:27 +02:00
|
|
|
{
|
2017-05-25 15:34:47 +02:00
|
|
|
DeviceState *dev = DEVICE(obj);
|
|
|
|
MiscState *s = SLAVIO_MISC(obj);
|
|
|
|
SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
|
2009-07-13 18:51:27 +02:00
|
|
|
|
2013-07-26 23:19:11 +02:00
|
|
|
sysbus_init_irq(sbd, &s->irq);
|
|
|
|
sysbus_init_irq(sbd, &s->fdc_tc);
|
2009-07-13 18:51:27 +02:00
|
|
|
|
|
|
|
/* 8 bit registers */
|
|
|
|
/* Slavio control */
|
2017-05-25 15:34:47 +02:00
|
|
|
memory_region_init_io(&s->cfg_iomem, obj, &slavio_cfg_mem_ops, s,
|
2011-11-15 12:13:52 +01:00
|
|
|
"configuration", MISC_SIZE);
|
2013-07-26 23:19:11 +02:00
|
|
|
sysbus_init_mmio(sbd, &s->cfg_iomem);
|
2009-07-13 18:51:27 +02:00
|
|
|
|
|
|
|
/* Diagnostics */
|
2017-05-25 15:34:47 +02:00
|
|
|
memory_region_init_io(&s->diag_iomem, obj, &slavio_diag_mem_ops, s,
|
2011-11-15 12:13:53 +01:00
|
|
|
"diagnostic", MISC_SIZE);
|
2013-07-26 23:19:11 +02:00
|
|
|
sysbus_init_mmio(sbd, &s->diag_iomem);
|
2009-07-13 18:51:27 +02:00
|
|
|
|
|
|
|
/* Modem control */
|
2017-05-25 15:34:47 +02:00
|
|
|
memory_region_init_io(&s->mdm_iomem, obj, &slavio_mdm_mem_ops, s,
|
2011-11-15 12:13:54 +01:00
|
|
|
"modem", MISC_SIZE);
|
2013-07-26 23:19:11 +02:00
|
|
|
sysbus_init_mmio(sbd, &s->mdm_iomem);
|
2009-07-13 18:51:27 +02:00
|
|
|
|
|
|
|
/* 16 bit registers */
|
|
|
|
/* ss600mp diag LEDs */
|
2017-05-25 15:34:47 +02:00
|
|
|
memory_region_init_io(&s->led_iomem, obj, &slavio_led_mem_ops, s,
|
2015-04-02 17:09:30 +02:00
|
|
|
"leds", LED_SIZE);
|
2013-07-26 23:19:11 +02:00
|
|
|
sysbus_init_mmio(sbd, &s->led_iomem);
|
2009-07-13 18:51:27 +02:00
|
|
|
|
|
|
|
/* 32 bit registers */
|
|
|
|
/* System control */
|
2017-05-25 15:34:47 +02:00
|
|
|
memory_region_init_io(&s->sysctrl_iomem, obj, &slavio_sysctrl_mem_ops, s,
|
2015-04-02 17:09:30 +02:00
|
|
|
"system-control", SYSCTRL_SIZE);
|
2013-07-26 23:19:11 +02:00
|
|
|
sysbus_init_mmio(sbd, &s->sysctrl_iomem);
|
2009-07-13 18:51:27 +02:00
|
|
|
|
|
|
|
/* AUX 1 (Misc System Functions) */
|
2017-05-25 15:34:47 +02:00
|
|
|
memory_region_init_io(&s->aux1_iomem, obj, &slavio_aux1_mem_ops, s,
|
2011-11-15 12:13:57 +01:00
|
|
|
"misc-system-functions", MISC_SIZE);
|
2013-07-26 23:19:11 +02:00
|
|
|
sysbus_init_mmio(sbd, &s->aux1_iomem);
|
2009-07-13 18:51:27 +02:00
|
|
|
|
|
|
|
/* AUX 2 (Software Powerdown Control) */
|
2017-05-25 15:34:47 +02:00
|
|
|
memory_region_init_io(&s->aux2_iomem, obj, &slavio_aux2_mem_ops, s,
|
2011-11-15 12:13:58 +01:00
|
|
|
"software-powerdown-control", MISC_SIZE);
|
2013-07-26 23:19:11 +02:00
|
|
|
sysbus_init_mmio(sbd, &s->aux2_iomem);
|
2009-07-13 18:51:27 +02:00
|
|
|
|
2013-07-26 23:19:11 +02:00
|
|
|
qdev_init_gpio_in(dev, slavio_set_power_fail, 1);
|
2009-07-13 18:51:27 +02:00
|
|
|
}
|
2008-01-27 10:49:28 +01:00
|
|
|
|
2012-01-24 20:12:29 +01:00
|
|
|
static void slavio_misc_class_init(ObjectClass *klass, void *data)
|
|
|
|
{
|
2011-12-08 04:34:16 +01:00
|
|
|
DeviceClass *dc = DEVICE_CLASS(klass);
|
2012-01-24 20:12:29 +01:00
|
|
|
|
2011-12-08 04:34:16 +01:00
|
|
|
dc->reset = slavio_misc_reset;
|
|
|
|
dc->vmsd = &vmstate_misc;
|
2012-01-24 20:12:29 +01:00
|
|
|
}
|
|
|
|
|
2013-01-10 16:19:07 +01:00
|
|
|
static const TypeInfo slavio_misc_info = {
|
2013-07-26 23:19:11 +02:00
|
|
|
.name = TYPE_SLAVIO_MISC,
|
2011-12-08 04:34:16 +01:00
|
|
|
.parent = TYPE_SYS_BUS_DEVICE,
|
|
|
|
.instance_size = sizeof(MiscState),
|
2017-05-25 15:34:47 +02:00
|
|
|
.instance_init = slavio_misc_init,
|
2011-12-08 04:34:16 +01:00
|
|
|
.class_init = slavio_misc_class_init,
|
2009-07-13 18:51:27 +02:00
|
|
|
};
|
|
|
|
|
2013-01-10 16:19:07 +01:00
|
|
|
static const TypeInfo apc_info = {
|
2013-07-26 23:21:50 +02:00
|
|
|
.name = TYPE_APC,
|
2011-12-08 04:34:16 +01:00
|
|
|
.parent = TYPE_SYS_BUS_DEVICE,
|
|
|
|
.instance_size = sizeof(MiscState),
|
2017-05-25 15:34:47 +02:00
|
|
|
.instance_init = apc_init,
|
2009-07-13 18:51:27 +02:00
|
|
|
};
|
|
|
|
|
2012-02-09 15:20:55 +01:00
|
|
|
static void slavio_misc_register_types(void)
|
2009-07-13 18:51:27 +02:00
|
|
|
{
|
2011-12-08 04:34:16 +01:00
|
|
|
type_register_static(&slavio_misc_info);
|
|
|
|
type_register_static(&apc_info);
|
2005-07-02 16:31:34 +02:00
|
|
|
}
|
2009-07-13 18:51:27 +02:00
|
|
|
|
2012-02-09 15:20:55 +01:00
|
|
|
type_init(slavio_misc_register_types)
|