]> git.proxmox.com Git - mirror_qemu.git/blame - hw/remote/machine.c
Remove qemu-common.h include from most units
[mirror_qemu.git] / hw / remote / machine.c
CommitLineData
3f0e7e57
JR
1/*
2 * Machine for remote device
3 *
4 * This machine type is used by the remote device process in multi-process
5 * QEMU. QEMU device models depend on parent busses, interrupt controllers,
6 * memory regions, etc. The remote machine type offers this environment so
7 * that QEMU device models can be used as remote devices.
8 *
9 * Copyright © 2018, 2021 Oracle and/or its affiliates.
10 *
11 * This work is licensed under the terms of the GNU GPL, version 2 or later.
12 * See the COPYING file in the top-level directory.
13 *
14 */
15
16#include "qemu/osdep.h"
3f0e7e57
JR
17
18#include "hw/remote/machine.h"
3f0e7e57
JR
19#include "exec/memory.h"
20#include "qapi/error.h"
bd36adb8
JR
21#include "hw/pci/pci_host.h"
22#include "hw/remote/iohub.h"
3f0e7e57
JR
23
24static void remote_machine_init(MachineState *machine)
25{
26 MemoryRegion *system_memory, *system_io, *pci_memory;
27 RemoteMachineState *s = REMOTE_MACHINE(machine);
28 RemotePCIHost *rem_host;
bd36adb8 29 PCIHostState *pci_host;
3f0e7e57
JR
30
31 system_memory = get_system_memory();
32 system_io = get_system_io();
33
34 pci_memory = g_new(MemoryRegion, 1);
35 memory_region_init(pci_memory, NULL, "pci", UINT64_MAX);
36
37 rem_host = REMOTE_PCIHOST(qdev_new(TYPE_REMOTE_PCIHOST));
38
39 rem_host->mr_pci_mem = pci_memory;
40 rem_host->mr_sys_mem = system_memory;
41 rem_host->mr_sys_io = system_io;
42
43 s->host = rem_host;
44
45 object_property_add_child(OBJECT(s), "remote-pcihost", OBJECT(rem_host));
46 memory_region_add_subregion_overlap(system_memory, 0x0, pci_memory, -1);
47
48 qdev_realize(DEVICE(rem_host), sysbus_get_default(), &error_fatal);
bd36adb8
JR
49
50 pci_host = PCI_HOST_BRIDGE(rem_host);
51
52 remote_iohub_init(&s->iohub);
53
54 pci_bus_irqs(pci_host->bus, remote_iohub_set_irq, remote_iohub_map_irq,
55 &s->iohub, REMOTE_IOHUB_NB_PIRQS);
3f0e7e57
JR
56}
57
58static void remote_machine_class_init(ObjectClass *oc, void *data)
59{
60 MachineClass *mc = MACHINE_CLASS(oc);
61
62 mc->init = remote_machine_init;
63 mc->desc = "Experimental remote machine";
64}
65
66static const TypeInfo remote_machine = {
67 .name = TYPE_REMOTE_MACHINE,
68 .parent = TYPE_MACHINE,
69 .instance_size = sizeof(RemoteMachineState),
70 .class_init = remote_machine_class_init,
71};
72
73static void remote_machine_register_types(void)
74{
75 type_register_static(&remote_machine);
76}
77
78type_init(remote_machine_register_types);