[PATCH 4/7][RFC] apps: oob echo: move code common in multiple files to header

8 views
Skip to first unread message

Ben Levinsky

unread,
Oct 29, 2019, 11:39:56 AM10/29/19
to open...@googlegroups.com, ed.mo...@xilinx.com, ser...@xilinx.com, manj...@xilinx.com
Previously struct packet definition in addition to some #define's
were duplicated across .c files. Move to shared .h file for cleaner design.

Signed-off-by: Ben Levinsky <ben.le...@xilinx.com>
---
apps/examples/oob_echo/rpmsg-echo.h | 17 +++++++++++++++++
apps/examples/oob_echo/rpmsg-oob-echo.c | 22 ----------------------
apps/examples/oob_echo/rpmsg-oob-ping.c | 17 -----------------
3 files changed, 17 insertions(+), 39 deletions(-)

diff --git a/apps/examples/oob_echo/rpmsg-echo.h b/apps/examples/oob_echo/rpmsg-echo.h
index d15eb56..829bd7f 100644
--- a/apps/examples/oob_echo/rpmsg-echo.h
+++ b/apps/examples/oob_echo/rpmsg-echo.h
@@ -3,4 +3,21 @@

#define RPMSG_SERVICE_NAME "rpmsg-openamp-demo-channel"

+#define OUT_OF_BAND (0x1UL<<31)
+#define INIT_MSG 0x2UL
+#define ACK_MSG 0X3UL
+#define DATA_MSG 0x4UL
+#define SHUTDOWN_MSG 0x5UL
+#define TABLE_BASE_ADDRESS 0x3ee20000UL
+#define BUFFER_SIZE 0x10000UL //64K.. can change to 65K as needed
+
+static struct packet {
+ unsigned packet_type;
+ unsigned buffer_index;
+ unsigned packet_length;
+};
+
+#define LPRINTF(format, ...) printf(format, ##__VA_ARGS__)
+//#define LPRINTF(format, ...)
+#define LPERROR(format, ...) LPRINTF("ERROR: " format, ##__VA_ARGS__)
#endif /* RPMSG_ECHO_H */
diff --git a/apps/examples/oob_echo/rpmsg-oob-echo.c b/apps/examples/oob_echo/rpmsg-oob-echo.c
index b4cc29a..3bf3c28 100644
--- a/apps/examples/oob_echo/rpmsg-oob-echo.c
+++ b/apps/examples/oob_echo/rpmsg-oob-echo.c
@@ -8,28 +8,6 @@ This application echoes back data that was sent to it by the master core. */
#include "platform_info.h"
#include "rpmsg-echo.h"

-#define OUT_OF_BAND (0x1UL<<31)
-#define INIT_MSG 0x2UL
-#define ACK_MSG 0X3UL
-#define DATA_MSG 0x4UL
-#define SHUTDOWN_MSG 0x5UL
-
-#define TABLE_BASE_ADDRESS 0x3ee20000UL
-#define BUFFER_SIZE 0x10000UL //64K.. can change to 65K as needed
-#define NUM_BUFFERS 16
-#define NUM_MESSAGES_TO_SEND 32
-
-static struct packet {
- unsigned packet_type;
- unsigned buffer_index;
- unsigned packet_length;
-};
-
-
-#define LPRINTF(format, ...) printf(format, ##__VA_ARGS__)
-//#define LPRINTF(format, ...)
-#define LPERROR(format, ...) LPRINTF("ERROR: " format, ##__VA_ARGS__)
-
static struct rpmsg_endpoint lept;
static int shutdown_req = 0;

diff --git a/apps/examples/oob_echo/rpmsg-oob-ping.c b/apps/examples/oob_echo/rpmsg-oob-ping.c
index 6508c32..46d88dd 100644
--- a/apps/examples/oob_echo/rpmsg-oob-ping.c
+++ b/apps/examples/oob_echo/rpmsg-oob-ping.c
@@ -17,28 +17,11 @@ This application echoes back data that was sent to it by the master core. */
#define LPRINTF(format, ...) printf(format, ##__VA_ARGS__)
#define LPERROR(format, ...) LPRINTF("ERROR: " format, ##__VA_ARGS__)

-
-#define OUT_OF_BAND (0x1UL<<31)
-#define INIT_MSG 0x2UL
-#define ACK_MSG 0X3UL
-#define DATA_MSG 0x4UL
-#define SHUTDOWN_MSG 0x5UL
-
-#define TABLE_BASE_ADDRESS 0x3ee20000UL
-#define BUFFER_SIZE 0x10000UL //64K.. can change to 65K as needed
#define NUM_BUFFERS 16
#define NUM_MESSAGES_TO_SEND 32

#define DEV_BUS_NAME "platform"

-
-static struct packet {
- unsigned packet_type;
- unsigned buffer_index;
- unsigned packet_length;
-};
-
-
static void* large_buffer;

static char data_to_send[BUFFER_SIZE];
--
2.7.4

Reply all
Reply to author
Forward
0 new messages