建立工程,成功创建两个虚拟串口
This commit is contained in:
247
source/OpenAMP/mw_if/app_if/openamp_conf_template.h
Normal file
247
source/OpenAMP/mw_if/app_if/openamp_conf_template.h
Normal file
@@ -0,0 +1,247 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file openamp_conf.h
|
||||
* @author MCD Application Team
|
||||
* @brief Configuration file for OpenAMP MW
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2019 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __OPENAMP_CONF__H__
|
||||
#define __OPENAMP_CONF__H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#if defined (__LOG_TRACE_IO_) || defined(__LOG_UART_IO_)
|
||||
#include "openamp_log.h"
|
||||
#endif
|
||||
|
||||
/* ########################## Mailbox Interface Selection ############################## */
|
||||
/**
|
||||
* @brief This is the list of Mailbox interface to be used in the OpenAMP MW
|
||||
* Please note that not all interfaces are supported by a STM32 device
|
||||
*/
|
||||
//#define MAILBOX_IPCC_IF_ENABLED
|
||||
//#define MAILBOX_HSEM_IF_ENABLED
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief Include Maibox interface header file
|
||||
*/
|
||||
|
||||
#ifdef MAILBOX_IPCC_IF_ENABLED
|
||||
#include "mbox_ipcc.h"
|
||||
#endif /* MAILBOX_IPCC_IF_ENABLED */
|
||||
|
||||
#ifdef MAILBOX_HSEM_IF_ENABLED
|
||||
#include "mbox_hsem.h"
|
||||
#endif /* MAILBOX_HSEM_IF_ENABLED */
|
||||
|
||||
/* ########################## Virtual Diver Module Selection ############################## */
|
||||
/**
|
||||
* @brief This is the list of modules to be used in the OpenAMP Virtual driver module
|
||||
* Please note that virtual driver are not supported on all stm32 families
|
||||
*/
|
||||
//#define VIRTUAL_UART_MODULE_ENABLED
|
||||
//#define VIRTUAL_I2C_MODULE_ENABLED
|
||||
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief Include Virtual Driver module's header file
|
||||
*/
|
||||
|
||||
#ifdef VIRTUAL_UART_MODULE_ENABLED
|
||||
#include "virt_uart.h"
|
||||
#endif /* VIRTUAL_UART_MODULE_ENABLED */
|
||||
|
||||
#ifdef VIRTUAL_I2C_MODULE_ENABLED
|
||||
#include "virt_i2c.h"
|
||||
#endif /* VIRTUAL_I2C_MODULE_ENABLED */
|
||||
|
||||
|
||||
/* ########################## Linux Master Selection ############################## */
|
||||
/**
|
||||
* @brief Due to Linux compatibility, it's important to distinguish if the MASTER is Linux or not.
|
||||
* In that case, the LINUX_RPROC_MASTER define is required
|
||||
*/
|
||||
//#define LINUX_RPROC_MASTER
|
||||
|
||||
|
||||
/* USER CODE BEGIN INCLUDE */
|
||||
|
||||
/* USER CODE END INCLUDE */
|
||||
|
||||
/** @addtogroup OPENAMP_MW
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup OPENAMP_CONF OPENAMP_CONF
|
||||
* @brief Configuration file for Openamp mw
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup OPENAMP_CONF_Exported_Variables OPENAMP_CONF_Exported_Variables
|
||||
* @brief Public variables.
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup OPENAMP_CONF_Exported_Defines OPENAMP_CONF_Exported_Defines
|
||||
* @brief Defines for configuration of the Openamp mw
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
#if defined (__ICCARM__)
|
||||
/*
|
||||
* For IAR, the .icf file should contain the following lines:
|
||||
* define symbol __OPENAMP_region_start__ = BASE_ADDRESS; (0x38000400 for example)
|
||||
* define symbol __OPENAMP_region_size__ = MEM_SIZE; (0xB000 as example)
|
||||
*
|
||||
* export symbol __OPENAMP_region_start__;
|
||||
* export symbol __OPENAMP_region_size__;
|
||||
*/
|
||||
extern const uint32_t __OPENAMP_region_start__;
|
||||
extern const uint8_t __OPENAMP_region_size__;
|
||||
#define SHM_START_ADDRESS ((metal_phys_addr_t)&__OPENAMP_region_start__)
|
||||
#define SHM_SIZE ((size_t)&__OPENAMP_region_size__)
|
||||
|
||||
#elif defined(__CC_ARM)
|
||||
/*
|
||||
* For MDK-ARM, the scatter file .sct should contain the following line:
|
||||
* LR_IROM1 .... {
|
||||
* ...
|
||||
* __OpenAMP_SHMEM__ 0x38000400 EMPTY 0x0000B000 {} ; Shared Memory area used by OpenAMP
|
||||
* }
|
||||
*
|
||||
*/
|
||||
extern unsigned int Image$$__OpenAMP_SHMEM__$$Base;
|
||||
extern unsigned int Image$$__OpenAMP_SHMEM__$$ZI$$Length;
|
||||
#define SHM_START_ADDRESS (unsigned int)&Image$$__OpenAMP_SHMEM__$$Base
|
||||
#define SHM_SIZE ((size_t)&Image$$__OpenAMP_SHMEM__$$ZI$$Length)
|
||||
|
||||
#else
|
||||
/*
|
||||
* for GCC add the following content to the .ld file:
|
||||
* MEMORY
|
||||
* {
|
||||
* ...
|
||||
* OPEN_AMP_SHMEM (xrw) : ORIGIN = 0x38000400, LENGTH = 63K
|
||||
* }
|
||||
* __OPENAMP_region_start__ = ORIGIN(OPEN_AMP_SHMEM);
|
||||
* __OPENAMP_region_end__ = ORIGIN(OPEN_AMP_SHMEM) + LENGTH(OPEN_AMP_SHMEM);
|
||||
*
|
||||
* using the LENGTH(OPEN_AMP_SHMEM) to set the SHM_SIZE lead to a crash thus we
|
||||
* use the start and end address.
|
||||
*/
|
||||
|
||||
extern int __OPENAMP_region_start__[]; /* defined by linker script */
|
||||
extern int __OPENAMP_region_end__[]; /* defined by linker script */
|
||||
|
||||
#define SHM_START_ADDRESS ((metal_phys_addr_t)__OPENAMP_region_start__)
|
||||
#define SHM_SIZE (size_t)((void *)__OPENAMP_region_end__ - (void *) __OPENAMP_region_start__)
|
||||
|
||||
#endif
|
||||
|
||||
#if defined LINUX_RPROC_MASTER
|
||||
#define VRING_RX_ADDRESS -1 /* allocated by Master processor: CA7 */
|
||||
#define VRING_TX_ADDRESS -1 /* allocated by Master processor: CA7 */
|
||||
#define VRING_BUFF_ADDRESS -1 /* allocated by Master processor: CA7 */
|
||||
#define VRING_ALIGNMENT 16 /* fixed to match with linux constraint */
|
||||
#define VRING_NUM_BUFFS 16 /* number of rpmsg buffer */
|
||||
#else
|
||||
#define VRING_RX_ADDRESS SHM_START_ADDRESS
|
||||
#define VRING_TX_ADDRESS (SHM_START_ADDRESS + 0x400)
|
||||
#define VRING_BUFF_ADDRESS (SHM_START_ADDRESS + 0x800)
|
||||
#define VRING_ALIGNMENT 4
|
||||
#define VRING_NUM_BUFFS 4 /* number of rpmsg buffers */
|
||||
#endif
|
||||
|
||||
/* Fixed parameter */
|
||||
#define NUM_RESOURCE_ENTRIES 2
|
||||
#define VRING_COUNT 2
|
||||
|
||||
#define VDEV_ID 0xFF
|
||||
#define VRING0_ID 0 /* VRING0 ID (master to remote) fixed to 0 for linux compatibility*/
|
||||
#define VRING1_ID 1 /* VRING1 ID (remote to master) fixed to 1 for linux compatibility */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup OPENAMP_CONF_Exported_Macros OPENAMP_CONF_Exported_Macros
|
||||
* @brief Aliases.
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* DEBUG macros */
|
||||
|
||||
#if defined (__LOG_TRACE_IO_) || defined(__LOG_UART_IO_)
|
||||
#define OPENAMP_log_dbg log_dbg
|
||||
#define OPENAMP_log_info log_info
|
||||
#define OPENAMP_log_warn log_warn
|
||||
#define OPENAMP_log_err log_err
|
||||
#else
|
||||
#define OPENAMP_log_dbg(...)
|
||||
#define OPENAMP_log_info(...)
|
||||
#define OPENAMP_log_warn(...)
|
||||
#define OPENAMP_log_err(...)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup OPENAMP_CONF_Exported_Types OPENAMP_CONF_Exported_Types
|
||||
* @brief Types.
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup OPENAMP_CONF_Exported_FunctionsPrototype OPENAMP_CONF_Exported_FunctionsPrototype
|
||||
* @brief Declaration of public functions for OpenAMP mw.
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Exported functions -------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __OPENAMP_CONF__H__ */
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
291
source/OpenAMP/mw_if/app_if/openamp_template.c
Normal file
291
source/OpenAMP/mw_if/app_if/openamp_template.c
Normal file
@@ -0,0 +1,291 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file openamp.c
|
||||
* @author MCD Application Team
|
||||
* @brief Code for openamp applications
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2019 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include "openamp.h"
|
||||
#include "rsc_table.h"
|
||||
#include "metal/sys.h"
|
||||
#include "metal/device.h"
|
||||
|
||||
/* Private includes ----------------------------------------------------------*/
|
||||
/* USER CODE BEGIN Includes */
|
||||
|
||||
/* USER CODE END Includes */
|
||||
|
||||
|
||||
/* Private define ------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN Define */
|
||||
|
||||
/* USER CODE END Define */
|
||||
|
||||
#define SHM_DEVICE_NAME "STM32_SHM"
|
||||
|
||||
/* Private macro -------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN PM */
|
||||
|
||||
/* USER CODE END PM */
|
||||
|
||||
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
/* USER CODE BEGIN PV */
|
||||
|
||||
/* USER CODE END PV */
|
||||
|
||||
static struct metal_io_region *shm_io;
|
||||
static struct metal_io_region *rsc_io;
|
||||
static struct shared_resource_table *rsc_table;
|
||||
static struct rpmsg_virtio_shm_pool shpool;
|
||||
static struct rpmsg_virtio_device rvdev;
|
||||
|
||||
|
||||
static metal_phys_addr_t shm_physmap;
|
||||
|
||||
struct metal_device shm_device = {
|
||||
.name = SHM_DEVICE_NAME,
|
||||
.num_regions = 2,
|
||||
.regions = {
|
||||
{.virt = NULL}, /* shared memory */
|
||||
{.virt = NULL}, /* rsc_table memory */
|
||||
},
|
||||
.node = { NULL },
|
||||
.irq_num = 0,
|
||||
.irq_info = NULL
|
||||
};
|
||||
|
||||
/* Private functions ---------------------------------------------------------*/
|
||||
/* USER CODE BEGIN PFP */
|
||||
|
||||
/* USER CODE END PFP */
|
||||
|
||||
static int OPENAMP_shmem_init(int RPMsgRole)
|
||||
{
|
||||
int status = 0;
|
||||
struct metal_device *device = NULL;
|
||||
struct metal_init_params metal_params = METAL_INIT_DEFAULTS;
|
||||
void* rsc_tab_addr = NULL;
|
||||
int rsc_size = 0;
|
||||
|
||||
|
||||
/* USER CODE BEGIN PRE_LIB_METAL_INIT */
|
||||
|
||||
/* USER CODE END PRE_LIB_METAL_INIT */
|
||||
metal_init(&metal_params);
|
||||
|
||||
status = metal_register_generic_device(&shm_device);
|
||||
if (status != 0) {
|
||||
return status;
|
||||
}
|
||||
|
||||
status = metal_device_open("generic", SHM_DEVICE_NAME, &device);
|
||||
if (status != 0) {
|
||||
return status;
|
||||
}
|
||||
|
||||
shm_physmap = SHM_START_ADDRESS;
|
||||
metal_io_init(&device->regions[0], (void *)SHM_START_ADDRESS, &shm_physmap,
|
||||
SHM_SIZE, -1, 0, NULL);
|
||||
|
||||
/* USER CODE BEGIN PRE_SHM_IO_INIT */
|
||||
|
||||
/* USER CODE END PRE_SHM_IO_INIT */
|
||||
shm_io = metal_device_io_region(device, 0);
|
||||
if (shm_io == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN POST_SHM_IO_INIT */
|
||||
|
||||
/* USER CODE END POST_SHM_IO_INIT */
|
||||
|
||||
/* Initialize resources table variables */
|
||||
resource_table_init(RPMsgRole, &rsc_tab_addr, &rsc_size);
|
||||
rsc_table = (struct shared_resource_table *)rsc_tab_addr;
|
||||
if (!rsc_table)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN POST_RSC_TABLE_INIT */
|
||||
|
||||
/* USER CODE END POST_RSC_TABLE_INIT */
|
||||
|
||||
metal_io_init(&device->regions[1], rsc_table,
|
||||
(metal_phys_addr_t *)rsc_table, rsc_size, -1U, 0, NULL);
|
||||
|
||||
/* USER CODE BEGIN POST_METAL_IO_INIT */
|
||||
|
||||
/* USER CODE END POST_METAL_IO_INIT */
|
||||
rsc_io = metal_device_io_region(device, 1);
|
||||
if (rsc_io == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN POST_RSC_IO_INIT */
|
||||
|
||||
/* USER CODE END POST_RSC_IO_INIT */
|
||||
return 0;
|
||||
}
|
||||
|
||||
int MX_OPENAMP_Init(int RPMsgRole, rpmsg_ns_bind_cb ns_bind_cb)
|
||||
{
|
||||
struct fw_rsc_vdev_vring *vring_rsc = NULL;
|
||||
struct virtio_device *vdev = NULL;
|
||||
int status = 0;
|
||||
|
||||
|
||||
/* USER CODE BEGIN MAILBOX_Init */
|
||||
|
||||
/* USER CODE END MAIL_BOX_Init */
|
||||
|
||||
MAILBOX_Init();
|
||||
|
||||
/* Libmetal Initilalization */
|
||||
status = OPENAMP_shmem_init(RPMsgRole);
|
||||
if(status)
|
||||
{
|
||||
return status;
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN PRE_VIRTIO_INIT */
|
||||
|
||||
/* USER CODE END PRE_VIRTIO_INIT */
|
||||
vdev = rproc_virtio_create_vdev(RPMsgRole, VDEV_ID, &rsc_table->vdev,
|
||||
rsc_io, NULL, MAILBOX_Notify, NULL);
|
||||
if (vdev == NULL)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
rproc_virtio_wait_remote_ready(vdev);
|
||||
|
||||
/* USER CODE BEGIN POST_VIRTIO_INIT */
|
||||
|
||||
/* USER CODE END POST_VIRTIO_INIT */
|
||||
vring_rsc = &rsc_table->vring0;
|
||||
status = rproc_virtio_init_vring(vdev, 0, vring_rsc->notifyid,
|
||||
(void *)vring_rsc->da, shm_io,
|
||||
vring_rsc->num, vring_rsc->align);
|
||||
if (status != 0)
|
||||
{
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
/* USER CODE BEGIN POST_VRING0_INIT */
|
||||
|
||||
/* USER CODE END POST_VRING0_INIT */
|
||||
vring_rsc = &rsc_table->vring1;
|
||||
status = rproc_virtio_init_vring(vdev, 1, vring_rsc->notifyid,
|
||||
(void *)vring_rsc->da, shm_io,
|
||||
vring_rsc->num, vring_rsc->align);
|
||||
if (status != 0)
|
||||
{
|
||||
return status;
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN POST_VRING1_INIT */
|
||||
|
||||
/* USER CODE END POST_VRING1_INIT */
|
||||
|
||||
rpmsg_virtio_init_shm_pool(&shpool, (void *)VRING_BUFF_ADDRESS,
|
||||
(size_t)SHM_SIZE);
|
||||
rpmsg_init_vdev(&rvdev, vdev, ns_bind_cb, shm_io, &shpool);
|
||||
|
||||
/* USER CODE BEGIN POST_RPMSG_INIT */
|
||||
|
||||
/* USER CODE END POST_RPMSG_INIT */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void OPENAMP_DeInit()
|
||||
{
|
||||
|
||||
/* USER CODE BEGIN PRE_OPENAMP_DEINIT */
|
||||
|
||||
/* USER CODE END PRE_OPENAMP_DEINIT */
|
||||
|
||||
rpmsg_deinit_vdev(&rvdev);
|
||||
|
||||
metal_finish();
|
||||
|
||||
/* USER CODE BEGIN POST_OPENAMP_DEINIT */
|
||||
|
||||
/* USER CODE END POST_OPENAMP_DEINIT */
|
||||
}
|
||||
|
||||
void OPENAMP_init_ept(struct rpmsg_endpoint *ept)
|
||||
{
|
||||
/* USER CODE BEGIN PRE_EP_INIT */
|
||||
|
||||
/* USER CODE END PRE_EP_INIT */
|
||||
|
||||
rpmsg_init_ept(ept, "", RPMSG_ADDR_ANY, RPMSG_ADDR_ANY, NULL, NULL);
|
||||
|
||||
/* USER CODE BEGIN POST_EP_INIT */
|
||||
|
||||
/* USER CODE END POST_EP_INIT */
|
||||
}
|
||||
|
||||
int OPENAMP_create_endpoint(struct rpmsg_endpoint *ept, const char *name,
|
||||
uint32_t dest, rpmsg_ept_cb cb,
|
||||
rpmsg_ns_unbind_cb unbind_cb)
|
||||
{
|
||||
int ret = 0;
|
||||
/* USER CODE BEGIN PRE_EP_CREATE */
|
||||
|
||||
/* USER CODE END PRE_EP_CREATE */
|
||||
|
||||
ret = rpmsg_create_ept(ept, &rvdev.rdev, name, RPMSG_ADDR_ANY, dest, cb,
|
||||
unbind_cb);
|
||||
|
||||
/* USER CODE BEGIN POST_EP_CREATE */
|
||||
|
||||
/* USER CODE END POST_EP_CREATE */
|
||||
return ret;
|
||||
}
|
||||
|
||||
void OPENAMP_check_for_message(void)
|
||||
{
|
||||
/* USER CODE BEGIN MSG_CHECK */
|
||||
|
||||
/* USER CODE END MSG_CHECK */
|
||||
MAILBOX_Poll(rvdev.vdev);
|
||||
}
|
||||
|
||||
void OPENAMP_Wait_EndPointready(struct rpmsg_endpoint *rp_ept)
|
||||
{
|
||||
/* USER CODE BEGIN EP_READY */
|
||||
|
||||
/* USER CODE END EP_READY */
|
||||
|
||||
while(!is_rpmsg_ept_ready(rp_ept))
|
||||
{
|
||||
/* USER CODE BEGIN 0 */
|
||||
|
||||
/* USER CODE END 0 */
|
||||
MAILBOX_Poll(rvdev.vdev);
|
||||
|
||||
/* USER CODE BEGIN 1 */
|
||||
|
||||
/* USER CODE END 1 */
|
||||
}
|
||||
}
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
90
source/OpenAMP/mw_if/app_if/openamp_template.h
Normal file
90
source/OpenAMP/mw_if/app_if/openamp_template.h
Normal file
@@ -0,0 +1,90 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file openamp.h
|
||||
* @brief Header for openamp applications
|
||||
* @author MCD Application Team
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2019 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __openamp_H
|
||||
#define __openamp_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "openamp/open_amp.h"
|
||||
#include "openamp_conf.h"
|
||||
|
||||
/* Private includes ----------------------------------------------------------*/
|
||||
/* USER CODE BEGIN Includes */
|
||||
|
||||
/* USER CODE END Includes */
|
||||
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN ET */
|
||||
|
||||
/* USER CODE END ET */
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/* USER CODE BEGIN EC */
|
||||
|
||||
/* USER CODE END EC */
|
||||
|
||||
/* Private defines -----------------------------------------------------------*/
|
||||
/* USER CODE BEGIN Private defines */
|
||||
|
||||
/* USER CODE END Private defines */
|
||||
|
||||
#define OPENAMP_send rpmsg_send
|
||||
#define OPENAMP_destroy_ept rpmsg_destroy_ept
|
||||
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN EM */
|
||||
|
||||
/* USER CODE END EM */
|
||||
|
||||
/* Exported functions prototypes ---------------------------------------------*/
|
||||
/* USER CODE BEGIN EFP */
|
||||
|
||||
/* USER CODE END EFP */
|
||||
|
||||
|
||||
/* Initialize the openamp framework*/
|
||||
int MX_OPENAMP_Init(int RPMsgRole, rpmsg_ns_bind_cb ns_bind_cb);
|
||||
|
||||
/* Deinitialize the openamp framework*/
|
||||
void OPENAMP_DeInit(void);
|
||||
|
||||
/* Initialize the endpoint struct*/
|
||||
void OPENAMP_init_ept(struct rpmsg_endpoint *ept);
|
||||
|
||||
/* Create and register the endpoint */
|
||||
int OPENAMP_create_endpoint(struct rpmsg_endpoint *ept, const char *name,
|
||||
uint32_t dest, rpmsg_ept_cb cb,
|
||||
rpmsg_ns_unbind_cb unbind_cb);
|
||||
|
||||
/* Check for new rpmsg reception */
|
||||
void OPENAMP_check_for_message(void);
|
||||
|
||||
/* Wait loop on endpoint ready ( message dest address is know)*/
|
||||
void OPENAMP_Wait_EndPointready(struct rpmsg_endpoint *rp_ept);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /*__openamp_H */
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
224
source/OpenAMP/mw_if/platform_if/mbox_hsem_template.c
Normal file
224
source/OpenAMP/mw_if/platform_if/mbox_hsem_template.c
Normal file
@@ -0,0 +1,224 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* File Name : mbox_hsem.c
|
||||
* Description : This file provides code for the configuration
|
||||
* of the mailbox based on hardware semaphore.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2019 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "openamp/open_amp.h"
|
||||
#include "stm32h7xx_hal.h"
|
||||
#include "openamp_conf.h"
|
||||
#include "mbox_hsem.h"
|
||||
|
||||
|
||||
/* Private define ------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN Define */
|
||||
|
||||
/* USER CODE END Define */
|
||||
|
||||
#define RX_NO_MSG 0
|
||||
#define RX_NEW_MSG 1
|
||||
|
||||
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
/* USER CODE BEGIN PV */
|
||||
|
||||
/* USER CODE END PV */
|
||||
|
||||
static uint32_t msg_received = RX_NO_MSG;
|
||||
|
||||
/* Private functions ---------------------------------------------------------*/
|
||||
/* USER CODE BEGIN PFP */
|
||||
|
||||
/* USER CODE END PFP */
|
||||
|
||||
void HAL_HSEM_FreeCallback(uint32_t SemMask)
|
||||
{
|
||||
|
||||
/* USER CODE BEGIN HSEM_FREE_CALLBACK */
|
||||
|
||||
/* USER CODE END HSEM_FREE_CALLBACK */
|
||||
|
||||
/* Prevent unused argument(s) compilation warning */
|
||||
UNUSED(SemMask);
|
||||
msg_received = RX_NEW_MSG;
|
||||
|
||||
#ifdef CORE_CM7
|
||||
|
||||
/* USER CODE BEGIN PRE_HSEM_FREE_CALLBACK_CM7 */
|
||||
|
||||
/* USER CODE END PRE_HSEM_FREE_CALLBACK_CM7 */
|
||||
|
||||
HAL_HSEM_ActivateNotification(__HAL_HSEM_SEMID_TO_MASK(HSEM_ID_1));
|
||||
|
||||
/* USER CODE BEGIN POST_HSEM_FREE_CALLBACK_CM7 */
|
||||
|
||||
/* USER CODE END POST_HSEM_FREE_CALLBACK_CM7 */
|
||||
|
||||
#endif
|
||||
#ifdef CORE_CM4
|
||||
|
||||
/* USER CODE BEGIN PRE_HSEM_FREE_CALLBACK_CM4 */
|
||||
|
||||
/* USER CODE END PRE_HSEM_FREE_CALLBACK_CM4 */
|
||||
|
||||
HAL_HSEM_ActivateNotification(__HAL_HSEM_SEMID_TO_MASK(HSEM_ID_0));
|
||||
|
||||
|
||||
/* USER CODE BEGIN POST_HSEM_FREE_CALLBACK_CM4 */
|
||||
|
||||
/* USER CODE END POST_HSEM_FREE_CALLBACK_CM4 */
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Initialize MAILBOX with IPCC peripheral
|
||||
* @param None
|
||||
* @retval : Operation result
|
||||
*/
|
||||
int MAILBOX_Init(void)
|
||||
{
|
||||
/* USER CODE BEGIN MAILBOX_INIT */
|
||||
|
||||
/* USER CODE END MAILBOX_INIT */
|
||||
__HAL_RCC_HSEM_CLK_ENABLE();
|
||||
|
||||
#ifdef CORE_CM7
|
||||
|
||||
/* USER CODE BEGIN PRE_MAILBOX_INIT_CM7 */
|
||||
|
||||
/* USER CODE END PRE_MAILBOX_INIT_CM7 */
|
||||
|
||||
/* Enable CM7 receive irq */
|
||||
HAL_NVIC_SetPriority(HSEM1_IRQn, 0, 1);
|
||||
HAL_NVIC_EnableIRQ(HSEM1_IRQn);
|
||||
HAL_HSEM_ActivateNotification(__HAL_HSEM_SEMID_TO_MASK(HSEM_ID_1));
|
||||
|
||||
/* USER CODE BEGIN POST_MAILBOX_INIT_CM7 */
|
||||
|
||||
/* USER CODE END POST_MAILBOX_INIT_CM7 */
|
||||
#endif
|
||||
#ifdef CORE_CM4
|
||||
|
||||
/* USER CODE BEGIN MAILBOX_INIT_CM4 */
|
||||
|
||||
/* USER CODE END MAILBOX_INIT_CM4 */
|
||||
|
||||
/* Enable CM4 receive irq */
|
||||
HAL_NVIC_SetPriority(HSEM2_IRQn, 0, 1);
|
||||
HAL_NVIC_EnableIRQ(HSEM2_IRQn);
|
||||
HAL_HSEM_ActivateNotification(__HAL_HSEM_SEMID_TO_MASK(HSEM_ID_0));
|
||||
|
||||
/* USER CODE BEGIN POST_MAILBOX_INIT_CM4 */
|
||||
|
||||
/* USER CODE END POST_MAILBOX_INIT_CM4 */
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Initialize MAILBOX with IPCC peripheral
|
||||
* @param virtio device
|
||||
* @retval : Operation result
|
||||
*/
|
||||
int MAILBOX_Poll(struct virtio_device *vdev)
|
||||
{
|
||||
/* If we got an interrupt, ask for the corresponding virtqueue processing */
|
||||
|
||||
if (msg_received == RX_NEW_MSG)
|
||||
{
|
||||
|
||||
/* USER CODE BEGIN NEW_MSG */
|
||||
|
||||
/* USER CODE END NEW_MSG */
|
||||
#ifdef CORE_CM7
|
||||
|
||||
/* USER CODE BEGIN PRE_NEW_MSG_CM7 */
|
||||
|
||||
/* USER CODE END PRE_NEW_MSG_CM7 */
|
||||
|
||||
rproc_virtio_notified(vdev, VRING0_ID);
|
||||
|
||||
/* USER CODE BEGIN POST_NEW_MSG_CM7 */
|
||||
|
||||
/* USER CODE END POST_NEW_MSG_CM7 */
|
||||
#endif
|
||||
#ifdef CORE_CM4
|
||||
|
||||
/* USER CODE BEGIN PRE_NEW_MSG_CM4 */
|
||||
|
||||
/* USER CODE END PRE_NEW_MSG_CM4 */
|
||||
|
||||
rproc_virtio_notified(vdev, VRING1_ID);
|
||||
|
||||
/* USER CODE BEGIN POST_NEW_MSG_CM4 */
|
||||
|
||||
/* USER CODE END POST_NEW_MSG_CM4 */
|
||||
#endif
|
||||
msg_received = RX_NO_MSG;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* USER CODE BEGIN NO_MSG */
|
||||
|
||||
/* USER CODE END NO_MSG */
|
||||
return -EAGAIN;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Callback function called by OpenAMP MW to notify message processing
|
||||
* @param VRING id
|
||||
* @retval Operation result
|
||||
*/
|
||||
int MAILBOX_Notify(void *priv, uint32_t id)
|
||||
{
|
||||
(void)priv;
|
||||
(void)id;
|
||||
|
||||
/* USER CODE BEGIN MAILBOX_NOTIFY*/
|
||||
|
||||
/* USER CODE END MAILBOX_NOTIFY */
|
||||
#ifdef CORE_CM7
|
||||
|
||||
/* USER CODE BEGIN PRE_MAILBOX_NOTIFY_CM7 */
|
||||
|
||||
/* USER CODE END PRE_MAILBOX_NOTIFY_CM7 */
|
||||
HAL_HSEM_FastTake(HSEM_ID_0);
|
||||
HAL_HSEM_Release(HSEM_ID_0,0);
|
||||
|
||||
/* USER CODE BEGIN POST_MAILBOX_NOTIFY_CM7 */
|
||||
|
||||
/* USER CODE END POST_MAILBOX_NOTIFY_CM7 */
|
||||
#endif
|
||||
#ifdef CORE_CM4
|
||||
|
||||
/* USER CODE BEGIN PRE_MAILBOX_NOTIFY_CM4 */
|
||||
|
||||
/* USER CODE END PRE_MAILBOX_NOTIFY_CM4 */
|
||||
|
||||
HAL_HSEM_FastTake(HSEM_ID_1);
|
||||
HAL_HSEM_Release(HSEM_ID_1,0);
|
||||
|
||||
/* USER CODE BEGIN POST_MAILBOX_NOTIFY_CM4 */
|
||||
|
||||
/* USER CODE END POST_MAILBOX_NOTIFY_CM4 */
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
62
source/OpenAMP/mw_if/platform_if/mbox_hsem_template.h
Normal file
62
source/OpenAMP/mw_if/platform_if/mbox_hsem_template.h
Normal file
@@ -0,0 +1,62 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file mabox_hsem.h
|
||||
* @author MCD Application Team
|
||||
* @brief header for mbox_hsem.c module
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2019 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef MBOX_HSEM_H_
|
||||
#define MBOX_HSEM_H_
|
||||
|
||||
/* Private includes ----------------------------------------------------------*/
|
||||
/* USER CODE BEGIN Includes */
|
||||
|
||||
/* USER CODE END Includes */
|
||||
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN ET */
|
||||
|
||||
/* USER CODE END ET */
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/* USER CODE BEGIN EC */
|
||||
|
||||
/* USER CODE END EC */
|
||||
|
||||
/* Private defines -----------------------------------------------------------*/
|
||||
/* USER CODE BEGIN Private defines */
|
||||
|
||||
/* USER CODE END Private defines */
|
||||
|
||||
#define HSEM_ID_0 0 /* CM7 to CM4 Notification */
|
||||
#define HSEM_ID_1 1 /* CM4 to CM7 Notification */
|
||||
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN EM */
|
||||
|
||||
/* USER CODE END EM */
|
||||
|
||||
/* Exported functions prototypes ---------------------------------------------*/
|
||||
/* USER CODE BEGIN EFP */
|
||||
|
||||
/* USER CODE END EFP */
|
||||
|
||||
int MAILBOX_Notify(void *priv, uint32_t id);
|
||||
int MAILBOX_Init(void);
|
||||
int MAILBOX_Poll(struct virtio_device *vdev);
|
||||
|
||||
#endif /* MBOX_HSEM_H_ */
|
248
source/OpenAMP/mw_if/platform_if/mbox_ipcc_template.c
Normal file
248
source/OpenAMP/mw_if/platform_if/mbox_ipcc_template.c
Normal file
@@ -0,0 +1,248 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file mbox_ipcc.c
|
||||
* @author MCD Application Team
|
||||
* @brief This file provides code for the configuration
|
||||
* of the mailbox_ipcc_if.c MiddleWare.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2019 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
* Channel direction and usage:
|
||||
*
|
||||
* ======== <-- new msg ---=============--------<------ =======
|
||||
* || || || CHANNEL 1 || || ||
|
||||
* || A7 || ------->-------=============--- buf free--> || M4 ||
|
||||
* || || || ||
|
||||
* ||master|| <-- buf free---=============--------<------ ||slave||
|
||||
* || || || CHANNEL 2 || || ||
|
||||
* ======== ------->-------=============----new msg --> =======
|
||||
*/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "openamp/open_amp.h"
|
||||
#include "stm32mp1xx_hal.h"
|
||||
#include "openamp_conf.h"
|
||||
|
||||
/* Private define ------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN Define */
|
||||
|
||||
/* USER CODE END Define */
|
||||
|
||||
#define MASTER_CPU_ID 0
|
||||
#define REMOTE_CPU_ID 1
|
||||
#define IPCC_CPU_A7 MASTER_CPU_ID
|
||||
#define IPCC_CPU_M4 REMOTE_CPU_ID
|
||||
|
||||
#define RX_NO_MSG 0
|
||||
#define RX_NEW_MSG 1
|
||||
#define RX_BUF_FREE 2
|
||||
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
/* USER CODE BEGIN PFP */
|
||||
|
||||
/* USER CODE END PFP */
|
||||
|
||||
extern IPCC_HandleTypeDef hipcc;
|
||||
int msg_received_ch1 = RX_NO_MSG;
|
||||
int msg_received_ch2 = RX_NO_MSG;
|
||||
uint32_t vring0_id = 0; /* used for channel 1 */
|
||||
uint32_t vring1_id = 1; /* used for channel 2 */
|
||||
|
||||
/* Private function prototypes -----------------------------------------------*/
|
||||
/* USER CODE BEGIN PFP */
|
||||
|
||||
/* USER CODE END PFP */
|
||||
|
||||
void IPCC_channel1_callback(IPCC_HandleTypeDef * hipcc, uint32_t ChannelIndex, IPCC_CHANNELDirTypeDef ChannelDir);
|
||||
void IPCC_channel2_callback(IPCC_HandleTypeDef * hipcc, uint32_t ChannelIndex, IPCC_CHANNELDirTypeDef ChannelDir);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Initialize MAILBOX with IPCC peripheral
|
||||
* @param None
|
||||
* @retval : Operation result
|
||||
*/
|
||||
int MAILBOX_Init(void)
|
||||
{
|
||||
|
||||
/* USER CODE BEGIN PRE_MAILBOX_INIT */
|
||||
|
||||
/* USER CODE END PRE_MAILBOX_INIT */
|
||||
|
||||
if (HAL_IPCC_ActivateNotification(&hipcc, IPCC_CHANNEL_1, IPCC_CHANNEL_DIR_RX,
|
||||
IPCC_channel1_callback) != HAL_OK) {
|
||||
OPENAMP_log_err("%s: ch_1 RX fail\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (HAL_IPCC_ActivateNotification(&hipcc, IPCC_CHANNEL_2, IPCC_CHANNEL_DIR_RX,
|
||||
IPCC_channel2_callback) != HAL_OK) {
|
||||
OPENAMP_log_err("%s: ch_2 RX fail\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
/* USER CODE BEGIN POST_MAILBOX_INIT */
|
||||
|
||||
/* USER CODE END POST_MAILBOX_INIT */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Initialize MAILBOX with IPCC peripheral
|
||||
* @param virtio device
|
||||
* @retval : Operation result
|
||||
*/
|
||||
int MAILBOX_Poll(struct virtio_device *vdev)
|
||||
{
|
||||
/* If we got an interrupt, ask for the corresponding virtqueue processing */
|
||||
int ret = -1;
|
||||
|
||||
/* USER CODE BEGIN PRE_MAILBOX_POLL */
|
||||
|
||||
/* USER CODE END PRE_MAILBOX_POLL */
|
||||
|
||||
if (msg_received_ch1 == RX_BUF_FREE) {
|
||||
|
||||
/* USER CODE BEGIN MSG_CHANNEL1 */
|
||||
|
||||
/* USER CODE END MSG_CHANNEL1 */
|
||||
|
||||
OPENAMP_log_dbg("Running virt0 (ch_1 buf free)\r\n");
|
||||
rproc_virtio_notified(vdev, VRING0_ID);
|
||||
msg_received_ch1 = RX_NO_MSG;
|
||||
ret = 0;
|
||||
}
|
||||
|
||||
if (msg_received_ch2 == RX_NEW_MSG) {
|
||||
|
||||
/* USER CODE BEGIN MSG_CHANNEL2 */
|
||||
|
||||
/* USER CODE END MSG_CHANNEL2 */
|
||||
|
||||
OPENAMP_log_dbg("Running virt1 (ch_2 new msg)\r\n");
|
||||
rproc_virtio_notified(vdev, VRING1_ID);
|
||||
msg_received_ch2 = RX_NO_MSG;
|
||||
|
||||
/* The OpenAMP framework does not notify for free buf: do it here */
|
||||
rproc_virtio_notified(NULL, VRING1_ID);
|
||||
ret = 0;
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN POST_MAILBOX_POLL */
|
||||
|
||||
/* USER CODE END POST_MAILBOX_POLL */
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Callback function called by OpenAMP MW to notify message processing
|
||||
* @param VRING id
|
||||
* @retval Operation result
|
||||
*/
|
||||
int MAILBOX_Notify(void *priv, uint32_t id)
|
||||
{
|
||||
uint32_t channel;
|
||||
(void)priv;
|
||||
|
||||
/* USER CODE BEGIN PRE_MAILBOX_NOTIFY */
|
||||
|
||||
/* USER CODE END PRE_MAILBOX_NOTIFY */
|
||||
|
||||
/* Called after virtqueue processing: time to inform the remote */
|
||||
if (id == VRING0_ID) {
|
||||
channel = IPCC_CHANNEL_1;
|
||||
OPENAMP_log_dbg("Send msg on ch_1\r\n");
|
||||
}
|
||||
else if (id == VRING1_ID) {
|
||||
/* Note: the OpenAMP framework never notifies this */
|
||||
channel = IPCC_CHANNEL_2;
|
||||
OPENAMP_log_dbg("Send 'buff free' on ch_2\r\n");
|
||||
}
|
||||
else {
|
||||
OPENAMP_log_err("invalid vring (%d)\r\n", (int)id);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Check that the channel is free (otherwise wait until it is) */
|
||||
if (HAL_IPCC_GetChannelStatus(&hipcc, channel, IPCC_CHANNEL_DIR_TX) == IPCC_CHANNEL_STATUS_OCCUPIED) {
|
||||
OPENAMP_log_dbg("Waiting for channel to be freed\r\n");
|
||||
while (HAL_IPCC_GetChannelStatus(&hipcc, channel, IPCC_CHANNEL_DIR_TX) == IPCC_CHANNEL_STATUS_OCCUPIED)
|
||||
;
|
||||
}
|
||||
|
||||
/* Inform A7 (either new message, or buf free) */
|
||||
HAL_IPCC_NotifyCPU(&hipcc, channel, IPCC_CHANNEL_DIR_TX);
|
||||
|
||||
/* USER CODE BEGIN POST_MAILBOX_NOTIFY */
|
||||
|
||||
/* USER CODE END POST_MAILBOX_NOTIFY */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Private function ---------------------------------------------------------*/
|
||||
/* USER CODE BEGIN 0 */
|
||||
|
||||
/* USER CODE END 0 */
|
||||
/* Callback from IPCC Interrupt Handler: Master Processor informs that there are some free buffers */
|
||||
void IPCC_channel1_callback(IPCC_HandleTypeDef * hipcc,
|
||||
uint32_t ChannelIndex, IPCC_CHANNELDirTypeDef ChannelDir)
|
||||
{
|
||||
|
||||
/* USER CODE BEGIN PRE_MAILBOX_CHANNEL1_CALLBACK */
|
||||
|
||||
/* USER CODE END PRE_MAILBOX_CHANNEL1_CALLBACK */
|
||||
|
||||
if (msg_received_ch1 != RX_NO_MSG)
|
||||
OPENAMP_log_dbg("IPCC_channel1_callback: previous IRQ not treated (status = %d)\r\n", msg_received_ch1);
|
||||
|
||||
msg_received_ch1 = RX_BUF_FREE;
|
||||
|
||||
/* Inform A7 that we have received the 'buff free' msg */
|
||||
OPENAMP_log_dbg("Ack 'buff free' message on ch1\r\n");
|
||||
HAL_IPCC_NotifyCPU(hipcc, ChannelIndex, IPCC_CHANNEL_DIR_RX);
|
||||
|
||||
/* USER CODE BEGIN POST_MAILBOX_CHANNEL1_CALLBACK */
|
||||
|
||||
/* USER CODE END POST_MAILBOX_CHANNEL1_CALLBACK */
|
||||
}
|
||||
|
||||
/* Callback from IPCC Interrupt Handler: new message received from Master Processor */
|
||||
void IPCC_channel2_callback(IPCC_HandleTypeDef * hipcc,
|
||||
uint32_t ChannelIndex, IPCC_CHANNELDirTypeDef ChannelDir)
|
||||
{
|
||||
|
||||
/* USER CODE BEGIN PRE_MAILBOX_CHANNEL2_CALLBACK */
|
||||
|
||||
/* USER CODE END PRE_MAILBOX_CHANNEL2_CALLBACK */
|
||||
|
||||
if (msg_received_ch2 != RX_NO_MSG)
|
||||
OPENAMP_log_dbg("IPCC_channel2_callback: previous IRQ not treated (status = %d)\r\n", msg_received_ch2);
|
||||
|
||||
msg_received_ch2 = RX_NEW_MSG;
|
||||
|
||||
/* Inform A7 that we have received the new msg */
|
||||
OPENAMP_log_dbg("Ack new message on ch2\r\n");
|
||||
HAL_IPCC_NotifyCPU(hipcc, ChannelIndex, IPCC_CHANNEL_DIR_RX);
|
||||
|
||||
/* USER CODE BEGIN POST_MAILBOX_CHANNEL2_CALLBACK */
|
||||
|
||||
/* USER CODE END POST_MAILBOX_CHANNEL2_CALLBACK */
|
||||
}
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
58
source/OpenAMP/mw_if/platform_if/mbox_ipcc_template.h
Normal file
58
source/OpenAMP/mw_if/platform_if/mbox_ipcc_template.h
Normal file
@@ -0,0 +1,58 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file mbox_ipcc.h
|
||||
* @author MCD Application Team
|
||||
* @brief Header for mbox_ipcc.c module
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2019 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef MBOX_IPCC_H_
|
||||
#define MBOX_IPCC_H_
|
||||
|
||||
/* Private includes ----------------------------------------------------------*/
|
||||
/* USER CODE BEGIN Includes */
|
||||
|
||||
/* USER CODE END Includes */
|
||||
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN ET */
|
||||
|
||||
/* USER CODE END ET */
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/* USER CODE BEGIN EC */
|
||||
|
||||
/* USER CODE END EC */
|
||||
|
||||
/* Private defines -----------------------------------------------------------*/
|
||||
/* USER CODE BEGIN Private defines */
|
||||
|
||||
/* USER CODE END Private defines */
|
||||
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN EM */
|
||||
|
||||
/* USER CODE END EM */
|
||||
|
||||
/* Exported functions prototypes ---------------------------------------------*/
|
||||
/* USER CODE BEGIN EFP */
|
||||
|
||||
/* USER CODE END EFP */
|
||||
|
||||
int MAILBOX_Notify(void *priv, uint32_t id);
|
||||
int MAILBOX_Init(void);
|
||||
int MAILBOX_Poll(struct virtio_device *vdev);
|
||||
|
||||
#endif /* MBOX_IPCC_H_ */
|
175
source/OpenAMP/mw_if/platform_if/rsc_table_template.c
Normal file
175
source/OpenAMP/mw_if/platform_if/rsc_table_template.c
Normal file
@@ -0,0 +1,175 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file rsc_table.c
|
||||
* @author MCD Application Team
|
||||
* @brief Ressource table
|
||||
*
|
||||
* This file provides a default resource table requested by remote proc to
|
||||
* load the elf file. It also allows to add debug trace using a shared buffer.
|
||||
*
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2019 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/** @addtogroup RSC_TABLE
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup resource_table
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup resource_table_Private_Includes
|
||||
* @{
|
||||
*/
|
||||
|
||||
#if defined(__ICCARM__) || defined (__CC_ARM)
|
||||
#include <stddef.h> /* needed for offsetof definition*/
|
||||
#endif
|
||||
#include "rsc_table.h"
|
||||
#include "openamp/open_amp.h"
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup resource_table_Private_TypesDefinitions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @addtogroup resource_table_Private_Defines
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Place resource table in special ELF section */
|
||||
#if defined(__GNUC__)
|
||||
#define __section_t(S) __attribute__((__section__(#S)))
|
||||
#define __resource __section_t(.resource_table)
|
||||
#endif
|
||||
|
||||
#if defined (LINUX_RPROC_MASTER)
|
||||
#ifdef VIRTIO_MASTER_ONLY
|
||||
#define CONST
|
||||
#else
|
||||
#define CONST const
|
||||
#endif
|
||||
#else
|
||||
#define CONST
|
||||
#endif
|
||||
|
||||
#define RPMSG_IPU_C0_FEATURES 1
|
||||
#define VRING_COUNT 2
|
||||
|
||||
/* VirtIO rpmsg device id */
|
||||
#define VIRTIO_ID_RPMSG_ 7
|
||||
|
||||
#if defined (__LOG_TRACE_IO_)
|
||||
extern char system_log_buf[];
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__)
|
||||
#if !defined (__CC_ARM) && !defined (LINUX_RPROC_MASTER)
|
||||
|
||||
/* Since GCC is not initializing the resource_table at startup, it is declared as volatile to avoid compiler optimization
|
||||
* for the CM4 (see resource_table_init() below)
|
||||
*/
|
||||
volatile struct shared_resource_table __resource __attribute__((used)) resource_table;
|
||||
#else
|
||||
CONST struct shared_resource_table __resource __attribute__((used)) resource_table = {
|
||||
#endif
|
||||
#elif defined(__ICCARM__)
|
||||
__root CONST struct shared_resource_table resource_table @ ".resource_table" = {
|
||||
#endif
|
||||
|
||||
#if defined(__ICCARM__) || defined (__CC_ARM) || defined (LINUX_RPROC_MASTER)
|
||||
.version = 1,
|
||||
#if defined (__LOG_TRACE_IO_)
|
||||
.num = 2,
|
||||
#else
|
||||
.num = 1,
|
||||
#endif
|
||||
.reserved = {0, 0},
|
||||
.offset = {
|
||||
offsetof(struct shared_resource_table, vdev),
|
||||
offsetof(struct shared_resource_table, cm_trace),
|
||||
},
|
||||
|
||||
/* Virtio device entry */
|
||||
.vdev= {
|
||||
RSC_VDEV, VIRTIO_ID_RPMSG_, 0, RPMSG_IPU_C0_FEATURES, 0, 0, 0,
|
||||
VRING_COUNT, {0, 0},
|
||||
},
|
||||
|
||||
/* Vring rsc entry - part of vdev rsc entry */
|
||||
.vring0 = {VRING_TX_ADDRESS, VRING_ALIGNMENT, VRING_NUM_BUFFS, VRING0_ID, 0},
|
||||
.vring1 = {VRING_RX_ADDRESS, VRING_ALIGNMENT, VRING_NUM_BUFFS, VRING1_ID, 0},
|
||||
|
||||
#if defined (__LOG_TRACE_IO_)
|
||||
.cm_trace = {
|
||||
RSC_TRACE,
|
||||
(uint32_t)system_log_buf, SYSTEM_TRACE_BUF_SZ, 0, "cm4_log",
|
||||
},
|
||||
#endif
|
||||
} ;
|
||||
#endif
|
||||
|
||||
void resource_table_init(int RPMsgRole, void **table_ptr, int *length)
|
||||
{
|
||||
|
||||
#if !defined (LINUX_RPROC_MASTER)
|
||||
#if defined (__GNUC__) && ! defined (__CC_ARM)
|
||||
#ifdef VIRTIO_MASTER_ONLY
|
||||
|
||||
/*
|
||||
* Currently the GCC linker doesn't initialize the resource_table global variable at startup
|
||||
* it is done here by the master application.
|
||||
*/
|
||||
memset(&resource_table, '\0', sizeof(struct shared_resource_table));
|
||||
resource_table.num = 1;
|
||||
resource_table.version = 1;
|
||||
resource_table.offset[0] = offsetof(struct shared_resource_table, vdev);
|
||||
|
||||
resource_table.vring0.da = VRING_TX_ADDRESS;
|
||||
resource_table.vring0.align = VRING_ALIGNMENT;
|
||||
resource_table.vring0.num = VRING_NUM_BUFFS;
|
||||
resource_table.vring0.notifyid = VRING0_ID;
|
||||
|
||||
resource_table.vring1.da = VRING_RX_ADDRESS;
|
||||
resource_table.vring1.align = VRING_ALIGNMENT;
|
||||
resource_table.vring1.num = VRING_NUM_BUFFS;
|
||||
resource_table.vring1.notifyid = VRING1_ID;
|
||||
|
||||
|
||||
resource_table.vdev.type = RSC_VDEV;
|
||||
resource_table.vdev.id = VIRTIO_ID_RPMSG_;
|
||||
resource_table.vdev.num_of_vrings=VRING_COUNT;
|
||||
resource_table.vdev.dfeatures = RPMSG_IPU_C0_FEATURES;
|
||||
#else
|
||||
|
||||
/* For the slave application let's wait until the resource_table is correctly initialized */
|
||||
while(resource_table.vring1.da != VRING_RX_ADDRESS)
|
||||
{
|
||||
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
(void)RPMsgRole;
|
||||
*length = sizeof(resource_table);
|
||||
*table_ptr = (void *)&resource_table;
|
||||
}
|
70
source/OpenAMP/mw_if/platform_if/rsc_table_template.h
Normal file
70
source/OpenAMP/mw_if/platform_if/rsc_table_template.h
Normal file
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* Copyright (c) 2019 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
*/
|
||||
|
||||
/* This file populates resource table for BM remote
|
||||
* for use by the Linux Master */
|
||||
|
||||
#ifndef RSC_TABLE_H_
|
||||
#define RSC_TABLE_H_
|
||||
|
||||
#include "openamp/open_amp.h"
|
||||
#include "openamp_conf.h"
|
||||
|
||||
/* Private includes ----------------------------------------------------------*/
|
||||
/* USER CODE BEGIN Includes */
|
||||
|
||||
/* USER CODE END Includes */
|
||||
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN ET */
|
||||
|
||||
/* Resource table for the given remote */
|
||||
struct shared_resource_table {
|
||||
unsigned int version;
|
||||
unsigned int num;
|
||||
unsigned int reserved[2];
|
||||
unsigned int offset[NUM_RESOURCE_ENTRIES];
|
||||
/* text carveout entry */
|
||||
|
||||
/* rpmsg vdev entry */
|
||||
struct fw_rsc_vdev vdev;
|
||||
struct fw_rsc_vdev_vring vring0;
|
||||
struct fw_rsc_vdev_vring vring1;
|
||||
struct fw_rsc_trace cm_trace;
|
||||
};
|
||||
|
||||
/* USER CODE END ET */
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/* USER CODE BEGIN EC */
|
||||
|
||||
/* USER CODE END EC */
|
||||
|
||||
/* Private defines -----------------------------------------------------------*/
|
||||
/* USER CODE BEGIN Private defines */
|
||||
|
||||
/* USER CODE END Private defines */
|
||||
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN EM */
|
||||
|
||||
/* USER CODE END EM */
|
||||
|
||||
/* Exported functions prototypes ---------------------------------------------*/
|
||||
/* USER CODE BEGIN EFP */
|
||||
|
||||
/* USER CODE END EFP */
|
||||
|
||||
void resource_table_init(int RPMsgRole, void **table_ptr, int *length);
|
||||
|
||||
#endif /* RSC_TABLE_H_ */
|
||||
|
55
source/OpenAMP/mw_if/st_readme.txt
Normal file
55
source/OpenAMP/mw_if/st_readme.txt
Normal file
@@ -0,0 +1,55 @@
|
||||
|
||||
@verbatim
|
||||
********************************************************************************
|
||||
* @file st_readme.txt
|
||||
* @author MCD Application Team
|
||||
* @brief This file lists the main modification done by STMicroelectronics on
|
||||
* OpenAMP/mw_if to work with the openAMP stack within the STM32 Cube_FW
|
||||
********************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2019 STMicroelectronics. All rights reserved.
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
@endverbatim
|
||||
|
||||
### V1.0.4/10-January-2020 ###
|
||||
===============================
|
||||
+ openamp_template.c, openamp_template.h, mbox_hsem_template.c, mbox_hsem_template.h, mbox_ipcc_template.c, mbox_ipcc_template.h, rsc_table_template.h:
|
||||
- Add "User Code " sections
|
||||
|
||||
+ openamp_template.c:
|
||||
- initialize local variables to '0'
|
||||
|
||||
### V1.0.3/08-November-2019 ##
|
||||
===============================
|
||||
+ openamp_conf_template.h:
|
||||
- replace the "STM32MP157Cxx" define macro with "LINUX_RPROC_MASTER" to support all STM32MP1 varieties
|
||||
|
||||
### V1.0.2/29-July-2019 ###
|
||||
============================
|
||||
|
||||
+ rsc_table_template.c:
|
||||
- fix a runtime issue when the "__LOG_TRACE_IO_" flag is not enabled.
|
||||
|
||||
### V1.0.1/15-June-2019 ###
|
||||
============================
|
||||
+ openamp_conf_template.h:
|
||||
- use "openamp_log.h" header name instead of "log.h" to avoid name clashing.
|
||||
|
||||
+ rsc_table_template.c:
|
||||
- correct declaration of the resource_table for the STM32MP1
|
||||
|
||||
|
||||
### V1.0.0/29-Mach-2019 ###
|
||||
============================
|
||||
+ First version compliant with the OpenAMP v2018.10 release
|
||||
|
||||
|
||||
* <h3><center>© COPYRIGHT STMicroelectronics</center></h3>
|
||||
*/
|
Reference in New Issue
Block a user