mirror of
https://github.com/izzy2lost/xemu.git
synced 2026-07-06 00:20:22 -07:00
Merge remote-tracking branch 'remotes/dgibson/tags/isa-cleanup-20170206' into staging
Allow ISA to be disabled on some platforms (v3)
This makes some cleanups that are a start on allowing ISA to be
compiled out for platforms which don't use it.
I posted this series last November, and it collected a number of R-bs
and no apparent objections. So, I've now rebased it (trivially) and
am sending a pull request in the hopes of merge. A lot of the pieces
here don't have a clear maintainer, so I'm sending it directly to
Peter.
Notes:
* Patch 3/3 triggers a style warning, but that's just because I'm
moving a C++ // comment verbatim from one file to another
Changes since v2:
* Trivial rebase
Changes since v1:
* Fixed some silly compile errors in 3/3 exposed by some
changes in other headers
# gpg: Signature made Mon 06 Feb 2017 01:37:50 GMT
# gpg: using RSA key 0x6C38CACA20D9B392
# gpg: Good signature from "David Gibson <david@gibson.dropbear.id.au>"
# gpg: aka "David Gibson (Red Hat) <dgibson@redhat.com>"
# gpg: aka "David Gibson (ozlabs.org) <dgibson@ozlabs.org>"
# gpg: aka "David Gibson (kernel.org) <dwg@kernel.org>"
# Primary key fingerprint: 75F4 6586 AE61 A66C C44E 87DC 6C38 CACA 20D9 B392
* remotes/dgibson/tags/isa-cleanup-20170206:
Split ISA and sysbus versions of m48t59 device
Allow ISA bus to be configured out
Split serial-isa into its own config option
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
include pci.mak
|
||||
include usb.mak
|
||||
CONFIG_SERIAL=y
|
||||
CONFIG_SERIAL_ISA=y
|
||||
CONFIG_I8254=y
|
||||
CONFIG_PCKBD=y
|
||||
CONFIG_VGA_CIRRUS=y
|
||||
|
||||
@@ -6,6 +6,7 @@ CONFIG_VGA=y
|
||||
CONFIG_NAND=y
|
||||
CONFIG_ECC=y
|
||||
CONFIG_SERIAL=y
|
||||
CONFIG_SERIAL_ISA=y
|
||||
CONFIG_PTIMER=y
|
||||
CONFIG_SD=y
|
||||
CONFIG_MAX7310=y
|
||||
|
||||
@@ -15,6 +15,7 @@ CONFIG_IPMI_EXTERN=y
|
||||
CONFIG_ISA_IPMI_KCS=y
|
||||
CONFIG_ISA_IPMI_BT=y
|
||||
CONFIG_SERIAL=y
|
||||
CONFIG_SERIAL_ISA=y
|
||||
CONFIG_PARALLEL=y
|
||||
CONFIG_I8254=y
|
||||
CONFIG_PCSPK=y
|
||||
|
||||
@@ -9,6 +9,7 @@ CONFIG_VGA_ISA_MM=y
|
||||
CONFIG_VGA_CIRRUS=y
|
||||
CONFIG_VMWARE_VGA=y
|
||||
CONFIG_SERIAL=y
|
||||
CONFIG_SERIAL_ISA=y
|
||||
CONFIG_PARALLEL=y
|
||||
CONFIG_I8254=y
|
||||
CONFIG_PCSPK=y
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
# Default configuration for moxie-softmmu
|
||||
|
||||
CONFIG_ISA_BUS=y
|
||||
CONFIG_MC146818RTC=y
|
||||
CONFIG_SERIAL=y
|
||||
CONFIG_SERIAL_ISA=y
|
||||
CONFIG_VGA=y
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
CONFIG_PCI=y
|
||||
# For now, CONFIG_IDE_CORE requires ISA, so we enable it here
|
||||
CONFIG_ISA_BUS=y
|
||||
CONFIG_VIRTIO_PCI=y
|
||||
CONFIG_VIRTIO=y
|
||||
CONFIG_USB_UHCI=y
|
||||
@@ -27,6 +29,7 @@ CONFIG_AHCI=y
|
||||
CONFIG_ESP=y
|
||||
CONFIG_ESP_PCI=y
|
||||
CONFIG_SERIAL=y
|
||||
CONFIG_SERIAL_ISA=y
|
||||
CONFIG_SERIAL_PCI=y
|
||||
CONFIG_IPACK=y
|
||||
CONFIG_WDT_IB6300ESB=y
|
||||
|
||||
@@ -46,6 +46,7 @@ CONFIG_PLATFORM_BUS=y
|
||||
CONFIG_ETSEC=y
|
||||
CONFIG_LIBDECNUMBER=y
|
||||
# For PReP
|
||||
CONFIG_SERIAL_ISA=y
|
||||
CONFIG_MC146818RTC=y
|
||||
CONFIG_ISA_TESTDEV=y
|
||||
CONFIG_RS6000_MC=y
|
||||
|
||||
@@ -52,6 +52,7 @@ CONFIG_XICS=$(CONFIG_PSERIES)
|
||||
CONFIG_XICS_SPAPR=$(CONFIG_PSERIES)
|
||||
CONFIG_XICS_KVM=$(and $(CONFIG_PSERIES),$(CONFIG_KVM))
|
||||
# For PReP
|
||||
CONFIG_SERIAL_ISA=y
|
||||
CONFIG_MC146818RTC=y
|
||||
CONFIG_ISA_TESTDEV=y
|
||||
CONFIG_MEM_HOTPLUG=y
|
||||
|
||||
@@ -5,6 +5,7 @@ include sound.mak
|
||||
include usb.mak
|
||||
CONFIG_M48T59=y
|
||||
CONFIG_SERIAL=y
|
||||
CONFIG_SERIAL_ISA=y
|
||||
CONFIG_I8257=y
|
||||
CONFIG_OPENPIC=y
|
||||
CONFIG_PFLASH_CFI01=y
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
include pci.mak
|
||||
include usb.mak
|
||||
CONFIG_SERIAL=y
|
||||
CONFIG_SERIAL_ISA=y
|
||||
CONFIG_PTIMER=y
|
||||
CONFIG_PFLASH_CFI02=y
|
||||
CONFIG_SH4=y
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
include pci.mak
|
||||
include usb.mak
|
||||
CONFIG_SERIAL=y
|
||||
CONFIG_SERIAL_ISA=y
|
||||
CONFIG_PTIMER=y
|
||||
CONFIG_PFLASH_CFI02=y
|
||||
CONFIG_SH4=y
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
# Default configuration for sparc-softmmu
|
||||
|
||||
CONFIG_ISA_BUS=y
|
||||
CONFIG_ECC=y
|
||||
CONFIG_ESP=y
|
||||
CONFIG_ESCC=y
|
||||
|
||||
@@ -5,6 +5,7 @@ include usb.mak
|
||||
CONFIG_M48T59=y
|
||||
CONFIG_PTIMER=y
|
||||
CONFIG_SERIAL=y
|
||||
CONFIG_SERIAL_ISA=y
|
||||
CONFIG_PARALLEL=y
|
||||
CONFIG_PCKBD=y
|
||||
CONFIG_FDC=y
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
# Default configuration for unicore32-softmmu
|
||||
CONFIG_ISA_BUS=y
|
||||
CONFIG_PUV3=y
|
||||
CONFIG_PTIMER=y
|
||||
CONFIG_PCKBD=y
|
||||
|
||||
@@ -15,6 +15,7 @@ CONFIG_IPMI_EXTERN=y
|
||||
CONFIG_ISA_IPMI_KCS=y
|
||||
CONFIG_ISA_IPMI_BT=y
|
||||
CONFIG_SERIAL=y
|
||||
CONFIG_SERIAL_ISA=y
|
||||
CONFIG_PARALLEL=y
|
||||
CONFIG_I8254=y
|
||||
CONFIG_PCSPK=y
|
||||
|
||||
@@ -2,7 +2,8 @@ common-obj-$(CONFIG_IPACK) += ipoctal232.o
|
||||
common-obj-$(CONFIG_ESCC) += escc.o
|
||||
common-obj-$(CONFIG_PARALLEL) += parallel.o
|
||||
common-obj-$(CONFIG_PL011) += pl011.o
|
||||
common-obj-$(CONFIG_SERIAL) += serial.o serial-isa.o
|
||||
common-obj-$(CONFIG_SERIAL) += serial.o
|
||||
common-obj-$(CONFIG_SERIAL_ISA) += serial-isa.o
|
||||
common-obj-$(CONFIG_SERIAL_PCI) += serial-pci.o
|
||||
common-obj-$(CONFIG_VIRTIO) += virtio-console.o
|
||||
common-obj-$(CONFIG_XILINX) += xilinx_uartlite.o
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
common-obj-y += isa-bus.o
|
||||
common-obj-$(CONFIG_ISA_BUS) += isa-bus.o
|
||||
common-obj-$(CONFIG_APM) += apm.o
|
||||
common-obj-$(CONFIG_I82378) += i82378.o
|
||||
common-obj-$(CONFIG_PC87312) += pc87312.o
|
||||
|
||||
@@ -6,6 +6,9 @@ common-obj-$(CONFIG_DS1338) += ds1338.o
|
||||
common-obj-$(CONFIG_HPET) += hpet.o
|
||||
common-obj-$(CONFIG_I8254) += i8254_common.o i8254.o
|
||||
common-obj-$(CONFIG_M48T59) += m48t59.o
|
||||
ifeq ($(CONFIG_ISA_BUS),y)
|
||||
common-obj-$(CONFIG_M48T59) += m48t59-isa.o
|
||||
endif
|
||||
common-obj-$(CONFIG_PL031) += pl031.o
|
||||
common-obj-$(CONFIG_PUV3) += puv3_ost.o
|
||||
common-obj-$(CONFIG_TWL92230) += twl92230.o
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* QEMU M48T59 and M48T08 NVRAM emulation (common header)
|
||||
*
|
||||
* Copyright (c) 2003-2005, 2007 Jocelyn Mayer
|
||||
* Copyright (c) 2013 Hervé Poussineau
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
#ifndef HW_M48T59_INTERNAL_H
|
||||
#define HW_M48T59_INTERNAL_H 1
|
||||
|
||||
//#define DEBUG_NVRAM
|
||||
|
||||
#if defined(DEBUG_NVRAM)
|
||||
#define NVRAM_PRINTF(fmt, ...) do { printf(fmt , ## __VA_ARGS__); } while (0)
|
||||
#else
|
||||
#define NVRAM_PRINTF(fmt, ...) do { } while (0)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The M48T02, M48T08 and M48T59 chips are very similar. The newer '59 has
|
||||
* alarm and a watchdog timer and related control registers. In the
|
||||
* PPC platform there is also a nvram lock function.
|
||||
*/
|
||||
|
||||
typedef struct M48txxInfo {
|
||||
const char *bus_name;
|
||||
uint32_t model; /* 2 = m48t02, 8 = m48t08, 59 = m48t59 */
|
||||
uint32_t size;
|
||||
} M48txxInfo;
|
||||
|
||||
typedef struct M48t59State {
|
||||
/* Hardware parameters */
|
||||
qemu_irq IRQ;
|
||||
MemoryRegion iomem;
|
||||
uint32_t size;
|
||||
int32_t base_year;
|
||||
/* RTC management */
|
||||
time_t time_offset;
|
||||
time_t stop_time;
|
||||
/* Alarm & watchdog */
|
||||
struct tm alarm;
|
||||
QEMUTimer *alrm_timer;
|
||||
QEMUTimer *wd_timer;
|
||||
/* NVRAM storage */
|
||||
uint8_t *buffer;
|
||||
/* Model parameters */
|
||||
uint32_t model; /* 2 = m48t02, 8 = m48t08, 59 = m48t59 */
|
||||
/* NVRAM storage */
|
||||
uint16_t addr;
|
||||
uint8_t lock;
|
||||
} M48t59State;
|
||||
|
||||
uint32_t m48t59_read(M48t59State *NVRAM, uint32_t addr);
|
||||
void m48t59_write(M48t59State *NVRAM, uint32_t addr, uint32_t val);
|
||||
void m48t59_reset_common(M48t59State *NVRAM);
|
||||
void m48t59_realize_common(M48t59State *s, Error **errp);
|
||||
|
||||
static inline void m48t59_toggle_lock(M48t59State *NVRAM, int lock)
|
||||
{
|
||||
NVRAM->lock ^= 1 << lock;
|
||||
}
|
||||
|
||||
extern const MemoryRegionOps m48t59_io_ops;
|
||||
|
||||
#endif /* HW_M48T59_INTERNAL_H */
|
||||
@@ -0,0 +1,181 @@
|
||||
/*
|
||||
* QEMU M48T59 and M48T08 NVRAM emulation (ISA bus interface
|
||||
*
|
||||
* Copyright (c) 2003-2005, 2007 Jocelyn Mayer
|
||||
* Copyright (c) 2013 Hervé Poussineau
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
#include "qemu/osdep.h"
|
||||
#include "hw/isa/isa.h"
|
||||
#include "hw/timer/m48t59.h"
|
||||
#include "m48t59-internal.h"
|
||||
|
||||
#define TYPE_M48TXX_ISA "isa-m48txx"
|
||||
#define M48TXX_ISA_GET_CLASS(obj) \
|
||||
OBJECT_GET_CLASS(M48txxISADeviceClass, (obj), TYPE_M48TXX_ISA)
|
||||
#define M48TXX_ISA_CLASS(klass) \
|
||||
OBJECT_CLASS_CHECK(M48txxISADeviceClass, (klass), TYPE_M48TXX_ISA)
|
||||
#define M48TXX_ISA(obj) \
|
||||
OBJECT_CHECK(M48txxISAState, (obj), TYPE_M48TXX_ISA)
|
||||
|
||||
typedef struct M48txxISAState {
|
||||
ISADevice parent_obj;
|
||||
M48t59State state;
|
||||
uint32_t io_base;
|
||||
MemoryRegion io;
|
||||
} M48txxISAState;
|
||||
|
||||
typedef struct M48txxISADeviceClass {
|
||||
ISADeviceClass parent_class;
|
||||
M48txxInfo info;
|
||||
} M48txxISADeviceClass;
|
||||
|
||||
static M48txxInfo m48txx_isa_info[] = {
|
||||
{
|
||||
.bus_name = "isa-m48t59",
|
||||
.model = 59,
|
||||
.size = 0x2000,
|
||||
}
|
||||
};
|
||||
|
||||
Nvram *m48t59_init_isa(ISABus *bus, uint32_t io_base, uint16_t size,
|
||||
int base_year, int model)
|
||||
{
|
||||
DeviceState *dev;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(m48txx_isa_info); i++) {
|
||||
if (m48txx_isa_info[i].size != size ||
|
||||
m48txx_isa_info[i].model != model) {
|
||||
continue;
|
||||
}
|
||||
|
||||
dev = DEVICE(isa_create(bus, m48txx_isa_info[i].bus_name));
|
||||
qdev_prop_set_uint32(dev, "iobase", io_base);
|
||||
qdev_prop_set_int32(dev, "base-year", base_year);
|
||||
qdev_init_nofail(dev);
|
||||
return NVRAM(dev);
|
||||
}
|
||||
|
||||
assert(false);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static uint32_t m48txx_isa_read(Nvram *obj, uint32_t addr)
|
||||
{
|
||||
M48txxISAState *d = M48TXX_ISA(obj);
|
||||
return m48t59_read(&d->state, addr);
|
||||
}
|
||||
|
||||
static void m48txx_isa_write(Nvram *obj, uint32_t addr, uint32_t val)
|
||||
{
|
||||
M48txxISAState *d = M48TXX_ISA(obj);
|
||||
m48t59_write(&d->state, addr, val);
|
||||
}
|
||||
|
||||
static void m48txx_isa_toggle_lock(Nvram *obj, int lock)
|
||||
{
|
||||
M48txxISAState *d = M48TXX_ISA(obj);
|
||||
m48t59_toggle_lock(&d->state, lock);
|
||||
}
|
||||
|
||||
static Property m48t59_isa_properties[] = {
|
||||
DEFINE_PROP_INT32("base-year", M48txxISAState, state.base_year, 0),
|
||||
DEFINE_PROP_UINT32("iobase", M48txxISAState, io_base, 0x74),
|
||||
DEFINE_PROP_END_OF_LIST(),
|
||||
};
|
||||
|
||||
static void m48t59_reset_isa(DeviceState *d)
|
||||
{
|
||||
M48txxISAState *isa = M48TXX_ISA(d);
|
||||
M48t59State *NVRAM = &isa->state;
|
||||
|
||||
m48t59_reset_common(NVRAM);
|
||||
}
|
||||
|
||||
static void m48t59_isa_realize(DeviceState *dev, Error **errp)
|
||||
{
|
||||
M48txxISADeviceClass *u = M48TXX_ISA_GET_CLASS(dev);
|
||||
ISADevice *isadev = ISA_DEVICE(dev);
|
||||
M48txxISAState *d = M48TXX_ISA(dev);
|
||||
M48t59State *s = &d->state;
|
||||
|
||||
s->model = u->info.model;
|
||||
s->size = u->info.size;
|
||||
isa_init_irq(isadev, &s->IRQ, 8);
|
||||
m48t59_realize_common(s, errp);
|
||||
memory_region_init_io(&d->io, OBJECT(dev), &m48t59_io_ops, s, "m48t59", 4);
|
||||
if (d->io_base != 0) {
|
||||
isa_register_ioport(isadev, &d->io, d->io_base);
|
||||
}
|
||||
}
|
||||
|
||||
static void m48txx_isa_class_init(ObjectClass *klass, void *data)
|
||||
{
|
||||
DeviceClass *dc = DEVICE_CLASS(klass);
|
||||
NvramClass *nc = NVRAM_CLASS(klass);
|
||||
|
||||
dc->realize = m48t59_isa_realize;
|
||||
dc->reset = m48t59_reset_isa;
|
||||
dc->props = m48t59_isa_properties;
|
||||
nc->read = m48txx_isa_read;
|
||||
nc->write = m48txx_isa_write;
|
||||
nc->toggle_lock = m48txx_isa_toggle_lock;
|
||||
}
|
||||
|
||||
static void m48txx_isa_concrete_class_init(ObjectClass *klass, void *data)
|
||||
{
|
||||
M48txxISADeviceClass *u = M48TXX_ISA_CLASS(klass);
|
||||
M48txxInfo *info = data;
|
||||
|
||||
u->info = *info;
|
||||
}
|
||||
|
||||
static const TypeInfo m48txx_isa_type_info = {
|
||||
.name = TYPE_M48TXX_ISA,
|
||||
.parent = TYPE_ISA_DEVICE,
|
||||
.instance_size = sizeof(M48txxISAState),
|
||||
.abstract = true,
|
||||
.class_init = m48txx_isa_class_init,
|
||||
.interfaces = (InterfaceInfo[]) {
|
||||
{ TYPE_NVRAM },
|
||||
{ }
|
||||
}
|
||||
};
|
||||
|
||||
static void m48t59_isa_register_types(void)
|
||||
{
|
||||
TypeInfo isa_type_info = {
|
||||
.parent = TYPE_M48TXX_ISA,
|
||||
.class_size = sizeof(M48txxISADeviceClass),
|
||||
.class_init = m48txx_isa_concrete_class_init,
|
||||
};
|
||||
int i;
|
||||
|
||||
type_register_static(&m48txx_isa_type_info);
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(m48txx_isa_info); i++) {
|
||||
isa_type_info.name = m48txx_isa_info[i].bus_name;
|
||||
isa_type_info.class_data = &m48txx_isa_info[i];
|
||||
type_register(&isa_type_info);
|
||||
}
|
||||
}
|
||||
|
||||
type_init(m48t59_isa_register_types)
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user