update hil_proc not to add new user data struct
authorWendy Liang <jliang@xilinx.com>
Thu, 22 Sep 2016 06:24:48 +0000 (23:24 -0700)
committerWendy Liang <jliang@xilinx.com>
Thu, 13 Oct 2016 05:01:50 +0000 (22:01 -0700)
This patch is to:
* hide hil_proc data struct details from user
* not to introduce new data structure for user to understand

Here is the new flow:
For RPMsg slave:
* proc = hil_create_proc(<hil_proc_ops>)
* hil_set_rpmsg_channel()
* hil_set_ipi()
* remoteproc_resource_init(<rsc_tabl>,<hil_proc>, ...)

For RPMsg master:
* proc = hil_create_proc(<hil_proc_ops>)
* hil_set_rpmsg_channel()
* hil_set_shm()
* hil_set_ipi()
* remoteproc_resource_init(<rsc_tabl>,<hil_proc>, ...)

Signed-off-by: Wendy Liang <jliang@xilinx.com>
12 files changed:
lib/common/hil.c
lib/include/openamp/env.h
lib/include/openamp/hil.h
lib/include/openamp/remoteproc.h
lib/include/openamp/remoteproc_plat.h [deleted file]
lib/include/openamp/rpmsg.h
lib/include/openamp/rpmsg_core.h
lib/remoteproc/CMakeLists.txt
lib/remoteproc/remoteproc.c
lib/remoteproc/remoteproc_plat.c [deleted file]
lib/rpmsg/remote_device.c
lib/rpmsg/rpmsg.c

index 7bf1c727db5d12fb12185d708daed7138f851a10..b522aa2ac31d18635dd0454582f2949dd14c908b 100644 (file)
  **************************************************************************/
 
 #include "openamp/hil.h"
-#include "metal/utilities.h"
+#include <metal/io.h>
+#include <metal/alloc.h>
+#include <metal/device.h>
+#include <metal/shmem.h>
+#include <metal/utilities.h>
+
+#define DEFAULT_VRING_MEM_SIZE 0x10000
 
 /*--------------------------- Globals ---------------------------------- */
 static METAL_DECLARE_LIST (procs);
@@ -57,35 +63,50 @@ unsigned long long shutdown_time_stamp;
 
 #endif
 
-/**
- * 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 the remote processor
- * @param cpu_id - cpu id
- *
- * @return - pointer to proc instance
- *
- */
-struct hil_proc *hil_create_proc(void *pdata, int cpu_id)
+metal_phys_addr_t hil_generic_start_paddr = 0;
+struct metal_io_region hil_shm_generic_io = {
+       0,
+       &hil_generic_start_paddr,
+       (size_t)(-1),
+       (sizeof(metal_phys_addr_t) << 3),
+       (metal_phys_addr_t)(-1),
+       0,
+       {NULL},
+};
+
+struct metal_io_region hil_devmem_generic_io = {
+       0,
+       &hil_generic_start_paddr,
+       (size_t)(-1),
+       (sizeof(metal_phys_addr_t) << 3),
+       (metal_phys_addr_t)(-1),
+       METAL_UNCACHED | METAL_SHARED_MEM,
+       {NULL},
+};
+
+struct hil_proc *hil_create_proc(struct hil_platform_ops *ops,
+                       unsigned long cpu_id, void *pdata)
 {
        struct hil_proc *proc = 0;
-       struct proc_info_hdr *info_hdr = (struct proc_info_hdr *)pdata;
-       struct metal_list *node;
+       int i;
 
-       /* If proc already exists then return it */
-       metal_list_for_each(&procs, node) {
-               proc = metal_container_of(node, struct hil_proc, node);
-               if (proc->cpu_id == (unsigned int)cpu_id) {
-                       return proc;
-               }
-       }
+       proc = metal_allocate_memory(sizeof(struct hil_proc));
+       if (!proc)
+               return NULL;
+       memset(proc, 0, sizeof(struct hil_proc));
 
-       proc = info_hdr->ops->initialize(pdata, cpu_id);
-       if (proc)
-               metal_list_add_tail(&procs, &proc->node);
+       proc->ops = ops;
+       proc->num_chnls = 1;
+       proc->cpu_id = cpu_id;
+       proc->pdata = pdata;
+
+       /* Setup generic shared memory I/O region */
+       proc->sh_buff.io = &hil_shm_generic_io;
+       /* Setup generic vrings I/O region */
+       for (i = 0; i < HIL_MAX_NUM_VRINGS; i++)
+               proc->vdev.vring_info[i].io = &hil_devmem_generic_io;
+
+       metal_list_add_tail(&procs, &proc->node);
 
        return proc;
 }
