forked from nuttx/nuttx-update
virtio-mmio: add secure virtio mmio device register api
In secure state, call virtio_register_mmio_device_secure() to register the secure virtio mmio device; In non-secure state, call virtio_register_mmio_device() to register the non-secure virtio mmio device; Board should ensure not mixed use the secure and non-seucre mmio device. Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
This commit is contained in:
parent
551b9b1626
commit
84d2aae63b
2 changed files with 56 additions and 7 deletions
|
@ -806,18 +806,14 @@ static int virtio_mmio_init_device(FAR struct virtio_mmio_device_s *vmdev,
|
|||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: virtio_register_mmio_device
|
||||
* Name: virtio_register_mmio_device_
|
||||
*
|
||||
* Description:
|
||||
* Register virtio mmio device to the virtio bus
|
||||
* Register secure or non-secure virtio mmio device to the virtio bus
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int virtio_register_mmio_device(FAR void *regs, int irq)
|
||||
static int virtio_register_mmio_device_(FAR void *regs, int irq, bool secure)
|
||||
{
|
||||
FAR struct virtio_mmio_device_s *vmdev;
|
||||
int ret;
|
||||
|
@ -843,6 +839,15 @@ int virtio_register_mmio_device(FAR void *regs, int irq)
|
|||
goto err;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_ARCH_TRUSTZONE_SECURE
|
||||
if (secure)
|
||||
{
|
||||
up_secure_irq(irq, true);
|
||||
}
|
||||
#else
|
||||
UNUSED(secure);
|
||||
#endif
|
||||
|
||||
/* Attach the intterupt before register the device driver */
|
||||
|
||||
ret = irq_attach(irq, virtio_mmio_interrupt, vmdev);
|
||||
|
@ -868,3 +873,35 @@ err:
|
|||
kmm_free(vmdev);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: virtio_register_mmio_device
|
||||
*
|
||||
* Description:
|
||||
* Register virtio mmio device to the virtio bus
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int virtio_register_mmio_device(FAR void *regs, int irq)
|
||||
{
|
||||
return virtio_register_mmio_device_(regs, irq, false);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: virtio_register_mmio_device_secure
|
||||
*
|
||||
* Description:
|
||||
* Register secure virtio mmio device to the virtio bus
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_ARCH_TRUSTZONE_SECURE
|
||||
int virtio_register_mmio_device_secure(FAR void *regs, int irq)
|
||||
{
|
||||
return virtio_register_mmio_device_(regs, irq, true);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -61,6 +61,18 @@ extern "C"
|
|||
|
||||
int virtio_register_mmio_device(FAR void *regs, int irq);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: virtio_register_mmio_device_secure
|
||||
*
|
||||
* Description:
|
||||
* Register secure virtio mmio device to the virtio bus
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_ARCH_TRUSTZONE_SECURE
|
||||
int virtio_register_mmio_device_secure(FAR void *regs, int irq);
|
||||
#endif
|
||||
|
||||
#undef EXTERN
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue