index 4a4d3b2c1ff580beaf96793cedec5a323732b35f..8dca8aa0638fb12a791916b7f55469bfba841bad 100644 (file)
#include "openamp/virtio.h"
#include "openamp/firmware.h"
#include "metal/list.h"
+#include "metal/io.h"
+#include "metal/device.h"
/* Configurable parameters */
#define HIL_MAX_CORES 2
struct proc_shm {
/* Start address of shared memory used for buffers. */
void *start_addr;
+ /* Start physical address of shared memory used for buffers. */
+ metal_phys_addr_t start_paddr;
+ /* sharmed memory I/O region */
+ struct metal_io_region *io;
+ /* sharmed memory metal device */
+ struct metal_device *dev;
/* Size of shared memory. */
unsigned long size;
/* Attributes for shared memory - cached or uncached. */
unsigned int priority;
/* Interrupt trigger type */
unsigned int trigger_type;
+ /* IPI metal device */
+ struct metal_device *dev;
+ /* IPI device I/O */
+ struct metal_io_region *io;
/* Private data */
void *data;
};
struct virtqueue *vq;
/* Vring logical address */
void *vaddr;
+ /* Vring metal device */
+ struct metal_device *dev;
+ /* Vring I/O region */
+ struct metal_io_region *io;
/* Number of vring descriptors */
unsigned short num_descs;
/* Vring alignment */
*
*/
struct proc_vdev {
+ /* Address for the vdev info */
+ void *vdev_info;
+ /* Vdev interrupt control block */
+ struct proc_intr intr_info;
/* Number of vrings */
unsigned int num_vrings;
/* Virtio device features */
*
*/
struct hil_proc {
- /* CPU ID as defined by the platform */
+ /* HIL CPU ID */
unsigned long cpu_id;
+ /* HIL platform ops table */
+ struct hil_platform_ops *ops;
/* Shared memory info */
struct proc_shm sh_buff;
/* Virtio device hardware info */
unsigned long num_chnls;
/* RPMsg channels array */
struct proc_chnl chnls[HIL_MAX_NUM_CHANNELS];
- /* HIL platform ops table */
- struct hil_platform_ops *ops;
- /* Attrbites to represent processor role, master or remote . This field is for
- * future use. */
- unsigned long attr;
- /*
- * CPU bitmask - shared variable updated by each core
- * after it has been initialized. This field is for future use.
- */
- unsigned long cpu_bitmask;
- /* Spin lock - This field is for future use. */
- volatile unsigned int *slock;
+ /* Initialized status */
+ int is_initialized;
+ /* private data */
+ void *pdata;
/* List node */
struct metal_list node;
};
/**
* hil_create_proc
*
- * This function creates a HIL proc instance for given CPU id and populates
- * it with platform info.
- *
- * @param pdata - platform data for remote processor
- * @param cpu_id - cpu id
+ * This function creates a HIL proc instance
*
+ * @param ops - hil proc platform operations
+ * @param cpu_id - remote CPU ID.
+ * E.g. the CPU ID of the remote processor in its
+ * cluster.
+ * @param pdata - private data
* @return - pointer to proc instance
*
*/
-struct hil_proc *hil_create_proc(void *pdata, int cpu_id);
+struct hil_proc *hil_create_proc(struct hil_platform_ops *ops,
+ unsigned long cpu_id, void *pdata);
/**
* hil_delete_proc
void hil_delete_proc(struct hil_proc *proc);
/**
- * hil_get_proc
+ * hil_init_proc
*
- * This function finds the proc instance based on the given ID
- * from the proc list and returns it to user.
+ * This function initialize a HIL proc instance with the given platform data
+ * @param proc - pointer to the hil_proc to initialize
*
- * @param cpu_id - cpu id
- *
- * @return - pointer to proc instance
+ * @return - 0 succeeded, non-0 for failure
*
*/
-struct hil_proc *hil_get_proc(int cpu_id);
+int hil_init_proc(struct hil_proc *proc);
/**
* hil_isr()
*/
int hil_enable_vring_notifications(int vring_index, struct virtqueue *vq);
+/**
+ * hil_vdev_notify()
+ *
+ * This function generates IPI to let the other side know that there is
+ * change to virtio device configs.
+ *
+ * @param vdev - pointer to virtio device
+ *
+ */
+void hil_vdev_notify(struct virtio_device *vdev);
+
/**
* hil_vring_notify()
*
* returns - status of function execution
*
*/
-int hil_get_firmware(char *fw_name, unsigned int *start_addr,
+int hil_get_firmware(char *fw_name, uintptr_t *start_addr,
unsigned int *size);
+/**
+ * hil_poll
+ *
+ * This function polls the remote processor.
+ * If it is blocking mode, it will not return until the remoteproc
+ * is signaled. If it is non-blocking mode, it will return 0
+ * if the remoteproc has pending signals, it will return non 0
+ * otherwise.
+ *
+ * @param proc - hil_proc to poll
+ * @param nonblock - 0 for blocking, non-0 for non-blocking.
+ *
+ * @return - 0 for no errors, non-0 for errors.
+ */
+int hil_poll (struct hil_proc *proc, int nonblock);
+
+/**
+ * hil_set_shm
+ *
+ * This function set HIL proc shared memory
+ *
+ * @param proc - hil_proc to set
+ * @param bus_name - bus name of the shared memory device
+ * @param name - name of the shared memory, or platform device
+ * mandatory for Linux system.
+ * @param paddr - physical address of the memory for baremetal/RTOS only
+ * @param size - size of the shared memory
+ *
+ * If name argument exists, it will open the specified libmetal
+ * shared memory or the specified libmetal device if bus_name
+ * is specified to get the I/O region of the shared memory. Otherwise, it
+ * will use a generic normal I/O region for the shared memory.
+ * paddr argument is for baremetal/RTOS system only. Linux system
+ * will not take this paddr, for Linux system, you have to specify
+ * the name, otherwise, you will get segfault later.
+ *
+ * @return - 0 for no errors, non-0 for errors.
+ */
+int hil_set_shm (struct hil_proc *proc,
+ const char *bus_name, const char *name,
+ metal_phys_addr_t paddr, size_t size);
+
+/**
+ * hil_set_vring
+ *
+ * This function set HIL proc vring
+ *
+ * @param proc - hil_proc to set
+ * @param index - vring index
+ * @param bus_name - bus name of the vring device
+ * @param name - name of the shared memory, or platform device
+ * mandatory for Linux system.
+ *
+ * If name argument exists, it will open the specified libmetal
+ * shared memory or the specified device if bus name is specified
+ * to get the I/O region of the vring.
+ *
+ * @return - 0 for no errors, non-0 for errors.
+ */
+int hil_set_vring (struct hil_proc *proc, int index,
+ const char *bus_name, const char *name);
+
+/**
+ * hil_set_ipi
+ *
+ * This function set HIL proc IPI
+ *
+ * @param proc - hil_proc to set
+ * @param index - vring index for the IPI
+ * @param irq - IPI irq vector ID
+ * @param data - IPI data
+ *
+ * @return - 0 for no errors, non-0 for errors.
+ */
+int hil_set_ipi (struct hil_proc *proc, int index,
+ unsigned int irq, void *data);
+
+/**
+ * hil_set_rpmsg_channel
+ *
+ * This function set HIL proc rpmsg_channel
+ *
+ * @param proc - hil_proc to set
+ * @param index - vring index for the rpmsg_channel
+ * @param name - RPMsg channel name
+ *
+ * @return - 0 for no errors, non-0 for errors.
+ */
+int hil_set_rpmsg_channel (struct hil_proc *proc, int index,
+ char *name);
+
/**
*
* This structure is an interface between HIL and platform porting
* This function generates IPI to let the other side know that there is
* job available for it.
*
- * @param cpu_id - ID of CPU which is to be notified
+ * @param proc - pointer to the hil_proc
* @param intr_info - pointer to interrupt info control block
*/
- void (*notify) (int cpu_id, struct proc_intr * intr_info);
-
- /**
- * get_status
- *
- * This function is used to check if the given core is
- * up and running. This call will return after it is confirmed
- * that remote core is initialized.
- *
- * @param cpu_id - ID of CPU for which status is requested.
- *
- * @return - execution status
- */
- int (*get_status) (int cpu_id);
+ void (*notify) (struct hil_proc *proc, struct proc_intr * intr_info);
/**
- * set_status
+ * boot_cpu
*
- * This function is used to update the status
- * of the given core i.e it is ready for IPC.
+ * This unction boots the remote processor.
*
- * @param cpu_id - ID of CPU for which status is to be set
+ * @param proc - pointer to the hil_proc
+ * @param start_addr - start address of remote cpu
*
* @return - execution status
*/
-
- int (*set_status) (int cpu_id);
+ int (*boot_cpu) (struct hil_proc *proc, unsigned int start_addr);
/**
- * boot_cpu
+ * shutdown_cpu
*
- * This function boots the remote processor.
+ * This function shutdowns the remote processor.
*
- * @param cpu_id - ID of CPU to boot
- * @param start_addr - start address of remote cpu
+ * @param proc - pointer to the hil_proc
*
- * @return - execution status
*/
- int (*boot_cpu) (int cpu_id, unsigned int start_addr);
+ void (*shutdown_cpu) (struct hil_proc *proc);
/**
- * shutdown_cpu
+ * poll
*
- * This function shutdowns the remote processor.
+ * This function polls the remote processor.
*
- * @param cpu_id - ID of CPU to shutdown
+ * @param proc - hil_proc to poll
+ * @param nonblock - 0 for blocking, non-0 for non-blocking.
*
+ * @return - 0 for no errors, non-0 for errors.
*/
- void (*shutdown_cpu) (int cpu_id);
+ int (*poll) (struct hil_proc *proc, int nonblock);
/**
* initialize
*
* This function initialize remote processor with platform data.
*
- * @param[in] pdata - platform data
- * @param[in] cpu_id - CPU id
+ * @param proc - hil_proc to poll
*
* @return NULL on failure, hil_proc pointer otherwise
*
*/
- struct hil_proc *(*initialize) (void *pdata, int cpu_id);
+ int (*initialize) (struct hil_proc *proc);
/**
* release