index bce24f0b114619c33eedfacfde74aef627235d27..ced4eef662e170e032c79123c992a8b0de4ad131 100644 (file)
#include "openamp/env.h"
#include "openamp/hil.h"
#include "metal/sys.h"
+#include "metal/alloc.h"
+#include "metal/sleep.h"
/**
* remoteproc_resource_init
*
* @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
* @param rproc_handle - pointer to new remoteproc instance
+ * @param rpmsg_role - 1 for rpmsg master, or 0 for rpmsg slave
*
* @param returns - status of function execution
*
*/
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,
- struct remote_proc **rproc_handle)
+ struct remote_proc **rproc_handle,
+ int rpmsg_role)
{
struct remote_proc *rproc;
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,
if (status == RPROC_SUCCESS) {
/* Initialize RPMSG "messaging" component */
*rproc_handle = rproc;
+ 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,
- RPMSG_MASTER);
+ remote_rpmsg_role);
} else {
status = RPROC_ERR_NO_RSC_TABLE;
}
} else {
- status = RPROC_ERR_CPU_ID;
+ status = RPROC_ERR_CPU_INIT;
}
} else {
status = RPROC_ERR_NO_MEM;
}
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;
}
* 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
* @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)
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,
}
}
} else {
- status = RPROC_ERR_NO_MEM;
+ status = RPROC_ERR_CPU_INIT;
}
} else {
status = RPROC_ERR_NO_MEM;
hil_delete_proc(rproc->proc);
rproc->proc = RPROC_NULL;
}
- env_free_memory(rproc);
+ metal_free_memory(rproc);
}
- metal_finish();
-
return RPROC_SUCCESS;
}
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 */
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,
{
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;
}
}