Add DMA350 memmove FreeRTOS example

Change-Id: Ie237a02edfa4f5efcb436852261c35f215c87ce2
Signed-off-by: Bence Balogh <bence.balogh@arm.com>
diff --git a/examples/corstone310_fvp_dma/common/amazon-freertos/LICENSE b/examples/corstone310_fvp_dma/common/amazon-freertos/LICENSE
new file mode 100644
index 0000000..c3acc7b
--- /dev/null
+++ b/examples/corstone310_fvp_dma/common/amazon-freertos/LICENSE
@@ -0,0 +1,27 @@
+The files of this directory are originally copied from amazon-freertos:
+https://github.com/aws/amazon-freertos/tree/202107.00
+
+Below is the copy of the amazon-freertos license file.
+
+
+MIT License
+
+Copyright (C) 2017 Amazon.com, Inc. or its affiliates.  All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/examples/corstone310_fvp_dma/common/amazon-freertos/aws_demo.c b/examples/corstone310_fvp_dma/common/amazon-freertos/aws_demo.c
new file mode 100644
index 0000000..a4a234b
--- /dev/null
+++ b/examples/corstone310_fvp_dma/common/amazon-freertos/aws_demo.c
@@ -0,0 +1,92 @@
+/*
+ * FreeRTOS V202012.00
+ * Copyright (C) 2020 Amazon.com, Inc. or its affiliates.  All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
+ * this software and associated documentation files (the "Software"), to deal in
+ * the Software without restriction, including without limitation the rights to
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+ * the Software, and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+ * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+ * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * http://aws.amazon.com/freertos
+ * http://www.FreeRTOS.org
+ */
+
+/**
+ * @file  iot_demo.c
+ * @brief Demo
+ */
+
+#include "FreeRTOS.h"
+
+
+/*-----------------------------------------------------------*/
+
+/* configUSE_STATIC_ALLOCATION is set to 1, so the application must provide an
+ * implementation of vApplicationGetIdleTaskMemory() to provide the memory that is
+ * used by the Idle task. */
+void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer,
+                                    StackType_t ** ppxIdleTaskStackBuffer,
+                                    uint32_t * pulIdleTaskStackSize )
+{
+    /* If the buffers to be provided to the Idle task are declared inside this
+     * function then they must be declared static - otherwise they will be allocated on
+     * the stack and so not exists after this function exits. */
+    static StaticTask_t xIdleTaskTCB;
+    static StackType_t uxIdleTaskStack[ configMINIMAL_STACK_SIZE ];
+
+    /* Pass out a pointer to the StaticTask_t structure in which the Idle
+     * task's state will be stored. */
+    *ppxIdleTaskTCBBuffer = &xIdleTaskTCB;
+
+    /* Pass out the array that will be used as the Idle task's stack. */
+    *ppxIdleTaskStackBuffer = uxIdleTaskStack;
+
+    /* Pass out the size of the array pointed to by *ppxIdleTaskStackBuffer.
+     * Note that, as the array is necessarily of type StackType_t,
+     * configMINIMAL_STACK_SIZE is specified in words, not bytes. */
+    *pulIdleTaskStackSize = configMINIMAL_STACK_SIZE;
+}
+/*-----------------------------------------------------------*/
+
+/**
+ * @brief This is to provide the memory that is used by the RTOS daemon/time task.
+ *
+ * If configUSE_STATIC_ALLOCATION is set to 1, so the application must provide an
+ * implementation of vApplicationGetTimerTaskMemory() to provide the memory that is
+ * used by the RTOS daemon/time task.
+ */
+void vApplicationGetTimerTaskMemory( StaticTask_t ** ppxTimerTaskTCBBuffer,
+                                     StackType_t ** ppxTimerTaskStackBuffer,
+                                     uint32_t * pulTimerTaskStackSize )
+{
+    /* If the buffers to be provided to the Timer task are declared inside this
+     * function then they must be declared static - otherwise they will be allocated on
+     * the stack and so not exists after this function exits. */
+    static StaticTask_t xTimerTaskTCB;
+    static StackType_t uxTimerTaskStack[ configTIMER_TASK_STACK_DEPTH ];
+
+    /* Pass out a pointer to the StaticTask_t structure in which the Idle
+     * task's state will be stored. */
+    *ppxTimerTaskTCBBuffer = &xTimerTaskTCB;
+
+    /* Pass out the array that will be used as the Timer task's stack. */
+    *ppxTimerTaskStackBuffer = uxTimerTaskStack;
+
+    /* Pass out the size of the array pointed to by *ppxTimerTaskStackBuffer.
+     * Note that, as the array is necessarily of type StackType_t,
+     * configMINIMAL_STACK_SIZE is specified in words, not bytes. */
+    *pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH;
+}
+/*-----------------------------------------------------------*/
diff --git a/examples/corstone310_fvp_dma/common/ext/freertos-kernel/CMakeLists.txt b/examples/corstone310_fvp_dma/common/ext/freertos-kernel/CMakeLists.txt
new file mode 100644
index 0000000..478117d
--- /dev/null
+++ b/examples/corstone310_fvp_dma/common/ext/freertos-kernel/CMakeLists.txt
@@ -0,0 +1,24 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2021-2022, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+#-------------------------------------------------------------------------------
+include(FetchContent)
+set(FETCHCONTENT_QUIET FALSE)
+# Needed to specfy submodule list
+if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.16.0")
+    cmake_policy(SET CMP0097 NEW)
+endif()
+if ("${FREERTOS_SRC_PATH}" STREQUAL "DOWNLOAD")
+    find_package(Git)
+    FetchContent_Declare(freertos_kernel
+        GIT_REPOSITORY https://github.com/gbrtth/FreeRTOS-Kernel.git
+        GIT_TAG M55-support
+    )
+    FetchContent_GetProperties(freertos_kernel)
+    if (NOT freertos_kernel)
+        FetchContent_Populate(freertos_kernel)
+        set(FREERTOS_SRC_PATH ${freertos_kernel_SOURCE_DIR} CACHE PATH "Path to FreeRTOS kernel (or DOWNLOAD to fetch automatically" FORCE)
+    endif ()
+endif ()
diff --git a/examples/corstone310_fvp_dma/common/print_log.c b/examples/corstone310_fvp_dma/common/print_log.c
new file mode 100644
index 0000000..1a9b344
--- /dev/null
+++ b/examples/corstone310_fvp_dma/common/print_log.c
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2018-2021 Arm Limited. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
+ * this software and associated documentation files (the "Software"), to deal in
+ * the Software without restriction, including without limitation the rights to
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+ * the Software, and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+ * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+ * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#include <stdio.h>
+#include <stdarg.h>
+
+#include "FreeRTOS.h"
+#include "semphr.h"
+#include "print_log.h"
+
+SemaphoreHandle_t xUARTMutex;
+
+static SemaphoreHandle_t prvCreateUARTMutex( void )
+{
+SemaphoreHandle_t xMutexHandle;
+	xMutexHandle = xSemaphoreCreateMutex();
+	configASSERT( xMutexHandle );
+	return xMutexHandle;
+}
+
+void vUARTLockInit( void )
+{
+	xUARTMutex = prvCreateUARTMutex();
+}
+
+static BaseType_t xUARTLockAcquire()
+{
+	return xSemaphoreTake( xUARTMutex, portMAX_DELAY );
+}
+
+static BaseType_t xUARTLockRelease( void )
+{
+	return xSemaphoreGive( xUARTMutex );
+}
+
+void vLoggingPrintf(const char *format, ...)
+{
+    va_list args;
+    BaseType_t schedulerState = xTaskGetSchedulerState();
+    /* A UART lock is used here to ensure that there is
+    * at most one task accessing UART at a time.
+    */
+    if (schedulerState != taskSCHEDULER_NOT_STARTED) {
+        xUARTLockAcquire();
+    }
+    va_start( args, format );
+    vprintf( format, args );
+    va_end ( args );
+    printf("\r\n");
+    if (schedulerState != taskSCHEDULER_NOT_STARTED) {
+        xUARTLockRelease();
+    }
+}
+
+void vLoggingPrint(const char * message)
+{
+    BaseType_t schedulerState = xTaskGetSchedulerState();
+    /* A UART lock is used here to ensure that there is
+    * at most one task accessing UART at a time.
+    */
+    if (schedulerState != taskSCHEDULER_NOT_STARTED) {
+        xUARTLockAcquire();
+    }
+    puts(message);
+    printf("\r\n");
+    if (schedulerState != taskSCHEDULER_NOT_STARTED) {
+        xUARTLockRelease();
+    }
+}
diff --git a/examples/corstone310_fvp_dma/common/print_log.h b/examples/corstone310_fvp_dma/common/print_log.h
new file mode 100644
index 0000000..7ae28aa
--- /dev/null
+++ b/examples/corstone310_fvp_dma/common/print_log.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2018-2021 Arm Limited. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
+ * this software and associated documentation files (the "Software"), to deal in
+ * the Software without restriction, including without limitation the rights to
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+ * the Software, and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+ * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+ * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#ifndef __PRINT_LOG_H__
+#define __PRINT_LOG_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @brief Initialize the mutex of UART.
+ */
+void vUARTLockInit(void);
+
+/*
+ * @brief Send printf formatted message to the serial line.
+ */
+void vLoggingPrintf(const char *format, ...);
+
+/*
+ * @brief Send message to the serial line.
+ */
+void vLoggingPrint(const char * message);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __PRINT_LOG_H__ */
diff --git a/examples/corstone310_fvp_dma/unprivileged_example/CMakeLists.txt b/examples/corstone310_fvp_dma/unprivileged_example/CMakeLists.txt
new file mode 100644
index 0000000..7069045
--- /dev/null
+++ b/examples/corstone310_fvp_dma/unprivileged_example/CMakeLists.txt
@@ -0,0 +1,169 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2021-2022, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+#-------------------------------------------------------------------------------
+
+############################# Configuration ############################################
+
+############################# External Dependencies ############################################
+
+set(FREERTOS_SRC_PATH     "DOWNLOAD"  CACHE PATH  "Path to FreeRTOS kernel (or DOWNLOAD to fetch automatically")
+
+add_subdirectory(../common/ext/freertos-kernel freertos-kernel)
+
+############################# Common variables ############################################
+
+# In actual NS integration, NS side build should include the source files
+# exported by TF-M build.
+# Directly include interface folder to simplify the NS build in this demo, since
+# install always occurs at the end of build.
+set(INTERFACE_SRC_DIR    ${CMAKE_SOURCE_DIR}/interface/src)
+set(INTERFACE_INC_DIR    ${CMAKE_SOURCE_DIR}/interface/include)
+set(TFM_SRC_DIR          ${CMAKE_SOURCE_DIR})
+
+#################### TF-M NS interface (header only) ###########################
+
+add_library(tfm_ns_interface INTERFACE)
+
+# Include interface headers exported by TF-M
+target_include_directories(tfm_ns_interface
+    INTERFACE
+        ${INTERFACE_INC_DIR}
+        ${CMAKE_BINARY_DIR}/generated/interface/include
+)
+
+# PSA interface files are generated from a template
+add_dependencies(tfm_ns_interface
+    tfm_generated_files
+)
+
+# Include selection of Secure Partitions from TF-M build.
+# It can be replaced by NS side configurations later.
+target_link_libraries(tfm_ns_interface
+    INTERFACE
+        tfm_partition_defs
+)
+
+target_compile_definitions(tfm_ns_interface
+    INTERFACE
+        TFM_PSA_API
+)
+
+############################# TFM NS app #######################################
+
+add_executable(tfm_ns)
+
+target_add_scatter_file(tfm_ns
+    $<$<C_COMPILER_ID:ARMClang>:${CMAKE_CURRENT_SOURCE_DIR}/freertos-demo/corstone310_freertos.sct>
+    $<$<C_COMPILER_ID:GNU>:${CMAKE_CURRENT_SOURCE_DIR}/corstone310_freertos.ld>
+)
+
+target_sources(tfm_ns
+    PRIVATE
+        main_ns.c
+        dma350_lib/dma350_lib_unprivileged.c
+        ../common/print_log.c
+        ../common/amazon-freertos/aws_demo.c
+        $<$<C_COMPILER_ID:ARMClang>:freertos-demo/section_limits.c>
+
+        # DMA350 files
+        device_definition.c
+        ${TFM_SRC_DIR}/platform/ext/target/arm/mps3/corstone310_fvp/native_drivers/dma350_ch_drv.c
+        ${TFM_SRC_DIR}/platform/ext/target/arm/mps3/corstone310_fvp/native_drivers/dma350_drv.c
+        ${TFM_SRC_DIR}/platform/ext/target/arm/mps3/corstone310_fvp/libraries/dma350_lib.c
+        ${TFM_SRC_DIR}/platform/ext/target/arm/mps3/corstone310_fvp/libraries/dma350_checker_layer.c
+
+        # freeRTOS kernel files
+        ${FREERTOS_SRC_PATH}/portable/Common/mpu_wrappers.c
+        ${FREERTOS_SRC_PATH}/portable/GCC/ARM_CM55_NTZ/non_secure/port.c
+        ${FREERTOS_SRC_PATH}/portable/GCC/ARM_CM55_NTZ/non_secure/portasm.c
+        ${FREERTOS_SRC_PATH}/list.c
+        ${FREERTOS_SRC_PATH}/queue.c
+        ${FREERTOS_SRC_PATH}/tasks.c
+        ${FREERTOS_SRC_PATH}/stream_buffer.c
+        ${FREERTOS_SRC_PATH}/timers.c
+        ${FREERTOS_SRC_PATH}/event_groups.c
+        ${FREERTOS_SRC_PATH}/portable/MemMang/heap_4.c
+        ${FREERTOS_SRC_PATH}/portable/ThirdParty/GCC/ARM_CM33_TFM/os_wrapper_freertos.c
+)
+
+target_include_directories(tfm_ns
+    PRIVATE
+        .
+        dma350_lib/
+        freertos-config/
+        ${INTERFACE_INC_DIR}/
+        ../common/amazon-freertos
+        ../common
+        # freeRTOS kernel
+        ${FREERTOS_SRC_PATH}/include/
+        ${FREERTOS_SRC_PATH}/portable/GCC/ARM_CM33_NTZ/non_secure/
+
+        # DMA350
+        ${TFM_SRC_DIR}/platform/ext/target/arm/mps3/corstone310_fvp/services/src/
+)
+
+target_compile_definitions(tfm_ns
+    PRIVATE
+        MBEDTLS_CONFIG_FILE="aws_mbedtls_config.h"
+        # Needed for DMA-350 library
+        CMSIS_DEVICE_HEADER=<corstone310.h>
+)
+
+target_link_libraries(tfm_ns
+    PRIVATE
+        platform_ns
+        tfm_api_ns
+        tfm_s_veneers
+)
+
+set_target_properties(tfm_ns PROPERTIES
+    SUFFIX ".axf"
+    RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
+)
+
+target_link_options(tfm_ns
+    PRIVATE
+        $<$<C_COMPILER_ID:GNU>:-Wl,-Map=${CMAKE_BINARY_DIR}/bin/tfm_ns.map>
+        $<$<C_COMPILER_ID:ARMClang>:--map>
+        $<$<C_COMPILER_ID:IAR>:--map\;${CMAKE_BINARY_DIR}/bin/tfm_ns.map>
+)
+
+add_convert_to_bin_target(tfm_ns)
+
+###################### TF-M NS interface api (NS lib) ##########################
+
+add_library(tfm_api_ns STATIC)
+
+target_sources(tfm_api_ns PRIVATE
+    $<$<BOOL:${TFM_PARTITION_PLATFORM}>:${INTERFACE_SRC_DIR}/tfm_platform_ipc_api.c>
+    $<$<BOOL:${TFM_PARTITION_PROTECTED_STORAGE}>:${INTERFACE_SRC_DIR}/tfm_ps_ipc_api.c>
+    $<$<BOOL:${TFM_PARTITION_INTERNAL_TRUSTED_STORAGE}>:${INTERFACE_SRC_DIR}/tfm_its_ipc_api.c>
+    $<$<BOOL:${TFM_PARTITION_CRYPTO}>:${INTERFACE_SRC_DIR}/tfm_crypto_ipc_api.c>
+    $<$<BOOL:${TFM_PARTITION_INITIAL_ATTESTATION}>:${INTERFACE_SRC_DIR}/tfm_initial_attestation_ipc_api.c>
+    $<$<BOOL:${TFM_PARTITION_FIRMWARE_UPDATE}>:${INTERFACE_SRC_DIR}/tfm_firmware_update_ipc_api.c>
+
+)
+
+target_sources(tfm_api_ns PRIVATE
+    ${INTERFACE_SRC_DIR}/tfm_psa_ns_api.c
+    ${TFM_TEST_REPO_PATH}/app/tfm_ns_interface.c
+)
+
+target_include_directories(tfm_api_ns PUBLIC
+    ${TFM_TEST_REPO_PATH}/ns_interface
+)
+
+target_link_libraries(tfm_api_ns
+    PUBLIC
+        tfm_ns_interface
+    PRIVATE
+        platform_ns
+)
+
+############################# CMSIS ############################################
+
+# Platform cmake config adds sources to CMSIS_5_tfm_ns, so we need to define it, but it is unused.
+add_library(CMSIS_5_tfm_ns INTERFACE)
diff --git a/examples/corstone310_fvp_dma/unprivileged_example/application_defined_privileged_functions.h b/examples/corstone310_fvp_dma/unprivileged_example/application_defined_privileged_functions.h
new file mode 100644
index 0000000..702f714
--- /dev/null
+++ b/examples/corstone310_fvp_dma/unprivileged_example/application_defined_privileged_functions.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2022 Arm Limited
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "dma350_checker_layer.h"
+
+enum dma350_lib_error_t request_dma350_priv_config(enum dma350_config_type_t config_type, uint8_t channel, void* args) FREERTOS_SYSTEM_CALL;
+
+enum dma350_lib_error_t request_dma350_priv_config(enum dma350_config_type_t config_type, uint8_t channel, void* args)
+{
+    BaseType_t xRunningPrivileged;
+    enum dma350_lib_error_t ret_val;
+
+    xPortRaisePrivilege(xRunningPrivileged);
+    ret_val = config_dma350_for_unprivileged_actor(config_type, channel, args);
+    vPortResetPrivilege(xRunningPrivileged);
+
+    return ret_val;
+}
diff --git a/examples/corstone310_fvp_dma/unprivileged_example/corstone310_freertos.ld b/examples/corstone310_fvp_dma/unprivileged_example/corstone310_freertos.ld
new file mode 100644
index 0000000..018f1ee
--- /dev/null
+++ b/examples/corstone310_fvp_dma/unprivileged_example/corstone310_freertos.ld
@@ -0,0 +1,194 @@
+
+;/*
+; * Copyright (c) 2021-2022 Arm Limited. All rights reserved.
+; *
+; * Licensed under the Apache License, Version 2.0 (the "License");
+; * you may not use this file except in compliance with the License.
+; * You may obtain a copy of the License at
+; *
+; *     http://www.apache.org/licenses/LICENSE-2.0
+; *
+; * Unless required by applicable law or agreed to in writing, software
+; * distributed under the License is distributed on an "AS IS" BASIS,
+; * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+; * See the License for the specific language governing permissions and
+; * limitations under the License.
+; *
+; *
+; * This file is derivative of CMSIS V5.00 gcc_arm.ld
+; */
+/* Linker script to configure memory regions. */
+/* This file will be run trough the pre-processor. */
+#include "region_defs.h"
+MEMORY
+{
+  FLASH (rx)  : ORIGIN = NS_CODE_START, LENGTH = NS_CODE_SIZE
+  RAM   (rwx) : ORIGIN = NS_DATA_START, LENGTH = NS_DATA_SIZE
+}
+__heap_size__  = NS_HEAP_SIZE;
+__psp_stack_size__ = NS_PSP_STACK_SIZE;
+__msp_stack_size__ = NS_MSP_STACK_SIZE;
+/* Library configurations */
+GROUP(libgcc.a libc.a libm.a libnosys.a)
+ENTRY(Reset_Handler)
+SECTIONS
+{
+    .text :
+    {
+        KEEP(*(.vectors))
+        __Vectors_End = .;
+        __Vectors_Size = __Vectors_End - __Vectors;
+        __end__ = .;
+    } > FLASH
+    /* Privileged functions - Section needs to be 32 byte aligned to satisfy MPU requirements. */
+    .privileged_functions : ALIGN(32)
+    {
+        . = ALIGN(32);
+        __privileged_functions_start__ = .;
+        *(privileged_functions)
+        . = ALIGN(32);
+        /* End address must be the last address in the region, therefore, -1. */
+        __privileged_functions_end__ = . - 1;
+    } > FLASH
+    /* FreeRTOS System calls - Section needs to be 32 byte aligned to satisfy MPU requirements. */
+    .freertos_system_calls : ALIGN(32)
+    {
+        . = ALIGN(32);
+        __syscalls_flash_start__ = .;
+        *(freertos_system_calls)
+        . = ALIGN(32);
+        /* End address must be the last address in the region, therefore, -1. */
+        __syscalls_flash_end__ = . - 1;
+    } > FLASH
+    .text2 :
+    {
+        . = ALIGN(32);
+        __unprivileged_flash_start__ = .;
+        *(.text*)
+        KEEP(*(.init))
+        KEEP(*(.fini))
+        /* .ctors */
+        *crtbegin.o(.ctors)
+        *crtbegin?.o(.ctors)
+        *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
+        *(SORT(.ctors.*))
+        *(.ctors)
+        /* .dtors */
+         *crtbegin.o(.dtors)
+         *crtbegin?.o(.dtors)
+         *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
+         *(SORT(.dtors.*))
+         *(.dtors)
+        *(.rodata*)
+        KEEP(*(.eh_frame*))
+        . = ALIGN(32);
+        /* End address must be the last address in the region, therefore, -1. */
+        __unprivileged_flash_end__ = . - 1;
+    } > FLASH
+    .ARM.extab :
+    {
+        *(.ARM.extab* .gnu.linkonce.armextab.*)
+    } > FLASH
+    __exidx_start = .;
+    .ARM.exidx :
+    {
+        *(.ARM.exidx* .gnu.linkonce.armexidx.*)
+    } > FLASH
+    __exidx_end = .;
+    /* To copy multiple ROM to RAM sections,
+     * define etext2/data2_start/data2_end and
+     * define __STARTUP_COPY_MULTIPLE in startup_cmsdk_mps3_an524_ns.S */
+    .copy.table :
+    {
+        . = ALIGN(4);
+        __copy_table_start__ = .;
+        LONG (__etext)
+        LONG (__data_start__)
+        LONG (__data_end__ - __data_start__)
+        LONG (DEFINED(__etext2) ? __etext2 : 0)
+        LONG (DEFINED(__data2_start__) ? __data2_start__ : 0)
+        LONG (DEFINED(__data2_start__) ? __data2_end__ - __data2_start__ : 0)
+        __copy_table_end__ = .;
+    } > FLASH
+    /* To clear multiple BSS sections,
+     * uncomment .zero.table section and,
+     * define __STARTUP_CLEAR_BSS_MULTIPLE in startup_cmsdk_mps3_an524_ns.S */
+    .zero.table :
+    {
+        . = ALIGN(4);
+        __zero_table_start__ = .;
+        LONG (__bss_start__)
+        LONG (__bss_end__ - __bss_start__)
+        LONG (DEFINED(__bss2_start__) ? __bss2_start__ : 0)
+        LONG (DEFINED(__bss2_start__) ? __bss2_end__ - __bss2_start__ : 0)
+        __zero_table_end__ = .;
+    } > FLASH
+    __etext = .;
+    .data : AT (__etext)
+    {
+        __data_start__ = .;
+        /* Privileged data - It needs to be 32 byte aligned to satisfy MPU requirements. */
+        . = ALIGN(32);
+        __privileged_sram_start__ = .;
+        *(privileged_data)
+        . = ALIGN(32);
+        /* End address must be the last address in the region, therefore, -1. */
+        __privileged_sram_end__ = . - 1;
+        *(vtable)
+        *(.data*)
+        . = ALIGN(4);
+        /* preinit data */
+        PROVIDE_HIDDEN (__preinit_array_start = .);
+        KEEP(*(.preinit_array))
+        PROVIDE_HIDDEN (__preinit_array_end = .);
+        . = ALIGN(4);
+        /* init data */
+        PROVIDE_HIDDEN (__init_array_start = .);
+        KEEP(*(SORT(.init_array.*)))
+        KEEP(*(.init_array))
+        PROVIDE_HIDDEN (__init_array_end = .);
+        . = ALIGN(4);
+        /* finit data */
+        PROVIDE_HIDDEN (__fini_array_start = .);
+        KEEP(*(SORT(.fini_array.*)))
+        KEEP(*(.fini_array))
+        PROVIDE_HIDDEN (__fini_array_end = .);
+        KEEP(*(.jcr*))
+        . = ALIGN(4);
+        /* All data end */
+        __data_end__ = .;
+    } > RAM
+    .bss :
+    {
+        . = ALIGN(4);
+        __bss_start__ = .;
+        *(.bss*)
+        *(COMMON)
+        . = ALIGN(4);
+        __bss_end__ = .;
+    } > RAM
+    bss_size = __bss_end__ - __bss_start__;
+    .msp_stack : ALIGN(32)
+    {
+        . += __msp_stack_size__;
+    } > RAM
+    Image$$ARM_LIB_STACK_MSP$$ZI$$Base = ADDR(.msp_stack);
+    Image$$ARM_LIB_STACK_MSP$$ZI$$Limit = ADDR(.msp_stack) + SIZEOF(.msp_stack);
+    .psp_stack : ALIGN(32)
+    {
+        . += __psp_stack_size__;
+    } > RAM
+    Image$$ARM_LIB_STACK$$ZI$$Base = ADDR(.psp_stack);
+    Image$$ARM_LIB_STACK$$ZI$$Limit = ADDR(.psp_stack) + SIZEOF(.psp_stack);
+    .heap : ALIGN(8)
+    {
+        . = ALIGN(8);
+        __end__ = .;
+        PROVIDE(end = .);
+        __HeapBase = .;
+        . += __heap_size__;
+        __HeapLimit = .;
+        __heap_limit = .; /* Add for _sbrk */
+    } > RAM
+    PROVIDE(__stack = Image$$ARM_LIB_STACK$$ZI$$Limit);
+}
diff --git a/examples/corstone310_fvp_dma/unprivileged_example/device_definition.c b/examples/corstone310_fvp_dma/unprivileged_example/device_definition.c
new file mode 100644
index 0000000..ab3e61f
--- /dev/null
+++ b/examples/corstone310_fvp_dma/unprivileged_example/device_definition.c
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2022 Arm Limited
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "platform_base_address.h"
+#include "device_definition.h"
+#include "dma350_drv.h"
+#include "dma350_ch_drv.h"
+#include "dma350_regdef.h"
+#include "dma350_checker_layer.h"
+
+/* DMA Channel Device structure definition */
+struct dma350_ch_dev_t DMA350_DMA0_CH1_DEV_NS = {
+    .cfg = {.ch_base = (DMACH_TypeDef *)(DMA_350_BASE_NS + 0x1100UL),
+            .channel = 1},
+    .data = {0}};
+struct dma350_ch_dev_t* const DMA350_DMA0_NS_CHANNELS[] = {
+    NULL,
+    &DMA350_DMA0_CH1_DEV_NS
+};
+
+struct dma350_checker_channels_t const DMA350_CHECKER_CHANNELS = {
+    .channels = DMA350_DMA0_NS_CHANNELS,
+    .number_of_channels = sizeof(DMA350_DMA0_NS_CHANNELS) /
+                          sizeof(DMA350_DMA0_NS_CHANNELS[0])
+};
diff --git a/examples/corstone310_fvp_dma/unprivileged_example/dma350_lib/dma350_lib_unprivileged.c b/examples/corstone310_fvp_dma/unprivileged_example/dma350_lib/dma350_lib_unprivileged.c
new file mode 100644
index 0000000..ce1176a
--- /dev/null
+++ b/examples/corstone310_fvp_dma/unprivileged_example/dma350_lib/dma350_lib_unprivileged.c
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2022, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ */
+
+#include "dma350_lib_unprivileged.h"
+#include "dma350_checker_layer.h"
+#include "dma350_privileged_config.h"
+
+#include <stddef.h>
+#include <stdint.h>
+
+enum dma350_lib_error_t dma350_memcpy_unpriv(uint8_t channel,
+                                        void* src, void* des, uint32_t size,
+                                        enum dma350_lib_exec_type_t exec_type)
+{
+    enum dma350_lib_error_t ret_val;
+    struct dma350_memcpy_config memcpy_config = {
+        .exec_type = exec_type,
+        .dst = des,
+        .src = src,
+        .size = size
+    };
+
+    ret_val = request_dma350_priv_config(DMA_CALL_MEMCPY, channel,
+                                        &memcpy_config);
+
+    return ret_val;
+}
+
+enum dma350_lib_error_t dma350_memmove_unpriv(uint8_t channel,
+                                        void* src, void* des, uint32_t size,
+                                        enum dma350_lib_exec_type_t exec_type)
+{
+    enum dma350_lib_error_t ret_val;
+    struct dma350_memmove_config memmove_config = {
+        .exec_type = exec_type,
+        .dst = des,
+        .src = src,
+        .size = size
+    };
+
+    ret_val = request_dma350_priv_config(DMA_CALL_MEMMOVE, channel,
+                                        &memmove_config);
+
+    return ret_val;
+}
+
+enum dma350_lib_error_t dma350_clear_done_irq_unpriv(uint8_t channel)
+{
+    enum dma350_lib_error_t ret_val;
+
+    ret_val = request_dma350_priv_config(DMA_CLEAR_DONE_IRQ, channel, NULL);
+
+    return ret_val;
+}
+
+enum dma350_lib_error_t dma350_ch_get_status_unpriv(uint8_t channel,
+                                        union dma350_ch_status_t *status)
+{
+    enum dma350_lib_error_t ret_val;
+
+    ret_val = request_dma350_priv_config(DMA_GET_STATUS, channel, status);
+
+    return ret_val;
+}
diff --git a/examples/corstone310_fvp_dma/unprivileged_example/dma350_lib/dma350_lib_unprivileged.h b/examples/corstone310_fvp_dma/unprivileged_example/dma350_lib/dma350_lib_unprivileged.h
new file mode 100644
index 0000000..ab0d6f6
--- /dev/null
+++ b/examples/corstone310_fvp_dma/unprivileged_example/dma350_lib/dma350_lib_unprivileged.h
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2022, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ */
+
+/**
+ * \file dma350_lib_unprivileged.h
+ *
+ * \brief Library functions for DMA350 Direct Access Memory
+ *      Functions:
+ *          1. Memory copy from non-privileged mode
+ *          2. Memory move from non-privileged mode
+ */
+
+#ifndef __DMA350_LIB_UNPRIVILEGED_H__
+#define __DMA350_LIB_UNPRIVILEGED_H__
+
+#include "dma350_lib.h"
+
+#include <stdint.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * \brief Clear a status bit of the dma channel
+ *
+ * \param[in] channel    DMA350 channel number
+ *
+ * \return Result of the operation \ref dma350_lib_error_t
+ *
+ * \note This function can be called from non-privileged level.
+ */
+enum dma350_lib_error_t dma350_clear_done_irq_unpriv(uint8_t channel);
+
+/**
+ * \brief Copy a specified number of bytes from one memory to another
+ *
+ * \param[in] channel    DMA350 channel number
+ * \param[in] src        Source address, where to copy from
+ * \param[in] des        Destination address, where to copy to
+ * \param[in] size       Number of bytes to copy
+ * \param[in] exec_type  Execution type \ref dma350_lib_exec_type_t
+ *
+ * \return Result of the operation \ref dma350_lib_error_t
+ *
+ * \note This function can be called from non-privileged level.
+ */
+enum dma350_lib_error_t dma350_memcpy_unpriv(uint8_t channel, void* src,
+                                        void* des, uint32_t size,
+                                        enum dma350_lib_exec_type_t exec_type);
+
+/**
+ * \brief Copy a specified number of bytes from one memory to another
+ *        or overlap on same memory.
+ *
+ * \param[in] channel    DMA350 channel number
+ * \param[in] src        Source address, where to move from
+ * \param[in] des        Destination address, where to move to
+ * \param[in] size       Number of bytes to move
+ * \param[in] exec_type  Execution type \ref dma350_lib_exec_type_t
+ *
+ * \return Result of the operation \ref dma350_lib_error_t
+ *
+ * \note This function can be called from non-privileged level.
+ */
+enum dma350_lib_error_t dma350_memmove_unpriv(uint8_t channel, void* src,
+                                        void* des, uint32_t size,
+                                        enum dma350_lib_exec_type_t exec_type);
+
+
+/**
+ * \brief Get the status of the dma channel
+ *
+ * \param[in] channel    DMA350 channel number
+ * \param[out] status    DMA350 channel status
+ *
+ * \return Result of the operation \ref dma350_lib_error_t
+ *
+ * \note This function can be called from non-privileged level.
+ */
+enum dma350_lib_error_t dma350_ch_get_status_unpriv(uint8_t channel,
+                                        union dma350_ch_status_t *status);
+
+#ifdef __cplusplus
+}
+#endif
+#endif /*__DMA350_LIB_UNPRIVILEGED_H__ */
diff --git a/examples/corstone310_fvp_dma/unprivileged_example/freertos-config/FreeRTOSConfig.h b/examples/corstone310_fvp_dma/unprivileged_example/freertos-config/FreeRTOSConfig.h
new file mode 100644
index 0000000..35c44e7
--- /dev/null
+++ b/examples/corstone310_fvp_dma/unprivileged_example/freertos-config/FreeRTOSConfig.h
@@ -0,0 +1,180 @@
+/*
+ * FreeRTOS Kernel V10.2.0
+ * Copyright (C) 2017 Amazon.com, Inc. or its affiliates.  All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
+ * this software and associated documentation files (the "Software"), to deal in
+ * the Software without restriction, including without limitation the rights to
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+ * the Software, and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+ * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+ * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * http://aws.amazon.com/freertos
+ * http://www.FreeRTOS.org
+ */
+
+#ifndef FREERTOS_CONFIG_H
+#define FREERTOS_CONFIG_H
+
+#include "system_core_init.h"
+
+#define configENABLE_FPU 0
+#define configENABLE_MPU 1
+#define configENABLE_TRUSTZONE 0
+#define configRUN_FREERTOS_SECURE_ONLY 0
+
+#include "print_log.h"
+#define configPRINT_STRING( X )   vLoggingPrint X
+
+#define configUSE_PREEMPTION                    1
+#define configUSE_PORT_OPTIMISED_TASK_SELECTION 0
+#define configUSE_TICKLESS_IDLE                 0
+#define configCPU_CLOCK_HZ                      ( ( unsigned long ) SystemCoreClock )
+#define configSYSTICK_CLOCK_HZ                  ( ( unsigned long ) SystemCoreClock )
+#define configTICK_RATE_HZ                      ( ( TickType_t ) 1000 )
+#define configMAX_PRIORITIES                    5
+#define configMINIMAL_STACK_SIZE                1024
+#define configMAX_TASK_NAME_LEN                 16
+#define configUSE_16_BIT_TICKS                  0
+#define configIDLE_SHOULD_YIELD                 1
+#define configUSE_TASK_NOTIFICATIONS            1
+#define configTASK_NOTIFICATION_ARRAY_ENTRIES   3
+#define configUSE_MUTEXES                       1
+#define configUSE_RECURSIVE_MUTEXES             1
+#define configUSE_COUNTING_SEMAPHORES           1
+#define configQUEUE_REGISTRY_SIZE               10
+#define configUSE_QUEUE_SETS                    0
+#define configUSE_TIME_SLICING                  0
+#define configUSE_NEWLIB_REENTRANT              0
+#define configENABLE_BACKWARD_COMPATIBILITY     0
+#define configNUM_THREAD_LOCAL_STORAGE_POINTERS 5
+#define configSTACK_DEPTH_TYPE                  uint32_t
+#define configMESSAGE_BUFFER_LENGTH_TYPE        size_t
+
+/* Memory allocation related definitions. */
+#define configSUPPORT_STATIC_ALLOCATION         1
+#define configSUPPORT_DYNAMIC_ALLOCATION        1
+#define configTOTAL_HEAP_SIZE                   0x10000
+#define configAPPLICATION_ALLOCATED_HEAP        0
+
+/* Hook function related definitions. */
+#define configUSE_IDLE_HOOK                     0
+#define configUSE_TICK_HOOK                     0
+#define configCHECK_FOR_STACK_OVERFLOW          0
+#define configUSE_MALLOC_FAILED_HOOK            0
+#define configUSE_DAEMON_TASK_STARTUP_HOOK      0
+
+/* Run time and task stats gathering related definitions. */
+#define configGENERATE_RUN_TIME_STATS           0
+#define configUSE_TRACE_FACILITY                0
+#define configUSE_STATS_FORMATTING_FUNCTIONS    0
+
+/* Co-routine related definitions. */
+#define configUSE_CO_ROUTINES                   0
+#define configMAX_CO_ROUTINE_PRIORITIES         1
+
+/* Software timer related definitions. */
+#define configUSE_TIMERS                        1
+#define configTIMER_TASK_PRIORITY               3
+#define configTIMER_QUEUE_LENGTH                10
+#define configTIMER_TASK_STACK_DEPTH            configMINIMAL_STACK_SIZE
+
+/* FreeRTOS MPU specific definitions. */
+#define configINCLUDE_APPLICATION_DEFINED_PRIVILEGED_FUNCTIONS 1
+#define configTOTAL_MPU_REGIONS                                8
+#define configENFORCE_SYSTEM_CALLS_FROM_KERNEL_ONLY            1
+
+/* Optional functions - most linkers will remove unused functions anyway. */
+#define INCLUDE_vTaskPrioritySet                1
+#define INCLUDE_uxTaskPriorityGet               1
+#define INCLUDE_vTaskDelete                     1
+#define INCLUDE_vTaskSuspend                    1
+#define INCLUDE_xResumeFromISR                  1
+#define INCLUDE_vTaskDelayUntil                 1
+#define INCLUDE_vTaskDelay                      1
+#define INCLUDE_xTaskGetSchedulerState          1
+#define INCLUDE_xTaskGetCurrentTaskHandle       1
+#define INCLUDE_uxTaskGetStackHighWaterMark     0
+#define INCLUDE_xTaskGetIdleTaskHandle          0
+#define INCLUDE_eTaskGetState                   0
+#define INCLUDE_xEventGroupSetBitFromISR        1
+#define INCLUDE_xTimerPendFunctionCall          0
+#define INCLUDE_xTaskAbortDelay                 0
+#define INCLUDE_xTaskGetHandle                  1
+#define INCLUDE_xTaskResumeFromISR              1
+
+/* Cortex-M specific definitions. */
+#ifdef __NVIC_PRIO_BITS
+    /* __NVIC_PRIO_BITS will be specified when CMSIS is being used. */
+    #define configPRIO_BITS    __NVIC_PRIO_BITS
+#else
+    #define configPRIO_BITS    3                                 /* 8 priority levels. */
+#endif
+
+/* The lowest interrupt priority that can be used in a call to a "set priority"
+function. */
+#define configLIBRARY_LOWEST_INTERRUPT_PRIORITY			0xf
+
+/* The highest interrupt priority that can be used by any interrupt service
+routine that makes calls to interrupt safe FreeRTOS API functions.  DO NOT CALL
+INTERRUPT SAFE FREERTOS API FUNCTIONS FROM ANY INTERRUPT THAT HAS A HIGHER
+PRIORITY THAN THIS! (higher priorities are lower numeric values. */
+#define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY	2
+
+/* Interrupt priorities used by the kernel port layer itself.  These are generic
+to all Cortex-M ports, and do not rely on any particular library functions. */
+#define configKERNEL_INTERRUPT_PRIORITY 		( configLIBRARY_LOWEST_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )
+/* !!!! configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to zero !!!!
+See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */
+#define configMAX_SYSCALL_INTERRUPT_PRIORITY 	( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )
+
+#define configMAC_INTERRUPT_PRIORITY            7
+
+/* MAC is read from HW */
+#define configMAC_ADDR0                      0
+#define configMAC_ADDR1                      0
+#define configMAC_ADDR2                      0
+#define configMAC_ADDR3                      0
+#define configMAC_ADDR4                      0
+#define configMAC_ADDR5                      0
+
+/* Default IP address configuration. Used if ipconfigUSE_DHCP is set to 0, or
+ * ipconfigUSE_DHCP is set to 1 but a DNS server cannot be contacted. */
+#define configIP_ADDR0                       0
+#define configIP_ADDR1                       0
+#define configIP_ADDR2                       0
+#define configIP_ADDR3                       0
+
+/* Default gateway IP address configuration. Used if ipconfigUSE_DHCP is set to
+ * 0, or ipconfigUSE_DHCP is set to 1 but a DNS server cannot be contacted. */
+#define configGATEWAY_ADDR0                  0
+#define configGATEWAY_ADDR1                  0
+#define configGATEWAY_ADDR2                  0
+#define configGATEWAY_ADDR3                  0
+
+/* Default DNS server configuration.  OpenDNS addresses are 208.67.222.222 and
+ * 208.67.220.220.  Used in ipconfigUSE_DHCP is set to 0, or ipconfigUSE_DHCP is
+ * set to 1 but a DNS server cannot be contacted.*/
+#define configDNS_SERVER_ADDR0               208
+#define configDNS_SERVER_ADDR1               67
+#define configDNS_SERVER_ADDR2               222
+#define configDNS_SERVER_ADDR3               222
+
+/* Default netmask configuration. Used if ipconfigUSE_DHCP is set to 0, or
+ * ipconfigUSE_DHCP is set to 1 but a DNS server cannot be contacted. */
+#define configNET_MASK0                      0
+#define configNET_MASK1                      0
+#define configNET_MASK2                      0
+#define configNET_MASK3                      0
+
+#endif /* FREERTOS_CONFIG_H */
diff --git a/examples/corstone310_fvp_dma/unprivileged_example/freertos-config/LICENSE b/examples/corstone310_fvp_dma/unprivileged_example/freertos-config/LICENSE
new file mode 100644
index 0000000..48f8587
--- /dev/null
+++ b/examples/corstone310_fvp_dma/unprivileged_example/freertos-config/LICENSE
@@ -0,0 +1,27 @@
+The files of this directory are orginally copied from amazon-freertos:
+https://github.com/aws/amazon-freertos/tree/202107.00
+
+Below is the copy of the amazon-freertos license file.
+
+
+MIT License
+
+Copyright (C) 2017 Amazon.com, Inc. or its affiliates.  All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/examples/corstone310_fvp_dma/unprivileged_example/freertos-demo/LICENSE.md b/examples/corstone310_fvp_dma/unprivileged_example/freertos-demo/LICENSE.md
new file mode 100644
index 0000000..ce9e452
--- /dev/null
+++ b/examples/corstone310_fvp_dma/unprivileged_example/freertos-demo/LICENSE.md
@@ -0,0 +1,12 @@
+The files of this directory are originally copied from FreeRTOS:
+https://github.com/FreeRTOS/FreeRTOS/tree/V10.4.1
+
+Below is the copy of the FreeRTOS license file.
+
+MIT License
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/examples/corstone310_fvp_dma/unprivileged_example/freertos-demo/corstone310_freertos.sct b/examples/corstone310_fvp_dma/unprivileged_example/freertos-demo/corstone310_freertos.sct
new file mode 100644
index 0000000..7cf3291
--- /dev/null
+++ b/examples/corstone310_fvp_dma/unprivileged_example/freertos-demo/corstone310_freertos.sct
@@ -0,0 +1,80 @@
+; NOTE: ARMv8-M MPU requires that each region must start on a 32 byte aligned
+; address and the size of a region must be a multiple of 32 bytes.
+;
+; Flash Layout
+;
+;  ---------------------
+; |   Privileged Code   |
+;  ---------------------
+; |    System Calls     |
+;  ---------------------
+; |  Unprivileged Code  |
+;  ---------------------
+;
+; RAM Layout
+;
+;  ---------------------
+; |   Privileged Data   |
+;  ---------------------
+; |  Unprivileged Data  |
+;  ---------------------
+#include "region_defs.h"
+
+LR_APP NS_CODE_START ; load region
+{
+    ER_IROM_NS_PRIVILEGED +0 ALIGN 32
+    {
+        *.o(RESET, +First)
+        *(InRoot$$Sections) ; All sections that must be in a root region
+        *(privileged_functions)
+    }
+
+    ER_IROM_NS_PRIVILEGED_ALIGN +0 ALIGN 32 EMPTY 0x0
+    {
+    }
+
+    ER_IROM_NS_FREERTOS_SYSTEM_CALLS +0 ALIGN 32
+    {
+        *(freertos_system_calls)
+    }
+
+    ER_IROM_NS_FREERTOS_SYSTEM_CALLS_ALIGN +0 ALIGN 32 EMPTY 0x0
+    {
+    }
+
+    ER_IROM_NS_UNPRIVILEGED +0 ALIGN 32
+    {
+        *(+RO)
+    }
+
+    ER_IROM_NS_UNPRIVILEGED_ALIGN +0 ALIGN 32 EMPTY 0x0
+    {
+    }
+
+    ER_IRAM_NS_PRIVILEGED NS_DATA_START ALIGN 32
+    {
+        *(privileged_data)
+    }
+
+    ER_IRAM_NS_PRIVILEGED_ALIGN +0 ALIGN 32 EMPTY 0x0
+    {
+    }
+
+    ER_IRAM_NS_UNPRIVILEGED +0 ALIGN 32
+    {
+        *(+RW, +ZI)
+    }
+
+    ER_IRAM_NS_UNPRIVILEGED_ALIGN +0 ALIGN 32 EMPTY 0x0
+    {
+    }
+
+    /* MSP */
+    ARM_LIB_STACK_MSP +0 ALIGN 32 EMPTY NS_MSP_STACK_SIZE {
+    }
+
+    /* PSP */
+    ARM_LIB_STACK +0 ALIGN 32 EMPTY NS_PSP_STACK_SIZE {
+    }
+
+}
diff --git a/examples/corstone310_fvp_dma/unprivileged_example/freertos-demo/section_limits.c b/examples/corstone310_fvp_dma/unprivileged_example/freertos-demo/section_limits.c
new file mode 100644
index 0000000..c72e357
--- /dev/null
+++ b/examples/corstone310_fvp_dma/unprivileged_example/freertos-demo/section_limits.c
@@ -0,0 +1,34 @@
+#include "stdint.h"
+
+extern uint32_t Image$$ER_IROM_NS_FREERTOS_SYSTEM_CALLS$$Base;
+extern uint32_t Image$$ER_IROM_NS_FREERTOS_SYSTEM_CALLS_ALIGN$$Limit;
+extern uint32_t Image$$ER_IROM_NS_PRIVILEGED$$Base;
+extern uint32_t Image$$ER_IROM_NS_PRIVILEGED_ALIGN$$Limit;
+extern uint32_t Image$$ER_IROM_NS_UNPRIVILEGED$$Base;
+extern uint32_t Image$$ER_IROM_NS_UNPRIVILEGED_ALIGN$$Limit;
+
+extern uint32_t Image$$ER_IRAM_NS_PRIVILEGED$$Base;
+extern uint32_t Image$$ER_IRAM_NS_PRIVILEGED_ALIGN$$Limit;
+extern uint32_t Image$$ER_IRAM_NS_UNPRIVILEGED$$Base;
+extern uint32_t Image$$ER_IRAM_NS_UNPRIVILEGED_ALIGN$$Limit;
+
+/* Privileged flash. */
+const uint32_t * __privileged_functions_start__		= ( uint32_t * ) &( Image$$ER_IROM_NS_PRIVILEGED$$Base );
+const uint32_t * __privileged_functions_end__		= ( uint32_t * ) ( ( uint32_t ) &( Image$$ER_IROM_NS_PRIVILEGED_ALIGN$$Limit ) - 0x1 ); /* Last address in privileged Flash region. */
+
+/* Flash containing system calls. */
+const uint32_t * __syscalls_flash_start__			= ( uint32_t * ) &( Image$$ER_IROM_NS_FREERTOS_SYSTEM_CALLS$$Base );
+const uint32_t * __syscalls_flash_end__				= ( uint32_t * ) ( ( uint32_t ) &( Image$$ER_IROM_NS_FREERTOS_SYSTEM_CALLS_ALIGN$$Limit ) - 0x1 ); /* Last address in Flash region containing system calls. */
+
+/* Unprivileged flash. Note that the section containing system calls is
+ * unprivileged so that unprivileged tasks can make system calls. */
+const uint32_t * __unprivileged_flash_start__		= ( uint32_t * ) &( Image$$ER_IROM_NS_UNPRIVILEGED$$Base );
+const uint32_t * __unprivileged_flash_end__			= ( uint32_t * ) ( ( uint32_t ) &( Image$$ER_IROM_NS_UNPRIVILEGED_ALIGN$$Limit ) - 0x1 ); /* Last address in un-privileged Flash region. */
+
+/* RAM with priviledged access only. This contains kernel data. */
+const uint32_t * __privileged_sram_start__			= ( uint32_t * ) &( Image$$ER_IRAM_NS_PRIVILEGED$$Base );
+const uint32_t * __privileged_sram_end__			= ( uint32_t * ) ( ( uint32_t ) &( Image$$ER_IRAM_NS_PRIVILEGED_ALIGN$$Limit ) - 0x1 ); /* Last address in privileged RAM. */
+
+/* Unprivileged RAM. */
+const uint32_t * __unprivileged_sram_start__		= ( uint32_t * ) &( Image$$ER_IRAM_NS_UNPRIVILEGED$$Base );
+const uint32_t * __unprivileged_sram_end__			= ( uint32_t * ) ( ( uint32_t ) &( Image$$ER_IRAM_NS_UNPRIVILEGED_ALIGN$$Limit ) - 0x1 ); /* Last address in un-privileged RAM. */
diff --git a/examples/corstone310_fvp_dma/unprivileged_example/main_ns.c b/examples/corstone310_fvp_dma/unprivileged_example/main_ns.c
new file mode 100644
index 0000000..710c101
--- /dev/null
+++ b/examples/corstone310_fvp_dma/unprivileged_example/main_ns.c
@@ -0,0 +1,192 @@
+/*
+ * Copyright (c) 2017-2022 Arm Limited
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#include "stdio.h"
+#include "stdbool.h"
+#include "string.h"
+#include "uart_stdout.h"
+#include "print_log.h"
+
+#include "FreeRTOS.h"
+#include "task.h"
+#include "queue.h"
+#include "mpu_wrappers.h"
+#include "dma350_drv.h"
+#include "device_definition.h"
+#include "dma350_lib_unprivileged.h"
+
+extern uint32_t tfm_ns_interface_init(void);
+
+/*
+ * Semihosting is a mechanism that enables code running on an ARM target
+ * to communicate and use the Input/Output facilities of a host computer
+ * that is running a debugger.
+ * There is an issue where if you use armclang at -O0 optimisation with
+ * no parameters specified in the main function, the initialisation code
+ * contains a breakpoint for semihosting by default. This will stop the
+ * code from running before main is reached.
+ * Semihosting can be disabled by defining __ARM_use_no_argv symbol
+ * (or using higher optimization level).
+ */
+#if defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
+__asm("  .global __ARM_use_no_argv\n");
+#endif
+
+/*
+ * With current clib settings there is no support for errno in case of Armclang
+ * but OTA sources require it.
+ */
+#if defined (__ARMCC_VERSION)
+int errno;
+#endif
+
+/* The queue is shared between the privileged and unprivileged task, so it
+ * needs to be statically allocated. */
+/* The queue is to be created to hold a maximum of 10 uint32_t
+variables. */
+#define QUEUE_LENGTH            10
+#define ITEM_SIZE               sizeof( uint32_t )
+#define STRING_TO_MOVE_LENGTH   13
+/* The variable used to hold the queue's data structure. */
+static StaticQueue_t xStaticQueue __attribute__( ( aligned( 32 ) ) ) ;
+
+/* The array to use as the queue's storage area.  This must be at least
+uxQueueLength * uxItemSize bytes. */
+uint8_t ucQueueStorageArea[ QUEUE_LENGTH * ITEM_SIZE ] __attribute__( ( aligned( 32 ) ) );
+QueueHandle_t xQueue __attribute__( ( aligned( 32 ) ) ) ;
+char dma350_test_memory_dst[32] __attribute__( ( aligned( 32 ) ) );
+
+extern struct dma350_ch_dev_t DMA350_DMA0_CH1_DEV_NS;
+/**
+ * @brief Starts an ADA DMA transaction, then sends the error result
+ *        code to the priv task.
+ *
+ * @param pvParameters[in] Parameters as passed during task creation.
+ */
+static void unprivTask( void * pvParameters );
+
+/**
+ * @brief Waits until the unpriv task finishes the DMA transaction
+ *        and prints the result code, and destination buffer content.
+ *
+ * @param pvParameters[in] Parameters as passed during task creation.
+ */
+static void privTask( void * pvParameters );
+
+static void unprivTask(void *pvParameters)
+{
+    BaseType_t xStatus = pdPASS;
+    char dma350_test_memory_src[STRING_TO_MOVE_LENGTH] = "NS Copy Test";
+    enum dma350_lib_error_t dma_config_ret_val = DMA350_LIB_ERR_INVALID_CONFIG_TYPE;
+
+    dma_config_ret_val = dma350_memmove_unpriv(1,
+                                               (void *)dma350_test_memory_src,
+                                               (void *)dma350_test_memory_dst,
+                                               STRING_TO_MOVE_LENGTH,
+                                               DMA350_LIB_EXEC_BLOCKING);
+
+    xStatus = xQueueSendToBack(xQueue, (uint32_t *)&dma_config_ret_val, portMAX_DELAY);
+
+    while(1)
+    {
+        vTaskDelay(10);
+    }
+}
+
+static void privTask(void *pvParameters)
+{
+    enum dma350_lib_error_t dma_config_ret_val = 0;
+    BaseType_t xStatus = pdPASS;
+
+    vLoggingPrintf("Starting privTask");
+
+    while(1){
+        xStatus = xQueueReceive(xQueue, (uint32_t *)&dma_config_ret_val, portMAX_DELAY);
+        if (xStatus == pdPASS){
+            vLoggingPrintf("Received DMA return status from unprivileged task: %d",
+                            dma_config_ret_val);
+            vLoggingPrintf("Buffer after DMA transaction: %s", dma350_test_memory_dst);
+        } else {
+            vLoggingPrintf("Error in queue reception.");
+        }
+    }
+
+    vTaskDelete(NULL);
+}
+
+int main()
+{
+    static StackType_t unprivTaskStack[ configMINIMAL_STACK_SIZE ]
+                       __attribute__( ( aligned( 32 ) ) );
+    static StackType_t privTaskStack[ configMINIMAL_STACK_SIZE ]
+                       __attribute__( ( aligned( 32 ) ) );
+
+    xQueue = xQueueCreateStatic(QUEUE_LENGTH, ITEM_SIZE, ucQueueStorageArea, &xStaticQueue);
+    if (xQueue == NULL){
+        vLoggingPrintf("Failed to create queue..");
+        while(1);
+    }
+
+    /* The unprivileged task can only access the 1st DMA channel and the test memory. */
+    TaskParameters_t unprivTaskParameters =
+    {
+        .pvTaskCode     = unprivTask,
+        .pcName         = "unprivTask",
+        .usStackDepth   = configMINIMAL_STACK_SIZE,
+        .pvParameters   = NULL,
+        .uxPriority     = tskIDLE_PRIORITY,
+        .puxStackBuffer = unprivTaskStack,
+        .xRegions       =
+        {
+            { &xQueue, sizeof(&xQueue), tskMPU_REGION_READ_ONLY | tskMPU_REGION_EXECUTE_NEVER },
+            { DMA350_DMA0_CH1_DEV_NS.cfg.ch_base, 0x100,
+                        tskMPU_REGION_READ_WRITE | tskMPU_REGION_EXECUTE_NEVER },
+            { dma350_test_memory_dst, 32,
+                        tskMPU_REGION_READ_WRITE | tskMPU_REGION_EXECUTE_NEVER },
+        }
+    };
+    TaskParameters_t privTaskParameters =
+    {
+        .pvTaskCode     = privTask,
+        .pcName         = "privTask",
+        .usStackDepth   = configMINIMAL_STACK_SIZE,
+        .pvParameters   = NULL,
+        .uxPriority     = tskIDLE_PRIORITY | portPRIVILEGE_BIT,
+        .puxStackBuffer = privTaskStack,
+        .xRegions       =
+        {
+            { 0, 0, 0 },
+        }
+    };
+
+    stdio_init();
+    vUARTLockInit();
+    tfm_ns_interface_init();
+
+    /* Create tasks */
+    xTaskCreateRestricted( &( unprivTaskParameters ), NULL );
+    xTaskCreateRestricted( &( privTaskParameters ), NULL );
+
+    vLoggingPrintf("Starting FreeRTOS scheduler");
+
+    /* Start the scheduler itself. */
+    vTaskStartScheduler();
+
+    while (1)
+    {
+    }
+}
diff --git a/examples/corstone310_fvp_dma/unprivileged_example/readme.rst b/examples/corstone310_fvp_dma/unprivileged_example/readme.rst
new file mode 100755
index 0000000..6762d74
--- /dev/null
+++ b/examples/corstone310_fvp_dma/unprivileged_example/readme.rst
@@ -0,0 +1,24 @@
+########################################
+Unprivileged DMA350 example for FreeRTOS
+########################################
+
+FreeRTOS example to use DMA350 from unprivileged task.
+For detailed description of how privilege separation can be achieved with
+DMA-350, checkout :doc:`DMA-350 privilege separation <dma350_privilege_separation.rst>`
+
+***********
+Build steps
+***********
+1. Run the following command in the tf-m directory:
+
+.. code-block::
+
+ $ cmake -S . -B cmake_build -DTFM_PLATFORM=arm/mps3/corstone310_fvp -DTFM_TOOLCHAIN_FILE=toolchain_ARMCLANG.cmake -DDEFAULT_NS_SCATTER=OFF -DNS_EVALUATION_APP_PATH=<tf-m-extras root>/examples/corstone310_fvp_dma/unprivileged_example
+
+2. Then:
+
+.. code-block::
+
+ $ cmake --build cmake_build -- install
+
+*Copyright (c) 2022, Arm Limited. All rights reserved.*
diff --git a/examples/examples_readme.rst b/examples/examples_readme.rst
index 6a160b7..a737920 100755
--- a/examples/examples_readme.rst
+++ b/examples/examples_readme.rst
@@ -5,5 +5,6 @@
 (The list and simple introduction of the examples in this folder)
 
 *  DMA-350 Secure tests
+*  Non-secure DMA-350 examples for the Corstone-310 FVP platform
 
 *Copyright (c) 2021-2022, Arm Limited. All rights reserved.*