1 /* master.c */
2
3 /*
4 * Copyright (c) 1997-2010,2013-2015 Wind River Systems, Inc.
5 *
6 * SPDX-License-Identifier: Apache-2.0
7 */
8
9 /*
10 *File Naming information.
11 * ------------------------
12 * Files that end with:
13 * _B : Is a file that contains a benchmark function
14 * _R : Is a file that contains the receiver task
15 * of a benchmark function
16 */
17 #include <zephyr/tc_util.h>
18 #include "master.h"
19
20 char msg[MAX_MSG];
21 char data_bench[MESSAGE_SIZE];
22
23 #ifdef PIPE_BENCH
24 struct k_pipe *test_pipes[] = {&PIPE_NOBUFF, &PIPE_SMALLBUFF, &PIPE_BIGBUFF};
25 #endif
26 char sline[SLINE_LEN + 1];
27 const char newline[] = "\n";
28
29 /*
30 * Time in timer cycles necessary to read time.
31 * Used for correction in time measurements.
32 */
33 uint32_t tm_off;
34
35
36 /********************************************************************/
37 /* static allocation */
38 K_THREAD_DEFINE(RECVTASK, 1024, recvtask, NULL, NULL, NULL, 5, 0, 0);
39
40 K_MSGQ_DEFINE(DEMOQX1, 1, 500, 4);
41 K_MSGQ_DEFINE(DEMOQX4, 4, 500, 4);
42 K_MSGQ_DEFINE(MB_COMM, 12, 1, 4);
43 K_MSGQ_DEFINE(CH_COMM, 12, 1, 4);
44
45 K_MEM_SLAB_DEFINE(MAP1, 16, 2, 4);
46
47 K_SEM_DEFINE(SEM0, 0, 1);
48 K_SEM_DEFINE(SEM1, 0, 1);
49 K_SEM_DEFINE(SEM2, 0, 1);
50 K_SEM_DEFINE(SEM3, 0, 1);
51 K_SEM_DEFINE(SEM4, 0, 1);
52 K_SEM_DEFINE(STARTRCV, 0, 1);
53
54 K_MBOX_DEFINE(MAILB1);
55
56 K_MUTEX_DEFINE(DEMO_MUTEX);
57
58 K_PIPE_DEFINE(PIPE_NOBUFF, 0, 4);
59 K_PIPE_DEFINE(PIPE_SMALLBUFF, 256, 4);
60 K_PIPE_DEFINE(PIPE_BIGBUFF, 4096, 4);
61
62 /**
63 *
64 * @brief Check for keypress
65 *
66 * @return 1 when a keyboard key is pressed, or 0 if no keyboard support
67 */
kbhit(void)68 int kbhit(void)
69 {
70 return 0;
71 }
72
73 /**
74 *
75 * @brief Close output for the test
76 *
77 */
output_close(void)78 void output_close(void)
79 {
80 }
81
82 /* no need to wait for user key press when using console */
83 #define WAIT_FOR_USER() {}
84
85
86 /**
87 *
88 * @brief Perform all selected benchmarks
89 * see config.h to select or to unselect
90 *
91 */
main(void)92 int main(void)
93 {
94 int continuously = 0;
95
96 bench_test_init();
97
98 PRINT_STRING(newline);
99 do {
100 PRINT_STRING(dashline);
101 PRINT_STRING("| S I M P L E S E R V I C E "
102 "M E A S U R E M E N T S | nsec |\n");
103 PRINT_STRING(dashline);
104 queue_test();
105 sema_test();
106 mutex_test();
107 memorymap_test();
108 mailbox_test();
109 pipe_test();
110 PRINT_STRING("| END OF TESTS "
111 " |\n");
112 PRINT_STRING(dashline);
113 PRINT_STRING("PROJECT EXECUTION SUCCESSFUL\n");
114 TC_PRINT_RUNID;
115 } while (continuously && !kbhit());
116
117 WAIT_FOR_USER();
118
119 k_thread_abort(RECVTASK);
120
121 output_close();
122 return 0;
123 }
124
125
126 /**
127 *
128 * @brief Dummy test
129 *
130 */
dummy_test(void)131 void dummy_test(void)
132 {
133 }
134