OpenAMP Library  353
remoteproc_virtio.h
Go to the documentation of this file.
1 /*
2  * Remoteproc Virtio Framework
3  *
4  * Copyright(c) 2018 Xilinx Ltd.
5  * Copyright(c) 2011 Texas Instruments, Inc.
6  * Copyright(c) 2011 Google, Inc.
7  * All rights reserved.
8  *
9  * SPDX-License-Identifier: BSD-3-Clause
10  */
11 
12 #ifndef REMOTEPROC_VIRTIO_H
13 #define REMOTEPROC_VIRTIO_H
14 
15 #include <metal/io.h>
16 #include <metal/list.h>
17 #include <openamp/virtio.h>
18 #include <metal/cache.h>
19 
20 #if defined __cplusplus
21 extern "C" {
22 #endif
23 
24 /* maximum number of vring descriptors for a vdev limited by 16-bit data type */
25 #define RPROC_MAX_VRING_DESC USHRT_MAX
26 
27 /* cache invalidation helpers for resource table */
28 #if defined(VIRTIO_USE_DCACHE)
29 #define RSC_TABLE_FLUSH(x, s) metal_cache_flush(x, s)
30 #define RSC_TABLE_INVALIDATE(x, s) metal_cache_invalidate(x, s)
31 #else
32 #define RSC_TABLE_FLUSH(x, s) do { } while (0)
33 #define RSC_TABLE_INVALIDATE(x, s) do { } while (0)
34 #endif /* VIRTIO_USE_DCACHE */
35 
36 /* define vdev notification function user should implement */
37 typedef int (*rpvdev_notify_func)(void *priv, uint32_t id);
38 
42  void *priv;
43 
45  void *vdev_rsc;
46 
48  struct metal_io_region *vdev_rsc_io;
49 
52 
54  struct virtio_device vdev;
55 
57  struct metal_list node;
58 };
59 
74 struct virtio_device *
75 rproc_virtio_create_vdev(unsigned int role, unsigned int notifyid,
76  void *rsc, struct metal_io_region *rsc_io,
77  void *priv,
78  rpvdev_notify_func notify,
79  virtio_dev_reset_cb rst_cb);
80 
86 void rproc_virtio_remove_vdev(struct virtio_device *vdev);
87 
101 int rproc_virtio_init_vring(struct virtio_device *vdev, unsigned int index,
102  unsigned int notifyid, void *va,
103  struct metal_io_region *io,
104  unsigned int num_descs, unsigned int align);
105 
114 int rproc_virtio_notified(struct virtio_device *vdev, uint32_t notifyid);
115 
123 
124 #if defined __cplusplus
125 }
126 #endif
127 
128 #endif /* REMOTEPROC_VIRTIO_H */
int rproc_virtio_init_vring(struct virtio_device *vdev, unsigned int index, unsigned int notifyid, void *va, struct metal_io_region *io, unsigned int num_descs, unsigned int align)
Initialize rproc virtio vring.
Definition: remoteproc_virtio.c:356
struct virtio_device * rproc_virtio_create_vdev(unsigned int role, unsigned int notifyid, void *rsc, struct metal_io_region *rsc_io, void *priv, rpvdev_notify_func notify, virtio_dev_reset_cb rst_cb)
Create rproc virtio vdev.
Definition: remoteproc_virtio.c:290
void rproc_virtio_wait_remote_ready(struct virtio_device *vdev)
Blocking function, waiting for the remote core is ready to start communications.
Definition: remoteproc_virtio.c:400
int(* rpvdev_notify_func)(void *priv, uint32_t id)
Definition: remoteproc_virtio.h:37
void rproc_virtio_remove_vdev(struct virtio_device *vdev)
Remove rproc virtio vdev.
Definition: remoteproc_virtio.c:344
int rproc_virtio_notified(struct virtio_device *vdev, uint32_t notifyid)
remoteproc virtio is got notified
Definition: remoteproc_virtio.c:377
Virtio structure for remoteproc instance.
Definition: remoteproc_virtio.h:40
struct metal_list node
List node.
Definition: remoteproc_virtio.h:57
rpvdev_notify_func notify
Notification function.
Definition: remoteproc_virtio.h:51
void * vdev_rsc
Address of vdev resource.
Definition: remoteproc_virtio.h:45
struct virtio_device vdev
Virtio device.
Definition: remoteproc_virtio.h:54
struct metal_io_region * vdev_rsc_io
Metal I/O region of vdev_info, can be NULL.
Definition: remoteproc_virtio.h:48
void * priv
Pointer to private data.
Definition: remoteproc_virtio.h:42
Structure definition for virtio devices for use by the applications/drivers.
Definition: virtio.h:188
unsigned int role
If it is virtio backend or front end.
Definition: virtio.h:199
void * priv
Private data.
Definition: virtio.h:211
uint32_t notifyid
Unique position on the virtio bus.
Definition: virtio.h:190
void(* virtio_dev_reset_cb)(struct virtio_device *vdev)
Definition: virtio.h:158