1 | /* |
---|
2 | * Copyright (c) 2013 Daniel Ramirez <javamonn@gmail.com> |
---|
3 | * |
---|
4 | * The license and distribution terms for this file may be |
---|
5 | * found in the file LICENSE in this distribution or at |
---|
6 | * http://www.rtems.org/license/LICENSE. |
---|
7 | */ |
---|
8 | |
---|
9 | #ifdef HAVE_CONFIG_H |
---|
10 | #include "config.h" |
---|
11 | #endif |
---|
12 | |
---|
13 | #include <bsp.h> |
---|
14 | |
---|
15 | #include <stdlib.h> |
---|
16 | #include <stdio.h> |
---|
17 | |
---|
18 | #include <sys/types.h> |
---|
19 | #include <sys/stat.h> |
---|
20 | #include <fcntl.h> |
---|
21 | #include <sys/ioctl.h> |
---|
22 | #include <unistd.h> |
---|
23 | #include <rtems/mw_uid.h> |
---|
24 | #include "termios_testdriver_intr.h" |
---|
25 | #include "tmacros.h" |
---|
26 | |
---|
27 | const char rtems_test_name[] = "UID 1"; |
---|
28 | |
---|
29 | #define UID_MESSAGE_COUNT 10 |
---|
30 | |
---|
31 | /* forward declarations to avoid warnings */ |
---|
32 | rtems_task Init(rtems_task_argument argument); |
---|
33 | void open_it(void); |
---|
34 | void register_it(void); |
---|
35 | void printf_uid_message(struct MW_UID_MESSAGE *uid); |
---|
36 | void receive_uid_message(void); |
---|
37 | void close_it(void); |
---|
38 | |
---|
39 | extern const char *Mouse_Type_Long; |
---|
40 | extern const char *Mouse_Type_Short; |
---|
41 | extern const unsigned char Mouse_Actions[]; |
---|
42 | extern const size_t Mouse_Actions_Size; |
---|
43 | extern const size_t Mouse_Actions_Per_Iteration; |
---|
44 | |
---|
45 | int Mouse_Index = 0; |
---|
46 | |
---|
47 | int Test_fd; |
---|
48 | |
---|
49 | void open_it(void) |
---|
50 | { |
---|
51 | /* open the file */ |
---|
52 | Test_fd = open( "/dev/mouse", O_RDONLY ); |
---|
53 | rtems_test_assert( Test_fd != -1 ); |
---|
54 | } |
---|
55 | |
---|
56 | void register_it(void) |
---|
57 | { |
---|
58 | int rc; |
---|
59 | char name[5] = "mous"; |
---|
60 | |
---|
61 | rc = uid_open_queue( name, 0, UID_MESSAGE_COUNT ); |
---|
62 | rtems_test_assert( rc == 0 ); |
---|
63 | |
---|
64 | rc = uid_register_device( Test_fd, name ); |
---|
65 | rtems_test_assert( rc == 0 ); |
---|
66 | } |
---|
67 | |
---|
68 | void printf_uid_message( |
---|
69 | struct MW_UID_MESSAGE *uid |
---|
70 | ) |
---|
71 | { |
---|
72 | uid_print_message_with_plugin( |
---|
73 | &rtems_test_printer, |
---|
74 | uid |
---|
75 | ); |
---|
76 | } |
---|
77 | |
---|
78 | void receive_uid_message(void) |
---|
79 | { |
---|
80 | int rc; |
---|
81 | struct MW_UID_MESSAGE uid; |
---|
82 | |
---|
83 | rc = uid_read_message( &uid, 0.5L ); |
---|
84 | if ( rc != sizeof(struct MW_UID_MESSAGE) ) |
---|
85 | return; |
---|
86 | printf_uid_message( &uid ); |
---|
87 | } |
---|
88 | |
---|
89 | void close_it(void) |
---|
90 | { |
---|
91 | int rc; |
---|
92 | |
---|
93 | rc = uid_unregister_device( Test_fd ); |
---|
94 | rtems_test_assert( rc == 0 ); |
---|
95 | |
---|
96 | rc = close( Test_fd ); |
---|
97 | rtems_test_assert( rc == 0 ); |
---|
98 | } |
---|
99 | |
---|
100 | rtems_task Init( |
---|
101 | rtems_task_argument ignored |
---|
102 | ) |
---|
103 | { |
---|
104 | |
---|
105 | TEST_BEGIN(); |
---|
106 | |
---|
107 | open_it(); |
---|
108 | register_it(); |
---|
109 | |
---|
110 | /* No message should ever be recieved. With a timeout val of 0, this |
---|
111 | * call will never return. We use this to check if patch was correct |
---|
112 | * by passing a number of ticks greater than 0 and less than 1. If |
---|
113 | * patch was correct, this call will timeout instead of waiting |
---|
114 | * indefinitely. |
---|
115 | */ |
---|
116 | receive_uid_message(); |
---|
117 | |
---|
118 | close_it(); |
---|
119 | TEST_END(); |
---|
120 | rtems_test_exit( 0 ); |
---|
121 | } |
---|
122 | |
---|
123 | /* configuration information */ |
---|
124 | |
---|
125 | #include <rtems/serial_mouse.h> |
---|
126 | #include "termios_testdriver_intr.h" |
---|
127 | |
---|
128 | /* NOTICE: the clock driver is explicitly disabled */ |
---|
129 | #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER |
---|
130 | #define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER |
---|
131 | #define CONFIGURE_APPLICATION_EXTRA_DRIVERS \ |
---|
132 | TERMIOS_TEST_DRIVER_TABLE_ENTRY, \ |
---|
133 | SERIAL_MOUSE_DRIVER_TABLE_ENTRY |
---|
134 | |
---|
135 | /* one for the console and one for the test port */ |
---|
136 | #define CONFIGURE_NUMBER_OF_TERMIOS_PORTS 2 |
---|
137 | |
---|
138 | /* we need to be able to open the test device and mouse */ |
---|
139 | #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 5 |
---|
140 | #define CONFIGURE_MAXIMUM_TASKS 1 |
---|
141 | #define CONFIGURE_MAXIMUM_TIMERS 2 |
---|
142 | #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 1 |
---|
143 | |
---|
144 | #define CONFIGURE_MESSAGE_BUFFER_MEMORY \ |
---|
145 | CONFIGURE_MESSAGE_BUFFERS_FOR_QUEUE( \ |
---|
146 | UID_MESSAGE_COUNT, \ |
---|
147 | sizeof(struct MW_UID_MESSAGE) \ |
---|
148 | ) |
---|
149 | |
---|
150 | #define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION |
---|
151 | |
---|
152 | #define CONFIGURE_RTEMS_INIT_TASKS_TABLE |
---|
153 | |
---|
154 | #define CONFIGURE_INIT_TASK_ATTRIBUTES RTEMS_FLOATING_POINT |
---|
155 | |
---|
156 | #define CONFIGURE_INIT |
---|
157 | |
---|
158 | #include <rtems/confdefs.h> |
---|
159 | |
---|
160 | /* end of file */ |
---|