]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - processor-sdk/open-amp.git/blobdiff - lib/remoteproc/remoteproc.c
Delete hil proc in remoteproc only
[processor-sdk/open-amp.git] / lib / remoteproc / remoteproc.c
index c6103c81f8949ae4c936afa9a6de524ded05b17d..ced4eef662e170e032c79123c992a8b0de4ad131 100644 (file)
@@ -35,6 +35,8 @@
 #include "openamp/env.h"
 #include "openamp/hil.h"
 #include "metal/sys.h"
+#include "metal/alloc.h"
+#include "metal/sleep.h"
 
 /**
  * remoteproc_resource_init
@@ -44,7 +46,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
@@ -55,7 +57,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,
@@ -67,17 +69,18 @@ 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;
        }
 
-       rproc = env_allocate_memory(sizeof(struct remote_proc));
+       rproc = metal_allocate_memory(sizeof(struct remote_proc));
        if (rproc) {
                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,
@@ -88,7 +91,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);
@@ -96,7 +99,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;
@@ -130,25 +133,11 @@ int remoteproc_resource_deinit(struct remote_proc *rproc)
                }
                if (rproc->proc) {
                        hil_delete_proc(rproc->proc);
+                       rproc->proc = NULL;
                }
-
-               env_free_memory(rproc);
+               metal_free_memory(rproc);
        }
 
-       metal_finish();
-
-       /*
-        * Flush and Invalidate the caches - When the application is built with
-        * Xilinx Standalone BSP, caches are invalidated as part of boot process.
-        * Even if the master boots firmware multiple times without hard reset on
-        * same core, caches are flushed and invalidated at the end of
-        * remoteproc_resource_deinit for this run and caches would be again
-        * invalidated before starting the main thread of the application on next
-        * run to avoid any cache inconsistencies.
-        */
-        env_flush_invalidate_all_caches();
-
-
        return RPROC_SUCCESS;
 }
 
@@ -159,7 +148,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
@@ -168,7 +157,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)
@@ -176,19 +165,20 @@ int remoteproc_init(char *fw_name, void *pdata,
 
        struct remote_proc *rproc;
        struct resource_table *rsc_table;
-       unsigned int fw_addr, fw_size, rsc_size;
+       unsigned int fw_size, rsc_size;
+       uintptr_t fw_addr;
        int status;
 
        if (!fw_name) {
                return RPROC_ERR_PARAM;
        }
 
-       rproc = env_allocate_memory(sizeof(struct remote_proc));
+       rproc = metal_allocate_memory(sizeof(struct remote_proc));
        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,
@@ -208,7 +198,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;
@@ -266,11 +256,9 @@ int remoteproc_deinit(struct remote_proc *rproc)
                        hil_delete_proc(rproc->proc);
                        rproc->proc = RPROC_NULL;
                }
-               env_free_memory(rproc);
+               metal_free_memory(rproc);
        }
 
-       metal_finish();
-
        return RPROC_SUCCESS;
 }
 
@@ -304,11 +292,11 @@ int remoteproc_boot(struct remote_proc *rproc)
                if (load_addr != RPROC_ERR_PTR) {
                        /* Start the remote cpu */
                        status = hil_boot_cpu(rproc->proc,
-                                             (unsigned int)load_addr);
+                                             (uintptr_t)load_addr);
                        if (status == RPROC_SUCCESS) {
                                /* Wait for remote side to come up. This delay is arbitrary and may
                                 * need adjustment for different configuration of remote systems */
-                               env_sleep_msec(RPROC_BOOT_DELAY);
+                               metal_sleep_usec(RPROC_BOOT_DELAY);
 
                                /* Initialize RPMSG "messaging" component */
 
@@ -319,14 +307,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,
@@ -356,12 +344,13 @@ int remoteproc_shutdown(struct remote_proc *rproc)
 {
 
        if (rproc) {
+               if (rproc->proc) {
+                       hil_shutdown_cpu(rproc->proc);
+               }
                if (rproc->rdev) {
                        rpmsg_deinit(rproc->rdev);
                        rproc->rdev = RPROC_NULL;
-               }
-               if (rproc->proc) {
-                       hil_shutdown_cpu(rproc->proc);
+                       rproc->proc = RPROC_NULL;
                }
        }