2011-04-01 06:15:21 +02:00
|
|
|
/*
|
|
|
|
* QEMU sPAPR VIO code
|
|
|
|
*
|
|
|
|
* Copyright (c) 2010 David Gibson, IBM Corporation <dwg@au1.ibm.com>
|
|
|
|
* Based on the s390 virtio bus code:
|
|
|
|
* Copyright (c) 2009 Alexander Graf <agraf@suse.de>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2016-01-26 19:16:58 +01:00
|
|
|
#include "qemu/osdep.h"
|
2016-08-02 19:38:00 +02:00
|
|
|
#include "qemu/error-report.h"
|
include/qemu/osdep.h: Don't include qapi/error.h
Commit 57cb38b included qapi/error.h into qemu/osdep.h to get the
Error typedef. Since then, we've moved to include qemu/osdep.h
everywhere. Its file comment explains: "To avoid getting into
possible circular include dependencies, this file should not include
any other QEMU headers, with the exceptions of config-host.h,
compiler.h, os-posix.h and os-win32.h, all of which are doing a
similar job to this file and are under similar constraints."
qapi/error.h doesn't do a similar job, and it doesn't adhere to
similar constraints: it includes qapi-types.h. That's in excess of
100KiB of crap most .c files don't actually need.
Add the typedef to qemu/typedefs.h, and include that instead of
qapi/error.h. Include qapi/error.h in .c files that need it and don't
get it now. Include qapi-types.h in qom/object.h for uint16List.
Update scripts/clean-includes accordingly. Update it further to match
reality: replace config.h by config-target.h, add sysemu/os-posix.h,
sysemu/os-win32.h. Update the list of includes in the qemu/osdep.h
comment quoted above similarly.
This reduces the number of objects depending on qapi/error.h from "all
of them" to less than a third. Unfortunately, the number depending on
qapi-types.h shrinks only a little. More work is needed for that one.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
[Fix compilation without the spice devel packages. - Paolo]
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-03-14 09:01:28 +01:00
|
|
|
#include "qapi/error.h"
|
2018-06-05 08:56:26 +02:00
|
|
|
#include "qapi/visitor.h"
|
2013-02-04 15:40:22 +01:00
|
|
|
#include "hw/hw.h"
|
2015-12-15 13:16:16 +01:00
|
|
|
#include "qemu/log.h"
|
2012-12-17 18:20:04 +01:00
|
|
|
#include "sysemu/sysemu.h"
|
2013-02-04 15:40:22 +01:00
|
|
|
#include "hw/boards.h"
|
|
|
|
#include "hw/loader.h"
|
2011-04-01 06:15:21 +02:00
|
|
|
#include "elf.h"
|
|
|
|
#include "hw/sysbus.h"
|
2012-12-17 18:20:04 +01:00
|
|
|
#include "sysemu/kvm.h"
|
|
|
|
#include "sysemu/device_tree.h"
|
2011-04-01 06:15:30 +02:00
|
|
|
#include "kvm_ppc.h"
|
2018-06-05 08:56:26 +02:00
|
|
|
#include "sysemu/qtest.h"
|
2011-04-01 06:15:21 +02:00
|
|
|
|
2013-02-05 17:06:20 +01:00
|
|
|
#include "hw/ppc/spapr.h"
|
|
|
|
#include "hw/ppc/spapr_vio.h"
|
2016-10-20 07:01:17 +02:00
|
|
|
#include "hw/ppc/fdt.h"
|
2016-09-14 20:48:25 +02:00
|
|
|
#include "trace.h"
|
2011-04-01 06:15:21 +02:00
|
|
|
|
|
|
|
#include <libfdt.h>
|
|
|
|
|
2018-07-30 16:11:32 +02:00
|
|
|
#define SPAPR_VIO_REG_BASE 0x71000000
|
|
|
|
|
2013-04-07 21:08:17 +02:00
|
|
|
static char *spapr_vio_get_dev_name(DeviceState *qdev)
|
|
|
|
{
|
spapr: Use CamelCase properly
The qemu coding standard is to use CamelCase for type and structure names,
and the pseries code follows that... sort of. There are quite a lot of
places where we bend the rules in order to preserve the capitalization of
internal acronyms like "PHB", "TCE", "DIMM" and most commonly "sPAPR".
That was a bad idea - it frequently leads to names ending up with hard to
read clusters of capital letters, and means they don't catch the eye as
type identifiers, which is kind of the point of the CamelCase convention in
the first place.
In short, keeping type identifiers look like CamelCase is more important
than preserving standard capitalization of internal "words". So, this
patch renames a heap of spapr internal type names to a more standard
CamelCase.
In addition to case changes, we also make some other identifier renames:
VIOsPAPR* -> SpaprVio*
The reverse word ordering was only ever used to mitigate the capital
cluster, so revert to the natural ordering.
VIOsPAPRVTYDevice -> SpaprVioVty
VIOsPAPRVLANDevice -> SpaprVioVlan
Brevity, since the "Device" didn't add useful information
sPAPRDRConnector -> SpaprDrc
sPAPRDRConnectorClass -> SpaprDrcClass
Brevity, and makes it clearer this is the same thing as a "DRC"
mentioned in many other places in the code
This is 100% a mechanical search-and-replace patch. It will, however,
conflict with essentially any and all outstanding patches touching the
spapr code.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-06 05:35:37 +01:00
|
|
|
SpaprVioDevice *dev = VIO_SPAPR_DEVICE(qdev);
|
|
|
|
SpaprVioDeviceClass *pc = VIO_SPAPR_DEVICE_GET_CLASS(dev);
|
2013-04-07 21:08:17 +02:00
|
|
|
|
|
|
|
/* Device tree style name device@reg */
|
2016-06-13 23:57:58 +02:00
|
|
|
return g_strdup_printf("%s@%x", pc->dt_name, dev->reg);
|
2013-04-07 21:08:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void spapr_vio_bus_class_init(ObjectClass *klass, void *data)
|
|
|
|
{
|
|
|
|
BusClass *k = BUS_CLASS(klass);
|
|
|
|
|
|
|
|
k->get_dev_path = spapr_vio_get_dev_name;
|
2014-03-17 03:40:25 +01:00
|
|
|
k->get_fw_dev_path = spapr_vio_get_dev_name;
|
2013-04-07 21:08:17 +02:00
|
|
|
}
|
|
|
|
|
2012-05-02 09:00:20 +02:00
|
|
|
static const TypeInfo spapr_vio_bus_info = {
|
|
|
|
.name = TYPE_SPAPR_VIO_BUS,
|
|
|
|
.parent = TYPE_BUS,
|
2013-04-07 21:08:17 +02:00
|
|
|
.class_init = spapr_vio_bus_class_init,
|
spapr: Use CamelCase properly
The qemu coding standard is to use CamelCase for type and structure names,
and the pseries code follows that... sort of. There are quite a lot of
places where we bend the rules in order to preserve the capitalization of
internal acronyms like "PHB", "TCE", "DIMM" and most commonly "sPAPR".
That was a bad idea - it frequently leads to names ending up with hard to
read clusters of capital letters, and means they don't catch the eye as
type identifiers, which is kind of the point of the CamelCase convention in
the first place.
In short, keeping type identifiers look like CamelCase is more important
than preserving standard capitalization of internal "words". So, this
patch renames a heap of spapr internal type names to a more standard
CamelCase.
In addition to case changes, we also make some other identifier renames:
VIOsPAPR* -> SpaprVio*
The reverse word ordering was only ever used to mitigate the capital
cluster, so revert to the natural ordering.
VIOsPAPRVTYDevice -> SpaprVioVty
VIOsPAPRVLANDevice -> SpaprVioVlan
Brevity, since the "Device" didn't add useful information
sPAPRDRConnector -> SpaprDrc
sPAPRDRConnectorClass -> SpaprDrcClass
Brevity, and makes it clearer this is the same thing as a "DRC"
mentioned in many other places in the code
This is 100% a mechanical search-and-replace patch. It will, however,
conflict with essentially any and all outstanding patches touching the
spapr code.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-06 05:35:37 +01:00
|
|
|
.instance_size = sizeof(SpaprVioBus),
|
2011-04-01 06:15:21 +02:00
|
|
|
};
|
|
|
|
|
spapr: Use CamelCase properly
The qemu coding standard is to use CamelCase for type and structure names,
and the pseries code follows that... sort of. There are quite a lot of
places where we bend the rules in order to preserve the capitalization of
internal acronyms like "PHB", "TCE", "DIMM" and most commonly "sPAPR".
That was a bad idea - it frequently leads to names ending up with hard to
read clusters of capital letters, and means they don't catch the eye as
type identifiers, which is kind of the point of the CamelCase convention in
the first place.
In short, keeping type identifiers look like CamelCase is more important
than preserving standard capitalization of internal "words". So, this
patch renames a heap of spapr internal type names to a more standard
CamelCase.
In addition to case changes, we also make some other identifier renames:
VIOsPAPR* -> SpaprVio*
The reverse word ordering was only ever used to mitigate the capital
cluster, so revert to the natural ordering.
VIOsPAPRVTYDevice -> SpaprVioVty
VIOsPAPRVLANDevice -> SpaprVioVlan
Brevity, since the "Device" didn't add useful information
sPAPRDRConnector -> SpaprDrc
sPAPRDRConnectorClass -> SpaprDrcClass
Brevity, and makes it clearer this is the same thing as a "DRC"
mentioned in many other places in the code
This is 100% a mechanical search-and-replace patch. It will, however,
conflict with essentially any and all outstanding patches touching the
spapr code.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-06 05:35:37 +01:00
|
|
|
SpaprVioDevice *spapr_vio_find_by_reg(SpaprVioBus *bus, uint32_t reg)
|
2011-04-01 06:15:21 +02:00
|
|
|
{
|
2011-12-23 22:34:39 +01:00
|
|
|
BusChild *kid;
|
spapr: Use CamelCase properly
The qemu coding standard is to use CamelCase for type and structure names,
and the pseries code follows that... sort of. There are quite a lot of
places where we bend the rules in order to preserve the capitalization of
internal acronyms like "PHB", "TCE", "DIMM" and most commonly "sPAPR".
That was a bad idea - it frequently leads to names ending up with hard to
read clusters of capital letters, and means they don't catch the eye as
type identifiers, which is kind of the point of the CamelCase convention in
the first place.
In short, keeping type identifiers look like CamelCase is more important
than preserving standard capitalization of internal "words". So, this
patch renames a heap of spapr internal type names to a more standard
CamelCase.
In addition to case changes, we also make some other identifier renames:
VIOsPAPR* -> SpaprVio*
The reverse word ordering was only ever used to mitigate the capital
cluster, so revert to the natural ordering.
VIOsPAPRVTYDevice -> SpaprVioVty
VIOsPAPRVLANDevice -> SpaprVioVlan
Brevity, since the "Device" didn't add useful information
sPAPRDRConnector -> SpaprDrc
sPAPRDRConnectorClass -> SpaprDrcClass
Brevity, and makes it clearer this is the same thing as a "DRC"
mentioned in many other places in the code
This is 100% a mechanical search-and-replace patch. It will, however,
conflict with essentially any and all outstanding patches touching the
spapr code.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-06 05:35:37 +01:00
|
|
|
SpaprVioDevice *dev = NULL;
|
2011-04-01 06:15:21 +02:00
|
|
|
|
2011-12-23 22:34:39 +01:00
|
|
|
QTAILQ_FOREACH(kid, &bus->bus.children, sibling) {
|
spapr: Use CamelCase properly
The qemu coding standard is to use CamelCase for type and structure names,
and the pseries code follows that... sort of. There are quite a lot of
places where we bend the rules in order to preserve the capitalization of
internal acronyms like "PHB", "TCE", "DIMM" and most commonly "sPAPR".
That was a bad idea - it frequently leads to names ending up with hard to
read clusters of capital letters, and means they don't catch the eye as
type identifiers, which is kind of the point of the CamelCase convention in
the first place.
In short, keeping type identifiers look like CamelCase is more important
than preserving standard capitalization of internal "words". So, this
patch renames a heap of spapr internal type names to a more standard
CamelCase.
In addition to case changes, we also make some other identifier renames:
VIOsPAPR* -> SpaprVio*
The reverse word ordering was only ever used to mitigate the capital
cluster, so revert to the natural ordering.
VIOsPAPRVTYDevice -> SpaprVioVty
VIOsPAPRVLANDevice -> SpaprVioVlan
Brevity, since the "Device" didn't add useful information
sPAPRDRConnector -> SpaprDrc
sPAPRDRConnectorClass -> SpaprDrcClass
Brevity, and makes it clearer this is the same thing as a "DRC"
mentioned in many other places in the code
This is 100% a mechanical search-and-replace patch. It will, however,
conflict with essentially any and all outstanding patches touching the
spapr code.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-06 05:35:37 +01:00
|
|
|
dev = (SpaprVioDevice *)kid->child;
|
2011-04-01 06:15:21 +02:00
|
|
|
if (dev->reg == reg) {
|
2011-11-13 18:18:58 +01:00
|
|
|
return dev;
|
2011-04-01 06:15:21 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-13 18:18:58 +01:00
|
|
|
return NULL;
|
2011-04-01 06:15:21 +02:00
|
|
|
}
|
|
|
|
|
spapr: Use CamelCase properly
The qemu coding standard is to use CamelCase for type and structure names,
and the pseries code follows that... sort of. There are quite a lot of
places where we bend the rules in order to preserve the capitalization of
internal acronyms like "PHB", "TCE", "DIMM" and most commonly "sPAPR".
That was a bad idea - it frequently leads to names ending up with hard to
read clusters of capital letters, and means they don't catch the eye as
type identifiers, which is kind of the point of the CamelCase convention in
the first place.
In short, keeping type identifiers look like CamelCase is more important
than preserving standard capitalization of internal "words". So, this
patch renames a heap of spapr internal type names to a more standard
CamelCase.
In addition to case changes, we also make some other identifier renames:
VIOsPAPR* -> SpaprVio*
The reverse word ordering was only ever used to mitigate the capital
cluster, so revert to the natural ordering.
VIOsPAPRVTYDevice -> SpaprVioVty
VIOsPAPRVLANDevice -> SpaprVioVlan
Brevity, since the "Device" didn't add useful information
sPAPRDRConnector -> SpaprDrc
sPAPRDRConnectorClass -> SpaprDrcClass
Brevity, and makes it clearer this is the same thing as a "DRC"
mentioned in many other places in the code
This is 100% a mechanical search-and-replace patch. It will, however,
conflict with essentially any and all outstanding patches touching the
spapr code.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-06 05:35:37 +01:00
|
|
|
static int vio_make_devnode(SpaprVioDevice *dev,
|
2011-04-01 06:15:21 +02:00
|
|
|
void *fdt)
|
|
|
|
{
|
spapr: Use CamelCase properly
The qemu coding standard is to use CamelCase for type and structure names,
and the pseries code follows that... sort of. There are quite a lot of
places where we bend the rules in order to preserve the capitalization of
internal acronyms like "PHB", "TCE", "DIMM" and most commonly "sPAPR".
That was a bad idea - it frequently leads to names ending up with hard to
read clusters of capital letters, and means they don't catch the eye as
type identifiers, which is kind of the point of the CamelCase convention in
the first place.
In short, keeping type identifiers look like CamelCase is more important
than preserving standard capitalization of internal "words". So, this
patch renames a heap of spapr internal type names to a more standard
CamelCase.
In addition to case changes, we also make some other identifier renames:
VIOsPAPR* -> SpaprVio*
The reverse word ordering was only ever used to mitigate the capital
cluster, so revert to the natural ordering.
VIOsPAPRVTYDevice -> SpaprVioVty
VIOsPAPRVLANDevice -> SpaprVioVlan
Brevity, since the "Device" didn't add useful information
sPAPRDRConnector -> SpaprDrc
sPAPRDRConnectorClass -> SpaprDrcClass
Brevity, and makes it clearer this is the same thing as a "DRC"
mentioned in many other places in the code
This is 100% a mechanical search-and-replace patch. It will, however,
conflict with essentially any and all outstanding patches touching the
spapr code.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-06 05:35:37 +01:00
|
|
|
SpaprVioDeviceClass *pc = VIO_SPAPR_DEVICE_GET_CLASS(dev);
|
2011-11-15 19:53:13 +01:00
|
|
|
int vdevice_off, node_off, ret;
|
|
|
|
char *dt_name;
|
2011-04-01 06:15:21 +02:00
|
|
|
|
|
|
|
vdevice_off = fdt_path_offset(fdt, "/vdevice");
|
|
|
|
if (vdevice_off < 0) {
|
|
|
|
return vdevice_off;
|
|
|
|
}
|
|
|
|
|
2013-04-07 21:08:17 +02:00
|
|
|
dt_name = spapr_vio_get_dev_name(DEVICE(dev));
|
2011-11-15 19:53:13 +01:00
|
|
|
node_off = fdt_add_subnode(fdt, vdevice_off, dt_name);
|
2013-01-16 18:22:29 +01:00
|
|
|
g_free(dt_name);
|
2011-04-01 06:15:21 +02:00
|
|
|
if (node_off < 0) {
|
|
|
|
return node_off;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = fdt_setprop_cell(fdt, node_off, "reg", dev->reg);
|
|
|
|
if (ret < 0) {
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2011-12-15 23:31:06 +01:00
|
|
|
if (pc->dt_type) {
|
2011-04-01 06:15:21 +02:00
|
|
|
ret = fdt_setprop_string(fdt, node_off, "device_type",
|
2011-12-15 23:31:06 +01:00
|
|
|
pc->dt_type);
|
2011-04-01 06:15:21 +02:00
|
|
|
if (ret < 0) {
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-12-15 23:31:06 +01:00
|
|
|
if (pc->dt_compatible) {
|
2011-04-01 06:15:21 +02:00
|
|
|
ret = fdt_setprop_string(fdt, node_off, "compatible",
|
2011-12-15 23:31:06 +01:00
|
|
|
pc->dt_compatible);
|
2011-04-01 06:15:21 +02:00
|
|
|
if (ret < 0) {
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-07 18:10:32 +02:00
|
|
|
if (dev->irq) {
|
2017-12-06 09:13:16 +01:00
|
|
|
uint32_t ints_prop[2];
|
2011-04-01 06:15:26 +02:00
|
|
|
|
2019-01-17 18:14:39 +01:00
|
|
|
spapr_dt_irq(ints_prop, dev->irq, false);
|
2011-04-01 06:15:26 +02:00
|
|
|
ret = fdt_setprop(fdt, node_off, "interrupts", ints_prop,
|
|
|
|
sizeof(ints_prop));
|
|
|
|
if (ret < 0) {
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-04-10 17:30:48 +02:00
|
|
|
ret = spapr_tcet_dma_dt(fdt, node_off, "ibm,my-dma-window", dev->tcet);
|
2012-06-27 06:50:44 +02:00
|
|
|
if (ret < 0) {
|
|
|
|
return ret;
|
2011-04-01 06:15:28 +02:00
|
|
|
}
|
|
|
|
|
2011-12-15 23:31:06 +01:00
|
|
|
if (pc->devnode) {
|
|
|
|
ret = (pc->devnode)(dev, fdt, node_off);
|
2011-04-01 06:15:21 +02:00
|
|
|
if (ret < 0) {
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return node_off;
|
|
|
|
}
|
|
|
|
|
2011-04-01 06:15:30 +02:00
|
|
|
/*
|
|
|
|
* CRQ handling
|
|
|
|
*/
|
spapr: Use CamelCase properly
The qemu coding standard is to use CamelCase for type and structure names,
and the pseries code follows that... sort of. There are quite a lot of
places where we bend the rules in order to preserve the capitalization of
internal acronyms like "PHB", "TCE", "DIMM" and most commonly "sPAPR".
That was a bad idea - it frequently leads to names ending up with hard to
read clusters of capital letters, and means they don't catch the eye as
type identifiers, which is kind of the point of the CamelCase convention in
the first place.
In short, keeping type identifiers look like CamelCase is more important
than preserving standard capitalization of internal "words". So, this
patch renames a heap of spapr internal type names to a more standard
CamelCase.
In addition to case changes, we also make some other identifier renames:
VIOsPAPR* -> SpaprVio*
The reverse word ordering was only ever used to mitigate the capital
cluster, so revert to the natural ordering.
VIOsPAPRVTYDevice -> SpaprVioVty
VIOsPAPRVLANDevice -> SpaprVioVlan
Brevity, since the "Device" didn't add useful information
sPAPRDRConnector -> SpaprDrc
sPAPRDRConnectorClass -> SpaprDrcClass
Brevity, and makes it clearer this is the same thing as a "DRC"
mentioned in many other places in the code
This is 100% a mechanical search-and-replace patch. It will, however,
conflict with essentially any and all outstanding patches touching the
spapr code.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-06 05:35:37 +01:00
|
|
|
static target_ulong h_reg_crq(PowerPCCPU *cpu, SpaprMachineState *spapr,
|
2011-04-01 06:15:30 +02:00
|
|
|
target_ulong opcode, target_ulong *args)
|
|
|
|
{
|
|
|
|
target_ulong reg = args[0];
|
|
|
|
target_ulong queue_addr = args[1];
|
|
|
|
target_ulong queue_len = args[2];
|
spapr: Use CamelCase properly
The qemu coding standard is to use CamelCase for type and structure names,
and the pseries code follows that... sort of. There are quite a lot of
places where we bend the rules in order to preserve the capitalization of
internal acronyms like "PHB", "TCE", "DIMM" and most commonly "sPAPR".
That was a bad idea - it frequently leads to names ending up with hard to
read clusters of capital letters, and means they don't catch the eye as
type identifiers, which is kind of the point of the CamelCase convention in
the first place.
In short, keeping type identifiers look like CamelCase is more important
than preserving standard capitalization of internal "words". So, this
patch renames a heap of spapr internal type names to a more standard
CamelCase.
In addition to case changes, we also make some other identifier renames:
VIOsPAPR* -> SpaprVio*
The reverse word ordering was only ever used to mitigate the capital
cluster, so revert to the natural ordering.
VIOsPAPRVTYDevice -> SpaprVioVty
VIOsPAPRVLANDevice -> SpaprVioVlan
Brevity, since the "Device" didn't add useful information
sPAPRDRConnector -> SpaprDrc
sPAPRDRConnectorClass -> SpaprDrcClass
Brevity, and makes it clearer this is the same thing as a "DRC"
mentioned in many other places in the code
This is 100% a mechanical search-and-replace patch. It will, however,
conflict with essentially any and all outstanding patches touching the
spapr code.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-06 05:35:37 +01:00
|
|
|
SpaprVioDevice *dev = spapr_vio_find_by_reg(spapr->vio_bus, reg);
|
2011-04-01 06:15:30 +02:00
|
|
|
|
|
|
|
if (!dev) {
|
2012-03-28 23:39:45 +02:00
|
|
|
hcall_dprintf("Unit 0x" TARGET_FMT_lx " does not exist\n", reg);
|
2011-04-01 06:15:30 +02:00
|
|
|
return H_PARAMETER;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* We can't grok a queue size bigger than 256M for now */
|
|
|
|
if (queue_len < 0x1000 || queue_len > 0x10000000) {
|
2012-03-28 23:39:45 +02:00
|
|
|
hcall_dprintf("Queue size too small or too big (0x" TARGET_FMT_lx
|
|
|
|
")\n", queue_len);
|
2011-04-01 06:15:30 +02:00
|
|
|
return H_PARAMETER;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check queue alignment */
|
|
|
|
if (queue_addr & 0xfff) {
|
2012-03-28 23:39:45 +02:00
|
|
|
hcall_dprintf("Queue not aligned (0x" TARGET_FMT_lx ")\n", queue_addr);
|
2011-04-01 06:15:30 +02:00
|
|
|
return H_PARAMETER;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check if device supports CRQs */
|
|
|
|
if (!dev->crq.SendFunc) {
|
2012-03-28 23:39:46 +02:00
|
|
|
hcall_dprintf("Device does not support CRQ\n");
|
2011-04-01 06:15:30 +02:00
|
|
|
return H_NOT_FOUND;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Already a queue ? */
|
|
|
|
if (dev->crq.qsize) {
|
2012-03-28 23:39:46 +02:00
|
|
|
hcall_dprintf("CRQ already registered\n");
|
2011-04-01 06:15:30 +02:00
|
|
|
return H_RESOURCE;
|
|
|
|
}
|
|
|
|
dev->crq.qladdr = queue_addr;
|
|
|
|
dev->crq.qsize = queue_len;
|
|
|
|
dev->crq.qnext = 0;
|
|
|
|
|
2016-09-14 20:48:25 +02:00
|
|
|
trace_spapr_vio_h_reg_crq(reg, queue_addr, queue_len);
|
2011-04-01 06:15:30 +02:00
|
|
|
return H_SUCCESS;
|
|
|
|
}
|
|
|
|
|
spapr: Use CamelCase properly
The qemu coding standard is to use CamelCase for type and structure names,
and the pseries code follows that... sort of. There are quite a lot of
places where we bend the rules in order to preserve the capitalization of
internal acronyms like "PHB", "TCE", "DIMM" and most commonly "sPAPR".
That was a bad idea - it frequently leads to names ending up with hard to
read clusters of capital letters, and means they don't catch the eye as
type identifiers, which is kind of the point of the CamelCase convention in
the first place.
In short, keeping type identifiers look like CamelCase is more important
than preserving standard capitalization of internal "words". So, this
patch renames a heap of spapr internal type names to a more standard
CamelCase.
In addition to case changes, we also make some other identifier renames:
VIOsPAPR* -> SpaprVio*
The reverse word ordering was only ever used to mitigate the capital
cluster, so revert to the natural ordering.
VIOsPAPRVTYDevice -> SpaprVioVty
VIOsPAPRVLANDevice -> SpaprVioVlan
Brevity, since the "Device" didn't add useful information
sPAPRDRConnector -> SpaprDrc
sPAPRDRConnectorClass -> SpaprDrcClass
Brevity, and makes it clearer this is the same thing as a "DRC"
mentioned in many other places in the code
This is 100% a mechanical search-and-replace patch. It will, however,
conflict with essentially any and all outstanding patches touching the
spapr code.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-06 05:35:37 +01:00
|
|
|
static target_ulong free_crq(SpaprVioDevice *dev)
|
2012-03-28 23:39:46 +02:00
|
|
|
{
|
|
|
|
dev->crq.qladdr = 0;
|
|
|
|
dev->crq.qsize = 0;
|
|
|
|
dev->crq.qnext = 0;
|
|
|
|
|
2016-09-14 20:48:25 +02:00
|
|
|
trace_spapr_vio_free_crq(dev->reg);
|
2012-03-28 23:39:46 +02:00
|
|
|
|
|
|
|
return H_SUCCESS;
|
|
|
|
}
|
|
|
|
|
spapr: Use CamelCase properly
The qemu coding standard is to use CamelCase for type and structure names,
and the pseries code follows that... sort of. There are quite a lot of
places where we bend the rules in order to preserve the capitalization of
internal acronyms like "PHB", "TCE", "DIMM" and most commonly "sPAPR".
That was a bad idea - it frequently leads to names ending up with hard to
read clusters of capital letters, and means they don't catch the eye as
type identifiers, which is kind of the point of the CamelCase convention in
the first place.
In short, keeping type identifiers look like CamelCase is more important
than preserving standard capitalization of internal "words". So, this
patch renames a heap of spapr internal type names to a more standard
CamelCase.
In addition to case changes, we also make some other identifier renames:
VIOsPAPR* -> SpaprVio*
The reverse word ordering was only ever used to mitigate the capital
cluster, so revert to the natural ordering.
VIOsPAPRVTYDevice -> SpaprVioVty
VIOsPAPRVLANDevice -> SpaprVioVlan
Brevity, since the "Device" didn't add useful information
sPAPRDRConnector -> SpaprDrc
sPAPRDRConnectorClass -> SpaprDrcClass
Brevity, and makes it clearer this is the same thing as a "DRC"
mentioned in many other places in the code
This is 100% a mechanical search-and-replace patch. It will, however,
conflict with essentially any and all outstanding patches touching the
spapr code.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-06 05:35:37 +01:00
|
|
|
static target_ulong h_free_crq(PowerPCCPU *cpu, SpaprMachineState *spapr,
|
2011-04-01 06:15:30 +02:00
|
|
|
target_ulong opcode, target_ulong *args)
|
|
|
|
{
|
|
|
|
target_ulong reg = args[0];
|
spapr: Use CamelCase properly
The qemu coding standard is to use CamelCase for type and structure names,
and the pseries code follows that... sort of. There are quite a lot of
places where we bend the rules in order to preserve the capitalization of
internal acronyms like "PHB", "TCE", "DIMM" and most commonly "sPAPR".
That was a bad idea - it frequently leads to names ending up with hard to
read clusters of capital letters, and means they don't catch the eye as
type identifiers, which is kind of the point of the CamelCase convention in
the first place.
In short, keeping type identifiers look like CamelCase is more important
than preserving standard capitalization of internal "words". So, this
patch renames a heap of spapr internal type names to a more standard
CamelCase.
In addition to case changes, we also make some other identifier renames:
VIOsPAPR* -> SpaprVio*
The reverse word ordering was only ever used to mitigate the capital
cluster, so revert to the natural ordering.
VIOsPAPRVTYDevice -> SpaprVioVty
VIOsPAPRVLANDevice -> SpaprVioVlan
Brevity, since the "Device" didn't add useful information
sPAPRDRConnector -> SpaprDrc
sPAPRDRConnectorClass -> SpaprDrcClass
Brevity, and makes it clearer this is the same thing as a "DRC"
mentioned in many other places in the code
This is 100% a mechanical search-and-replace patch. It will, however,
conflict with essentially any and all outstanding patches touching the
spapr code.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-06 05:35:37 +01:00
|
|
|
SpaprVioDevice *dev = spapr_vio_find_by_reg(spapr->vio_bus, reg);
|
2011-04-01 06:15:30 +02:00
|
|
|
|
|
|
|
if (!dev) {
|
2012-03-28 23:39:45 +02:00
|
|
|
hcall_dprintf("Unit 0x" TARGET_FMT_lx " does not exist\n", reg);
|
2011-04-01 06:15:30 +02:00
|
|
|
return H_PARAMETER;
|
|
|
|
}
|
|
|
|
|
2012-03-28 23:39:46 +02:00
|
|
|
return free_crq(dev);
|
2011-04-01 06:15:30 +02:00
|
|
|
}
|
|
|
|
|
spapr: Use CamelCase properly
The qemu coding standard is to use CamelCase for type and structure names,
and the pseries code follows that... sort of. There are quite a lot of
places where we bend the rules in order to preserve the capitalization of
internal acronyms like "PHB", "TCE", "DIMM" and most commonly "sPAPR".
That was a bad idea - it frequently leads to names ending up with hard to
read clusters of capital letters, and means they don't catch the eye as
type identifiers, which is kind of the point of the CamelCase convention in
the first place.
In short, keeping type identifiers look like CamelCase is more important
than preserving standard capitalization of internal "words". So, this
patch renames a heap of spapr internal type names to a more standard
CamelCase.
In addition to case changes, we also make some other identifier renames:
VIOsPAPR* -> SpaprVio*
The reverse word ordering was only ever used to mitigate the capital
cluster, so revert to the natural ordering.
VIOsPAPRVTYDevice -> SpaprVioVty
VIOsPAPRVLANDevice -> SpaprVioVlan
Brevity, since the "Device" didn't add useful information
sPAPRDRConnector -> SpaprDrc
sPAPRDRConnectorClass -> SpaprDrcClass
Brevity, and makes it clearer this is the same thing as a "DRC"
mentioned in many other places in the code
This is 100% a mechanical search-and-replace patch. It will, however,
conflict with essentially any and all outstanding patches touching the
spapr code.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-06 05:35:37 +01:00
|
|
|
static target_ulong h_send_crq(PowerPCCPU *cpu, SpaprMachineState *spapr,
|
2011-04-01 06:15:30 +02:00
|
|
|
target_ulong opcode, target_ulong *args)
|
|
|
|
{
|
|
|
|
target_ulong reg = args[0];
|
|
|
|
target_ulong msg_hi = args[1];
|
|
|
|
target_ulong msg_lo = args[2];
|
spapr: Use CamelCase properly
The qemu coding standard is to use CamelCase for type and structure names,
and the pseries code follows that... sort of. There are quite a lot of
places where we bend the rules in order to preserve the capitalization of
internal acronyms like "PHB", "TCE", "DIMM" and most commonly "sPAPR".
That was a bad idea - it frequently leads to names ending up with hard to
read clusters of capital letters, and means they don't catch the eye as
type identifiers, which is kind of the point of the CamelCase convention in
the first place.
In short, keeping type identifiers look like CamelCase is more important
than preserving standard capitalization of internal "words". So, this
patch renames a heap of spapr internal type names to a more standard
CamelCase.
In addition to case changes, we also make some other identifier renames:
VIOsPAPR* -> SpaprVio*
The reverse word ordering was only ever used to mitigate the capital
cluster, so revert to the natural ordering.
VIOsPAPRVTYDevice -> SpaprVioVty
VIOsPAPRVLANDevice -> SpaprVioVlan
Brevity, since the "Device" didn't add useful information
sPAPRDRConnector -> SpaprDrc
sPAPRDRConnectorClass -> SpaprDrcClass
Brevity, and makes it clearer this is the same thing as a "DRC"
mentioned in many other places in the code
This is 100% a mechanical search-and-replace patch. It will, however,
conflict with essentially any and all outstanding patches touching the
spapr code.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-06 05:35:37 +01:00
|
|
|
SpaprVioDevice *dev = spapr_vio_find_by_reg(spapr->vio_bus, reg);
|
2011-04-01 06:15:30 +02:00
|
|
|
uint64_t crq_mangle[2];
|
|
|
|
|
|
|
|
if (!dev) {
|
2012-03-28 23:39:45 +02:00
|
|
|
hcall_dprintf("Unit 0x" TARGET_FMT_lx " does not exist\n", reg);
|
2011-04-01 06:15:30 +02:00
|
|
|
return H_PARAMETER;
|
|
|
|
}
|
|
|
|
crq_mangle[0] = cpu_to_be64(msg_hi);
|
|
|
|
crq_mangle[1] = cpu_to_be64(msg_lo);
|
|
|
|
|
|
|
|
if (dev->crq.SendFunc) {
|
|
|
|
return dev->crq.SendFunc(dev, (uint8_t *)crq_mangle);
|
|
|
|
}
|
|
|
|
|
|
|
|
return H_HARDWARE;
|
|
|
|
}
|
|
|
|
|
spapr: Use CamelCase properly
The qemu coding standard is to use CamelCase for type and structure names,
and the pseries code follows that... sort of. There are quite a lot of
places where we bend the rules in order to preserve the capitalization of
internal acronyms like "PHB", "TCE", "DIMM" and most commonly "sPAPR".
That was a bad idea - it frequently leads to names ending up with hard to
read clusters of capital letters, and means they don't catch the eye as
type identifiers, which is kind of the point of the CamelCase convention in
the first place.
In short, keeping type identifiers look like CamelCase is more important
than preserving standard capitalization of internal "words". So, this
patch renames a heap of spapr internal type names to a more standard
CamelCase.
In addition to case changes, we also make some other identifier renames:
VIOsPAPR* -> SpaprVio*
The reverse word ordering was only ever used to mitigate the capital
cluster, so revert to the natural ordering.
VIOsPAPRVTYDevice -> SpaprVioVty
VIOsPAPRVLANDevice -> SpaprVioVlan
Brevity, since the "Device" didn't add useful information
sPAPRDRConnector -> SpaprDrc
sPAPRDRConnectorClass -> SpaprDrcClass
Brevity, and makes it clearer this is the same thing as a "DRC"
mentioned in many other places in the code
This is 100% a mechanical search-and-replace patch. It will, however,
conflict with essentially any and all outstanding patches touching the
spapr code.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-06 05:35:37 +01:00
|
|
|
static target_ulong h_enable_crq(PowerPCCPU *cpu, SpaprMachineState *spapr,
|
2011-04-01 06:15:30 +02:00
|
|
|
target_ulong opcode, target_ulong *args)
|
|
|
|
{
|
|
|
|
target_ulong reg = args[0];
|
spapr: Use CamelCase properly
The qemu coding standard is to use CamelCase for type and structure names,
and the pseries code follows that... sort of. There are quite a lot of
places where we bend the rules in order to preserve the capitalization of
internal acronyms like "PHB", "TCE", "DIMM" and most commonly "sPAPR".
That was a bad idea - it frequently leads to names ending up with hard to
read clusters of capital letters, and means they don't catch the eye as
type identifiers, which is kind of the point of the CamelCase convention in
the first place.
In short, keeping type identifiers look like CamelCase is more important
than preserving standard capitalization of internal "words". So, this
patch renames a heap of spapr internal type names to a more standard
CamelCase.
In addition to case changes, we also make some other identifier renames:
VIOsPAPR* -> SpaprVio*
The reverse word ordering was only ever used to mitigate the capital
cluster, so revert to the natural ordering.
VIOsPAPRVTYDevice -> SpaprVioVty
VIOsPAPRVLANDevice -> SpaprVioVlan
Brevity, since the "Device" didn't add useful information
sPAPRDRConnector -> SpaprDrc
sPAPRDRConnectorClass -> SpaprDrcClass
Brevity, and makes it clearer this is the same thing as a "DRC"
mentioned in many other places in the code
This is 100% a mechanical search-and-replace patch. It will, however,
conflict with essentially any and all outstanding patches touching the
spapr code.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-06 05:35:37 +01:00
|
|
|
SpaprVioDevice *dev = spapr_vio_find_by_reg(spapr->vio_bus, reg);
|
2011-04-01 06:15:30 +02:00
|
|
|
|
|
|
|
if (!dev) {
|
2012-03-28 23:39:45 +02:00
|
|
|
hcall_dprintf("Unit 0x" TARGET_FMT_lx " does not exist\n", reg);
|
2011-04-01 06:15:30 +02:00
|
|
|
return H_PARAMETER;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Returns negative error, 0 success, or positive: queue full */
|
spapr: Use CamelCase properly
The qemu coding standard is to use CamelCase for type and structure names,
and the pseries code follows that... sort of. There are quite a lot of
places where we bend the rules in order to preserve the capitalization of
internal acronyms like "PHB", "TCE", "DIMM" and most commonly "sPAPR".
That was a bad idea - it frequently leads to names ending up with hard to
read clusters of capital letters, and means they don't catch the eye as
type identifiers, which is kind of the point of the CamelCase convention in
the first place.
In short, keeping type identifiers look like CamelCase is more important
than preserving standard capitalization of internal "words". So, this
patch renames a heap of spapr internal type names to a more standard
CamelCase.
In addition to case changes, we also make some other identifier renames:
VIOsPAPR* -> SpaprVio*
The reverse word ordering was only ever used to mitigate the capital
cluster, so revert to the natural ordering.
VIOsPAPRVTYDevice -> SpaprVioVty
VIOsPAPRVLANDevice -> SpaprVioVlan
Brevity, since the "Device" didn't add useful information
sPAPRDRConnector -> SpaprDrc
sPAPRDRConnectorClass -> SpaprDrcClass
Brevity, and makes it clearer this is the same thing as a "DRC"
mentioned in many other places in the code
This is 100% a mechanical search-and-replace patch. It will, however,
conflict with essentially any and all outstanding patches touching the
spapr code.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-06 05:35:37 +01:00
|
|
|
int spapr_vio_send_crq(SpaprVioDevice *dev, uint8_t *crq)
|
2011-04-01 06:15:30 +02:00
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
uint8_t byte;
|
|
|
|
|
|
|
|
if (!dev->crq.qsize) {
|
2016-08-02 19:38:00 +02:00
|
|
|
error_report("spapr_vio_send_creq on uninitialized queue");
|
2011-04-01 06:15:30 +02:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Maybe do a fast path for KVM just writing to the pages */
|
2012-06-27 06:50:44 +02:00
|
|
|
rc = spapr_vio_dma_read(dev, dev->crq.qladdr + dev->crq.qnext, &byte, 1);
|
2011-04-01 06:15:30 +02:00
|
|
|
if (rc) {
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
if (byte != 0) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2012-06-27 06:50:44 +02:00
|
|
|
rc = spapr_vio_dma_write(dev, dev->crq.qladdr + dev->crq.qnext + 8,
|
2011-04-01 06:15:30 +02:00
|
|
|
&crq[8], 8);
|
|
|
|
if (rc) {
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
kvmppc_eieio();
|
|
|
|
|
2012-06-27 06:50:44 +02:00
|
|
|
rc = spapr_vio_dma_write(dev, dev->crq.qladdr + dev->crq.qnext, crq, 8);
|
2011-04-01 06:15:30 +02:00
|
|
|
if (rc) {
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
dev->crq.qnext = (dev->crq.qnext + 16) % dev->crq.qsize;
|
|
|
|
|
|
|
|
if (dev->signal_state & 1) {
|
2012-08-07 18:10:32 +02:00
|
|
|
qemu_irq_pulse(spapr_vio_qirq(dev));
|
2011-04-01 06:15:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-04-01 06:15:32 +02:00
|
|
|
/* "quiesce" handling */
|
|
|
|
|
spapr: Use CamelCase properly
The qemu coding standard is to use CamelCase for type and structure names,
and the pseries code follows that... sort of. There are quite a lot of
places where we bend the rules in order to preserve the capitalization of
internal acronyms like "PHB", "TCE", "DIMM" and most commonly "sPAPR".
That was a bad idea - it frequently leads to names ending up with hard to
read clusters of capital letters, and means they don't catch the eye as
type identifiers, which is kind of the point of the CamelCase convention in
the first place.
In short, keeping type identifiers look like CamelCase is more important
than preserving standard capitalization of internal "words". So, this
patch renames a heap of spapr internal type names to a more standard
CamelCase.
In addition to case changes, we also make some other identifier renames:
VIOsPAPR* -> SpaprVio*
The reverse word ordering was only ever used to mitigate the capital
cluster, so revert to the natural ordering.
VIOsPAPRVTYDevice -> SpaprVioVty
VIOsPAPRVLANDevice -> SpaprVioVlan
Brevity, since the "Device" didn't add useful information
sPAPRDRConnector -> SpaprDrc
sPAPRDRConnectorClass -> SpaprDrcClass
Brevity, and makes it clearer this is the same thing as a "DRC"
mentioned in many other places in the code
This is 100% a mechanical search-and-replace patch. It will, however,
conflict with essentially any and all outstanding patches touching the
spapr code.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-06 05:35:37 +01:00
|
|
|
static void spapr_vio_quiesce_one(SpaprVioDevice *dev)
|
2011-04-01 06:15:32 +02:00
|
|
|
{
|
2013-04-10 17:30:48 +02:00
|
|
|
if (dev->tcet) {
|
2013-07-18 21:32:58 +02:00
|
|
|
device_reset(DEVICE(dev->tcet));
|
2011-04-01 06:15:32 +02:00
|
|
|
}
|
2012-09-12 18:57:13 +02:00
|
|
|
free_crq(dev);
|
2011-04-01 06:15:32 +02:00
|
|
|
}
|
|
|
|
|
spapr: Use CamelCase properly
The qemu coding standard is to use CamelCase for type and structure names,
and the pseries code follows that... sort of. There are quite a lot of
places where we bend the rules in order to preserve the capitalization of
internal acronyms like "PHB", "TCE", "DIMM" and most commonly "sPAPR".
That was a bad idea - it frequently leads to names ending up with hard to
read clusters of capital letters, and means they don't catch the eye as
type identifiers, which is kind of the point of the CamelCase convention in
the first place.
In short, keeping type identifiers look like CamelCase is more important
than preserving standard capitalization of internal "words". So, this
patch renames a heap of spapr internal type names to a more standard
CamelCase.
In addition to case changes, we also make some other identifier renames:
VIOsPAPR* -> SpaprVio*
The reverse word ordering was only ever used to mitigate the capital
cluster, so revert to the natural ordering.
VIOsPAPRVTYDevice -> SpaprVioVty
VIOsPAPRVLANDevice -> SpaprVioVlan
Brevity, since the "Device" didn't add useful information
sPAPRDRConnector -> SpaprDrc
sPAPRDRConnectorClass -> SpaprDrcClass
Brevity, and makes it clearer this is the same thing as a "DRC"
mentioned in many other places in the code
This is 100% a mechanical search-and-replace patch. It will, however,
conflict with essentially any and all outstanding patches touching the
spapr code.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-06 05:35:37 +01:00
|
|
|
void spapr_vio_set_bypass(SpaprVioDevice *dev, bool bypass)
|
2015-01-29 06:04:58 +01:00
|
|
|
{
|
|
|
|
if (!dev->tcet) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
memory_region_set_enabled(&dev->mrbypass, bypass);
|
|
|
|
memory_region_set_enabled(spapr_tce_get_iommu(dev->tcet), !bypass);
|
|
|
|
|
|
|
|
dev->tcet->bypass = bypass;
|
|
|
|
}
|
|
|
|
|
spapr: Use CamelCase properly
The qemu coding standard is to use CamelCase for type and structure names,
and the pseries code follows that... sort of. There are quite a lot of
places where we bend the rules in order to preserve the capitalization of
internal acronyms like "PHB", "TCE", "DIMM" and most commonly "sPAPR".
That was a bad idea - it frequently leads to names ending up with hard to
read clusters of capital letters, and means they don't catch the eye as
type identifiers, which is kind of the point of the CamelCase convention in
the first place.
In short, keeping type identifiers look like CamelCase is more important
than preserving standard capitalization of internal "words". So, this
patch renames a heap of spapr internal type names to a more standard
CamelCase.
In addition to case changes, we also make some other identifier renames:
VIOsPAPR* -> SpaprVio*
The reverse word ordering was only ever used to mitigate the capital
cluster, so revert to the natural ordering.
VIOsPAPRVTYDevice -> SpaprVioVty
VIOsPAPRVLANDevice -> SpaprVioVlan
Brevity, since the "Device" didn't add useful information
sPAPRDRConnector -> SpaprDrc
sPAPRDRConnectorClass -> SpaprDrcClass
Brevity, and makes it clearer this is the same thing as a "DRC"
mentioned in many other places in the code
This is 100% a mechanical search-and-replace patch. It will, however,
conflict with essentially any and all outstanding patches touching the
spapr code.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-06 05:35:37 +01:00
|
|
|
static void rtas_set_tce_bypass(PowerPCCPU *cpu, SpaprMachineState *spapr,
|
2013-06-19 22:40:30 +02:00
|
|
|
uint32_t token,
|
2011-04-01 06:15:32 +02:00
|
|
|
uint32_t nargs, target_ulong args,
|
|
|
|
uint32_t nret, target_ulong rets)
|
|
|
|
{
|
spapr: Use CamelCase properly
The qemu coding standard is to use CamelCase for type and structure names,
and the pseries code follows that... sort of. There are quite a lot of
places where we bend the rules in order to preserve the capitalization of
internal acronyms like "PHB", "TCE", "DIMM" and most commonly "sPAPR".
That was a bad idea - it frequently leads to names ending up with hard to
read clusters of capital letters, and means they don't catch the eye as
type identifiers, which is kind of the point of the CamelCase convention in
the first place.
In short, keeping type identifiers look like CamelCase is more important
than preserving standard capitalization of internal "words". So, this
patch renames a heap of spapr internal type names to a more standard
CamelCase.
In addition to case changes, we also make some other identifier renames:
VIOsPAPR* -> SpaprVio*
The reverse word ordering was only ever used to mitigate the capital
cluster, so revert to the natural ordering.
VIOsPAPRVTYDevice -> SpaprVioVty
VIOsPAPRVLANDevice -> SpaprVioVlan
Brevity, since the "Device" didn't add useful information
sPAPRDRConnector -> SpaprDrc
sPAPRDRConnectorClass -> SpaprDrcClass
Brevity, and makes it clearer this is the same thing as a "DRC"
mentioned in many other places in the code
This is 100% a mechanical search-and-replace patch. It will, however,
conflict with essentially any and all outstanding patches touching the
spapr code.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-06 05:35:37 +01:00
|
|
|
SpaprVioBus *bus = spapr->vio_bus;
|
|
|
|
SpaprVioDevice *dev;
|
2011-04-01 06:15:32 +02:00
|
|
|
uint32_t unit, enable;
|
|
|
|
|
|
|
|
if (nargs != 2) {
|
2013-11-19 05:28:54 +01:00
|
|
|
rtas_st(rets, 0, RTAS_OUT_PARAM_ERROR);
|
2011-04-01 06:15:32 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
unit = rtas_ld(args, 0);
|
|
|
|
enable = rtas_ld(args, 1);
|
|
|
|
dev = spapr_vio_find_by_reg(bus, unit);
|
|
|
|
if (!dev) {
|
2013-11-19 05:28:54 +01:00
|
|
|
rtas_st(rets, 0, RTAS_OUT_PARAM_ERROR);
|
2011-04-01 06:15:32 +02:00
|
|
|
return;
|
|
|
|
}
|
2012-06-27 06:50:44 +02:00
|
|
|
|
2013-04-10 17:30:48 +02:00
|
|
|
if (!dev->tcet) {
|
2013-11-19 05:28:54 +01:00
|
|
|
rtas_st(rets, 0, RTAS_OUT_PARAM_ERROR);
|
2012-09-12 18:57:20 +02:00
|
|
|
return;
|
2011-04-01 06:15:32 +02:00
|
|
|
}
|
|
|
|
|
2015-01-29 06:04:58 +01:00
|
|
|
spapr_vio_set_bypass(dev, !!enable);
|
2012-09-12 18:57:20 +02:00
|
|
|
|
2013-11-19 05:28:54 +01:00
|
|
|
rtas_st(rets, 0, RTAS_OUT_SUCCESS);
|
2011-04-01 06:15:32 +02:00
|
|
|
}
|
|
|
|
|
spapr: Use CamelCase properly
The qemu coding standard is to use CamelCase for type and structure names,
and the pseries code follows that... sort of. There are quite a lot of
places where we bend the rules in order to preserve the capitalization of
internal acronyms like "PHB", "TCE", "DIMM" and most commonly "sPAPR".
That was a bad idea - it frequently leads to names ending up with hard to
read clusters of capital letters, and means they don't catch the eye as
type identifiers, which is kind of the point of the CamelCase convention in
the first place.
In short, keeping type identifiers look like CamelCase is more important
than preserving standard capitalization of internal "words". So, this
patch renames a heap of spapr internal type names to a more standard
CamelCase.
In addition to case changes, we also make some other identifier renames:
VIOsPAPR* -> SpaprVio*
The reverse word ordering was only ever used to mitigate the capital
cluster, so revert to the natural ordering.
VIOsPAPRVTYDevice -> SpaprVioVty
VIOsPAPRVLANDevice -> SpaprVioVlan
Brevity, since the "Device" didn't add useful information
sPAPRDRConnector -> SpaprDrc
sPAPRDRConnectorClass -> SpaprDrcClass
Brevity, and makes it clearer this is the same thing as a "DRC"
mentioned in many other places in the code
This is 100% a mechanical search-and-replace patch. It will, however,
conflict with essentially any and all outstanding patches touching the
spapr code.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-06 05:35:37 +01:00
|
|
|
static void rtas_quiesce(PowerPCCPU *cpu, SpaprMachineState *spapr,
|
2013-06-19 22:40:30 +02:00
|
|
|
uint32_t token,
|
2011-04-01 06:15:32 +02:00
|
|
|
uint32_t nargs, target_ulong args,
|
|
|
|
uint32_t nret, target_ulong rets)
|
|
|
|
{
|
spapr: Use CamelCase properly
The qemu coding standard is to use CamelCase for type and structure names,
and the pseries code follows that... sort of. There are quite a lot of
places where we bend the rules in order to preserve the capitalization of
internal acronyms like "PHB", "TCE", "DIMM" and most commonly "sPAPR".
That was a bad idea - it frequently leads to names ending up with hard to
read clusters of capital letters, and means they don't catch the eye as
type identifiers, which is kind of the point of the CamelCase convention in
the first place.
In short, keeping type identifiers look like CamelCase is more important
than preserving standard capitalization of internal "words". So, this
patch renames a heap of spapr internal type names to a more standard
CamelCase.
In addition to case changes, we also make some other identifier renames:
VIOsPAPR* -> SpaprVio*
The reverse word ordering was only ever used to mitigate the capital
cluster, so revert to the natural ordering.
VIOsPAPRVTYDevice -> SpaprVioVty
VIOsPAPRVLANDevice -> SpaprVioVlan
Brevity, since the "Device" didn't add useful information
sPAPRDRConnector -> SpaprDrc
sPAPRDRConnectorClass -> SpaprDrcClass
Brevity, and makes it clearer this is the same thing as a "DRC"
mentioned in many other places in the code
This is 100% a mechanical search-and-replace patch. It will, however,
conflict with essentially any and all outstanding patches touching the
spapr code.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-06 05:35:37 +01:00
|
|
|
SpaprVioBus *bus = spapr->vio_bus;
|
2011-12-23 22:34:39 +01:00
|
|
|
BusChild *kid;
|
spapr: Use CamelCase properly
The qemu coding standard is to use CamelCase for type and structure names,
and the pseries code follows that... sort of. There are quite a lot of
places where we bend the rules in order to preserve the capitalization of
internal acronyms like "PHB", "TCE", "DIMM" and most commonly "sPAPR".
That was a bad idea - it frequently leads to names ending up with hard to
read clusters of capital letters, and means they don't catch the eye as
type identifiers, which is kind of the point of the CamelCase convention in
the first place.
In short, keeping type identifiers look like CamelCase is more important
than preserving standard capitalization of internal "words". So, this
patch renames a heap of spapr internal type names to a more standard
CamelCase.
In addition to case changes, we also make some other identifier renames:
VIOsPAPR* -> SpaprVio*
The reverse word ordering was only ever used to mitigate the capital
cluster, so revert to the natural ordering.
VIOsPAPRVTYDevice -> SpaprVioVty
VIOsPAPRVLANDevice -> SpaprVioVlan
Brevity, since the "Device" didn't add useful information
sPAPRDRConnector -> SpaprDrc
sPAPRDRConnectorClass -> SpaprDrcClass
Brevity, and makes it clearer this is the same thing as a "DRC"
mentioned in many other places in the code
This is 100% a mechanical search-and-replace patch. It will, however,
conflict with essentially any and all outstanding patches touching the
spapr code.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-06 05:35:37 +01:00
|
|
|
SpaprVioDevice *dev = NULL;
|
2011-04-01 06:15:32 +02:00
|
|
|
|
|
|
|
if (nargs != 0) {
|
2013-11-19 05:28:54 +01:00
|
|
|
rtas_st(rets, 0, RTAS_OUT_PARAM_ERROR);
|
2011-04-01 06:15:32 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-12-23 22:34:39 +01:00
|
|
|
QTAILQ_FOREACH(kid, &bus->bus.children, sibling) {
|
spapr: Use CamelCase properly
The qemu coding standard is to use CamelCase for type and structure names,
and the pseries code follows that... sort of. There are quite a lot of
places where we bend the rules in order to preserve the capitalization of
internal acronyms like "PHB", "TCE", "DIMM" and most commonly "sPAPR".
That was a bad idea - it frequently leads to names ending up with hard to
read clusters of capital letters, and means they don't catch the eye as
type identifiers, which is kind of the point of the CamelCase convention in
the first place.
In short, keeping type identifiers look like CamelCase is more important
than preserving standard capitalization of internal "words". So, this
patch renames a heap of spapr internal type names to a more standard
CamelCase.
In addition to case changes, we also make some other identifier renames:
VIOsPAPR* -> SpaprVio*
The reverse word ordering was only ever used to mitigate the capital
cluster, so revert to the natural ordering.
VIOsPAPRVTYDevice -> SpaprVioVty
VIOsPAPRVLANDevice -> SpaprVioVlan
Brevity, since the "Device" didn't add useful information
sPAPRDRConnector -> SpaprDrc
sPAPRDRConnectorClass -> SpaprDrcClass
Brevity, and makes it clearer this is the same thing as a "DRC"
mentioned in many other places in the code
This is 100% a mechanical search-and-replace patch. It will, however,
conflict with essentially any and all outstanding patches touching the
spapr code.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-06 05:35:37 +01:00
|
|
|
dev = (SpaprVioDevice *)kid->child;
|
2011-04-01 06:15:32 +02:00
|
|
|
spapr_vio_quiesce_one(dev);
|
|
|
|
}
|
|
|
|
|
2013-11-19 05:28:54 +01:00
|
|
|
rtas_st(rets, 0, RTAS_OUT_SUCCESS);
|
2011-04-01 06:15:32 +02:00
|
|
|
}
|
|
|
|
|
spapr: Use CamelCase properly
The qemu coding standard is to use CamelCase for type and structure names,
and the pseries code follows that... sort of. There are quite a lot of
places where we bend the rules in order to preserve the capitalization of
internal acronyms like "PHB", "TCE", "DIMM" and most commonly "sPAPR".
That was a bad idea - it frequently leads to names ending up with hard to
read clusters of capital letters, and means they don't catch the eye as
type identifiers, which is kind of the point of the CamelCase convention in
the first place.
In short, keeping type identifiers look like CamelCase is more important
than preserving standard capitalization of internal "words". So, this
patch renames a heap of spapr internal type names to a more standard
CamelCase.
In addition to case changes, we also make some other identifier renames:
VIOsPAPR* -> SpaprVio*
The reverse word ordering was only ever used to mitigate the capital
cluster, so revert to the natural ordering.
VIOsPAPRVTYDevice -> SpaprVioVty
VIOsPAPRVLANDevice -> SpaprVioVlan
Brevity, since the "Device" didn't add useful information
sPAPRDRConnector -> SpaprDrc
sPAPRDRConnectorClass -> SpaprDrcClass
Brevity, and makes it clearer this is the same thing as a "DRC"
mentioned in many other places in the code
This is 100% a mechanical search-and-replace patch. It will, however,
conflict with essentially any and all outstanding patches touching the
spapr code.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-06 05:35:37 +01:00
|
|
|
static SpaprVioDevice *reg_conflict(SpaprVioDevice *dev)
|
2011-12-12 19:24:35 +01:00
|
|
|
{
|
spapr: Use CamelCase properly
The qemu coding standard is to use CamelCase for type and structure names,
and the pseries code follows that... sort of. There are quite a lot of
places where we bend the rules in order to preserve the capitalization of
internal acronyms like "PHB", "TCE", "DIMM" and most commonly "sPAPR".
That was a bad idea - it frequently leads to names ending up with hard to
read clusters of capital letters, and means they don't catch the eye as
type identifiers, which is kind of the point of the CamelCase convention in
the first place.
In short, keeping type identifiers look like CamelCase is more important
than preserving standard capitalization of internal "words". So, this
patch renames a heap of spapr internal type names to a more standard
CamelCase.
In addition to case changes, we also make some other identifier renames:
VIOsPAPR* -> SpaprVio*
The reverse word ordering was only ever used to mitigate the capital
cluster, so revert to the natural ordering.
VIOsPAPRVTYDevice -> SpaprVioVty
VIOsPAPRVLANDevice -> SpaprVioVlan
Brevity, since the "Device" didn't add useful information
sPAPRDRConnector -> SpaprDrc
sPAPRDRConnectorClass -> SpaprDrcClass
Brevity, and makes it clearer this is the same thing as a "DRC"
mentioned in many other places in the code
This is 100% a mechanical search-and-replace patch. It will, however,
conflict with essentially any and all outstanding patches touching the
spapr code.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-06 05:35:37 +01:00
|
|
|
SpaprVioBus *bus = SPAPR_VIO_BUS(dev->qdev.parent_bus);
|
2011-12-23 22:34:39 +01:00
|
|
|
BusChild *kid;
|
spapr: Use CamelCase properly
The qemu coding standard is to use CamelCase for type and structure names,
and the pseries code follows that... sort of. There are quite a lot of
places where we bend the rules in order to preserve the capitalization of
internal acronyms like "PHB", "TCE", "DIMM" and most commonly "sPAPR".
That was a bad idea - it frequently leads to names ending up with hard to
read clusters of capital letters, and means they don't catch the eye as
type identifiers, which is kind of the point of the CamelCase convention in
the first place.
In short, keeping type identifiers look like CamelCase is more important
than preserving standard capitalization of internal "words". So, this
patch renames a heap of spapr internal type names to a more standard
CamelCase.
In addition to case changes, we also make some other identifier renames:
VIOsPAPR* -> SpaprVio*
The reverse word ordering was only ever used to mitigate the capital
cluster, so revert to the natural ordering.
VIOsPAPRVTYDevice -> SpaprVioVty
VIOsPAPRVLANDevice -> SpaprVioVlan
Brevity, since the "Device" didn't add useful information
sPAPRDRConnector -> SpaprDrc
sPAPRDRConnectorClass -> SpaprDrcClass
Brevity, and makes it clearer this is the same thing as a "DRC"
mentioned in many other places in the code
This is 100% a mechanical search-and-replace patch. It will, however,
conflict with essentially any and all outstanding patches touching the
spapr code.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-06 05:35:37 +01:00
|
|
|
SpaprVioDevice *other;
|
2011-12-12 19:24:35 +01:00
|
|
|
|
|
|
|
/*
|
2012-04-25 19:55:41 +02:00
|
|
|
* Check for a device other than the given one which is already
|
|
|
|
* using the requested address. We have to open code this because
|
|
|
|
* the given dev might already be in the list.
|
2011-12-12 19:24:35 +01:00
|
|
|
*/
|
2011-12-23 22:34:39 +01:00
|
|
|
QTAILQ_FOREACH(kid, &bus->bus.children, sibling) {
|
2013-04-07 21:08:16 +02:00
|
|
|
other = VIO_SPAPR_DEVICE(kid->child);
|
2011-12-12 19:24:35 +01:00
|
|
|
|
2012-04-25 19:55:41 +02:00
|
|
|
if (other != dev && other->reg == dev->reg) {
|
|
|
|
return other;
|
2011-12-12 19:24:35 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-04-12 04:44:13 +02:00
|
|
|
static void spapr_vio_busdev_reset(DeviceState *qdev)
|
2012-03-28 23:39:46 +02:00
|
|
|
{
|
spapr: Use CamelCase properly
The qemu coding standard is to use CamelCase for type and structure names,
and the pseries code follows that... sort of. There are quite a lot of
places where we bend the rules in order to preserve the capitalization of
internal acronyms like "PHB", "TCE", "DIMM" and most commonly "sPAPR".
That was a bad idea - it frequently leads to names ending up with hard to
read clusters of capital letters, and means they don't catch the eye as
type identifiers, which is kind of the point of the CamelCase convention in
the first place.
In short, keeping type identifiers look like CamelCase is more important
than preserving standard capitalization of internal "words". So, this
patch renames a heap of spapr internal type names to a more standard
CamelCase.
In addition to case changes, we also make some other identifier renames:
VIOsPAPR* -> SpaprVio*
The reverse word ordering was only ever used to mitigate the capital
cluster, so revert to the natural ordering.
VIOsPAPRVTYDevice -> SpaprVioVty
VIOsPAPRVLANDevice -> SpaprVioVlan
Brevity, since the "Device" didn't add useful information
sPAPRDRConnector -> SpaprDrc
sPAPRDRConnectorClass -> SpaprDrcClass
Brevity, and makes it clearer this is the same thing as a "DRC"
mentioned in many other places in the code
This is 100% a mechanical search-and-replace patch. It will, however,
conflict with essentially any and all outstanding patches touching the
spapr code.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-06 05:35:37 +01:00
|
|
|
SpaprVioDevice *dev = VIO_SPAPR_DEVICE(qdev);
|
|
|
|
SpaprVioDeviceClass *pc = VIO_SPAPR_DEVICE_GET_CLASS(dev);
|
2012-03-28 23:39:46 +02:00
|
|
|
|
2012-09-12 18:57:13 +02:00
|
|
|
/* Shut down the request queue and TCEs if necessary */
|
|
|
|
spapr_vio_quiesce_one(dev);
|
|
|
|
|
|
|
|
dev->signal_state = 0;
|
2012-04-12 04:44:13 +02:00
|
|
|
|
2015-01-29 06:04:58 +01:00
|
|
|
spapr_vio_set_bypass(dev, false);
|
2012-04-12 04:44:13 +02:00
|
|
|
if (pc->reset) {
|
|
|
|
pc->reset(dev);
|
|
|
|
}
|
2012-03-28 23:39:46 +02:00
|
|
|
}
|
|
|
|
|
2018-07-30 16:11:32 +02:00
|
|
|
/*
|
|
|
|
* The register property of a VIO device is defined in livirt using
|
|
|
|
* 0x1000 as a base register number plus a 0x1000 increment. For the
|
|
|
|
* VIO tty device, the base number is changed to 0x30000000. QEMU uses
|
|
|
|
* a base register number of 0x71000000 and then a simple increment.
|
|
|
|
*
|
|
|
|
* The formula below tries to compute a unique index number from the
|
|
|
|
* register value that will be used to define the IRQ number of the
|
|
|
|
* VIO device.
|
|
|
|
*
|
|
|
|
* A maximum of 256 VIO devices is covered. Collisions are possible
|
|
|
|
* but they will be detected when the IRQ is claimed.
|
|
|
|
*/
|
|
|
|
static inline uint32_t spapr_vio_reg_to_irq(uint32_t reg)
|
|
|
|
{
|
|
|
|
uint32_t irq;
|
|
|
|
|
|
|
|
if (reg >= SPAPR_VIO_REG_BASE) {
|
|
|
|
/*
|
|
|
|
* VIO device register values when allocated by QEMU. For
|
|
|
|
* these, we simply mask the high bits to fit the overall
|
|
|
|
* range: [0x00 - 0xff].
|
|
|
|
*
|
|
|
|
* The nvram VIO device (reg=0x71000000) is a static device of
|
|
|
|
* the pseries machine and so is always allocated by QEMU. Its
|
|
|
|
* IRQ number is 0x0.
|
|
|
|
*/
|
|
|
|
irq = reg & 0xff;
|
|
|
|
|
|
|
|
} else if (reg >= 0x30000000) {
|
|
|
|
/*
|
|
|
|
* VIO tty devices register values, when allocated by livirt,
|
|
|
|
* are mapped in range [0xf0 - 0xff], gives us a maximum of 16
|
|
|
|
* vtys.
|
|
|
|
*/
|
|
|
|
irq = 0xf0 | ((reg >> 12) & 0xf);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* Other VIO devices register values, when allocated by
|
|
|
|
* livirt, should be mapped in range [0x00 - 0xef]. Conflicts
|
|
|
|
* will be detected when IRQ is claimed.
|
|
|
|
*/
|
|
|
|
irq = (reg >> 12) & 0xff;
|
|
|
|
}
|
|
|
|
|
|
|
|
return SPAPR_IRQ_VIO | irq;
|
|
|
|
}
|
|
|
|
|
2015-02-27 11:52:17 +01:00
|
|
|
static void spapr_vio_busdev_realize(DeviceState *qdev, Error **errp)
|
2011-04-01 06:15:21 +02:00
|
|
|
{
|
spapr: Use CamelCase properly
The qemu coding standard is to use CamelCase for type and structure names,
and the pseries code follows that... sort of. There are quite a lot of
places where we bend the rules in order to preserve the capitalization of
internal acronyms like "PHB", "TCE", "DIMM" and most commonly "sPAPR".
That was a bad idea - it frequently leads to names ending up with hard to
read clusters of capital letters, and means they don't catch the eye as
type identifiers, which is kind of the point of the CamelCase convention in
the first place.
In short, keeping type identifiers look like CamelCase is more important
than preserving standard capitalization of internal "words". So, this
patch renames a heap of spapr internal type names to a more standard
CamelCase.
In addition to case changes, we also make some other identifier renames:
VIOsPAPR* -> SpaprVio*
The reverse word ordering was only ever used to mitigate the capital
cluster, so revert to the natural ordering.
VIOsPAPRVTYDevice -> SpaprVioVty
VIOsPAPRVLANDevice -> SpaprVioVlan
Brevity, since the "Device" didn't add useful information
sPAPRDRConnector -> SpaprDrc
sPAPRDRConnectorClass -> SpaprDrcClass
Brevity, and makes it clearer this is the same thing as a "DRC"
mentioned in many other places in the code
This is 100% a mechanical search-and-replace patch. It will, however,
conflict with essentially any and all outstanding patches touching the
spapr code.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-06 05:35:37 +01:00
|
|
|
SpaprMachineState *spapr = SPAPR_MACHINE(qdev_get_machine());
|
|
|
|
SpaprVioDevice *dev = (SpaprVioDevice *)qdev;
|
|
|
|
SpaprVioDeviceClass *pc = VIO_SPAPR_DEVICE_GET_CLASS(dev);
|
2011-04-01 06:15:21 +02:00
|
|
|
char *id;
|
2016-02-26 10:44:07 +01:00
|
|
|
Error *local_err = NULL;
|
2011-12-12 19:24:35 +01:00
|
|
|
|
2012-04-25 19:55:41 +02:00
|
|
|
if (dev->reg != -1) {
|
|
|
|
/*
|
|
|
|
* Explicitly assigned address, just verify that no-one else
|
|
|
|
* is using it. other mechanism). We have to open code this
|
|
|
|
* rather than using spapr_vio_find_by_reg() because sdev
|
|
|
|
* itself is already in the list.
|
|
|
|
*/
|
spapr: Use CamelCase properly
The qemu coding standard is to use CamelCase for type and structure names,
and the pseries code follows that... sort of. There are quite a lot of
places where we bend the rules in order to preserve the capitalization of
internal acronyms like "PHB", "TCE", "DIMM" and most commonly "sPAPR".
That was a bad idea - it frequently leads to names ending up with hard to
read clusters of capital letters, and means they don't catch the eye as
type identifiers, which is kind of the point of the CamelCase convention in
the first place.
In short, keeping type identifiers look like CamelCase is more important
than preserving standard capitalization of internal "words". So, this
patch renames a heap of spapr internal type names to a more standard
CamelCase.
In addition to case changes, we also make some other identifier renames:
VIOsPAPR* -> SpaprVio*
The reverse word ordering was only ever used to mitigate the capital
cluster, so revert to the natural ordering.
VIOsPAPRVTYDevice -> SpaprVioVty
VIOsPAPRVLANDevice -> SpaprVioVlan
Brevity, since the "Device" didn't add useful information
sPAPRDRConnector -> SpaprDrc
sPAPRDRConnectorClass -> SpaprDrcClass
Brevity, and makes it clearer this is the same thing as a "DRC"
mentioned in many other places in the code
This is 100% a mechanical search-and-replace patch. It will, however,
conflict with essentially any and all outstanding patches touching the
spapr code.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-06 05:35:37 +01:00
|
|
|
SpaprVioDevice *other = reg_conflict(dev);
|
2012-04-25 19:55:41 +02:00
|
|
|
|
|
|
|
if (other) {
|
2015-02-27 11:52:17 +01:00
|
|
|
error_setg(errp, "%s and %s devices conflict at address %#x",
|
|
|
|
object_get_typename(OBJECT(qdev)),
|
|
|
|
object_get_typename(OBJECT(&other->qdev)),
|
|
|
|
dev->reg);
|
|
|
|
return;
|
2012-04-25 19:55:41 +02:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* Need to assign an address */
|
spapr: Use CamelCase properly
The qemu coding standard is to use CamelCase for type and structure names,
and the pseries code follows that... sort of. There are quite a lot of
places where we bend the rules in order to preserve the capitalization of
internal acronyms like "PHB", "TCE", "DIMM" and most commonly "sPAPR".
That was a bad idea - it frequently leads to names ending up with hard to
read clusters of capital letters, and means they don't catch the eye as
type identifiers, which is kind of the point of the CamelCase convention in
the first place.
In short, keeping type identifiers look like CamelCase is more important
than preserving standard capitalization of internal "words". So, this
patch renames a heap of spapr internal type names to a more standard
CamelCase.
In addition to case changes, we also make some other identifier renames:
VIOsPAPR* -> SpaprVio*
The reverse word ordering was only ever used to mitigate the capital
cluster, so revert to the natural ordering.
VIOsPAPRVTYDevice -> SpaprVioVty
VIOsPAPRVLANDevice -> SpaprVioVlan
Brevity, since the "Device" didn't add useful information
sPAPRDRConnector -> SpaprDrc
sPAPRDRConnectorClass -> SpaprDrcClass
Brevity, and makes it clearer this is the same thing as a "DRC"
mentioned in many other places in the code
This is 100% a mechanical search-and-replace patch. It will, however,
conflict with essentially any and all outstanding patches touching the
spapr code.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-06 05:35:37 +01:00
|
|
|
SpaprVioBus *bus = SPAPR_VIO_BUS(dev->qdev.parent_bus);
|
2012-04-25 19:55:41 +02:00
|
|
|
|
|
|
|
do {
|
|
|
|
dev->reg = bus->next_reg++;
|
|
|
|
} while (reg_conflict(dev));
|
2011-12-12 19:24:35 +01:00
|
|
|
}
|
2011-04-01 06:15:21 +02:00
|
|
|
|
2011-11-15 19:53:13 +01:00
|
|
|
/* Don't overwrite ids assigned on the command line */
|
|
|
|
if (!dev->qdev.id) {
|
2013-04-07 21:08:17 +02:00
|
|
|
id = spapr_vio_get_dev_name(DEVICE(dev));
|
2011-11-15 19:53:13 +01:00
|
|
|
dev->qdev.id = id;
|
2011-04-01 06:15:21 +02:00
|
|
|
}
|
|
|
|
|
2019-01-09 15:31:19 +01:00
|
|
|
dev->irq = spapr_vio_reg_to_irq(dev->reg);
|
2018-07-30 16:11:32 +02:00
|
|
|
|
2019-01-09 15:31:19 +01:00
|
|
|
if (SPAPR_MACHINE_GET_CLASS(spapr)->legacy_irq_allocation) {
|
|
|
|
dev->irq = spapr_irq_findone(spapr, &local_err);
|
|
|
|
if (local_err) {
|
|
|
|
error_propagate(errp, local_err);
|
|
|
|
return;
|
2018-06-18 19:34:00 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
spapr_irq_claim(spapr, dev->irq, false, &local_err);
|
2016-02-26 10:44:07 +01:00
|
|
|
if (local_err) {
|
|
|
|
error_propagate(errp, local_err);
|
2015-02-27 11:52:17 +01:00
|
|
|
return;
|
2011-05-26 11:52:46 +02:00
|
|
|
}
|
2011-04-01 06:15:21 +02:00
|
|
|
|
2012-09-12 18:57:20 +02:00
|
|
|
if (pc->rtce_window_size) {
|
2015-05-07 07:33:31 +02:00
|
|
|
uint32_t liobn = SPAPR_VIO_LIOBN(dev->reg);
|
2015-01-29 06:04:58 +01:00
|
|
|
|
|
|
|
memory_region_init(&dev->mrroot, OBJECT(dev), "iommu-spapr-root",
|
|
|
|
ram_size);
|
|
|
|
memory_region_init_alias(&dev->mrbypass, OBJECT(dev),
|
|
|
|
"iommu-spapr-bypass", get_system_memory(),
|
|
|
|
0, ram_size);
|
|
|
|
memory_region_add_subregion_overlap(&dev->mrroot, 0, &dev->mrbypass, 1);
|
|
|
|
address_space_init(&dev->as, &dev->mrroot, qdev->id);
|
|
|
|
|
2016-06-01 10:57:33 +02:00
|
|
|
dev->tcet = spapr_tce_new_table(qdev, liobn);
|
|
|
|
spapr_tce_table_enable(dev->tcet, SPAPR_TCE_PAGE_SHIFT, 0,
|
|
|
|
pc->rtce_window_size >> SPAPR_TCE_PAGE_SHIFT);
|
2015-01-29 06:04:58 +01:00
|
|
|
dev->tcet->vdev = dev;
|
|
|
|
memory_region_add_subregion_overlap(&dev->mrroot, 0,
|
|
|
|
spapr_tce_get_iommu(dev->tcet), 2);
|
2012-09-12 18:57:20 +02:00
|
|
|
}
|
2011-04-01 06:15:28 +02:00
|
|
|
|
2015-02-27 11:52:17 +01:00
|
|
|
pc->realize(dev, errp);
|
2011-04-01 06:15:21 +02:00
|
|
|
}
|
|
|
|
|
spapr: Use CamelCase properly
The qemu coding standard is to use CamelCase for type and structure names,
and the pseries code follows that... sort of. There are quite a lot of
places where we bend the rules in order to preserve the capitalization of
internal acronyms like "PHB", "TCE", "DIMM" and most commonly "sPAPR".
That was a bad idea - it frequently leads to names ending up with hard to
read clusters of capital letters, and means they don't catch the eye as
type identifiers, which is kind of the point of the CamelCase convention in
the first place.
In short, keeping type identifiers look like CamelCase is more important
than preserving standard capitalization of internal "words". So, this
patch renames a heap of spapr internal type names to a more standard
CamelCase.
In addition to case changes, we also make some other identifier renames:
VIOsPAPR* -> SpaprVio*
The reverse word ordering was only ever used to mitigate the capital
cluster, so revert to the natural ordering.
VIOsPAPRVTYDevice -> SpaprVioVty
VIOsPAPRVLANDevice -> SpaprVioVlan
Brevity, since the "Device" didn't add useful information
sPAPRDRConnector -> SpaprDrc
sPAPRDRConnectorClass -> SpaprDrcClass
Brevity, and makes it clearer this is the same thing as a "DRC"
mentioned in many other places in the code
This is 100% a mechanical search-and-replace patch. It will, however,
conflict with essentially any and all outstanding patches touching the
spapr code.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-06 05:35:37 +01:00
|
|
|
static target_ulong h_vio_signal(PowerPCCPU *cpu, SpaprMachineState *spapr,
|
2011-04-01 06:15:26 +02:00
|
|
|
target_ulong opcode,
|
|
|
|
target_ulong *args)
|
|
|
|
{
|
|
|
|
target_ulong reg = args[0];
|
|
|
|
target_ulong mode = args[1];
|
spapr: Use CamelCase properly
The qemu coding standard is to use CamelCase for type and structure names,
and the pseries code follows that... sort of. There are quite a lot of
places where we bend the rules in order to preserve the capitalization of
internal acronyms like "PHB", "TCE", "DIMM" and most commonly "sPAPR".
That was a bad idea - it frequently leads to names ending up with hard to
read clusters of capital letters, and means they don't catch the eye as
type identifiers, which is kind of the point of the CamelCase convention in
the first place.
In short, keeping type identifiers look like CamelCase is more important
than preserving standard capitalization of internal "words". So, this
patch renames a heap of spapr internal type names to a more standard
CamelCase.
In addition to case changes, we also make some other identifier renames:
VIOsPAPR* -> SpaprVio*
The reverse word ordering was only ever used to mitigate the capital
cluster, so revert to the natural ordering.
VIOsPAPRVTYDevice -> SpaprVioVty
VIOsPAPRVLANDevice -> SpaprVioVlan
Brevity, since the "Device" didn't add useful information
sPAPRDRConnector -> SpaprDrc
sPAPRDRConnectorClass -> SpaprDrcClass
Brevity, and makes it clearer this is the same thing as a "DRC"
mentioned in many other places in the code
This is 100% a mechanical search-and-replace patch. It will, however,
conflict with essentially any and all outstanding patches touching the
spapr code.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-06 05:35:37 +01:00
|
|
|
SpaprVioDevice *dev = spapr_vio_find_by_reg(spapr->vio_bus, reg);
|
|
|
|
SpaprVioDeviceClass *pc;
|
2011-04-01 06:15:26 +02:00
|
|
|
|
|
|
|
if (!dev) {
|
|
|
|
return H_PARAMETER;
|
|
|
|
}
|
|
|
|
|
2011-12-15 23:31:06 +01:00
|
|
|
pc = VIO_SPAPR_DEVICE_GET_CLASS(dev);
|
2011-04-01 06:15:26 +02:00
|
|
|
|
2011-12-15 23:31:06 +01:00
|
|
|
if (mode & ~pc->signal_mask) {
|
2011-04-01 06:15:26 +02:00
|
|
|
return H_PARAMETER;
|
|
|
|
}
|
|
|
|
|
|
|
|
dev->signal_state = mode;
|
|
|
|
|
|
|
|
return H_SUCCESS;
|
|
|
|
}
|
|
|
|
|
spapr: Use CamelCase properly
The qemu coding standard is to use CamelCase for type and structure names,
and the pseries code follows that... sort of. There are quite a lot of
places where we bend the rules in order to preserve the capitalization of
internal acronyms like "PHB", "TCE", "DIMM" and most commonly "sPAPR".
That was a bad idea - it frequently leads to names ending up with hard to
read clusters of capital letters, and means they don't catch the eye as
type identifiers, which is kind of the point of the CamelCase convention in
the first place.
In short, keeping type identifiers look like CamelCase is more important
than preserving standard capitalization of internal "words". So, this
patch renames a heap of spapr internal type names to a more standard
CamelCase.
In addition to case changes, we also make some other identifier renames:
VIOsPAPR* -> SpaprVio*
The reverse word ordering was only ever used to mitigate the capital
cluster, so revert to the natural ordering.
VIOsPAPRVTYDevice -> SpaprVioVty
VIOsPAPRVLANDevice -> SpaprVioVlan
Brevity, since the "Device" didn't add useful information
sPAPRDRConnector -> SpaprDrc
sPAPRDRConnectorClass -> SpaprDrcClass
Brevity, and makes it clearer this is the same thing as a "DRC"
mentioned in many other places in the code
This is 100% a mechanical search-and-replace patch. It will, however,
conflict with essentially any and all outstanding patches touching the
spapr code.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-06 05:35:37 +01:00
|
|
|
SpaprVioBus *spapr_vio_bus_init(void)
|
2011-04-01 06:15:21 +02:00
|
|
|
{
|
spapr: Use CamelCase properly
The qemu coding standard is to use CamelCase for type and structure names,
and the pseries code follows that... sort of. There are quite a lot of
places where we bend the rules in order to preserve the capitalization of
internal acronyms like "PHB", "TCE", "DIMM" and most commonly "sPAPR".
That was a bad idea - it frequently leads to names ending up with hard to
read clusters of capital letters, and means they don't catch the eye as
type identifiers, which is kind of the point of the CamelCase convention in
the first place.
In short, keeping type identifiers look like CamelCase is more important
than preserving standard capitalization of internal "words". So, this
patch renames a heap of spapr internal type names to a more standard
CamelCase.
In addition to case changes, we also make some other identifier renames:
VIOsPAPR* -> SpaprVio*
The reverse word ordering was only ever used to mitigate the capital
cluster, so revert to the natural ordering.
VIOsPAPRVTYDevice -> SpaprVioVty
VIOsPAPRVLANDevice -> SpaprVioVlan
Brevity, since the "Device" didn't add useful information
sPAPRDRConnector -> SpaprDrc
sPAPRDRConnectorClass -> SpaprDrcClass
Brevity, and makes it clearer this is the same thing as a "DRC"
mentioned in many other places in the code
This is 100% a mechanical search-and-replace patch. It will, however,
conflict with essentially any and all outstanding patches touching the
spapr code.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-06 05:35:37 +01:00
|
|
|
SpaprVioBus *bus;
|
2011-04-01 06:15:21 +02:00
|
|
|
BusState *qbus;
|
|
|
|
DeviceState *dev;
|
|
|
|
|
|
|
|
/* Create bridge device */
|
2015-12-23 12:30:12 +01:00
|
|
|
dev = qdev_create(NULL, TYPE_SPAPR_VIO_BRIDGE);
|
2011-04-01 06:15:21 +02:00
|
|
|
qdev_init_nofail(dev);
|
|
|
|
|
|
|
|
/* Create bus on bridge device */
|
2012-05-02 09:00:20 +02:00
|
|
|
qbus = qbus_create(TYPE_SPAPR_VIO_BUS, dev, "spapr-vio");
|
2015-12-23 12:30:12 +01:00
|
|
|
bus = SPAPR_VIO_BUS(qbus);
|
2018-07-30 16:11:32 +02:00
|
|
|
bus->next_reg = SPAPR_VIO_REG_BASE;
|
2011-04-01 06:15:21 +02:00
|
|
|
|
2011-04-01 06:15:26 +02:00
|
|
|
/* hcall-vio */
|
|
|
|
spapr_register_hypercall(H_VIO_SIGNAL, h_vio_signal);
|
|
|
|
|
2011-04-01 06:15:30 +02:00
|
|
|
/* hcall-crq */
|
|
|
|
spapr_register_hypercall(H_REG_CRQ, h_reg_crq);
|
|
|
|
spapr_register_hypercall(H_FREE_CRQ, h_free_crq);
|
|
|
|
spapr_register_hypercall(H_SEND_CRQ, h_send_crq);
|
|
|
|
spapr_register_hypercall(H_ENABLE_CRQ, h_enable_crq);
|
|
|
|
|
2011-04-01 06:15:32 +02:00
|
|
|
/* RTAS calls */
|
2014-06-23 15:26:32 +02:00
|
|
|
spapr_rtas_register(RTAS_IBM_SET_TCE_BYPASS, "ibm,set-tce-bypass",
|
|
|
|
rtas_set_tce_bypass);
|
|
|
|
spapr_rtas_register(RTAS_QUIESCE, "quiesce", rtas_quiesce);
|
2011-04-01 06:15:32 +02:00
|
|
|
|
2011-04-01 06:15:21 +02:00
|
|
|
return bus;
|
|
|
|
}
|
|
|
|
|
2012-01-24 20:12:29 +01:00
|
|
|
static void spapr_vio_bridge_class_init(ObjectClass *klass, void *data)
|
|
|
|
{
|
2014-03-17 03:40:25 +01:00
|
|
|
DeviceClass *dc = DEVICE_CLASS(klass);
|
2012-01-24 20:12:29 +01:00
|
|
|
|
2014-03-17 03:40:25 +01:00
|
|
|
dc->fw_name = "vdevice";
|
2012-01-24 20:12:29 +01:00
|
|
|
}
|
|
|
|
|
2013-01-10 16:19:07 +01:00
|
|
|
static const TypeInfo spapr_vio_bridge_info = {
|
2015-12-23 12:30:12 +01:00
|
|
|
.name = TYPE_SPAPR_VIO_BRIDGE,
|
2011-12-08 04:34:16 +01:00
|
|
|
.parent = TYPE_SYS_BUS_DEVICE,
|
|
|
|
.class_init = spapr_vio_bridge_class_init,
|
2011-04-01 06:15:21 +02:00
|
|
|
};
|
|
|
|
|
2013-07-18 21:32:55 +02:00
|
|
|
const VMStateDescription vmstate_spapr_vio = {
|
|
|
|
.name = "spapr_vio",
|
|
|
|
.version_id = 1,
|
|
|
|
.minimum_version_id = 1,
|
2014-04-16 15:24:04 +02:00
|
|
|
.fields = (VMStateField[]) {
|
2013-07-18 21:32:55 +02:00
|
|
|
/* Sanity check */
|
spapr: Use CamelCase properly
The qemu coding standard is to use CamelCase for type and structure names,
and the pseries code follows that... sort of. There are quite a lot of
places where we bend the rules in order to preserve the capitalization of
internal acronyms like "PHB", "TCE", "DIMM" and most commonly "sPAPR".
That was a bad idea - it frequently leads to names ending up with hard to
read clusters of capital letters, and means they don't catch the eye as
type identifiers, which is kind of the point of the CamelCase convention in
the first place.
In short, keeping type identifiers look like CamelCase is more important
than preserving standard capitalization of internal "words". So, this
patch renames a heap of spapr internal type names to a more standard
CamelCase.
In addition to case changes, we also make some other identifier renames:
VIOsPAPR* -> SpaprVio*
The reverse word ordering was only ever used to mitigate the capital
cluster, so revert to the natural ordering.
VIOsPAPRVTYDevice -> SpaprVioVty
VIOsPAPRVLANDevice -> SpaprVioVlan
Brevity, since the "Device" didn't add useful information
sPAPRDRConnector -> SpaprDrc
sPAPRDRConnectorClass -> SpaprDrcClass
Brevity, and makes it clearer this is the same thing as a "DRC"
mentioned in many other places in the code
This is 100% a mechanical search-and-replace patch. It will, however,
conflict with essentially any and all outstanding patches touching the
spapr code.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-06 05:35:37 +01:00
|
|
|
VMSTATE_UINT32_EQUAL(reg, SpaprVioDevice, NULL),
|
|
|
|
VMSTATE_UINT32_EQUAL(irq, SpaprVioDevice, NULL),
|
2013-07-18 21:32:55 +02:00
|
|
|
|
|
|
|
/* General VIO device state */
|
spapr: Use CamelCase properly
The qemu coding standard is to use CamelCase for type and structure names,
and the pseries code follows that... sort of. There are quite a lot of
places where we bend the rules in order to preserve the capitalization of
internal acronyms like "PHB", "TCE", "DIMM" and most commonly "sPAPR".
That was a bad idea - it frequently leads to names ending up with hard to
read clusters of capital letters, and means they don't catch the eye as
type identifiers, which is kind of the point of the CamelCase convention in
the first place.
In short, keeping type identifiers look like CamelCase is more important
than preserving standard capitalization of internal "words". So, this
patch renames a heap of spapr internal type names to a more standard
CamelCase.
In addition to case changes, we also make some other identifier renames:
VIOsPAPR* -> SpaprVio*
The reverse word ordering was only ever used to mitigate the capital
cluster, so revert to the natural ordering.
VIOsPAPRVTYDevice -> SpaprVioVty
VIOsPAPRVLANDevice -> SpaprVioVlan
Brevity, since the "Device" didn't add useful information
sPAPRDRConnector -> SpaprDrc
sPAPRDRConnectorClass -> SpaprDrcClass
Brevity, and makes it clearer this is the same thing as a "DRC"
mentioned in many other places in the code
This is 100% a mechanical search-and-replace patch. It will, however,
conflict with essentially any and all outstanding patches touching the
spapr code.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-06 05:35:37 +01:00
|
|
|
VMSTATE_UINT64(signal_state, SpaprVioDevice),
|
|
|
|
VMSTATE_UINT64(crq.qladdr, SpaprVioDevice),
|
|
|
|
VMSTATE_UINT32(crq.qsize, SpaprVioDevice),
|
|
|
|
VMSTATE_UINT32(crq.qnext, SpaprVioDevice),
|
2013-07-18 21:32:55 +02:00
|
|
|
|
|
|
|
VMSTATE_END_OF_LIST()
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2011-12-08 04:34:16 +01:00
|
|
|
static void vio_spapr_device_class_init(ObjectClass *klass, void *data)
|
|
|
|
{
|
|
|
|
DeviceClass *k = DEVICE_CLASS(klass);
|
2015-02-27 11:52:17 +01:00
|
|
|
k->realize = spapr_vio_busdev_realize;
|
2012-04-12 04:44:13 +02:00
|
|
|
k->reset = spapr_vio_busdev_reset;
|
2012-05-02 09:00:20 +02:00
|
|
|
k->bus_type = TYPE_SPAPR_VIO_BUS;
|
2011-12-08 04:34:16 +01:00
|
|
|
}
|
|
|
|
|
2013-01-10 16:19:07 +01:00
|
|
|
static const TypeInfo spapr_vio_type_info = {
|
2011-12-15 23:31:06 +01:00
|
|
|
.name = TYPE_VIO_SPAPR_DEVICE,
|
|
|
|
.parent = TYPE_DEVICE,
|
spapr: Use CamelCase properly
The qemu coding standard is to use CamelCase for type and structure names,
and the pseries code follows that... sort of. There are quite a lot of
places where we bend the rules in order to preserve the capitalization of
internal acronyms like "PHB", "TCE", "DIMM" and most commonly "sPAPR".
That was a bad idea - it frequently leads to names ending up with hard to
read clusters of capital letters, and means they don't catch the eye as
type identifiers, which is kind of the point of the CamelCase convention in
the first place.
In short, keeping type identifiers look like CamelCase is more important
than preserving standard capitalization of internal "words". So, this
patch renames a heap of spapr internal type names to a more standard
CamelCase.
In addition to case changes, we also make some other identifier renames:
VIOsPAPR* -> SpaprVio*
The reverse word ordering was only ever used to mitigate the capital
cluster, so revert to the natural ordering.
VIOsPAPRVTYDevice -> SpaprVioVty
VIOsPAPRVLANDevice -> SpaprVioVlan
Brevity, since the "Device" didn't add useful information
sPAPRDRConnector -> SpaprDrc
sPAPRDRConnectorClass -> SpaprDrcClass
Brevity, and makes it clearer this is the same thing as a "DRC"
mentioned in many other places in the code
This is 100% a mechanical search-and-replace patch. It will, however,
conflict with essentially any and all outstanding patches touching the
spapr code.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-06 05:35:37 +01:00
|
|
|
.instance_size = sizeof(SpaprVioDevice),
|
2011-12-15 23:31:06 +01:00
|
|
|
.abstract = true,
|
spapr: Use CamelCase properly
The qemu coding standard is to use CamelCase for type and structure names,
and the pseries code follows that... sort of. There are quite a lot of
places where we bend the rules in order to preserve the capitalization of
internal acronyms like "PHB", "TCE", "DIMM" and most commonly "sPAPR".
That was a bad idea - it frequently leads to names ending up with hard to
read clusters of capital letters, and means they don't catch the eye as
type identifiers, which is kind of the point of the CamelCase convention in
the first place.
In short, keeping type identifiers look like CamelCase is more important
than preserving standard capitalization of internal "words". So, this
patch renames a heap of spapr internal type names to a more standard
CamelCase.
In addition to case changes, we also make some other identifier renames:
VIOsPAPR* -> SpaprVio*
The reverse word ordering was only ever used to mitigate the capital
cluster, so revert to the natural ordering.
VIOsPAPRVTYDevice -> SpaprVioVty
VIOsPAPRVLANDevice -> SpaprVioVlan
Brevity, since the "Device" didn't add useful information
sPAPRDRConnector -> SpaprDrc
sPAPRDRConnectorClass -> SpaprDrcClass
Brevity, and makes it clearer this is the same thing as a "DRC"
mentioned in many other places in the code
This is 100% a mechanical search-and-replace patch. It will, however,
conflict with essentially any and all outstanding patches touching the
spapr code.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-06 05:35:37 +01:00
|
|
|
.class_size = sizeof(SpaprVioDeviceClass),
|
2011-12-08 04:34:16 +01:00
|
|
|
.class_init = vio_spapr_device_class_init,
|
2011-12-15 23:31:06 +01:00
|
|
|
};
|
|
|
|
|
2012-02-09 15:20:55 +01:00
|
|
|
static void spapr_vio_register_types(void)
|
2011-04-01 06:15:21 +02:00
|
|
|
{
|
2012-05-02 09:00:20 +02:00
|
|
|
type_register_static(&spapr_vio_bus_info);
|
2011-12-08 04:34:16 +01:00
|
|
|
type_register_static(&spapr_vio_bridge_info);
|
2011-12-15 23:31:06 +01:00
|
|
|
type_register_static(&spapr_vio_type_info);
|
2011-04-01 06:15:21 +02:00
|
|
|
}
|
|
|
|
|
2012-02-09 15:20:55 +01:00
|
|
|
type_init(spapr_vio_register_types)
|
2011-04-01 06:15:21 +02:00
|
|
|
|
2011-12-12 19:24:32 +01:00
|
|
|
static int compare_reg(const void *p1, const void *p2)
|
|
|
|
{
|
spapr: Use CamelCase properly
The qemu coding standard is to use CamelCase for type and structure names,
and the pseries code follows that... sort of. There are quite a lot of
places where we bend the rules in order to preserve the capitalization of
internal acronyms like "PHB", "TCE", "DIMM" and most commonly "sPAPR".
That was a bad idea - it frequently leads to names ending up with hard to
read clusters of capital letters, and means they don't catch the eye as
type identifiers, which is kind of the point of the CamelCase convention in
the first place.
In short, keeping type identifiers look like CamelCase is more important
than preserving standard capitalization of internal "words". So, this
patch renames a heap of spapr internal type names to a more standard
CamelCase.
In addition to case changes, we also make some other identifier renames:
VIOsPAPR* -> SpaprVio*
The reverse word ordering was only ever used to mitigate the capital
cluster, so revert to the natural ordering.
VIOsPAPRVTYDevice -> SpaprVioVty
VIOsPAPRVLANDevice -> SpaprVioVlan
Brevity, since the "Device" didn't add useful information
sPAPRDRConnector -> SpaprDrc
sPAPRDRConnectorClass -> SpaprDrcClass
Brevity, and makes it clearer this is the same thing as a "DRC"
mentioned in many other places in the code
This is 100% a mechanical search-and-replace patch. It will, however,
conflict with essentially any and all outstanding patches touching the
spapr code.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-06 05:35:37 +01:00
|
|
|
SpaprVioDevice const *dev1, *dev2;
|
2011-12-12 19:24:32 +01:00
|
|
|
|
spapr: Use CamelCase properly
The qemu coding standard is to use CamelCase for type and structure names,
and the pseries code follows that... sort of. There are quite a lot of
places where we bend the rules in order to preserve the capitalization of
internal acronyms like "PHB", "TCE", "DIMM" and most commonly "sPAPR".
That was a bad idea - it frequently leads to names ending up with hard to
read clusters of capital letters, and means they don't catch the eye as
type identifiers, which is kind of the point of the CamelCase convention in
the first place.
In short, keeping type identifiers look like CamelCase is more important
than preserving standard capitalization of internal "words". So, this
patch renames a heap of spapr internal type names to a more standard
CamelCase.
In addition to case changes, we also make some other identifier renames:
VIOsPAPR* -> SpaprVio*
The reverse word ordering was only ever used to mitigate the capital
cluster, so revert to the natural ordering.
VIOsPAPRVTYDevice -> SpaprVioVty
VIOsPAPRVLANDevice -> SpaprVioVlan
Brevity, since the "Device" didn't add useful information
sPAPRDRConnector -> SpaprDrc
sPAPRDRConnectorClass -> SpaprDrcClass
Brevity, and makes it clearer this is the same thing as a "DRC"
mentioned in many other places in the code
This is 100% a mechanical search-and-replace patch. It will, however,
conflict with essentially any and all outstanding patches touching the
spapr code.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-06 05:35:37 +01:00
|
|
|
dev1 = (SpaprVioDevice *)*(DeviceState **)p1;
|
|
|
|
dev2 = (SpaprVioDevice *)*(DeviceState **)p2;
|
2011-12-12 19:24:32 +01:00
|
|
|
|
|
|
|
if (dev1->reg < dev2->reg) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
if (dev1->reg == dev2->reg) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* dev1->reg > dev2->reg */
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
spapr: Use CamelCase properly
The qemu coding standard is to use CamelCase for type and structure names,
and the pseries code follows that... sort of. There are quite a lot of
places where we bend the rules in order to preserve the capitalization of
internal acronyms like "PHB", "TCE", "DIMM" and most commonly "sPAPR".
That was a bad idea - it frequently leads to names ending up with hard to
read clusters of capital letters, and means they don't catch the eye as
type identifiers, which is kind of the point of the CamelCase convention in
the first place.
In short, keeping type identifiers look like CamelCase is more important
than preserving standard capitalization of internal "words". So, this
patch renames a heap of spapr internal type names to a more standard
CamelCase.
In addition to case changes, we also make some other identifier renames:
VIOsPAPR* -> SpaprVio*
The reverse word ordering was only ever used to mitigate the capital
cluster, so revert to the natural ordering.
VIOsPAPRVTYDevice -> SpaprVioVty
VIOsPAPRVLANDevice -> SpaprVioVlan
Brevity, since the "Device" didn't add useful information
sPAPRDRConnector -> SpaprDrc
sPAPRDRConnectorClass -> SpaprDrcClass
Brevity, and makes it clearer this is the same thing as a "DRC"
mentioned in many other places in the code
This is 100% a mechanical search-and-replace patch. It will, however,
conflict with essentially any and all outstanding patches touching the
spapr code.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-06 05:35:37 +01:00
|
|
|
void spapr_dt_vdevice(SpaprVioBus *bus, void *fdt)
|
2011-04-01 06:15:21 +02:00
|
|
|
{
|
2011-12-12 19:24:32 +01:00
|
|
|
DeviceState *qdev, **qdevs;
|
2011-12-23 22:34:39 +01:00
|
|
|
BusChild *kid;
|
2011-12-12 19:24:32 +01:00
|
|
|
int i, num, ret = 0;
|
2016-10-20 07:01:17 +02:00
|
|
|
int node;
|
|
|
|
|
|
|
|
_FDT(node = fdt_add_subnode(fdt, 0, "vdevice"));
|
|
|
|
|
|
|
|
_FDT(fdt_setprop_string(fdt, node, "device_type", "vdevice"));
|
|
|
|
_FDT(fdt_setprop_string(fdt, node, "compatible", "IBM,vdevice"));
|
|
|
|
_FDT(fdt_setprop_cell(fdt, node, "#address-cells", 1));
|
|
|
|
_FDT(fdt_setprop_cell(fdt, node, "#size-cells", 0));
|
|
|
|
_FDT(fdt_setprop_cell(fdt, node, "#interrupt-cells", 2));
|
|
|
|
_FDT(fdt_setprop(fdt, node, "interrupt-controller", NULL, 0));
|
2011-04-01 06:15:21 +02:00
|
|
|
|
2011-12-12 19:24:32 +01:00
|
|
|
/* Count qdevs on the bus list */
|
|
|
|
num = 0;
|
2011-12-23 22:34:39 +01:00
|
|
|
QTAILQ_FOREACH(kid, &bus->bus.children, sibling) {
|
2011-12-12 19:24:32 +01:00
|
|
|
num++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Copy out into an array of pointers */
|
2018-11-27 14:05:18 +01:00
|
|
|
qdevs = g_new(DeviceState *, num);
|
2011-12-12 19:24:32 +01:00
|
|
|
num = 0;
|
2011-12-23 22:34:39 +01:00
|
|
|
QTAILQ_FOREACH(kid, &bus->bus.children, sibling) {
|
|
|
|
qdevs[num++] = kid->child;
|
2011-12-12 19:24:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Sort the array */
|
|
|
|
qsort(qdevs, num, sizeof(qdev), compare_reg);
|
|
|
|
|
|
|
|
/* Hack alert. Give the devices to libfdt in reverse order, we happen
|
|
|
|
* to know that will mean they are in forward order in the tree. */
|
|
|
|
for (i = num - 1; i >= 0; i--) {
|
spapr: Use CamelCase properly
The qemu coding standard is to use CamelCase for type and structure names,
and the pseries code follows that... sort of. There are quite a lot of
places where we bend the rules in order to preserve the capitalization of
internal acronyms like "PHB", "TCE", "DIMM" and most commonly "sPAPR".
That was a bad idea - it frequently leads to names ending up with hard to
read clusters of capital letters, and means they don't catch the eye as
type identifiers, which is kind of the point of the CamelCase convention in
the first place.
In short, keeping type identifiers look like CamelCase is more important
than preserving standard capitalization of internal "words". So, this
patch renames a heap of spapr internal type names to a more standard
CamelCase.
In addition to case changes, we also make some other identifier renames:
VIOsPAPR* -> SpaprVio*
The reverse word ordering was only ever used to mitigate the capital
cluster, so revert to the natural ordering.
VIOsPAPRVTYDevice -> SpaprVioVty
VIOsPAPRVLANDevice -> SpaprVioVlan
Brevity, since the "Device" didn't add useful information
sPAPRDRConnector -> SpaprDrc
sPAPRDRConnectorClass -> SpaprDrcClass
Brevity, and makes it clearer this is the same thing as a "DRC"
mentioned in many other places in the code
This is 100% a mechanical search-and-replace patch. It will, however,
conflict with essentially any and all outstanding patches touching the
spapr code.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-06 05:35:37 +01:00
|
|
|
SpaprVioDevice *dev = (SpaprVioDevice *)(qdevs[i]);
|
|
|
|
SpaprVioDeviceClass *vdc = VIO_SPAPR_DEVICE_GET_CLASS(dev);
|
2011-04-01 06:15:21 +02:00
|
|
|
|
|
|
|
ret = vio_make_devnode(dev, fdt);
|
|
|
|
if (ret < 0) {
|
2016-10-20 07:01:17 +02:00
|
|
|
error_report("Couldn't create device node /vdevice/%s@%"PRIx32,
|
|
|
|
vdc->dt_name, dev->reg);
|
|
|
|
exit(1);
|
2011-04-01 06:15:21 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-28 15:54:03 +01:00
|
|
|
g_free(qdevs);
|
2011-04-01 06:15:21 +02:00
|
|
|
}
|
2011-12-13 05:24:34 +01:00
|
|
|
|
spapr: Use CamelCase properly
The qemu coding standard is to use CamelCase for type and structure names,
and the pseries code follows that... sort of. There are quite a lot of
places where we bend the rules in order to preserve the capitalization of
internal acronyms like "PHB", "TCE", "DIMM" and most commonly "sPAPR".
That was a bad idea - it frequently leads to names ending up with hard to
read clusters of capital letters, and means they don't catch the eye as
type identifiers, which is kind of the point of the CamelCase convention in
the first place.
In short, keeping type identifiers look like CamelCase is more important
than preserving standard capitalization of internal "words". So, this
patch renames a heap of spapr internal type names to a more standard
CamelCase.
In addition to case changes, we also make some other identifier renames:
VIOsPAPR* -> SpaprVio*
The reverse word ordering was only ever used to mitigate the capital
cluster, so revert to the natural ordering.
VIOsPAPRVTYDevice -> SpaprVioVty
VIOsPAPRVLANDevice -> SpaprVioVlan
Brevity, since the "Device" didn't add useful information
sPAPRDRConnector -> SpaprDrc
sPAPRDRConnectorClass -> SpaprDrcClass
Brevity, and makes it clearer this is the same thing as a "DRC"
mentioned in many other places in the code
This is 100% a mechanical search-and-replace patch. It will, however,
conflict with essentially any and all outstanding patches touching the
spapr code.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-06 05:35:37 +01:00
|
|
|
gchar *spapr_vio_stdout_path(SpaprVioBus *bus)
|
2011-12-13 05:24:34 +01:00
|
|
|
{
|
spapr: Use CamelCase properly
The qemu coding standard is to use CamelCase for type and structure names,
and the pseries code follows that... sort of. There are quite a lot of
places where we bend the rules in order to preserve the capitalization of
internal acronyms like "PHB", "TCE", "DIMM" and most commonly "sPAPR".
That was a bad idea - it frequently leads to names ending up with hard to
read clusters of capital letters, and means they don't catch the eye as
type identifiers, which is kind of the point of the CamelCase convention in
the first place.
In short, keeping type identifiers look like CamelCase is more important
than preserving standard capitalization of internal "words". So, this
patch renames a heap of spapr internal type names to a more standard
CamelCase.
In addition to case changes, we also make some other identifier renames:
VIOsPAPR* -> SpaprVio*
The reverse word ordering was only ever used to mitigate the capital
cluster, so revert to the natural ordering.
VIOsPAPRVTYDevice -> SpaprVioVty
VIOsPAPRVLANDevice -> SpaprVioVlan
Brevity, since the "Device" didn't add useful information
sPAPRDRConnector -> SpaprDrc
sPAPRDRConnectorClass -> SpaprDrcClass
Brevity, and makes it clearer this is the same thing as a "DRC"
mentioned in many other places in the code
This is 100% a mechanical search-and-replace patch. It will, however,
conflict with essentially any and all outstanding patches touching the
spapr code.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2019-03-06 05:35:37 +01:00
|
|
|
SpaprVioDevice *dev;
|
2011-12-13 05:24:34 +01:00
|
|
|
char *name, *path;
|
|
|
|
|
|
|
|
dev = spapr_vty_get_default(bus);
|
2016-10-24 03:05:57 +02:00
|
|
|
if (!dev) {
|
|
|
|
return NULL;
|
2011-12-13 05:24:34 +01:00
|
|
|
}
|
|
|
|
|
2013-04-07 21:08:17 +02:00
|
|
|
name = spapr_vio_get_dev_name(DEVICE(dev));
|
2013-01-16 18:22:29 +01:00
|
|
|
path = g_strdup_printf("/vdevice/%s", name);
|
2011-12-13 05:24:34 +01:00
|
|
|
|
2013-01-16 18:22:29 +01:00
|
|
|
g_free(name);
|
2016-10-24 03:05:57 +02:00
|
|
|
return path;
|
2011-12-13 05:24:34 +01:00
|
|
|
}
|