@@ -102,16 +123,54 @@ struct hil_proc *hil_create_proc(void *pdata, int cpu_id)
 void hil_delete_proc(struct hil_proc *proc)
 {
        struct metal_list *node;
+       struct metal_device *dev;
+       struct metal_io_region *io;
+       struct proc_vring *vring;
+       int i;
        metal_list_for_each(&procs, node) {
                if (proc ==
                        metal_container_of(node, struct hil_proc, node)) {
                        metal_list_del(&proc->node);
                        proc->ops->release(proc);
+                       /* Close shmem device */
+                       dev = proc->sh_buff.dev;
+                       io = proc->sh_buff.io;
+                       if (dev) {
+                               metal_device_close(dev);
+                       } else if (io && io->ops.close) {
+                               io->ops.close(io);
+                       }
+
+                       /* Close vring device */
+                       for (i = 0; i < HIL_MAX_NUM_VRINGS; i++) {
+                               vring = &proc->vdev.vring_info[i];
+                               dev = vring->dev;
+                               io = vring->io;
+                               if (dev) {
+                                       metal_device_close(dev);
+                               } if (io && io->ops.close) {
+                                       io->ops.close(io);
+                               }
+                       }
+
+                       metal_free_memory(proc);
                        return;
                }
        }
 }
 
+int hil_init_proc(struct hil_proc *proc)
+{
+       int ret = 0;
+       if (!proc->is_initialized && proc->ops->initialize) {
+               ret = proc->ops->initialize(proc);
+               if (!ret)
+                       proc->is_initialized = 1;
+               else
+                       return -1;
+       }
+       return 0;
+}
 /**
  * hil_isr()
  *
@@ -127,32 +186,6 @@ void hil_isr(struct proc_vring *vring_hw)
        virtqueue_notification(vring_hw->vq);
 }
 
-/**
- * hil_get_proc
- *
- * This function finds the proc instance based on the given ID
- * from the proc list and returns it to user.
- *
- * @param cpu_id - cpu id
- *
- * @return - pointer to hil proc instance
- *
- */
-struct hil_proc *hil_get_proc(int cpu_id)
-{
-       struct metal_list *node;
-       struct hil_proc *proc;
-
-       metal_list_for_each(&procs, node) {
-               proc = metal_container_of(node, struct hil_proc, node);
-               if (proc->cpu_id == (unsigned int)cpu_id) {
-                       return proc;
-               }
-       }
-
-       return NULL;
-}
-
 /**
  * hil_get_chnl_info
  *
@@ -269,7 +302,7 @@ void hil_vring_notify(struct virtqueue *vq)
            &proc_hw->vdev.vring_info[vq->vq_queue_index];
 
        if (proc_hw->ops->notify) {
-               proc_hw->ops->notify(proc_hw->cpu_id, &vring_hw->intr_info);
+               proc_hw->ops->notify(proc_hw, &vring_hw->intr_info);
        }
 }
 
@@ -324,7 +357,7 @@ int hil_boot_cpu(struct hil_proc *proc, unsigned int start_addr)
 {
 
        if (proc->ops->boot_cpu) {
-               proc->ops->boot_cpu(proc->cpu_id, start_addr);
+               proc->ops->boot_cpu(proc, start_addr);
        }
 #if defined (OPENAMP_BENCHMARK_ENABLE)
        boot_time_stamp = env_get_timestamp();
@@ -344,7 +377,7 @@ int hil_boot_cpu(struct hil_proc *proc, unsigned int start_addr)
 void hil_shutdown_cpu(struct hil_proc *proc)
 {
        if (proc->ops->shutdown_cpu) {
-               proc->ops->shutdown_cpu(proc->cpu_id);
+               proc->ops->shutdown_cpu(proc);
        }
 #if defined (OPENAMP_BENCHMARK_ENABLE)
        shutdown_time_stamp = env_get_timestamp();
@@ -374,3 +407,100 @@ int hil_poll (struct hil_proc *proc, int nonblock)
 {
        return proc->ops->poll(proc, nonblock);
 }
+
+int hil_set_shm (struct hil_proc *proc,
+                const char *bus_name, const char *name,
+                metal_phys_addr_t paddr, size_t size)
+{
+       struct metal_device *dev;
+       struct metal_io_region *io;
+       int ret;
+       if (!proc)
+               return -1;
+       if (name && bus_name) {
+               ret = metal_device_open(bus_name, name, &dev);
+               if (ret)
+                       return ret;
+               io = metal_device_io_region(dev, 0);
+               if (!io)
+                       return -1;
+               proc->sh_buff.io = io;
+               proc->sh_buff.dev = dev;
+       } else if (name) {
+               ret = metal_shmem_open(name, size, &io);
+               if (ret)
+                       return ret;
+               proc->sh_buff.io = io;
+       }
+       if (!paddr && io) {
+               proc->sh_buff.start_paddr = io->physmap[0];
+               proc->sh_buff.start_addr = io->virt;
+       } else {
+               proc->sh_buff.start_paddr = paddr;
+       }
+       if (!size && io)
+               proc->sh_buff.size = io->size;
+       else
+               proc->sh_buff.size = size;
+
+       metal_io_mem_map(proc->sh_buff.start_paddr, proc->sh_buff.io,
+                        proc->sh_buff.size);
+       return 0;
+}
+
+int hil_set_vring (struct hil_proc *proc, int index,
+                const char *bus_name, const char *name)
+{
+       struct metal_device *dev;
+       struct metal_io_region *io;
+       struct proc_vring *vring;
+       int ret;
+
+       if (!proc)
+               return -1;
+       if (index >= HIL_MAX_NUM_VRINGS)
+               return -1;
+       vring = &proc->vdev.vring_info[index];
+       if (name && bus_name) {
+               ret = metal_device_open(bus_name, name, &dev);
+               if (ret)
+                       return ret;
+               io = metal_device_io_region(dev, 0);
+               if (!io)
+                       return -1;
+               vring->io = io;
+               vring->dev = dev;
+       } else if (name) {
+               ret = metal_shmem_open(name, DEFAULT_VRING_MEM_SIZE, &io);
+               if (ret)
+                       return ret;
+               vring->io = io;
+       }
+
+       return 0;
+}
+
+int hil_set_ipi (struct hil_proc *proc, int index,
+                unsigned int irq, void *data)
+{
+       struct proc_intr *vring_intr;
+
+       if (!proc)
+               return -1;
+       vring_intr = &proc->vdev.vring_info[index].intr_info;
+       vring_intr->vect_id = irq;
+       vring_intr->data = data;
+       return 0;
+}
+
+int hil_set_rpmsg_channel (struct hil_proc *proc, int index,
+                          char *name)
+{
+       if (!proc)
+               return -1;
+       if (index >= HIL_MAX_NUM_CHANNELS)
+               return -1;
+       strcpy(proc->chnls[index].name, name);
+       return 0;
+}
+
index 4fbdaa9a61856b70f6a535984bf20bd7f67f1156..a399d89b6f9ede818513b82dbf4e78c9261ac180 100644 (file)
@@ -65,7 +65,7 @@
 #define openamp_print(format, ...) printf(format, ##__VA_ARGS__)
 
 #ifdef OPENAMP_DEBUG
-#define openamp_dbg(format, ...) openamp_print(i"DEBUG: " format, ##__VA_ARGS__)
+#define openamp_dbg(format, ...) openamp_print("DEBUG: " format, ##__VA_ARGS__)
 #else
 #define openamp_dbg(...)
 #endif
index 565629bc897856e1721ba177ca0c2a843a5a7fc9..96c833142a2ecdcf8347d7b89356f649a6cb5e6e 100644 (file)
 /* Reserved CPU id */
 #define HIL_RSVD_CPU_ID                 0xffffffff
 
