mirror of https://gitee.com/openkylin/qemu.git
Sparc32: convert iommu to qdev
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
This commit is contained in:
parent
fa28ec521b
commit
5f750b2ea0
56
hw/iommu.c
56
hw/iommu.c
|
@ -21,8 +21,9 @@
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
* THE SOFTWARE.
|
* THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
#include "hw.h"
|
|
||||||
#include "sun4m.h"
|
#include "sun4m.h"
|
||||||
|
#include "sysbus.h"
|
||||||
|
|
||||||
/* debug iommu */
|
/* debug iommu */
|
||||||
//#define DEBUG_IOMMU
|
//#define DEBUG_IOMMU
|
||||||
|
@ -127,6 +128,7 @@
|
||||||
#define IOMMU_PAGE_MASK ~(IOMMU_PAGE_SIZE - 1)
|
#define IOMMU_PAGE_MASK ~(IOMMU_PAGE_SIZE - 1)
|
||||||
|
|
||||||
typedef struct IOMMUState {
|
typedef struct IOMMUState {
|
||||||
|
SysBusDevice busdev;
|
||||||
uint32_t regs[IOMMU_NREGS];
|
uint32_t regs[IOMMU_NREGS];
|
||||||
target_phys_addr_t iostart;
|
target_phys_addr_t iostart;
|
||||||
uint32_t version;
|
uint32_t version;
|
||||||
|
@ -366,20 +368,52 @@ static void iommu_reset(void *opaque)
|
||||||
|
|
||||||
void *iommu_init(target_phys_addr_t addr, uint32_t version, qemu_irq irq)
|
void *iommu_init(target_phys_addr_t addr, uint32_t version, qemu_irq irq)
|
||||||
{
|
{
|
||||||
IOMMUState *s;
|
DeviceState *dev;
|
||||||
int iommu_io_memory;
|
SysBusDevice *s;
|
||||||
|
IOMMUState *d;
|
||||||
|
|
||||||
s = qemu_mallocz(sizeof(IOMMUState));
|
dev = qdev_create(NULL, "iommu");
|
||||||
|
qdev_set_prop_int(dev, "version", version);
|
||||||
|
qdev_init(dev);
|
||||||
|
s = sysbus_from_qdev(dev);
|
||||||
|
sysbus_connect_irq(s, 0, irq);
|
||||||
|
sysbus_mmio_map(s, 0, addr);
|
||||||
|
|
||||||
s->version = version;
|
d = FROM_SYSBUS(IOMMUState, s);
|
||||||
s->irq = irq;
|
|
||||||
|
|
||||||
iommu_io_memory = cpu_register_io_memory(iommu_mem_read,
|
return d;
|
||||||
iommu_mem_write, s);
|
}
|
||||||
cpu_register_physical_memory(addr, IOMMU_NREGS * 4, iommu_io_memory);
|
|
||||||
|
|
||||||
register_savevm("iommu", addr, 2, iommu_save, iommu_load, s);
|
static void iommu_init1(SysBusDevice *dev)
|
||||||
|
{
|
||||||
|
IOMMUState *s = FROM_SYSBUS(IOMMUState, dev);
|
||||||
|
int io;
|
||||||
|
|
||||||
|
sysbus_init_irq(dev, &s->irq);
|
||||||
|
|
||||||
|
s->version = qdev_get_prop_int(&dev->qdev, "version", 0);
|
||||||
|
|
||||||
|
io = cpu_register_io_memory(iommu_mem_read, iommu_mem_write, s);
|
||||||
|
sysbus_init_mmio(dev, IOMMU_NREGS * sizeof(uint32_t), io);
|
||||||
|
|
||||||
|
register_savevm("iommu", -1, 2, iommu_save, iommu_load, s);
|
||||||
qemu_register_reset(iommu_reset, s);
|
qemu_register_reset(iommu_reset, s);
|
||||||
iommu_reset(s);
|
iommu_reset(s);
|
||||||
return s;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static SysBusDeviceInfo iommu_info = {
|
||||||
|
.init = iommu_init1,
|
||||||
|
.qdev.name = "iommu",
|
||||||
|
.qdev.size = sizeof(IOMMUState),
|
||||||
|
.qdev.props = (DevicePropList[]) {
|
||||||
|
{.name = "version", .type = PROP_TYPE_INT},
|
||||||
|
{.name = NULL}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
static void iommu_register_devices(void)
|
||||||
|
{
|
||||||
|
sysbus_register_withprop(&iommu_info);
|
||||||
|
}
|
||||||
|
|
||||||
|
device_init(iommu_register_devices)
|
||||||
|
|
Loading…
Reference in New Issue