source: rtems/testsuites/libtests/mouse01/init.c @ 8d7aea0d

4.115
Last change on this file since 8d7aea0d was 3d4f749, checked in by Joel Sherrill <joel.sherrill@…>, on 03/14/11 at 16:18:10

2011-03-14 Joel Sherrill <joel.sherrill@…>

  • Makefile.am, configure.ac: Add test for Mouse Parser Engine (Microsoft Mouse paths) and Serial Mouse Driver.
  • mouse01/.cvsignore, mouse01/Makefile.am, mouse01/init.c, mouse01/mouse01.doc, mouse01/mouse01.scn, mouse01/msmouse.c, mouse01/serial_mouse_config.c: New files.
  • Property mode set to 100644
File size: 3.4 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-2011.
3 *  On-Line Applications Research Corporation (OAR).
4 *
5 *  The license and distribution terms for this file may be
6 *  found in the file LICENSE in this distribution or at
7 *  http://www.rtems.com/license/LICENSE.
8 *
9 *  $Id$
10 */
11
12#include <bsp.h>
13
14#include <stdlib.h>
15#include <stdio.h>
16
17#include <sys/types.h>
18#include <sys/stat.h>
19#include <fcntl.h>
20#include <sys/ioctl.h>
21#include <unistd.h>
22#include <rtems/mw_uid.h>
23#include "termios_testdriver_intr.h"
24#include "tmacros.h"
25
26extern const char *Mouse_Type_Long;
27extern const char *Mouse_Type_Short;
28extern const unsigned char Mouse_Actions[];
29extern const size_t Mouse_Actions_Size;
30extern const size_t Mouse_Actions_Per_Iteration;
31
32int Mouse_Index = 0;
33
34bool enqueue_next_action(
35  const unsigned char *actions,
36  size_t               max,
37  size_t               to_enqueue
38)
39{
40  if ( (Mouse_Index + to_enqueue) > max )
41    return false;
42
43  termios_test_driver_set_rx_enqueue_now( true );
44 
45  termios_test_driver_set_rx( &actions[Mouse_Index], to_enqueue );
46  Mouse_Index += to_enqueue;
47
48  return true;
49}
50
51int Test_fd;
52
53void open_it(void)
54{
55  /* open the file */
56  puts( "open(/dev/mouse) - OK " );
57  Test_fd = open( "/dev/mouse", O_RDONLY );
58  rtems_test_assert( Test_fd != -1 );
59}
60
61void register_it(void)
62{
63  int                rc;
64  char               name[5] = "mous";
65
66  printf( "uid_open_queue() - mouse queue\n" );
67  rc = uid_open_queue( name, 0, 10 );
68  rtems_test_assert( rc == 0 );
69
70  printf( "uid_register_device() - OK\n");
71  rc = uid_register_device( Test_fd, name );
72  rtems_test_assert( rc == 0 );
73}
74
75void printf_uid_message(
76  struct MW_UID_MESSAGE *uid
77)
78{
79  uid_print_message_with_plugin(
80    stdout,
81    (rtems_printk_plugin_t)fprintf,
82    uid
83  );
84}
85
86void receive_uid_message(void)
87{
88  int                    rc;
89  struct MW_UID_MESSAGE  uid;
90
91  rc = uid_read_message( &uid, 0 );
92  if ( rc != sizeof(struct MW_UID_MESSAGE) )
93    return;
94  printf_uid_message( &uid );
95}
96
97void close_it(void)
98{
99  int rc;
100
101  printf( "uid_unregister_device() - OK\n" );
102  rc = uid_unregister_device( Test_fd );
103  rtems_test_assert( rc == 0 );
104
105  puts( "close(/dev/mouse) - OK " );
106  rc = close( Test_fd );
107  rtems_test_assert( rc == 0 );
108}
109
110rtems_task Init(
111  rtems_task_argument ignored
112)
113{
114  bool more_data;
115
116  printf( "\n\n*** %s TEST ***\n", Mouse_Type_Long );
117
118  open_it();
119  register_it();
120  do {
121    more_data = enqueue_next_action(
122      Mouse_Actions,
123      Mouse_Actions_Size,
124      Mouse_Actions_Per_Iteration
125    );
126    receive_uid_message();
127  } while (more_data);
128  close_it();
129  printf( "*** END OF %s TEST ***\n", Mouse_Type_Long );
130  rtems_test_exit( 0 );
131}
132
133/* configuration information */
134
135#include <rtems/serial_mouse.h>
136#include "termios_testdriver_intr.h"
137
138/* NOTICE: the clock driver is explicitly disabled */
139#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
140#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
141#define CONFIGURE_APPLICATION_EXTRA_DRIVERS \
142    TERMIOS_TEST_DRIVER_TABLE_ENTRY, \
143    SERIAL_MOUSE_DRIVER_TABLE_ENTRY
144
145/* one for the console and one for the test port */
146#define CONFIGURE_NUMBER_OF_TERMIOS_PORTS 2
147
148/* we need to be able to open the test device and mouse */
149#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 5
150#define CONFIGURE_MAXIMUM_TASKS  1
151#define CONFIGURE_MAXIMUM_TIMERS 2
152#define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 1
153
154#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
155#define CONFIGURE_INIT
156
157#include <rtems/confdefs.h>
158
159/* end of file */
Note: See TracBrowser for help on using the repository browser.