-/**
- * struct proc_info_hdr
- *
- * This structure is maintained by hardware interface layer
- * for user to pass hardware information to remote processor.
- */
-struct proc_info_hdr {
-       /* CPU ID as defined by the platform */
-       unsigned long cpu_id;
-       /* HIL platform ops table */
-       struct hil_platform_ops *ops;
-};
-
 /**
  * struct proc_shm
  *
@@ -79,8 +66,12 @@ struct proc_info_hdr {
 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. */
@@ -174,7 +165,7 @@ 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;
@@ -186,6 +177,8 @@ struct hil_proc {
        unsigned long num_chnls;
        /* RPMsg channels array */
        struct proc_chnl chnls[HIL_MAX_NUM_CHANNELS];
+       /* Initialized status */
+       int is_initialized;
        /* Attrbites to represent processor role, master or remote . This field is for
         * future use. */
        unsigned long attr;
@@ -196,6 +189,8 @@ struct hil_proc {
        unsigned long cpu_bitmask;
        /* Spin lock - This field is for future use. */
        volatile unsigned int *slock;
+       /* private data */
+       void *pdata;
        /* List node */
        struct metal_list node;
 };
@@ -203,16 +198,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 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
@@ -226,17 +223,15 @@ struct hil_proc *hil_create_proc(void *pdata, int cpu_id);
 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()
@@ -410,6 +405,82 @@ int hil_get_firmware(char *fw_name, uintptr_t *start_addr,
  * @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
@@ -435,58 +506,32 @@ struct hil_platform_ops {
      * 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);
-
-    /**
-     * set_status
-     *
-     * This function is used to update the status
-     * of the given core i.e it is ready for IPC.
-     *
-     * @param cpu_id - ID of CPU for which status is to be set
-     *
-     * @return - execution status
-     */
-
-       int (*set_status) (int cpu_id);
+       void (*notify) (struct hil_proc *proc, struct proc_intr * intr_info);
 
     /**
      * boot_cpu
      *
-     * This function boots the remote processor.
+     * This unction boots the remote processor.
      *
-     * @param cpu_id     - ID of CPU to boot
+     * @param proc - pointer to the hil_proc
      * @param start_addr - start address of remote cpu
      *
      * @return - execution status
      */
-       int (*boot_cpu) (int cpu_id, unsigned int start_addr);
+       int (*boot_cpu) (struct hil_proc *proc, unsigned int start_addr);
 
     /**
      * shutdown_cpu
      *
      *  This function shutdowns the remote processor.
      *
-     * @param cpu_id    - ID of CPU to shutdown
+     * @param proc - pointer to the hil_proc
      *
      */
-       void (*shutdown_cpu) (int cpu_id);
+       void (*shutdown_cpu) (struct hil_proc *proc);
 
     /**
      * poll
@@ -505,13 +550,12 @@ struct hil_platform_ops {
      *
      *  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
index 315869390f12a28ac8c69c6994b8ae0f1cbe46a9..cf80e9809f10fba1f3d450d5fb85c883e2734081 100644 (file)
@@ -364,7 +364,7 @@ struct rsc_table_info {
 
 /* Remoteproc error codes */
 #define RPROC_ERR_BASE                          -4000
-#define RPROC_ERR_CPU_ID                        (RPROC_ERR_BASE -1)
+#define RPROC_ERR_CPU_INIT                      (RPROC_ERR_BASE -1)
 #define RPROC_ERR_NO_RSC_TABLE                  (RPROC_ERR_BASE -2)
 #define RPROC_ERR_NO_MEM                        (RPROC_ERR_BASE -3)
 #define RPROC_ERR_RSC_TAB_TRUNC                 (RPROC_ERR_BASE -4)
@@ -386,7 +386,7 @@ struct rsc_table_info {
  *
  * @param rsc_info          - pointer to resource table info control
  *                            block
- * @param pdata             - platform data for remote processor
+ * @param proc              - pointer to the hil_proc
  * @param channel_created   - callback function for channel creation
  * @param channel_destroyed - callback function for channel deletion
  * @param default_cb        - default callback for channel I/O
@@ -398,7 +398,7 @@ struct rsc_table_info {
  *
  */
 int remoteproc_resource_init(struct rsc_table_info *rsc_info,
-                            void *pdata,
+                           struct hil_proc *proc,
                             rpmsg_chnl_cb_t channel_created,
                             rpmsg_chnl_cb_t channel_destroyed,
                             rpmsg_rx_cb_t default_cb,
@@ -425,7 +425,7 @@ int remoteproc_resource_deinit(struct remote_proc *rproc);
  * remoteproc master applications are allowed to call this function.
  *
  * @param fw_name           - name of firmware
- * @param pdata             - platform data for remote processor
+ * @param proc              - pointer to hil_proc
  * @param channel_created   - callback function for channel creation
  * @param channel_destroyed - callback function for channel deletion
  * @param default_cb        - default callback for channel I/O
@@ -434,7 +434,7 @@ int remoteproc_resource_deinit(struct remote_proc *rproc);
  * @param returns - status of function execution
  *
  */
-int remoteproc_init(char *fw_name, void *pdata,
+int remoteproc_init(char *fw_name, struct hil_proc *proc,
                    rpmsg_chnl_cb_t channel_created,
                    rpmsg_chnl_cb_t channel_destroyed,
                    rpmsg_rx_cb_t default_cb,
diff --git a/lib/include/openamp/remoteproc_plat.h b/lib/include/openamp/remoteproc_plat.h
deleted file mode 100644 (file)
index 457c5f9..0000000
+++ /dev/null
@@ -1,105 +0,0 @@
-#ifndef _REMOTEPROC_PLAT_H_
-#define _REMOTEPROC_PLAT_H_
-
-/*
- * Copyright (c) 2016 Xilinx, Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- *    this list of conditions and the following disclaimer in the documentation
- *    and/or other materials provided with the distribution.
- * 3. Neither the name of the <ORGANIZATION> nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-/**************************************************************************
- * FILE NAME
- *
- *       remoteproc_platform.h
- *
- * DESCRIPTION
- *
- *       This file defines the platform data structure, user can use those
- *       structures to specify platform dependent data. Remoteproc drivers
- *       can use them to get the platform data.
- *
- ***************************************************************************/
-
-#include "openamp/hil.h"
-#include "metal/list.h"
-#include "metal/io.h"
-
-
-/** Platform data resource type */
-enum plat_rsc_type {
-       PLAT_RSC_VRING = 0,
-       PLAT_RSC_SHM = 1,
-       PLAT_RSC_RPMSG_CHANNEL = 2,
-       PLAT_RSC_LAST = 3,
-};
-
-/** vring data structure */
-struct plat_vring {
-       unsigned int type;
-       char *ipi_bus_name;
-       char *ipi_dev_name;
-       void *ipi_dev_data;
-       char *vdev_bus_name;
-       char *vdev_name;
-};
-
-/** shared memory structure */
-struct plat_shm {
-       unsigned int type;
-       char *shm_name;
-       size_t size;
-};
-
-/** RPMSG channel structure */
-struct plat_rpmsg_chnl {
-       unsigned int type;
-       char *name;
-};
-
-/**
- * rproc_init_plat_data
- *
- * setup remoteproc common data based on the input platform data.
- *
- * @param[in] pdata    - input platform data
- * @param[in] proc      - hil proc to set with the platform data
- *
- * @returns - 0 for success, non-zero for errors.
- *
- */
-int rproc_init_plat_data(void *pdata, struct hil_proc *proc);
-
-/**
- * rproc_close_plat
- *
- * close remoteproc platform resource
- *
- * @param[in] proc      - hil proc which holds the platform data
- *
- */
-void rproc_close_plat(struct hil_proc *proc);
-
-#endif                         /* _REMOTEPROC_PLAT_H_ */
index b126ffc2a256f4882ec48588589a98a3216b9893..022cfd1b2c1cbbd410289163e1ab437b6cc0993e 100644 (file)
@@ -319,13 +319,11 @@ static inline int rpmsg_trysend_offchannel(struct rpmsg_channel *rpdev,
 /**
  * rpmsg_init
  *
- * Thus function allocates and initializes the rpmsg driver resources for given
- * device id (cpu id).The successful return from this function leaves
+ * Thus function allocates and initializes the rpmsg driver resources for
+ * the given hil_proc.The successful return from this function leaves
  * fully enabled IPC link.
  *
- * @param pdata             - platform data for remote processor
- * @param dev_id            - rpmsg remote device for which driver is to
- *                            be initialized
+ * @param proc              - pointer to hil_proc
  * @param rdev              - pointer to newly created remote device
  * @param channel_created   - callback function for channel creation
  * @param channel_destroyed - callback function for channel deletion
@@ -335,7 +333,8 @@ static inline int rpmsg_trysend_offchannel(struct rpmsg_channel *rpdev,
  *
  */
 
-int rpmsg_init(void *pdata, int dev_id, struct remote_device **rdev,
+int rpmsg_init(struct hil_proc *proc,
+              struct remote_device **rdev,
               rpmsg_chnl_cb_t channel_created,
               rpmsg_chnl_cb_t channel_destroyed,
               rpmsg_rx_cb_t default_cb, int role);
index 3cc68ec562c1fa3299357f593250e861491b72cb..0923e2409e8135a60f29b5a1e5ddc9bbb1808130 100644 (file)
@@ -76,7 +76,7 @@
 #define RPMSG_ERR_PARAM                         (RPMSG_ERROR_BASE - 4)
 #define RPMSG_ERR_DEV_STATE                     (RPMSG_ERROR_BASE - 5)
 #define RPMSG_ERR_BUFF_SIZE                     (RPMSG_ERROR_BASE - 6)
-#define RPMSG_ERR_DEV_ID                        (RPMSG_ERROR_BASE - 7)
+#define RPMSG_ERR_DEV_INIT                      (RPMSG_ERROR_BASE - 7)
 #define RPMSG_ERR_DEV_ADDR                      (RPMSG_ERROR_BASE - 8)
 
 #if (RPMSG_DEBUG == true)
@@ -162,7 +162,8 @@ void rpmsg_ns_callback(struct rpmsg_channel *server_chnl,
                       void *data, int len, void *priv, unsigned long src);
 
 /* Remote device functions */
-int rpmsg_rdev_init(void *pdata, struct remote_device **rdev, int dev_id, int role,
+int rpmsg_rdev_init(struct hil_proc *proc,
+                   struct remote_device **rdev, int role,
                    rpmsg_chnl_cb_t channel_created,
                    rpmsg_chnl_cb_t channel_destroyed,
                    rpmsg_rx_cb_t default_cb);
index 3b54d7847e1eb941055eeb949dd93446e67b4e23..acd240ae7672d9a0c9ba778f8b3ceb553f20da67 100644 (file)
@@ -2,5 +2,4 @@ collect (PROJECT_LIB_SOURCES elf_loader.c)
 collect (PROJECT_LIB_SOURCES remoteproc.c)
 collect (PROJECT_LIB_SOURCES remoteproc_loader.c)
 collect (PROJECT_LIB_SOURCES rsc_table_parser.c)
-collect (PROJECT_LIB_SOURCES remoteproc_plat.c)
 add_subdirectory (drivers)
index f933bdafa166fdb4d50908103eeccf3b26e180a8..50fb8c6b6bf33455aa1b361c6df420260bbef6d4 100644 (file)
@@ -45,7 +45,7 @@
  *
  * @param rsc_info          - pointer to resource table info control
  *                                                       block
- * @param pdata             - platform data for remote processor
+ * @param proc              - pointer to the hil_proc
  * @param channel_created   - callback function for channel creation
  * @param channel_destroyed - callback function for channel deletion
  * @param default_cb        - default callback for channel I/O
@@ -56,7 +56,7 @@
  *
  */
 int remoteproc_resource_init(struct rsc_table_info *rsc_info,
-                            void *pdata,
+                            struct hil_proc *proc,
                             rpmsg_chnl_cb_t channel_created,
                             rpmsg_chnl_cb_t channel_destroyed,
                             rpmsg_rx_cb_t default_cb,
@@ -68,7 +68,7 @@ int remoteproc_resource_init(struct rsc_table_info *rsc_info,
        int status;
        int remote_rpmsg_role;
 
-       if (!rsc_info) {
+       if (!rsc_info || !proc) {
                return RPROC_ERR_PARAM;
        }
 
@@ -77,8 +77,9 @@ int remoteproc_resource_init(struct rsc_table_info *rsc_info,
                memset(rproc, 0x00, sizeof(struct remote_proc));
                /* There can be only one master for remote configuration so use the
                 * rsvd cpu id for creating hil proc */
-               rproc->proc = hil_create_proc(pdata, HIL_RSVD_CPU_ID);
-               if (rproc->proc) {
+               rproc->proc = proc;
+               status = hil_init_proc(proc);
+               if (!status) {
                        /* Parse resource table */
                        status =
                            handle_rsc_table(rproc, rsc_info->rsc_tab,
@@ -89,7 +90,7 @@ int remoteproc_resource_init(struct rsc_table_info *rsc_info,
                                remote_rpmsg_role = (rpmsg_role == RPMSG_MASTER?
                                                RPMSG_REMOTE : RPMSG_MASTER);
                                status =
-                                   rpmsg_init(NULL, rproc->proc->cpu_id,
+                                   rpmsg_init(proc,
                                               &rproc->rdev, channel_created,
                                               channel_destroyed, default_cb,
                                               remote_rpmsg_role);
@@ -97,7 +98,7 @@ int remoteproc_resource_init(struct rsc_table_info *rsc_info,
                                status = RPROC_ERR_NO_RSC_TABLE;
                        }
                } else {
-                       status = RPROC_ERR_CPU_ID;
+                       status = RPROC_ERR_CPU_INIT;
                }
        } else {
                status = RPROC_ERR_NO_MEM;
@@ -142,7 +143,7 @@ int remoteproc_resource_deinit(struct remote_proc *rproc)
  * remoteproc master applications are allowed to call this function.
  *
  * @param fw_name           - name of frimware
- * @param pdata             - platform data for remote processor
+ * @param proc              - pointer to hil_proc
  * @param channel_created   - callback function for channel creation
  * @param channel_destroyed - callback function for channel deletion
  * @param default_cb        - default callback for channel I/O
@@ -151,7 +152,7 @@ int remoteproc_resource_deinit(struct remote_proc *rproc)
  * @param returns - status of function execution
  *
  */
-int remoteproc_init(char *fw_name, void *pdata,
+int remoteproc_init(char *fw_name, struct hil_proc *proc,
                    rpmsg_chnl_cb_t channel_created,
                    rpmsg_chnl_cb_t channel_destroyed, rpmsg_rx_cb_t default_cb,
                    struct remote_proc **rproc_handle)
@@ -171,8 +172,8 @@ int remoteproc_init(char *fw_name, void *pdata,
        if (rproc) {
                memset((void *)rproc, 0x00, sizeof(struct remote_proc));
                /* Create proc instance */
-               rproc->proc = hil_create_proc(pdata, HIL_RSVD_CPU_ID);
-               if (rproc->proc) {
+               status = hil_init_proc(proc);
+               if (!status) {
                        /* Retrieve firmware attributes */
                        status =
                            hil_get_firmware(fw_name, &fw_addr,
@@ -192,7 +193,7 @@ int remoteproc_init(char *fw_name, void *pdata,
                                }
                        }
                } else {
-                       status = RPROC_ERR_NO_MEM;
+                       status = RPROC_ERR_CPU_INIT;
                }
        } else {
                status = RPROC_ERR_NO_MEM;
@@ -301,14 +302,14 @@ int remoteproc_boot(struct remote_proc *rproc)
                                   configuration only. */
 #if defined (OPENAMP_REMOTE_LINUX_ENABLE)
                                status =
-                                   rpmsg_init(NULL, rproc->proc->cpu_id,
+                                   rpmsg_init(rproc->proc,
                                               &rproc->rdev,
                                               rproc->channel_created,
                                               rproc->channel_destroyed,
                                               rproc->default_cb, RPMSG_MASTER);
 #else
                                status =
-                                   rpmsg_init(NULL, rproc->proc->cpu_id,
+                                   rpmsg_init(rproc->proc,
                                               &rproc->rdev,
                                               rproc->channel_created,
                                               rproc->channel_destroyed,
diff --git a/lib/remoteproc/remoteproc_plat.c b/lib/remoteproc/remoteproc_plat.c
deleted file mode 100644 (file)
index decfab0..0000000
+++ /dev/null
@@ -1,172 +0,0 @@
-/*
- * Copyright (c) 2016 Xilinx, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- *    this list of conditions and the following disclaimer in the documentation
- *    and/or other materials provided with the distribution.
- * 3. Neither the name of Mentor Graphics Corporation nor the names of its
- *    contributors may be used to endorse or promote products derived from this
- *    software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <string.h>
-#include "openamp/hil.h"
-#include "openamp/remoteproc_plat.h"
-#include "metal/device.h"
-#include "metal/io.h"
-#include "metal/shmem.h"
-
-/**
- * rproc_platform_open_metal_dev
- *
- * Open metal device and get the I/O region
- *
- * @param[in]  bus_name - metal device bus name
- * @param[in]  dev_name - metal device name
- * @param[out] dev - return metal device handle
- * @param[out] io - return metal device I/O region
- *
- * @return - 0 for success, non-zero for errors.
- */
-static int rproc_plat_open_metal_dev(char *bus_name, char *dev_name,
-                                    struct metal_device **dev,
-                                    struct metal_io_region **io)
-{
-       int ret;
-       ret = metal_device_open(bus_name, dev_name, dev);
-       if (ret)
-               return ret;
-       *io = metal_device_io_region(*dev, 0);
-       if (!(*io)) {
-               metal_device_close(*dev);
-               *dev = 0;
-               return -1;
-       }
-       return 0;
-}
-
-int rproc_init_plat_data(void *pdata,
-                            struct hil_proc *proc)
-{
-       unsigned int type;
-       struct metal_device *dev;
-       struct metal_io_region *io;
-       int num_vrings = 0;
-       int num_rpmsg_chnls = 0;
-       int ret;
-
-       if (!proc || !pdata)
-               return -1;
-       memcpy(proc, pdata, sizeof(struct proc_info_hdr));
-
-       pdata += sizeof(struct proc_info_hdr);
-       while(1) {
-               type = *((unsigned int *)pdata);
-               if (type > PLAT_RSC_LAST) {
-                       return -1;
-               } else if (type == PLAT_RSC_LAST) {
-                       proc->vdev.num_vrings = num_vrings;
-                       proc->num_chnls = num_rpmsg_chnls;
-                       return 0;
-               } else if (type == PLAT_RSC_VRING) {
-                       struct plat_vring *pvring =
-                               (struct plat_vring *)pdata;
-                       struct proc_vring *vring = 
-                               &proc->vdev.vring_info[num_vrings];
-                       /* Open the vring IPI device */
-                       if (pvring->ipi_dev_name) {
-                               ret = rproc_plat_open_metal_dev(
-                                               pvring->ipi_bus_name,
-                                               pvring->ipi_dev_name,
-                                               &dev, &io);
-                               if (ret)
-                                       return ret;
-                               vring->intr_info.dev = dev;
-                               vring->intr_info.io = io;
-                               vring->intr_info.vect_id =
-                                       (uintptr_t)dev->irq_info;
-                       }
-                       vring->intr_info.data = pvring->ipi_dev_data;
-                       /* Open the vring descriptor memory device */
-                       if (pvring->vdev_name) {
-                               ret = rproc_plat_open_metal_dev(
-                                               pvring->vdev_bus_name,
-                                               pvring->vdev_name,
-                                               &dev, &io);
-                               if (ret)
-                                       return ret;
-                               vring->dev = dev;
-                               vring->io = io;
-                       }
-                       num_vrings++;
-                       pdata += sizeof(struct plat_vring);
-               } else if (type == PLAT_RSC_SHM) {
-                       struct plat_shm *pshm =
-                               (struct plat_shm *)pdata;
-                       /* Open the shared memory device */
-                       ret = metal_shmem_open(pshm->shm_name,
-                                               pshm->size,
-                                               &io);
-                       if (ret)
-                               return ret;
-                       proc->sh_buff.io = io;
-                       if (io->size != (size_t)(-1)) {
-                               metal_io_mem_map(
-                                       metal_io_virt_to_phys(io, io->virt),
-                                       io, io->size);
-                               proc->sh_buff.start_addr = io->virt;
-                               proc->sh_buff.size = io->size;
-                       }
-                       pdata += sizeof(struct plat_shm);
-               } else if (type == PLAT_RSC_RPMSG_CHANNEL) {
-                       struct plat_rpmsg_chnl *pchl =
-                               (struct plat_rpmsg_chnl *)pdata;
-                       strcpy(proc->chnls[num_rpmsg_chnls].name, pchl->name);
-                       num_rpmsg_chnls++;
-                       pdata += sizeof(struct plat_rpmsg_chnl);
-               }
-       }
-
-}
-
-void rproc_close_plat(struct hil_proc *proc)
-{
-       if (!proc)
-               return;
-       int i;
-       int num_vrings = proc->vdev.num_vrings;
-       struct metal_device *dev;
-       struct proc_vring *vring;
-
-       /* Close the vrings devices */
-       for (i = 0; i < num_vrings; i++) {
-               vring = &proc->vdev.vring_info[i];
-               dev = vring->dev;
-               if (dev) {
-                       metal_device_close(dev);
-                       vring->dev = NULL;
-               }
-               dev = vring->intr_info.dev;
-               if (dev) {
-                       metal_device_close(dev);
-                       vring->intr_info.dev = NULL;
-               }
-       }
-}
index 746e681c2b2a29368cb92cb26e1611fac0c4ed81..d0828c7db51f754ed3d630faf4fe846e826a7a30 100644 (file)
@@ -79,9 +79,8 @@ virtio_dispatch rpmsg_rdev_config_ops = {
  * This function creates and initializes the remote device. The remote device
  * encapsulates virtio device.
  *
- * @param pdata             - platform data for remote processor
+ * @param proc              - pointer to hil_proc
  * @param rdev              - pointer to newly created remote device
- * @param dev-id            - ID of device to create , remote cpu id
  * @param role              - role of the other device, Master or Remote
  * @param channel_created   - callback function for channel creation
  * @param channel_destroyed - callback function for channel deletion
@@ -90,23 +89,22 @@ virtio_dispatch rpmsg_rdev_config_ops = {
  * @return - status of function execution
  *
  */
-int rpmsg_rdev_init(void *pdata, struct remote_device **rdev, int dev_id, int role,
+int rpmsg_rdev_init(struct hil_proc *proc,
+                   struct remote_device **rdev, int role,
                    rpmsg_chnl_cb_t channel_created,
                    rpmsg_chnl_cb_t channel_destroyed, rpmsg_rx_cb_t default_cb)
 {
 
        struct remote_device *rdev_loc;
        struct virtio_device *virt_dev;
-       struct hil_proc *proc;
        struct proc_shm *shm;
        int status;
 
+       if (!proc)
+               return RPMSG_ERR_PARAM;
        /* Initialize HIL data structures for given device */
-       proc = hil_create_proc(pdata, dev_id);
-
-       if (!proc) {
-               return RPMSG_ERR_DEV_ID;
-       }
+       if (hil_init_proc(proc))
+               return RPMSG_ERR_DEV_INIT;
 
        /* Create software representation of remote processor. */
        rdev_loc = (struct remote_device *)metal_allocate_memory(sizeof(struct remote_device));
index 595ad5e69217afbf7d4f22ce36fb6c15fb38a25d..0bf3b58fb10872fbf0a952f7c76eb58a7baf549b 100644 (file)
  * rpmsg_init
  *
  * Thus function allocates and initializes the rpmsg driver resources for
- * given device ID(cpu id). The successful return from this function leaves
+ * given hil_proc. The successful return from this function leaves
  * fully enabled IPC link.
  *
- * @param pdata             - platform data for remote processor
- * @param dev_id            - remote device for which driver is to
- *                            be initialized
+ * @param proc              - pointer to hil_proc
  * @param rdev              - pointer to newly created remote device
  * @param channel_created   - callback function for channel creation
  * @param channel_destroyed - callback function for channel deletion
@@ -78,7 +76,8 @@
  *
  */
 
-int rpmsg_init(void *pdata, int dev_id, struct remote_device **rdev,
+int rpmsg_init(struct hil_proc *proc,
+              struct remote_device **rdev,
               rpmsg_chnl_cb_t channel_created,
               rpmsg_chnl_cb_t channel_destroyed,
               rpmsg_rx_cb_t default_cb, int role)
@@ -86,7 +85,8 @@ int rpmsg_init(void *pdata, int dev_id, struct remote_device **rdev,
        int status;
 
        /* Initialize the remote device for given cpu id */
-       status = rpmsg_rdev_init(pdata, rdev, dev_id, role, channel_created,
+       status = rpmsg_rdev_init(proc, rdev, role,
+                                channel_created,
                                 channel_destroyed, default_cb);
        if (status == RPMSG_SUCCESS) {
                /* Kick off IPC with the remote device */