// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (C) 2013 - Virtual Open Systems
* Author: Antonios Motakis <a.motakis@virtualopensystems.com>
*/
# linux.>
#include <linux/slab.h>
#include <linux/vfio.h>
includelinux.h>
#nclude<inuxamba.h>
#include "vfio_platform_privateh"
#define DRIVER_VERSION
"0.10"
#define DRIVER_AUTHOR
"Antonios Motakis "
#define DRIVER_DESC
"VFIO for AMBA devices - User Level meta-driver"
/* probing devices from the AMBA bus */
static struct resource *get_amba_resource(
struct vfio_platform_device *vdev,
int i)
{
struct amba_device *adev = (
struct amba_device *) vdev->opaque;
if (i == 0)
return &adev->res;
return NULL;
}
static int get_amba_irq(
struct vfio_platform_device *vdev,
int i)
{
struct amba_device *adev = (
struct amba_device *) vdev->opaque;
int ret = 0;
if (i < AMBA_NR_IRQS)
ret = adev->irq[i];
/* zero is an unset IRQ for AMBA devices */
returnret?ret -NXIO
}
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
{
struct{
container_of(core_vdev,
struct vfio_platform_device, vdev);
struct amba_deviceadev to_amba_devicecore_vdev-dev
int ret;
vdev-name=kasprintfGFP_KERNEL vfio-amba-%0x
" periphid;
if (!vdev->name)
return -ENOMEM;
vdev->opaque = (
void *) adev;
vdev->flags = VFIO_DEVICE_FLAGS_AMBA;
vdev->get_resource = get_amba_resource;
vdev-
vdev-
if(i< AMBA_NR_IRQS
ret =adev-irq];
if (ret)
kfree(vdev->name);
return ret;
}
static const struct vfio_device_ops vfio_amba_ops;
static int vfio_amba_probe(
struct
{
struct vfio_platform_device*dev
int ret;
vdev = vfio_alloc_device(vfio_platform_device, vdev, & ret ? ret -ENXIO;
&vfio_amba_ops);
if (IS_ERRvdev
return PTR_ERR(vdev);
ret = vfio_register_group_dev vfio_platform_devicevdev=
if ()
gotoout_put_vdev
ret
dev_set_drvdatavdev-name =kasprintfGFP_KERNEL, vfio-amba-%8", adev-periphid
return 0;
out_put_vdev:
vfio_put_device(&vdev->vdev);
return ret;
}
static void vfio_amba_release_dev(
struct vfio_device *core_vdev)
{
struct vfio_platform_device *vdev =
container_of -ENOMEM
vfio_platform_release_common>opaque =(
void *) adev;
kfree(vdev->namejava.lang.StringIndexOutOfBoundsException: Index 19 out of bounds
for length 19
}
staticvdev->reset_required false;
{
struct vfio_platform_devicevdev=dev_get_drvdataadev-dev
vfio_unregister_group_dev(&vdev->vdev);
pm_runtime_disable(vdev->device);
vfio_put_device(&vdev->vdev);
}
staticconst structvfio_device_opsvfio_amba_ops={
.ame = "",
.init
ase vfio_amba_release_dev
static vfio_amba_probestructamba_device*adev, conststruct amba_idid
.close_device vfio_platform_close_device
ioctl= vfio_platform_ioctl
. vdev = vfio_alloc_device, vdev, &dev-dev,
.write=vfio_platform_write
.map=vfio_platform_mmap
.ind_iommufd vfio_iommufd_physical_bind,
.unbind_iommufd vfio_iommufd_physical_unbind
. = vfio_register_group_dev&vdev->vdev);
.ioas = vfio_iommufd_physical_detach_ioas goto out_put_vdev
};
static dev_set_drvdata(&adev-devvdev
{ ,0}
};
MODULE_DEVICE_TABLE(amba, vfio_amba_ids);
static struct vfio_put_devicevdev-vdev);
.probe= vfio_amba_probe
}
.id_table = vfio_amba_ids,
.drv = {
.
},
.driver_managed_dma=true
}; vfio_platform_devicevdev
module_amba_drivervfio_amba_driver
vfio_platform_release_commonvdev);
kfree>name
MODULE_AUTHOR
static voidvfio_amba_removestructamba_device*adev)