From 7cf18a9b3dae4b334df11d6e4f119a232f8ca403 Mon Sep 17 00:00:00 2001 From: Andrew Davis Date: Fri, 15 Mar 2024 10:59:07 -0500 Subject: [PATCH] apps: Move common function declaration to common header Several platform_*() functions are common across the example machines. They actually have to be as they are consumed by example apps that build across these machines. Move these common declarations to common a header. Signed-off-by: Andrew Davis --- apps/CMakeLists.txt | 2 + apps/include/platform_info_common.h | 79 +++++++++++++++++++ .../microblaze_generic/platform_info.h | 59 +------------- apps/machine/zynq7/platform_info.h | 59 +------------- apps/machine/zynqmp/platform_info.h | 60 +------------- apps/machine/zynqmp_r5/platform_info.h | 59 +------------- .../linux/machine/generic/platform_info.h | 65 +-------------- 7 files changed, 90 insertions(+), 293 deletions(-) create mode 100644 apps/include/platform_info_common.h diff --git a/apps/CMakeLists.txt b/apps/CMakeLists.txt index 95b48e0f0..d91825660 100644 --- a/apps/CMakeLists.txt +++ b/apps/CMakeLists.txt @@ -8,6 +8,8 @@ set (APPS_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}") set (APPS_SHARE_DIR "${CMAKE_CURRENT_BINARY_DIR}/share") +collect (APP_INC_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/include") + add_subdirectory (machine) add_subdirectory (system) add_subdirectory (tests) diff --git a/apps/include/platform_info_common.h b/apps/include/platform_info_common.h new file mode 100644 index 000000000..c1f5c6613 --- /dev/null +++ b/apps/include/platform_info_common.h @@ -0,0 +1,79 @@ +/* + * Copyright (C) 2024 Texas Instruments, Inc. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef PLATFORM_INFO_COMMON_H +#define PLATFORM_INFO_COMMON_H + +#include +#include +#include + +#if defined __cplusplus +extern "C" { +#endif + +/** + * platform_init - initialize the platform + * + * Initialize the platform. + * + * @argc: number of arguments + * @argv: array of the input arguments + * @platform: pointer to store the platform data pointer + * + * return 0 for success or negative value for failure + */ +int platform_init(int argc, char *argv[], void **platform); + +/** + * platform_create_rpmsg_vdev - create rpmsg vdev + * + * Create rpmsg virtio device, and return the rpmsg virtio + * device pointer. + * + * @platform: pointer to the private data + * @vdev_index: index of the virtio device, there can more than one vdev + * on the platform. + * @role: virtio driver or virtio device of the vdev + * @rst_cb: virtio device reset callback + * @ns_bind_cb: rpmsg name service bind callback + * + * return pointer to the rpmsg virtio device + */ +struct rpmsg_device * +platform_create_rpmsg_vdev(void *platform, unsigned int vdev_index, + unsigned int role, + void (*rst_cb)(struct virtio_device *vdev), + rpmsg_ns_bind_cb ns_bind_cb); + +/** + * platform_poll - platform poll function + * + * @platform: pointer to the platform + * + * return negative value for errors, otherwise 0. + */ +int platform_poll(void *platform); + +/** + * platform_release_rpmsg_vdev - release rpmsg virtio device + * + * @rpdev: pointer to the rpmsg device + */ +void platform_release_rpmsg_vdev(struct rpmsg_device *rpdev, void *platform); + +/** + * platform_cleanup - clean up the platform resource + * + * @platform: pointer to the platform + */ +void platform_cleanup(void *platform); + +#if defined __cplusplus +} +#endif + +#endif /* PLATFORM_INFO_COMMON_H */ diff --git a/apps/machine/microblaze_generic/platform_info.h b/apps/machine/microblaze_generic/platform_info.h index edfde5c83..d14dbf5b0 100644 --- a/apps/machine/microblaze_generic/platform_info.h +++ b/apps/machine/microblaze_generic/platform_info.h @@ -10,6 +10,8 @@ #include #include +#include "platform_info_common.h" + #if defined __cplusplus extern "C" { #endif @@ -33,63 +35,6 @@ struct remoteproc_priv { atomic_int ipi_nokick; }; -/** - * platform_init - initialize the platform - * - * Initialize the platform. - * - * @argc: number of arguments - * @argv: array of the input arguments - * @platform: pointer to store the platform data pointer - * - * return 0 for success or negative value for failure - */ -int platform_init(int argc, char *argv[], void **platform); - -/** - * platform_create_rpmsg_vdev - create rpmsg vdev - * - * Create rpmsg virtio device, and return the rpmsg virtio - * device pointer. - * - * @platform: pointer to the private data - * @vdev_index: index of the virtio device, there can more than one vdev - * on the platform. - * @role: virtio driver or virtio device of the vdev - * @rst_cb: virtio device reset callback - * @ns_bind_cb: rpmsg name service bind callback - * - * return pointer to the rpmsg virtio device - */ -struct rpmsg_device * -platform_create_rpmsg_vdev(void *platform, unsigned int vdev_index, - unsigned int role, - void (*rst_cb)(struct virtio_device *vdev), - rpmsg_ns_bind_cb ns_bind_cb); - -/** - * platform_poll - platform poll function - * - * @platform: pointer to the platform - * - * return negative value for errors, otherwise 0. - */ -int platform_poll(void *platform); - -/** - * platform_release_rpmsg_vdev - release rpmsg virtio device - * - * @rpdev: pointer to the rpmsg device - */ -void platform_release_rpmsg_vdev(struct rpmsg_device *rpdev, void *platform); - -/** - * platform_cleanup - clean up the platform resource - * - * @platform: pointer to the platform - */ -void platform_cleanup(void *platform); - #if defined __cplusplus } #endif diff --git a/apps/machine/zynq7/platform_info.h b/apps/machine/zynq7/platform_info.h index bb259700b..f7586a012 100644 --- a/apps/machine/zynq7/platform_info.h +++ b/apps/machine/zynq7/platform_info.h @@ -12,6 +12,8 @@ #include #include +#include "platform_info_common.h" + #if defined __cplusplus extern "C" { #endif @@ -50,63 +52,6 @@ struct remoteproc_priv { atomic_int nokick; /* 0 for kick from other side */ }; -/** - * platform_init - initialize the platform - * - * It will initialize the platform. - * - * @argc: number of arguments - * @argv: array of the input arguments - * @platform: pointer to store the platform data pointer - * - * return 0 for success or negative value for failure - */ -int platform_init(int argc, char *argv[], void **platform); - -/** - * platform_create_rpmsg_vdev - create rpmsg vdev - * - * It will create rpmsg virtio device, and returns the rpmsg virtio - * device pointer. - * - * @platform: pointer to the private data - * @vdev_index: index of the virtio device, there can more than one vdev - * on the platform. - * @role: virtio driver or virtio device of the vdev - * @rst_cb: virtio device reset callback - * @ns_bind_cb: rpmsg name service bind callback - * - * return pointer to the rpmsg virtio device - */ -struct rpmsg_device * -platform_create_rpmsg_vdev(void *platform, unsigned int vdev_index, - unsigned int role, - void (*rst_cb)(struct virtio_device *vdev), - rpmsg_ns_bind_cb ns_bind_cb); - -/** - * platform_poll - platform poll function - * - * @platform: pointer to the platform - * - * return negative value for errors, otherwise 0. - */ -int platform_poll(void *platform); - -/** - * platform_release_rpmsg_vdev - release rpmsg virtio device - * - * @rpdev: pointer to the rpmsg device - */ -void platform_release_rpmsg_vdev(struct rpmsg_device *rpdev, void *platform); - -/** - * platform_cleanup - clean up the platform resource - * - * @platform: pointer to the platform - */ -void platform_cleanup(void *platform); - #if defined __cplusplus } #endif diff --git a/apps/machine/zynqmp/platform_info.h b/apps/machine/zynqmp/platform_info.h index 7e8d0f9e3..6dccecf13 100644 --- a/apps/machine/zynqmp/platform_info.h +++ b/apps/machine/zynqmp/platform_info.h @@ -16,6 +16,8 @@ #include #include +#include "platform_info_common.h" + #if defined __cplusplus extern "C" { #endif @@ -51,64 +53,6 @@ struct remoteproc_priv { #define POLL_STOP 0x1U #endif /* RPMSG_NO_IPI */ - -/** - * platform_init - initialize the platform - * - * It will initialize the platform. - * - * @argc: number of arguments - * @argv: array of the input arguments - * @platform: pointer to store the platform data pointer - * - * return 0 for success or negative value for failure - */ -int platform_init(int argc, char *argv[], void **platform); - -/** - * platform_create_rpmsg_vdev - create rpmsg vdev - * - * It will create rpmsg virtio device, and returns the rpmsg virtio - * device pointer. - * - * @platform: pointer to the private data - * @vdev_index: index of the virtio device, there can more than one vdev - * on the platform. - * @role: virtio driver or virtio device of the vdev - * @rst_cb: virtio device reset callback - * @ns_bind_cb: rpmsg name service bind callback - * - * return pointer to the rpmsg virtio device - */ -struct rpmsg_device * -platform_create_rpmsg_vdev(void *platform, unsigned int vdev_index, - unsigned int role, - void (*rst_cb)(struct virtio_device *vdev), - rpmsg_ns_bind_cb ns_bind_cb); - -/** - * platform_poll - platform poll function - * - * @platform: pointer to the platform - * - * return negative value for errors, otherwise 0. - */ -int platform_poll(void *platform); - -/** - * platform_release_rpmsg_vdev - release rpmsg virtio device - * - * @rpdev: pointer to the rpmsg device - */ -void platform_release_rpmsg_vdev(struct rpmsg_device *rpdev, void *platform); - -/** - * platform_cleanup - clean up the platform resource - * - * @platform: pointer to the platform - */ -void platform_cleanup(void *platform); - #if defined __cplusplus } #endif diff --git a/apps/machine/zynqmp_r5/platform_info.h b/apps/machine/zynqmp_r5/platform_info.h index 075b69e2c..6e4b7fd97 100644 --- a/apps/machine/zynqmp_r5/platform_info.h +++ b/apps/machine/zynqmp_r5/platform_info.h @@ -13,6 +13,8 @@ #include #include +#include "platform_info_common.h" + #if defined __cplusplus extern "C" { #endif @@ -73,63 +75,6 @@ struct remoteproc_priv { #endif /* !RPMSG_NO_IPI */ }; -/** - * platform_init - initialize the platform - * - * It will initialize the platform. - * - * @argc: number of arguments - * @argv: array of the input arguments - * @platform: pointer to store the platform data pointer - * - * return 0 for success or negative value for failure - */ -int platform_init(int argc, char *argv[], void **platform); - -/** - * platform_create_rpmsg_vdev - create rpmsg vdev - * - * It will create rpmsg virtio device, and returns the rpmsg virtio - * device pointer. - * - * @platform: pointer to the private data - * @vdev_index: index of the virtio device, there can more than one vdev - * on the platform. - * @role: virtio driver or virtio device of the vdev - * @rst_cb: virtio device reset callback - * @ns_bind_cb: rpmsg name service bind callback - * - * return pointer to the rpmsg virtio device - */ -struct rpmsg_device * -platform_create_rpmsg_vdev(void *platform, unsigned int vdev_index, - unsigned int role, - void (*rst_cb)(struct virtio_device *vdev), - rpmsg_ns_bind_cb ns_bind_cb); - -/** - * platform_poll - platform poll function - * - * @platform: pointer to the platform - * - * return negative value for errors, otherwise 0. - */ -int platform_poll(void *platform); - -/** - * platform_release_rpmsg_vdev - release rpmsg virtio device - * - * @rpdev: pointer to the rpmsg device - */ -void platform_release_rpmsg_vdev(struct rpmsg_device *rpdev, void *platform); - -/** - * platform_cleanup - clean up the platform resource - * - * @platform: pointer to the platform - */ -void platform_cleanup(void *platform); - #if defined __cplusplus } #endif diff --git a/apps/system/linux/machine/generic/platform_info.h b/apps/system/linux/machine/generic/platform_info.h index 82d242db8..b9f453148 100644 --- a/apps/system/linux/machine/generic/platform_info.h +++ b/apps/system/linux/machine/generic/platform_info.h @@ -16,69 +16,6 @@ #include #include -#if defined __cplusplus -extern "C" { -#endif - -/** - * platform_init - initialize the platform - * - * It will initialize the platform. - * - * @argc: number of arguments - * @argv: array of the input arguments - * @platform: pointer to store the platform data pointer - * - * return 0 for success or negative value for failure - */ -int platform_init(int argc, char *argv[], void **platform); - -/** - * platform_create_rpmsg_vdev - create rpmsg vdev - * - * It will create rpmsg virtio device, and returns the rpmsg virtio - * device pointer. - * - * @platform: pointer to the private data - * @vdev_index: index of the virtio device, there can more than one vdev - * on the platform. - * @role: virtio driver or virtio device of the vdev - * @rst_cb: virtio device reset callback - * @ns_bind_cb: rpmsg name service bind callback - * - * return pointer to the rpmsg virtio device - */ -struct rpmsg_device * -platform_create_rpmsg_vdev(void *platform, unsigned int vdev_index, - unsigned int role, - void (*rst_cb)(struct virtio_device *vdev), - rpmsg_ns_bind_cb ns_bind_cb); - -/** - * platform_poll - platform poll function - * - * @platform: pointer to the platform - * - * return negative value for errors, otherwise 0. - */ -int platform_poll(void *platform); - -/** - * platform_release_rpmsg_vdev - release rpmsg virtio device - * - * @rpdev: pointer to the rpmsg device - */ -void platform_release_rpmsg_vdev(struct rpmsg_device *rpdev, void *platform); - -/** - * platform_cleanup - clean up the platform resource - * - * @platform: pointer to the platform - */ -void platform_cleanup(void *platform); - -#if defined __cplusplus -} -#endif +#include "platform_info_common.h" #endif /* PLATFORM_INFO_H */