summaryrefslogtreecommitdiff
path: root/middleware/multicore/open-amp/porting
diff options
context:
space:
mode:
authorStefan Agner <stefan.agner@toradex.com>2016-01-12 14:06:54 -0800
committerStefan Agner <stefan.agner@toradex.com>2016-01-12 14:06:54 -0800
commita57cc2c988482010061b9e68344fdf1969889763 (patch)
tree5c050337492ce27c09b47421b123980b5a79f8d9 /middleware/multicore/open-amp/porting
initial commit, FreeRTOS_BSP_1.0.0_iMX7D
Diffstat (limited to 'middleware/multicore/open-amp/porting')
-rw-r--r--middleware/multicore/open-amp/porting/config/config.c48
-rw-r--r--middleware/multicore/open-amp/porting/config/config.h51
-rw-r--r--middleware/multicore/open-amp/porting/env/env.h431
-rw-r--r--middleware/multicore/open-amp/porting/env/freertos_env.c461
-rw-r--r--middleware/multicore/open-amp/porting/imx7d_m4/plat_porting.h50
-rw-r--r--middleware/multicore/open-amp/porting/imx7d_m4/platform.c115
-rw-r--r--middleware/multicore/open-amp/porting/imx7d_m4/platform.h41
-rw-r--r--middleware/multicore/open-amp/porting/imx7d_m4/platform_info.c245
8 files changed, 1442 insertions, 0 deletions
diff --git a/middleware/multicore/open-amp/porting/config/config.c b/middleware/multicore/open-amp/porting/config/config.c
new file mode 100644
index 0000000..fe29d72
--- /dev/null
+++ b/middleware/multicore/open-amp/porting/config/config.c
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2014, Mentor Graphics Corporation
+ * 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.
+ */
+
+/**************************************************************************
+ * FILE NAME
+ *
+ * config.c
+ *
+ * COMPONENT
+ *
+ * OpenAMP stack.
+ *
+ * DESCRIPTION
+ *
+ *
+ **************************************************************************/
+
+#include "config.h"
+
+int config_get_firmware(char *fw_name, unsigned int *start_addr, unsigned int *size) {
+ return -1;
+}
diff --git a/middleware/multicore/open-amp/porting/config/config.h b/middleware/multicore/open-amp/porting/config/config.h
new file mode 100644
index 0000000..23bc36f
--- /dev/null
+++ b/middleware/multicore/open-amp/porting/config/config.h
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2014, Mentor Graphics Corporation
+ * 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.
+ */
+
+#ifndef CONFIG_H
+#define CONFIG_H
+
+#include "../env/env.h"
+
+/* Max supprted ISR counts */
+#define ISR_COUNT 2
+
+/**
+ * Structure to keep track of registered ISR's.
+ */
+struct isr_info {
+ int vector;
+ int priority;
+ int type;
+ void *data;
+ void (*isr)(int vector, void *data);
+};
+
+int config_get_firmware(char *fw_name, unsigned int *start_addr, unsigned int *size);
+
+#endif
diff --git a/middleware/multicore/open-amp/porting/env/env.h b/middleware/multicore/open-amp/porting/env/env.h
new file mode 100644
index 0000000..05b9e62
--- /dev/null
+++ b/middleware/multicore/open-amp/porting/env/env.h
@@ -0,0 +1,431 @@
+/*
+ * Copyright (c) 2014, Mentor Graphics Corporation
+ * All rights reserved.
+ * Copyright (c) 2015 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.
+ */
+
+ /**************************************************************************
+ * FILE NAME
+ *
+ * env.h
+ *
+ * COMPONENT
+ *
+ * OpenAMP stack.
+ *
+ * DESCRIPTION
+ *
+ * This file defines abstraction layer for OpenAMP stack. The implementor
+ * must provide definition of all the functions.
+ *
+ * DATA STRUCTURES
+ *
+ * none
+ *
+ * FUNCTIONS
+ *
+ * env_allocate_memory
+ * env_free_memory
+ * env_memset
+ * env_memcpy
+ * env_strlen
+ * env_strcpy
+ * env_strncpy
+ * env_print
+ * env_map_vatopa
+ * env_map_patova
+ * env_mb
+ * env_rmb
+ * env_wmb
+ * env_create_mutex
+ * env_delete_mutex
+ * env_lock_mutex
+ * env_unlock_mutex
+ * env_sleep_msec
+ * env_disable_interrupts
+ * env_restore_interrupts
+ *
+ **************************************************************************/
+#ifndef _ENV_H_
+#define _ENV_H_
+
+#include <FreeRTOS.h>
+#include <task.h>
+#include "device_imx.h"
+#include "debug_console_imx.h"
+/**
+ * env_init
+ *
+ * Initializes OS/BM environment.
+ *
+ * @returns - execution status
+ */
+
+int env_init(void);
+
+/**
+ * env_deinit
+ *
+ * Uninitializes OS/BM environment.
+ *
+ * @returns - execution status
+ */
+
+int env_deinit(void);
+/**
+ * -------------------------------------------------------------------------
+ *
+ * Dynamic memory management functions. The parameters
+ * are similar to standard c functions.
+ *
+ *-------------------------------------------------------------------------
+ **/
+
+/**
+ * env_allocate_memory
+ *
+ * Allocates memory with the given size.
+ *
+ * @param size - size of memory to allocate
+ *
+ * @return - pointer to allocated memory
+ */
+void *env_allocate_memory(unsigned int size);
+
+/**
+ * env_free_memory
+ *
+ * Frees memory pointed by the given parameter.
+ *
+ * @param ptr - pointer to memory to free
+ */
+void env_free_memory(void *ptr);
+
+/**
+ * -------------------------------------------------------------------------
+ *
+ * RTL Functions
+ *
+ *-------------------------------------------------------------------------
+ */
+
+void env_memset(void *, int, unsigned long);
+void env_memcpy(void *, void const *, unsigned long);
+size_t env_strlen(const char *);
+void env_strcpy(char *, const char *);
+int env_strcmp(const char *, const char *);
+void env_strncpy(char *, const char *, unsigned long);
+int env_strncmp(char *, const char *, unsigned long);
+#define env_print(...) PRINTF(__VA_ARGS__)
+
+/**
+ *-----------------------------------------------------------------------------
+ *
+ * Functions to convert physical address to virtual address and vice versa.
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+/**
+ * env_map_vatopa
+ *
+ * Converts logical address to physical address
+ *
+ * @param address - pointer to logical address
+ *
+ * @return - physical address
+ */
+unsigned long env_map_vatopa(void *address);
+
+/**
+ * env_map_patova
+ *
+ * Converts physical address to logical address
+ *
+ * @param address - pointer to physical address
+ *
+ * @return - logical address
+ *
+ */
+void *env_map_patova(unsigned long address);
+
+/**
+ *-----------------------------------------------------------------------------
+ *
+ * Abstractions for memory barrier instructions.
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+/**
+ * env_mb
+ *
+ * Inserts memory barrier.
+ */
+
+void env_mb(void);
+
+/**
+ * env_rmb
+ *
+ * Inserts read memory barrier
+ */
+
+void env_rmb(void);
+
+/**
+ * env_wmb
+ *
+ * Inserts write memory barrier
+ */
+
+void env_wmb(void);
+
+/**
+ *-----------------------------------------------------------------------------
+ *
+ * Abstractions for OS lock primitives.
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+/**
+ * env_create_mutex
+ *
+ * Creates a mutex with given initial count.
+ *
+ * @param lock - pointer to created mutex
+ * @param count - initial count 0 or 1
+ *
+ * @return - status of function execution
+ */
+int env_create_mutex(void **lock , int count);
+
+/**
+ * env_delete_mutex
+ *
+ * Deletes the given lock.
+ *
+ * @param lock - mutex to delete
+ */
+
+void env_delete_mutex(void *lock);
+
+/**
+ * env_lock_mutex
+ *
+ * Tries to acquire the lock, if lock is not available then call to
+ * this function will suspend.
+ *
+ * @param lock - mutex to lock
+ *
+ */
+
+void env_lock_mutex(void *lock);
+
+/**
+ * env_unlock_mutex
+ *
+ * Releases the given lock.
+ *
+ * @param lock - mutex to unlock
+ */
+
+void env_unlock_mutex(void *lock);
+
+/**
+ * env_create_sync_lock
+ *
+ * Creates a synchronization lock primitive. It is used
+ * when signal has to be sent from the interrupt context to main
+ * thread context.
+ *
+ * @param lock - pointer to created sync lock object
+ * @param state - initial state , lock or unlocked
+ *
+ * @returns - status of function execution
+ */
+#define LOCKED 0
+#define UNLOCKED 1
+
+int env_create_sync_lock(void **lock , int state);
+
+/**
+ * env_create_sync_lock
+ *
+ * Deletes given sync lock object.
+ *
+ * @param lock - sync lock to delete.
+ *
+ */
+
+void env_delete_sync_lock(void *lock);
+
+
+/**
+ * env_acquire_sync_lock
+ *
+ * Tries to acquire the sync lock.
+ *
+ * @param lock - sync lock to acquire.
+ */
+void env_acquire_sync_lock(void *lock);
+
+/**
+ * env_release_sync_lock
+ *
+ * Releases synchronization lock.
+ *
+ * @param lock - sync lock to release.
+ */
+void env_release_sync_lock(void *lock);
+
+/**
+ * env_sleep_msec
+ *
+ * Suspends the calling thread for given time in msecs.
+ *
+ * @param num_msec - delay in msecs
+ */
+void env_sleep_msec(int num_msec);
+
+/**
+ * env_disable_interrupts
+ *
+ * Disables system interrupts
+ *
+ */
+void env_disable_interrupts(void);
+
+/**
+ * env_restore_interrupts
+ *
+ * Enables system interrupts
+ *
+ */
+void env_restore_interrupts(void);
+
+/**
+ * env_register_isr
+ *
+ * Registers interrupt handler for the given interrupt vector.
+ *
+ * @param vector - interrupt vector number
+ * @param data - private data
+ * @param isr - interrupt handler
+ */
+
+void env_register_isr(int vector, void *data,
+ void (*isr)(int vector, void *data));
+
+void env_update_isr(int vector, void *data,
+ void (*isr)(int vector, void *data));
+
+/**
+ * env_enable_interrupt
+ *
+ * Enables the given interrupt.
+ *
+ * @param vector - interrupt vector number
+ * @param priority - interrupt priority
+ * @param polarity - interrupt polarity
+ */
+
+void env_enable_interrupt(unsigned int vector, unsigned int priority,
+ unsigned int polarity);
+
+/**
+ * env_disable_interrupt
+ *
+ * Disables the given interrupt.
+ *
+ * @param vector - interrupt vector number
+ */
+
+void env_disable_interrupt(unsigned int vector);
+
+/**
+ * env_map_memory
+ *
+ * Enables memory mapping for given memory region.
+ *
+ * @param pa - physical address of memory
+ * @param va - logical address of memory
+ * @param size - memory size
+ * param flags - flags for cache/uncached and access type
+ *
+ * Currently only first byte of flag parameter is used and bits mapping is defined as follow;
+ *
+ * Cache bits
+ * 0x0000_0001 = No cache
+ * 0x0000_0010 = Write back
+ * 0x0000_0100 = Write through
+ * 0x0000_x000 = Not used
+ *
+ * Memory types
+ *
+ * 0x0001_xxxx = Memory Mapped
+ * 0x0010_xxxx = IO Mapped
+ * 0x0100_xxxx = Shared
+ * 0x1000_xxxx = TLB
+ */
+
+/* Macros for caching scheme used by the shared memory */
+#define UNCACHED (1 << 0)
+#define WB_CACHE (1 << 1)
+#define WT_CACHE (1 << 2)
+
+/* Memory Types */
+#define MEM_MAPPED (1 << 4)
+#define IO_MAPPED (1 << 5)
+#define SHARED_MEM (1 << 6)
+#define TLB_MEM (1 << 7)
+
+void env_map_memory(unsigned int pa, unsigned int va, unsigned int size,
+ unsigned int flags);
+
+/**
+ * env_get_timestamp
+ *
+ * Returns a 64 bit time stamp.
+ *
+ *
+ */
+unsigned long long env_get_timestamp(void);
+
+/**
+ * env_disable_cache
+ *
+ * Disables system caches.
+ *
+ */
+
+void env_disable_cache(void);
+
+typedef void LOCK;
+
+#endif /* _ENV_H_ */
diff --git a/middleware/multicore/open-amp/porting/env/freertos_env.c b/middleware/multicore/open-amp/porting/env/freertos_env.c
new file mode 100644
index 0000000..18c2afc
--- /dev/null
+++ b/middleware/multicore/open-amp/porting/env/freertos_env.c
@@ -0,0 +1,461 @@
+/*
+ * Copyright (c) 2014, Mentor Graphics Corporation
+ * All rights reserved.
+ * Copyright (c) 2015 Xilinx, Inc. All rights reserved.
+ * Copyright (c) 2015 Freescale, 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.
+ */
+
+/**************************************************************************
+ * FILE NAME
+ *
+ * freertos_env.c
+ *
+ *
+ * DESCRIPTION
+ *
+ * This file is Free RTOS Implementation of env layer for OpenAMP.
+ *
+ *
+ **************************************************************************/
+
+#include "env.h"
+#include "../config/config.h"
+
+#include <stdlib.h>
+#include <string.h>
+
+#if (defined(__CC_ARM))
+#define MEM_BARRIER() __schedule_barrier()
+#elif (defined(__GNUC__))
+#define MEM_BARRIER() asm volatile("" ::: "memory")
+#else
+#define MEM_BARRIER()
+#endif
+
+/*
+ * function decalaration for platform provided facility
+ */
+extern void platform_interrupt_enable(void);
+extern void platform_interrupt_disable(void);
+
+/**
+ * Structure to keep track of registered ISR's.
+ */
+struct isr_info isr_table[ISR_COUNT];
+int Intr_Count = 0;
+
+/**
+ * env_init
+ *
+ * Initializes OS/BM environment.
+ *
+ */
+int env_init() {
+ return 0;
+}
+
+/**
+ * env_deinit
+ *
+ * Uninitializes OS/BM environment.
+ *
+ * @returns - execution status
+ */
+
+int env_deinit() {
+ return 0;
+}
+/**
+ * env_allocate_memory - implementation
+ *
+ * @param size
+ */
+void *env_allocate_memory(unsigned int size)
+{
+ return (pvPortMalloc(size));
+}
+
+/**
+ * env_free_memory - implementation
+ *
+ * @param ptr
+ */
+void env_free_memory(void *ptr)
+{
+ if (ptr != NULL)
+ {
+ vPortFree(ptr);
+ }
+}
+
+/**
+ *
+ * env_memset - implementation
+ *
+ * @param ptr
+ * @param value
+ * @param size
+ */
+void env_memset(void *ptr, int value, unsigned long size)
+{
+ memset(ptr, value, size);
+}
+
+/**
+ *
+ * env_memcpy - implementation
+ *
+ * @param dst
+ * @param src
+ * @param len
+ */
+void env_memcpy(void *dst, void const * src, unsigned long len) {
+ memcpy(dst,src,len);
+}
+
+/**
+ *
+ * env_strcmp - implementation
+ *
+ * @param dst
+ * @param src
+ */
+
+int env_strcmp(const char *dst, const char *src){
+ return (strcmp(dst, src));
+}
+
+/**
+ *
+ * env_strncpy - implementation
+ *
+ * @param dest
+ * @param src
+ * @param len
+ */
+void env_strncpy(char * dest, const char *src, unsigned long len)
+{
+ strncpy(dest, src, len);
+}
+
+/**
+ *
+ * env_strncmp - implementation
+ *
+ * @param dest
+ * @param src
+ * @param len
+ */
+int env_strncmp(char * dest, const char *src, unsigned long len)
+{
+ return (strncmp(dest, src, len));
+}
+
+/**
+ *
+ * env_mb - implementation
+ *
+ */
+void env_mb()
+{
+ MEM_BARRIER();
+}
+
+/**
+ * osalr_mb - implementation
+ */
+void env_rmb()
+{
+ MEM_BARRIER();
+}
+
+/**
+ * env_wmb - implementation
+ */
+void env_wmb()
+{
+ MEM_BARRIER();
+}
+
+/**
+ * env_map_vatopa - implementation
+ *
+ * @param address
+ */
+unsigned long env_map_vatopa(void *address)
+{
+ return (unsigned long)address;
+}
+
+/**
+ * env_map_patova - implementation
+ *
+ * @param address
+ */
+void *env_map_patova(unsigned long address)
+{
+ return ((void *)address);
+}
+
+/**
+ * env_create_mutex
+ *
+ * Creates a mutex with the given initial count.
+ *
+ */
+int env_create_mutex(void **lock, int count)
+{
+ return 0;
+}
+
+/**
+ * env_delete_mutex
+ *
+ * Deletes the given lock
+ *
+ */
+void env_delete_mutex(void *lock)
+{
+}
+
+/**
+ * env_lock_mutex
+ *
+ * Tries to acquire the lock, if lock is not available then call to
+ * this function will suspend.
+ *
+ * system level interrupt is disabled to avoid race condition, this has the same effect of a lock
+ *
+ */
+void env_lock_mutex(void *lock)
+{
+ env_disable_interrupts();
+}
+
+/**
+ * env_unlock_mutex
+ *
+ * Releases the given lock.
+ *
+ * system level interrupt is disabled to avoid race condition, this has the same effect of a lock
+ *
+ */
+
+void env_unlock_mutex(void *lock)
+{
+ env_restore_interrupts();
+}
+
+
+/**
+ * env_create_sync_lock
+ *
+ * Creates a synchronization lock primitive. It is used
+ * when signal has to be sent from the interrupt context to main
+ * thread context.
+ */
+int env_create_sync_lock(void **lock , int state)
+{
+ return 0;
+}
+
+/**
+ * env_delete_sync_lock
+ *
+ * Deletes the given lock
+ *
+ */
+void env_delete_sync_lock(void *lock)
+{
+}
+
+/**
+ * env_acquire_sync_lock
+ *
+ * Tries to acquire the lock, if lock is not available then call to
+ * this function waits for lock to become available.
+ */
+void env_acquire_sync_lock(void *lock)
+{
+}
+
+/**
+ * env_release_sync_lock
+ *
+ * Releases the given lock.
+ */
+
+void env_release_sync_lock(void *lock)
+{
+}
+
+/**
+ * env_sleep_msec
+ *
+ * Suspends the calling thread for given time , in msecs.
+ */
+
+void env_sleep_msec(int num_msec)
+{
+ /* portSUPPRESS_TICKS_AND_SLEEP */
+ vTaskDelay(num_msec * portTICK_PERIOD_MS);
+}
+
+/**
+ * env_disable_interrupts
+ *
+ * Disables system interrupts
+ *
+ */
+void env_disable_interrupts()
+{
+ taskDISABLE_INTERRUPTS();
+}
+
+/**
+ * env_restore_interrupts
+ *
+ * Enables system interrupts
+ *
+ */
+void env_restore_interrupts()
+{
+ taskENABLE_INTERRUPTS();
+}
+
+/**
+ * env_register_isr
+ *
+ * Registers interrupt handler for the given interrupt vector.
+ *
+ * @param vector - vring index
+ * @param isr - interrupt handler
+ */
+void env_register_isr(int vector , void *data ,
+ void (*isr)(int vector , void *data))
+{
+ env_disable_interrupts();
+
+ if(Intr_Count < ISR_COUNT)
+ {
+ /* Save interrupt data */
+ isr_table[Intr_Count].vector = vector;
+ isr_table[Intr_Count].data = data;
+ isr_table[Intr_Count++].isr = isr;
+ }
+
+ env_restore_interrupts();
+}
+
+/**
+ * env_enable_interrupt
+ *
+ * Enables the given interrupt
+ *
+ * @param vector - vring index
+ * @param priority - interrupt priority
+ * @param polarity - interrupt polarity
+ */
+
+void env_enable_interrupt(unsigned int vector , unsigned int priority ,
+ unsigned int polarity)
+{
+ platform_interrupt_enable();
+}
+
+/**
+ * env_disable_interrupt
+ *
+ * Disables the given interrupt
+ *
+ * @param vector - interrupt vector number
+ */
+
+void env_disable_interrupt(unsigned int vector)
+{
+ platform_interrupt_disable();
+}
+
+/**
+ * env_map_memory
+ *
+ * Enables memory mapping for given memory region.
+ *
+ * @param pa - physical address of memory
+ * @param va - logical address of memory
+ * @param size - memory size
+ * param flags - flags for cache/uncached and access type
+ */
+
+void env_map_memory(unsigned int pa, unsigned int va, unsigned int size,
+ unsigned int flags)
+{
+}
+
+/**
+ * env_disable_cache
+ *
+ * Disables system caches.
+ *
+ */
+
+void env_disable_cache()
+{
+}
+
+/**
+ *
+ * env_get_timestamp
+ *
+ * Returns a 64 bit time stamp.
+ *
+ *
+ */
+unsigned long long env_get_timestamp(void)
+{
+ return 0;
+}
+
+/*========================================================= */
+/* Util data / functions for MQX */
+
+void freertos_env_isr(int vector) {
+ int idx;
+ struct isr_info *info;
+
+ env_disable_interrupt(vector);
+ for(idx = 0; idx < ISR_COUNT; idx++)
+ {
+ info = &isr_table[idx];
+ if(info->vector == vector)
+ {
+ info->isr(info->vector , info->data); /*platform_isr*/
+ env_enable_interrupt(info->vector , info->priority, info->type);
+ break;
+ }
+ }
+}
diff --git a/middleware/multicore/open-amp/porting/imx7d_m4/plat_porting.h b/middleware/multicore/open-amp/porting/imx7d_m4/plat_porting.h
new file mode 100644
index 0000000..4c25960
--- /dev/null
+++ b/middleware/multicore/open-amp/porting/imx7d_m4/plat_porting.h
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2015, Freescale Corporation
+ * 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.
+ */
+
+/**************************************************************************
+ * FILE NAME
+ *
+ * plat_porting.h
+ *
+ * DESCRIPTION
+ *
+ * This file contains the declaration of porting related function
+ * and macros
+ *
+ **************************************************************************/
+#ifndef PLAT_PORTING_H_
+#define PLAT_PORTING_H_
+
+/* MU_RPMSG_CHANNEL is the MU channel used for master and remote to notify each other*/
+#define MU_RPMSG_CHANNEL 1
+
+/* platform specific rpmsg handler which is invoked when a notification is received from peer*/
+void rpmsg_handler(void);
+
+#endif /* PLAT_PORTING_H_ */
diff --git a/middleware/multicore/open-amp/porting/imx7d_m4/platform.c b/middleware/multicore/open-amp/porting/imx7d_m4/platform.c
new file mode 100644
index 0000000..6b1fc8f
--- /dev/null
+++ b/middleware/multicore/open-amp/porting/imx7d_m4/platform.c
@@ -0,0 +1,115 @@
+/*
+ * Copyright (c) 2015, Freescale Corporation
+ * 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.
+ */
+
+/**************************************************************************
+ * FILE NAME
+ *
+ * platform.c
+ *
+ * DESCRIPTION
+ *
+ * This file is the Implementation of IPC hardware layer interface
+ * for Freescale i.MX7 Dual platform.
+ *
+ **************************************************************************/
+
+#include "device_imx.h"
+#include "platform.h"
+#include "plat_porting.h"
+#include "mu_imx.h"
+
+extern void freertos_env_isr(int vector);
+
+// uint32_t channel_id;
+/*--------------------------- Globals ---------------------------------- */
+
+struct hil_platform_ops proc_ops = {
+ .enable_interrupt = _enable_interrupt,
+ .notify = _notify,
+ .boot_cpu = _boot_cpu,
+ .shutdown_cpu = _shutdown_cpu,
+};
+
+void rpmsg_handler(void)
+{
+ uint32_t msg, channel;
+
+ if (MU_TryReceiveMsg(MU0_B, MU_RPMSG_CHANNEL, &msg) == kStatus_MU_Success) {
+ channel = msg >> 16;
+ freertos_env_isr(channel);
+ }
+
+ return;
+}
+
+int _enable_interrupt(struct proc_vring *vring_hw) { /*enable_interrupt*/
+ /* Register ISR*/
+ env_register_isr(vring_hw->intr_info.vect_id, vring_hw, platform_isr);
+
+ /*
+ * Prepare the MU Hardware, enable channel 1 interrupt
+ */
+ MU_EnableRxFullInt(MU0_B, MU_RPMSG_CHANNEL);
+
+ return 0;
+}
+
+void _notify(int cpu_id, struct proc_intr *intr_info)
+{
+ /*
+ * As Linux suggests, use MU->Data Channle 1 as communication channel
+ */
+ uint32_t msg = (intr_info->vect_id) << 16;
+ MU_SendMsg(MU0_B, MU_RPMSG_CHANNEL, msg);
+}
+
+
+int _boot_cpu(int cpu_id, unsigned int load_addr)
+{
+ return 0;
+}
+
+void _shutdown_cpu(int cpu_id)
+{
+}
+
+void platform_isr(int vect_id, void *data)
+{
+ hil_isr(((struct proc_vring *) data));
+}
+
+void platform_interrupt_enable()
+{
+ NVIC_EnableIRQ(MU_INT_M4_IRQn);
+}
+
+void platform_interrupt_disable()
+{
+ NVIC_DisableIRQ(MU_INT_M4_IRQn);
+}
diff --git a/middleware/multicore/open-amp/porting/imx7d_m4/platform.h b/middleware/multicore/open-amp/porting/imx7d_m4/platform.h
new file mode 100644
index 0000000..14a92cc
--- /dev/null
+++ b/middleware/multicore/open-amp/porting/imx7d_m4/platform.h
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2014, Mentor Graphics Corporation
+ * 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.
+ */
+
+#ifndef PLATFORM_H_
+#define PLATFORM_H_
+
+#include "../../common/hil/hil.h"
+
+int _enable_interrupt(struct proc_vring *vring_hw);
+void _notify(int cpu_id, struct proc_intr *intr_info);
+int _boot_cpu(int cpu_id, unsigned int load_addr);
+void _shutdown_cpu(int cpu_id);
+void platform_isr(int vect_id, void *data);
+
+#endif /* PLATFORM_H_ */
diff --git a/middleware/multicore/open-amp/porting/imx7d_m4/platform_info.c b/middleware/multicore/open-amp/porting/imx7d_m4/platform_info.c
new file mode 100644
index 0000000..aaef04f
--- /dev/null
+++ b/middleware/multicore/open-amp/porting/imx7d_m4/platform_info.c
@@ -0,0 +1,245 @@
+/*
+ * Copyright (c) 2015, Freescale Corporation
+ * 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.
+ */
+
+/**************************************************************************
+ * FILE NAME
+ *
+ * platform_info.c
+ *
+ * DESCRIPTION
+ *
+ * This file implements APIs to get platform specific
+ * information for OpenAMP.
+ *
+ **************************************************************************/
+
+#include "platform.h"
+#include "../../rpmsg/rpmsg.h"
+
+/* Reference implementation that show cases platform_get_cpu_info and
+ platform_get_for_firmware API implementation for Bare metal environment */
+
+extern struct hil_platform_ops proc_ops;
+
+/*
+ * Linux requirems the ALIGN to 0x1000 instead of 0x80
+ */
+#define VRING_ALIGN 0x1000
+
+/*
+ * Linux has a different alignment requirement, and its have 512 buffers instead of 32 buffers for the 2 ring
+ */
+#define VRING0_BASE 0xBFFF0000
+#define VRING1_BASE 0xBFFF8000
+
+/*
+ * 32 MSG (16 rx, 16 tx), 512 bytes each, it is only used when RPMSG driver is working in master mode, otherwise
+ * the share memory is managed by the other side.
+ * When working with Linux, SHM_ADDR and SHM_SIZE is not used
+ */
+#define SHM_ADDR 0
+#define SHM_SIZE 0
+
+/* IPI_VECT here defines VRING index in MU */
+#define VRING0_IPI_VECT 0
+#define VRING1_IPI_VECT 1
+
+#define MASTER_CPU_ID 0
+#define REMOTE_CPU_ID 1
+
+/**
+ * This array provdes defnition of CPU nodes for master and remote
+ * context. It contains two nodes beacuse the same file is intended
+ * to use with both master and remote configurations. On zynq platform
+ * only one node defintion is required for master/remote as there
+ * are only two cores present in the platform.
+ *
+ * Only platform specific info is populated here. Rest of information
+ * is obtained during resource table parsing.The platform specific
+ * information includes;
+ *
+ * -CPU ID
+ * -Shared Memory
+ * -Interrupts
+ * -Channel info.
+ *
+ * Although the channel info is not platform specific information
+ * but it is conveneient to keep it in HIL so that user can easily
+ * provide it without modifying the generic part.
+ *
+ * It is good idea to define hil_proc structure with platform
+ * specific fields populated as this can be easily copied to hil_proc
+ * structure passed as parameter in platform_get_processor_info. The
+ * other option is to populate the required structures individually
+ * and copy them one by one to hil_proc structure in platform_get_processor_info
+ * function. The first option is adopted here.
+ *
+ *
+ * 1) First node in the array is intended for the remote contexts and it
+ * defines Master CPU ID, shared memory, interrupts info, number of channels
+ * and there names. This node defines only one channel
+ * "rpmsg-data-channel".
+ *
+ * 2)Second node is required by the master and it defines remote CPU ID,
+ * shared memory and interrupts info. In general no channel info is required by the
+ * Master node, however in baremetal master and linux remote case the linux
+ * rpmsg bus driver behaves as master so the rpmsg driver on linux side still needs
+ * channel info. This information is not required by the masters for baremetal
+ * remotes.
+ *
+ */
+struct hil_proc proc_table []=
+{
+ /* CPU node for remote context */
+ {
+ /* CPU ID of master */
+ MASTER_CPU_ID,
+
+ /* Shared memory info - Last field is not used currently */
+ {
+ (void*)SHM_ADDR, SHM_SIZE, 0x00
+ },
+
+ /* VirtIO device info */ /*struct proc_vdev*/
+ {
+ 2, (1<<VIRTIO_RPMSG_F_NS), 0, /*num_vring, dfeatures, gfeatures*/
+
+ /* Vring info */ /*struct proc_vring*/
+ {
+ /*[0]*/
+ { /* TX */
+ NULL, (void*)VRING0_BASE/*phy_addr*/, 256/*num_descs*/, VRING_ALIGN/*align*/,
+ /*struct virtqueue, phys_addr, num_descs, align*/
+ {
+ /*struct proc_intr*/
+ VRING0_IPI_VECT,0,0,NULL
+ }
+ },
+ /*[1]*/
+ { /* RX */
+ NULL, (void*)VRING1_BASE, 256, VRING_ALIGN,
+ {
+ VRING1_IPI_VECT,0,0,NULL
+ }
+ }
+ }
+ },
+
+ /* Number of RPMSG channels */
+ 1, /*num_chnls*/
+
+ /* RPMSG channel info - Only channel name is expected currently */
+ {
+ {"rpmsg-openamp-demo-channel"} /*chnl name*/
+ },
+
+ /* HIL platform ops table. */
+ &proc_ops, /*struct hil_platform_ops*/
+
+ /* Next three fields are for future use only */
+ 0,
+ 0,
+ NULL
+ },
+
+ /* CPU node for remote context */
+ {
+ /* CPU ID of remote */
+ REMOTE_CPU_ID,
+
+ /* Shared memory info - Last field is not used currently */
+ {
+ (void*)SHM_ADDR, SHM_SIZE, 0x00
+ },
+
+ /* VirtIO device info */
+ {
+ 2, (1<<VIRTIO_RPMSG_F_NS), 0,
+ {
+ {/* RX */
+ NULL, (void*)VRING0_BASE, 256, VRING_ALIGN,
+ {
+ VRING0_IPI_VECT,0,0,NULL
+ }
+ },
+ {/* TX */
+ NULL, (void*)VRING1_BASE, 256, VRING_ALIGN,
+ {
+ VRING1_IPI_VECT,0,0,NULL
+ }
+ }
+ }
+ },
+
+ /* Number of RPMSG channels */
+ 1,
+
+ /* RPMSG channel info - Only channel name is expected currently */
+ {
+ {"rpmsg-openamp-demo-channel"}
+ },
+
+ /* HIL platform ops table. */
+ &proc_ops,
+
+ /* Next three fields are for future use only */
+ 0,
+ 0,
+ NULL
+ }
+};
+
+/**
+ * platform_get_processor_info
+ *
+ * Copies the target info from the user defined data structures to
+ * HIL proc data structure.In case of remote contexts this function
+ * is called with the reserved CPU ID HIL_RSVD_CPU_ID, because for
+ * remotes there is only one master.
+ *
+ * @param proc - HIL proc to populate
+ * @param cpu_id - CPU ID
+ *
+ * return - status of execution
+ */
+int platform_get_processor_info(struct hil_proc *proc , int cpu_id) {
+ int idx;
+ for(idx = 0; idx < sizeof(proc_table)/sizeof(struct hil_proc); idx++) {
+ if((cpu_id == HIL_RSVD_CPU_ID) || (proc_table[idx].cpu_id == cpu_id) ) {
+ env_memcpy(proc,&proc_table[idx], sizeof(struct hil_proc));
+ return 0;
+ }
+ }
+ return -1;
+}
+
+int platform_get_processor_for_fw(char *fw_name) {
+
+ return 1;
+}