Skip to content

Commit

Permalink
apps: Move common function declaration to common header
Browse files Browse the repository at this point in the history
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 <afd@ti.com>
  • Loading branch information
glneo committed Mar 15, 2024
1 parent 79b795e commit 7cf18a9
Show file tree
Hide file tree
Showing 7 changed files with 90 additions and 293 deletions.
2 changes: 2 additions & 0 deletions apps/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
79 changes: 79 additions & 0 deletions apps/include/platform_info_common.h
Original file line number Diff line number Diff line change
@@ -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 <openamp/remoteproc.h>
#include <openamp/virtio.h>
#include <openamp/rpmsg.h>

#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 */
59 changes: 2 additions & 57 deletions apps/machine/microblaze_generic/platform_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#include <openamp/virtio.h>
#include <openamp/rpmsg.h>

#include "platform_info_common.h"

#if defined __cplusplus
extern "C" {
#endif
Expand All @@ -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
Expand Down
59 changes: 2 additions & 57 deletions apps/machine/zynq7/platform_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
#include <openamp/virtio.h>
#include <openamp/rpmsg.h>

#include "platform_info_common.h"

#if defined __cplusplus
extern "C" {
#endif
Expand Down Expand Up @@ -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
Expand Down
60 changes: 2 additions & 58 deletions apps/machine/zynqmp/platform_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
#include <openamp/virtio.h>
#include <openamp/rpmsg.h>

#include "platform_info_common.h"

#if defined __cplusplus
extern "C" {
#endif
Expand Down Expand Up @@ -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
Expand Down
59 changes: 2 additions & 57 deletions apps/machine/zynqmp_r5/platform_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
#include <openamp/virtio.h>
#include <openamp/rpmsg.h>

#include "platform_info_common.h"

#if defined __cplusplus
extern "C" {
#endif
Expand Down Expand Up @@ -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
Expand Down
Loading

0 comments on commit 7cf18a9

Please sign in to comment.