2005-07-02 18:31:34 +04:00
|
|
|
/*
|
|
|
|
* QEMU Sparc SLAVIO aux io port emulation
|
2007-09-17 01:08:06 +04:00
|
|
|
*
|
2005-07-02 18:31:34 +04:00
|
|
|
* Copyright (c) 2005 Fabrice Bellard
|
2007-09-17 01:08:06 +04:00
|
|
|
*
|
2005-07-02 18:31:34 +04: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 20:51:27 +04:00
|
|
|
|
2007-11-17 20:14:51 +03:00
|
|
|
#include "sun4m.h"
|
|
|
|
#include "sysemu.h"
|
2009-07-13 20:51:27 +04:00
|
|
|
#include "sysbus.h"
|
2007-11-17 20:14:51 +03:00
|
|
|
|
2005-07-02 18:31:34 +04:00
|
|
|
/* debug misc */
|
|
|
|
//#define DEBUG_MISC
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef DEBUG_MISC
|
2009-05-13 21:53:17 +04:00
|
|
|
#define MISC_DPRINTF(fmt, ...) \
|
|
|
|
do { printf("MISC: " fmt , ## __VA_ARGS__); } while (0)
|
2005-07-02 18:31:34 +04:00
|
|
|
#else
|
2009-05-13 21:53:17 +04:00
|
|
|
#define MISC_DPRINTF(fmt, ...)
|
2005-07-02 18:31:34 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
typedef struct MiscState {
|
2009-07-13 20:51:27 +04:00
|
|
|
SysBusDevice busdev;
|
2007-04-07 22:14:41 +04:00
|
|
|
qemu_irq irq;
|
2009-08-29 17:37:09 +04:00
|
|
|
uint32_t dummy;
|
2005-07-02 18:31:34 +04:00
|
|
|
uint8_t config;
|
|
|
|
uint8_t aux1, aux2;
|
2007-11-04 20:27:07 +03:00
|
|
|
uint8_t diag, mctrl;
|
2009-08-29 17:37:09 +04:00
|
|
|
uint8_t sysctrl;
|
2007-11-11 20:56:38 +03:00
|
|
|
uint16_t leds;
|
2008-03-21 21:05:23 +03:00
|
|
|
qemu_irq fdc_tc;
|
2005-07-02 18:31:34 +04:00
|
|
|
} MiscState;
|
|
|
|
|
2009-07-13 20:51:27 +04:00
|
|
|
typedef struct APCState {
|
|
|
|
SysBusDevice busdev;
|
|
|
|
qemu_irq cpu_halt;
|
|
|
|
} APCState;
|
|
|
|
|
2007-05-26 21:39:43 +04:00
|
|
|
#define MISC_SIZE 1
|
2008-12-02 20:51:19 +03:00
|
|
|
#define SYSCTRL_SIZE 4
|
2005-07-02 18:31:34 +04:00
|
|
|
|
2008-03-21 21:05:23 +03:00
|
|
|
#define AUX1_TC 0x02
|
|
|
|
|
2007-12-01 17:53:22 +03: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 18:31:34 +04:00
|
|
|
static void slavio_misc_update_irq(void *opaque)
|
|
|
|
{
|
|
|
|
MiscState *s = opaque;
|
|
|
|
|
2007-12-01 17:53:22 +03:00
|
|
|
if ((s->aux2 & AUX2_PWRFAIL) && (s->config & CFG_PWRINTEN)) {
|
2007-04-07 22:14:41 +04:00
|
|
|
MISC_DPRINTF("Raise IRQ\n");
|
|
|
|
qemu_irq_raise(s->irq);
|
2005-07-02 18:31:34 +04:00
|
|
|
} else {
|
2007-04-07 22:14:41 +04:00
|
|
|
MISC_DPRINTF("Lower IRQ\n");
|
|
|
|
qemu_irq_lower(s->irq);
|
2005-07-02 18:31:34 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void slavio_misc_reset(void *opaque)
|
|
|
|
{
|
|
|
|
MiscState *s = opaque;
|
|
|
|
|
2005-10-30 20:24:19 +03:00
|
|
|
// Diagnostic and system control registers not cleared in reset
|
2005-07-02 18:31:34 +04:00
|
|
|
s->config = s->aux1 = s->aux2 = s->mctrl = 0;
|
|
|
|
}
|
|
|
|
|
2009-08-09 11:27:29 +04:00
|
|
|
static void slavio_set_power_fail(void *opaque, int irq, int power_failing)
|
2005-07-02 18:31:34 +04:00
|
|
|
{
|
|
|
|
MiscState *s = opaque;
|
|
|
|
|
|
|
|
MISC_DPRINTF("Power fail: %d, config: %d\n", power_failing, s->config);
|
2007-12-01 17:53:22 +03:00
|
|
|
if (power_failing && (s->config & CFG_PWRINTEN)) {
|
|
|
|
s->aux2 |= AUX2_PWRFAIL;
|
2005-07-02 18:31:34 +04:00
|
|
|
} else {
|
2007-12-01 17:53:22 +03:00
|
|
|
s->aux2 &= ~AUX2_PWRFAIL;
|
2005-07-02 18:31:34 +04:00
|
|
|
}
|
|
|
|
slavio_misc_update_irq(s);
|
|
|
|
}
|
|
|
|
|
2008-12-02 20:51:19 +03:00
|
|
|
static void slavio_cfg_mem_writeb(void *opaque, target_phys_addr_t addr,
|
|
|
|
uint32_t val)
|
|
|
|
{
|
|
|
|
MiscState *s = opaque;
|
|
|
|
|
|
|
|
MISC_DPRINTF("Write config %2.2x\n", val & 0xff);
|
|
|
|
s->config = val & 0xff;
|
|
|
|
slavio_misc_update_irq(s);
|
|
|
|
}
|
|
|
|
|
|
|
|
static uint32_t slavio_cfg_mem_readb(void *opaque, target_phys_addr_t addr)
|
|
|
|
{
|
|
|
|
MiscState *s = opaque;
|
|
|
|
uint32_t ret = 0;
|
|
|
|
|
|
|
|
ret = s->config;
|
|
|
|
MISC_DPRINTF("Read config %2.2x\n", ret);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2009-08-25 22:29:31 +04:00
|
|
|
static CPUReadMemoryFunc * const slavio_cfg_mem_read[3] = {
|
2008-12-02 20:51:19 +03:00
|
|
|
slavio_cfg_mem_readb,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
};
|
|
|
|
|
2009-08-25 22:29:31 +04:00
|
|
|
static CPUWriteMemoryFunc * const slavio_cfg_mem_write[3] = {
|
2008-12-02 20:51:19 +03:00
|
|
|
slavio_cfg_mem_writeb,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
};
|
|
|
|
|
|
|
|
static void slavio_diag_mem_writeb(void *opaque, target_phys_addr_t addr,
|
2007-11-04 20:27:07 +03:00
|
|
|
uint32_t val)
|
2005-07-02 18:31:34 +04:00
|
|
|
{
|
|
|
|
MiscState *s = opaque;
|
|
|
|
|
2008-12-02 20:51:19 +03:00
|
|
|
MISC_DPRINTF("Write diag %2.2x\n", val & 0xff);
|
|
|
|
s->diag = val & 0xff;
|
2005-07-02 18:31:34 +04:00
|
|
|
}
|
|
|
|
|
2008-12-02 20:51:19 +03:00
|
|
|
static uint32_t slavio_diag_mem_readb(void *opaque, target_phys_addr_t addr)
|
2005-07-02 18:31:34 +04:00
|
|
|
{
|
|
|
|
MiscState *s = opaque;
|
|
|
|
uint32_t ret = 0;
|
|
|
|
|
2008-12-02 20:51:19 +03:00
|
|
|
ret = s->diag;
|
|
|
|
MISC_DPRINTF("Read diag %2.2x\n", ret);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2009-08-25 22:29:31 +04:00
|
|
|
static CPUReadMemoryFunc * const slavio_diag_mem_read[3] = {
|
2008-12-02 20:51:19 +03:00
|
|
|
slavio_diag_mem_readb,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
};
|
|
|
|
|
2009-08-25 22:29:31 +04:00
|
|
|
static CPUWriteMemoryFunc * const slavio_diag_mem_write[3] = {
|
2008-12-02 20:51:19 +03:00
|
|
|
slavio_diag_mem_writeb,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
};
|
|
|
|
|
|
|
|
static void slavio_mdm_mem_writeb(void *opaque, target_phys_addr_t addr,
|
|
|
|
uint32_t val)
|
|
|
|
{
|
|
|
|
MiscState *s = opaque;
|
|
|
|
|
|
|
|
MISC_DPRINTF("Write modem control %2.2x\n", val & 0xff);
|
|
|
|
s->mctrl = val & 0xff;
|
|
|
|
}
|
|
|
|
|
|
|
|
static uint32_t slavio_mdm_mem_readb(void *opaque, target_phys_addr_t addr)
|
|
|
|
{
|
|
|
|
MiscState *s = opaque;
|
|
|
|
uint32_t ret = 0;
|
|
|
|
|
|
|
|
ret = s->mctrl;
|
|
|
|
MISC_DPRINTF("Read modem control %2.2x\n", ret);
|
2005-07-02 18:31:34 +04:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2009-08-25 22:29:31 +04:00
|
|
|
static CPUReadMemoryFunc * const slavio_mdm_mem_read[3] = {
|
2008-12-02 20:51:19 +03:00
|
|
|
slavio_mdm_mem_readb,
|
2008-01-01 20:06:38 +03:00
|
|
|
NULL,
|
|
|
|
NULL,
|
2005-07-02 18:31:34 +04:00
|
|
|
};
|
|
|
|
|
2009-08-25 22:29:31 +04:00
|
|
|
static CPUWriteMemoryFunc * const slavio_mdm_mem_write[3] = {
|
2008-12-02 20:51:19 +03:00
|
|
|
slavio_mdm_mem_writeb,
|
2008-01-01 20:06:38 +03:00
|
|
|
NULL,
|
|
|
|
NULL,
|
2005-07-02 18:31:34 +04:00
|
|
|
};
|
|
|
|
|
2008-01-27 12:49:28 +03:00
|
|
|
static void slavio_aux1_mem_writeb(void *opaque, target_phys_addr_t addr,
|
|
|
|
uint32_t val)
|
|
|
|
{
|
|
|
|
MiscState *s = opaque;
|
|
|
|
|
|
|
|
MISC_DPRINTF("Write aux1 %2.2x\n", val & 0xff);
|
2008-03-21 21:05:23 +03: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 12:49:28 +03:00
|
|
|
s->aux1 = val & 0xff;
|
|
|
|
}
|
|
|
|
|
|
|
|
static uint32_t slavio_aux1_mem_readb(void *opaque, target_phys_addr_t addr)
|
|
|
|
{
|
|
|
|
MiscState *s = opaque;
|
|
|
|
uint32_t ret = 0;
|
|
|
|
|
|
|
|
ret = s->aux1;
|
|
|
|
MISC_DPRINTF("Read aux1 %2.2x\n", ret);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2009-08-25 22:29:31 +04:00
|
|
|
static CPUReadMemoryFunc * const slavio_aux1_mem_read[3] = {
|
2008-01-27 12:49:28 +03:00
|
|
|
slavio_aux1_mem_readb,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
};
|
|
|
|
|
2009-08-25 22:29:31 +04:00
|
|
|
static CPUWriteMemoryFunc * const slavio_aux1_mem_write[3] = {
|
2008-01-27 12:49:28 +03:00
|
|
|
slavio_aux1_mem_writeb,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
};
|
|
|
|
|
|
|
|
static void slavio_aux2_mem_writeb(void *opaque, target_phys_addr_t addr,
|
|
|
|
uint32_t val)
|
|
|
|
{
|
|
|
|
MiscState *s = opaque;
|
|
|
|
|
|
|
|
val &= AUX2_PWRINTCLR | AUX2_PWROFF;
|
|
|
|
MISC_DPRINTF("Write aux2 %2.2x\n", val);
|
|
|
|
val |= s->aux2 & AUX2_PWRFAIL;
|
|
|
|
if (val & AUX2_PWRINTCLR) // Clear Power Fail int
|
|
|
|
val &= AUX2_PWROFF;
|
|
|
|
s->aux2 = val;
|
|
|
|
if (val & AUX2_PWROFF)
|
|
|
|
qemu_system_shutdown_request();
|
|
|
|
slavio_misc_update_irq(s);
|
|
|
|
}
|
|
|
|
|
|
|
|
static uint32_t slavio_aux2_mem_readb(void *opaque, target_phys_addr_t addr)
|
|
|
|
{
|
|
|
|
MiscState *s = opaque;
|
|
|
|
uint32_t ret = 0;
|
|
|
|
|
|
|
|
ret = s->aux2;
|
|
|
|
MISC_DPRINTF("Read aux2 %2.2x\n", ret);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2009-08-25 22:29:31 +04:00
|
|
|
static CPUReadMemoryFunc * const slavio_aux2_mem_read[3] = {
|
2008-01-27 12:49:28 +03:00
|
|
|
slavio_aux2_mem_readb,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
};
|
|
|
|
|
2009-08-25 22:29:31 +04:00
|
|
|
static CPUWriteMemoryFunc * const slavio_aux2_mem_write[3] = {
|
2008-01-27 12:49:28 +03:00
|
|
|
slavio_aux2_mem_writeb,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
};
|
|
|
|
|
|
|
|
static void apc_mem_writeb(void *opaque, target_phys_addr_t addr, uint32_t val)
|
|
|
|
{
|
2009-07-13 20:51:27 +04:00
|
|
|
APCState *s = opaque;
|
2008-01-27 12:49:28 +03:00
|
|
|
|
|
|
|
MISC_DPRINTF("Write power management %2.2x\n", val & 0xff);
|
2008-11-02 13:51:05 +03:00
|
|
|
qemu_irq_raise(s->cpu_halt);
|
2008-01-27 12:49:28 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static uint32_t apc_mem_readb(void *opaque, target_phys_addr_t addr)
|
|
|
|
{
|
|
|
|
uint32_t ret = 0;
|
|
|
|
|
|
|
|
MISC_DPRINTF("Read power management %2.2x\n", ret);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2009-08-25 22:29:31 +04:00
|
|
|
static CPUReadMemoryFunc * const apc_mem_read[3] = {
|
2008-01-27 12:49:28 +03:00
|
|
|
apc_mem_readb,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
};
|
|
|
|
|
2009-08-25 22:29:31 +04:00
|
|
|
static CPUWriteMemoryFunc * const apc_mem_write[3] = {
|
2008-01-27 12:49:28 +03:00
|
|
|
apc_mem_writeb,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
};
|
|
|
|
|
2007-11-04 20:27:07 +03:00
|
|
|
static uint32_t slavio_sysctrl_mem_readl(void *opaque, target_phys_addr_t addr)
|
|
|
|
{
|
|
|
|
MiscState *s = opaque;
|
2008-12-02 20:51:19 +03:00
|
|
|
uint32_t ret = 0;
|
2007-11-04 20:27:07 +03:00
|
|
|
|
2008-12-02 20:51:19 +03:00
|
|
|
switch (addr) {
|
2007-11-04 20:27:07 +03:00
|
|
|
case 0:
|
|
|
|
ret = s->sysctrl;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2008-12-21 19:00:20 +03:00
|
|
|
MISC_DPRINTF("Read system control %08x\n", ret);
|
2007-11-04 20:27:07 +03:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void slavio_sysctrl_mem_writel(void *opaque, target_phys_addr_t addr,
|
|
|
|
uint32_t val)
|
|
|
|
{
|
|
|
|
MiscState *s = opaque;
|
|
|
|
|
2008-12-21 19:00:20 +03:00
|
|
|
MISC_DPRINTF("Write system control %08x\n", val);
|
2008-12-02 20:51:19 +03:00
|
|
|
switch (addr) {
|
2007-11-04 20:27:07 +03:00
|
|
|
case 0:
|
2007-12-01 17:53:22 +03:00
|
|
|
if (val & SYS_RESET) {
|
|
|
|
s->sysctrl = SYS_RESETSTAT;
|
2007-11-04 20:27:07 +03:00
|
|
|
qemu_system_reset_request();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-25 22:29:31 +04:00
|
|
|
static CPUReadMemoryFunc * const slavio_sysctrl_mem_read[3] = {
|
2008-01-01 20:06:38 +03:00
|
|
|
NULL,
|
|
|
|
NULL,
|
2007-11-04 20:27:07 +03:00
|
|
|
slavio_sysctrl_mem_readl,
|
|
|
|
};
|
|
|
|
|
2009-08-25 22:29:31 +04:00
|
|
|
static CPUWriteMemoryFunc * const slavio_sysctrl_mem_write[3] = {
|
2008-01-01 20:06:38 +03:00
|
|
|
NULL,
|
|
|
|
NULL,
|
2007-11-04 20:27:07 +03:00
|
|
|
slavio_sysctrl_mem_writel,
|
|
|
|
};
|
|
|
|
|
2008-01-01 20:06:38 +03:00
|
|
|
static uint32_t slavio_led_mem_readw(void *opaque, target_phys_addr_t addr)
|
2007-11-11 20:56:38 +03:00
|
|
|
{
|
|
|
|
MiscState *s = opaque;
|
2008-12-02 20:51:19 +03:00
|
|
|
uint32_t ret = 0;
|
2007-11-11 20:56:38 +03:00
|
|
|
|
2008-12-02 20:51:19 +03:00
|
|
|
switch (addr) {
|
2007-11-11 20:56:38 +03:00
|
|
|
case 0:
|
|
|
|
ret = s->leds;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2008-12-21 19:00:20 +03:00
|
|
|
MISC_DPRINTF("Read diagnostic LED %04x\n", ret);
|
2007-11-11 20:56:38 +03:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2008-01-01 20:06:38 +03:00
|
|
|
static void slavio_led_mem_writew(void *opaque, target_phys_addr_t addr,
|
2007-11-11 20:56:38 +03:00
|
|
|
uint32_t val)
|
|
|
|
{
|
|
|
|
MiscState *s = opaque;
|
|
|
|
|
2008-12-21 19:00:20 +03:00
|
|
|
MISC_DPRINTF("Write diagnostic LED %04x\n", val & 0xffff);
|
2008-12-02 20:51:19 +03:00
|
|
|
switch (addr) {
|
2007-11-11 20:56:38 +03:00
|
|
|
case 0:
|
2007-12-01 18:02:20 +03:00
|
|
|
s->leds = val;
|
2007-11-11 20:56:38 +03:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-25 22:29:31 +04:00
|
|
|
static CPUReadMemoryFunc * const slavio_led_mem_read[3] = {
|
2008-01-01 20:06:38 +03:00
|
|
|
NULL,
|
|
|
|
slavio_led_mem_readw,
|
|
|
|
NULL,
|
2007-11-11 20:56:38 +03:00
|
|
|
};
|
|
|
|
|
2009-08-25 22:29:31 +04:00
|
|
|
static CPUWriteMemoryFunc * const slavio_led_mem_write[3] = {
|
2008-01-01 20:06:38 +03:00
|
|
|
NULL,
|
|
|
|
slavio_led_mem_writew,
|
|
|
|
NULL,
|
2007-11-11 20:56:38 +03:00
|
|
|
};
|
|
|
|
|
2009-08-29 17:37:09 +04:00
|
|
|
static const VMStateDescription vmstate_misc = {
|
|
|
|
.name ="slavio_misc",
|
|
|
|
.version_id = 1,
|
|
|
|
.minimum_version_id = 1,
|
|
|
|
.minimum_version_id_old = 1,
|
|
|
|
.fields = (VMStateField []) {
|
|
|
|
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 18:31:34 +04:00
|
|
|
|
2009-08-14 12:36:05 +04:00
|
|
|
static int apc_init1(SysBusDevice *dev)
|
2009-07-13 20:51:27 +04:00
|
|
|
{
|
|
|
|
APCState *s = FROM_SYSBUS(APCState, dev);
|
|
|
|
int io;
|
2005-07-02 18:31:34 +04:00
|
|
|
|
2009-07-13 20:51:27 +04:00
|
|
|
sysbus_init_irq(dev, &s->cpu_halt);
|
|
|
|
|
|
|
|
/* Power management (APC) XXX: not a Slavio device */
|
|
|
|
io = cpu_register_io_memory(apc_mem_read, apc_mem_write, s);
|
|
|
|
sysbus_init_mmio(dev, MISC_SIZE, io);
|
2009-08-14 12:36:05 +04:00
|
|
|
return 0;
|
2009-07-13 20:51:27 +04:00
|
|
|
}
|
|
|
|
|
2009-08-14 12:36:05 +04:00
|
|
|
static int slavio_misc_init1(SysBusDevice *dev)
|
2009-07-13 20:51:27 +04:00
|
|
|
{
|
|
|
|
MiscState *s = FROM_SYSBUS(MiscState, dev);
|
|
|
|
int io;
|
|
|
|
|
|
|
|
sysbus_init_irq(dev, &s->irq);
|
|
|
|
sysbus_init_irq(dev, &s->fdc_tc);
|
|
|
|
|
|
|
|
/* 8 bit registers */
|
|
|
|
/* Slavio control */
|
|
|
|
io = cpu_register_io_memory(slavio_cfg_mem_read,
|
|
|
|
slavio_cfg_mem_write, s);
|
|
|
|
sysbus_init_mmio(dev, MISC_SIZE, io);
|
|
|
|
|
|
|
|
/* Diagnostics */
|
|
|
|
io = cpu_register_io_memory(slavio_diag_mem_read,
|
|
|
|
slavio_diag_mem_write, s);
|
|
|
|
sysbus_init_mmio(dev, MISC_SIZE, io);
|
|
|
|
|
|
|
|
/* Modem control */
|
|
|
|
io = cpu_register_io_memory(slavio_mdm_mem_read,
|
|
|
|
slavio_mdm_mem_write, s);
|
|
|
|
sysbus_init_mmio(dev, MISC_SIZE, io);
|
|
|
|
|
|
|
|
/* 16 bit registers */
|
|
|
|
/* ss600mp diag LEDs */
|
|
|
|
io = cpu_register_io_memory(slavio_led_mem_read,
|
|
|
|
slavio_led_mem_write, s);
|
|
|
|
sysbus_init_mmio(dev, MISC_SIZE, io);
|
|
|
|
|
|
|
|
/* 32 bit registers */
|
|
|
|
/* System control */
|
|
|
|
io = cpu_register_io_memory(slavio_sysctrl_mem_read,
|
|
|
|
slavio_sysctrl_mem_write, s);
|
|
|
|
sysbus_init_mmio(dev, SYSCTRL_SIZE, io);
|
|
|
|
|
|
|
|
/* AUX 1 (Misc System Functions) */
|
|
|
|
io = cpu_register_io_memory(slavio_aux1_mem_read,
|
|
|
|
slavio_aux1_mem_write, s);
|
|
|
|
sysbus_init_mmio(dev, MISC_SIZE, io);
|
|
|
|
|
|
|
|
/* AUX 2 (Software Powerdown Control) */
|
|
|
|
io = cpu_register_io_memory(slavio_aux2_mem_read,
|
|
|
|
slavio_aux2_mem_write, s);
|
|
|
|
sysbus_init_mmio(dev, MISC_SIZE, io);
|
|
|
|
|
2009-08-09 11:27:29 +04:00
|
|
|
qdev_init_gpio_in(&dev->qdev, slavio_set_power_fail, 1);
|
|
|
|
|
2009-08-29 17:37:09 +04:00
|
|
|
vmstate_register(-1, &vmstate_misc, s);
|
2009-06-27 11:25:07 +04:00
|
|
|
qemu_register_reset(slavio_misc_reset, s);
|
2005-07-02 18:31:34 +04:00
|
|
|
slavio_misc_reset(s);
|
2009-08-14 12:36:05 +04:00
|
|
|
return 0;
|
2009-07-13 20:51:27 +04:00
|
|
|
}
|
2008-01-27 12:49:28 +03:00
|
|
|
|
2009-07-13 20:51:27 +04:00
|
|
|
static SysBusDeviceInfo slavio_misc_info = {
|
|
|
|
.init = slavio_misc_init1,
|
|
|
|
.qdev.name = "slavio_misc",
|
|
|
|
.qdev.size = sizeof(MiscState),
|
|
|
|
};
|
|
|
|
|
|
|
|
static SysBusDeviceInfo apc_info = {
|
|
|
|
.init = apc_init1,
|
|
|
|
.qdev.name = "apc",
|
|
|
|
.qdev.size = sizeof(MiscState),
|
|
|
|
};
|
|
|
|
|
|
|
|
static void slavio_misc_register_devices(void)
|
|
|
|
{
|
|
|
|
sysbus_register_withprop(&slavio_misc_info);
|
|
|
|
sysbus_register_withprop(&apc_info);
|
2005-07-02 18:31:34 +04:00
|
|
|
}
|
2009-07-13 20:51:27 +04:00
|
|
|
|
|
|
|
device_init(slavio_misc_register_devices)
|