]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - processor-sdk/open-amp.git/blobdiff - lib/include/openamp/hil.h
hil: add hil_vdev_notify
[processor-sdk/open-amp.git] / lib / include / openamp / hil.h
index a8d8f44d1e6f51a20da04509a30c46b00c41579d..8dca8aa0638fb12a791916b7f55469bfba841bad 100644 (file)
@@ -45,6 +45,8 @@
 #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. */
@@ -86,6 +94,10 @@ struct proc_intr {
        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;
 };
@@ -100,8 +112,12 @@ struct proc_intr {
 struct proc_vring {
        /* Pointer to virtqueue encapsulating the vring */
        struct virtqueue *vq;
-       /* Vring physical address */
-       void *phy_addr;
+       /* 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 */
@@ -118,6 +134,10 @@ struct proc_vring {
  *
  */
 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 */
@@ -149,8 +169,10 @@ struct proc_chnl {
 *
 */
 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 */
@@ -159,18 +181,10 @@ struct hil_proc {
        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;
 };
@@ -178,15 +192,18 @@ struct hil_proc {
 /**
  * hil_create_proc
  *
- * This function creates a HIL proc instance for given CPU id and populates
- * it with platform info.
- *
- * @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(int cpu_id);
+struct hil_proc *hil_create_proc(struct hil_platform_ops *ops,
+                               unsigned long cpu_id, void *pdata);
 
 /**
  * hil_delete_proc
@@ -200,17 +217,15 @@ struct hil_proc *hil_create_proc(int cpu_id);
 void hil_delete_proc(struct hil_proc *proc);
 
 /**
- * hil_get_proc
- *
- * This function finds the proc instance based on the given ID
- * from the proc list and returns it to user.
+ * hil_init_proc
  *
- * @param cpu_id - cpu id
+ * This function initialize a HIL proc instance with the given platform data
+ * @param proc  - pointer to the hil_proc to initialize
  *
- * @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()
@@ -224,18 +239,6 @@ struct hil_proc *hil_get_proc(int cpu_id);
  */
 void hil_isr(struct proc_vring *vring_hw);
 
-/**
- * hil_get_cpuforfw
- *
- * This function provides the CPU ID for the given firmware.
- *
- * @param fw_name - name of firmware
- *
- * @return - cpu id
- *
- */
-int hil_get_cpuforfw(char *fw_name);
-
 /**
  * hil_get_vdev_info
  *
@@ -305,6 +308,17 @@ struct proc_shm *hil_get_shm_info(struct hil_proc *proc);
  */
 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()
  *
@@ -378,9 +392,100 @@ void hil_shutdown_cpu(struct hil_proc *proc);
  * 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
@@ -400,89 +505,72 @@ struct hil_platform_ops {
      */
        int (*enable_interrupt) (struct proc_vring * vring_hw);
 
-    /**
-     * reg_ipi_after_deinit()
-     * This function register interrupt(IPI) after openamp resource .
-     *
-     * @param vring_hw - pointer to vring control block
-     */
-       void (*reg_ipi_after_deinit) (struct proc_vring * vring_hw);
-
     /**
      * notify()
      *
      * 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);
+       void (*notify) (struct hil_proc *proc, struct proc_intr * intr_info);
 
     /**
-     * get_status
+     * boot_cpu
      *
-     * 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.
+     * This unction boots the remote processor.
      *
-     * @param cpu_id - ID of CPU for which status is requested.
+     * @param proc - pointer to the hil_proc
+     * @param start_addr - start address of remote cpu
      *
      * @return - execution status
      */
-       int (*get_status) (int cpu_id);
+       int (*boot_cpu) (struct hil_proc *proc, unsigned int start_addr);
 
     /**
-     * set_status
+     * shutdown_cpu
      *
-     * This function is used to update the status
-     * of the given core i.e it is ready for IPC.
+     *  This function shutdowns the remote processor.
      *
-     * @param cpu_id - ID of CPU for which status is to be set
+     * @param proc - pointer to the hil_proc
      *
-     * @return - execution status
      */
-
-       int (*set_status) (int cpu_id);
+       void (*shutdown_cpu) (struct hil_proc *proc);
 
     /**
-     * boot_cpu
+     * poll
      *
-     * This function boots the remote processor.
+     * This function polls the remote processor.
      *
-     * @param cpu_id     - ID of CPU to boot
-     * @param start_addr - start address of remote cpu
+     * @param proc     - hil_proc to poll
+     * @param nonblock - 0 for blocking, non-0 for non-blocking.
      *
-     * @return - execution status
+     * @return - 0 for no errors, non-0 for errors.
      */
-       int (*boot_cpu) (int cpu_id, unsigned int start_addr);
+       int (*poll) (struct hil_proc *proc, int nonblock);
 
     /**
-     * shutdown_cpu
+     * initialize
      *
-     *  This function shutdowns the remote processor.
+     *  This function initialize remote processor with platform data.
+     *
+     * @param proc     - hil_proc to poll
      *
-     * @param cpu_id    - ID of CPU to shutdown
+     * @return NULL on failure, hil_proc pointer otherwise
      *
      */
-       void (*shutdown_cpu) (int cpu_id);
+       int (*initialize) (struct hil_proc *proc);
 
     /**
-     * initialize
+     * release
      *
-     *  This function initialize remote processor with platform data.
+     *  This function is to release remote processor resource
      *
-     * @param[in] pdata - platform data
      * @param[in] proc - pointer to the remote processor
-     * @param[in] cpu_id - CPU id
-     *
-     * @return 0 on sucess, otherwise on failure
      *
      */
-       int (*initialize) (void *pdata,
-                                 struct hil_proc *proc,
-                                 int cpu_id);
-
+       void (*release) (struct hil_proc *proc);
 };
 
 /* Utility macros for register read/write */