source: rtems/c/src/lib/libbsp/powerpc/beatnik/irq/irq_test_app.c @ 1c554014

4.115
Last change on this file since 1c554014 was 1c554014, checked in by Ralf Corsépius <ralf.corsepius@…>, on 07/19/12 at 14:14:53

Remove CVS-Ids.

  • Property mode set to 100644
File size: 4.4 KB
Line 
1/*  Init
2 *
3 *  This routine is the initialization task for this test program.
4 *  It is called from init_exec and has the responsibility for creating
5 *  and starting the tasks that make up the test.  If the time of day
6 *  clock is required for the test, it should also be set to a known
7 *  value by this function.
8 *
9 *  Input parameters:  NONE
10 *
11 *  Output parameters:  NONE
12 *
13 *  COPYRIGHT (c) 1989-1999.
14 *  On-Line Applications Research Corporation (OAR).
15 *
16 *  The license and distribution terms for this file may be
17 *  found in the file LICENSE in this distribution or at
18 *  http://www.rtems.com/license/LICENSE.
19 *
20 *  OAR init.c Template modified by T. Straumann who provided
21 *  the implementation of this application.
22 */
23
24#define CONFIGURE_INIT
25
26#include <rtems.h>
27
28/* functions */
29rtems_task Init(
30  rtems_task_argument argument
31);
32                                                                                                                                                           
33/* configuration information */
34#include <bsp.h> /* for device driver prototypes */
35#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
36#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
37#define CONFIGURE_MAXIMUM_TASKS            1
38#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
39#define CONFIGURE_USE_MINIIMFS_AS_BASE_FILESYSTEM
40#include <confdefs.h>
41
42#include <stdio.h>
43#include <stdlib.h>
44
45#include <bsp/irq.h>
46#include <rtems/bspIo.h>
47
48
49void noop(){}
50int  connected() {return 1;}
51
52rtems_irq_connect_data blah = { 0, 0, noop, noop, connected };
53extern void discovery_pic_set_debug_irq();
54
55#define WIRE_IRQ (BSP_IRQ_GPP_0 + 6)
56#define ABRT_IRQ (BSP_IRQ_GPP_0 + 2)
57
58static volatile int testno=0;
59static volatile int wloops =0;
60static volatile int aloops =0;
61
62void wire_hdl()
63{
64        if ( 1 == testno ) {
65                BSP_disable_irq_at_pic(WIRE_IRQ);
66        }
67
68        if ( 2 == testno || 3 == testno ) {
69                discovery_pic_set_debug_irq(0);
70                printk("WIRE -- this message should be printed %s\n", 3==testno ? "FIRST":"SECOND");
71        } else {
72        }
73
74        /* assume the driver checks for less than 1000 loops */
75        if ( ++wloops > 1000) {
76                printk("wire IRQ. FAILURE -- driver couldn't catch runaway ISR. Disabling IRQ source.\n");
77                discovery_pic_set_debug_irq(0);
78                BSP_disable_irq_at_pic(WIRE_IRQ);
79        }
80        /*
81        */
82}
83
84void abrt_hdl()
85{
86        aloops++;
87        if ( 2 == testno || 3 == testno ) {
88                discovery_pic_set_debug_irq(1);
89                printk("ABRT -- this message should be printed %s\n", 2==testno ? "FIRST":"SECOND");
90        } else
91                printk("ABRT IRQ\n");
92
93        if ( 1== testno ) {
94                BSP_enable_irq_at_pic(WIRE_IRQ);
95        }
96        BSP_disable_irq_at_pic(ABRT_IRQ);
97}
98
99
100rtems_task Init(
101  rtems_task_argument ignored
102)
103{
104  blah.name = WIRE_IRQ;
105  blah.hdl  = wire_hdl;
106  if (!BSP_install_rtems_irq_handler(&blah)) {
107        fprintf(stderr,"installing handler 1 failed\n");
108  }
109  blah.name = ABRT_IRQ;
110  blah.hdl  = abrt_hdl;
111  if (!BSP_install_rtems_irq_handler(&blah)) {
112        fprintf(stderr,"installing handler 2 failed\n");
113  }
114  printf("Hello, testing the ISR dispatcher...\n");
115  printf(" 1. Trying to catch runaway interrupt\n");
116  printf("    If the system freezes, the test failed!\n");
117  fflush(stdout); sleep(1);
118  aloops = wloops = 0;
119  discovery_pic_set_debug_irq(1);
120  printf("    >>> %s\n", wloops<1000 ? "SUCCESS" : "FAILED");
121  discovery_pic_set_debug_irq(0);
122
123  testno++;
124  printf(" 2. Testing enabling / disabling interrupt from ISR\n");
125  printf("    Hit the ABORT key for this test\n");
126  fflush(stdout); sleep(1);
127  aloops = wloops = 0;
128  BSP_disable_irq_at_pic(WIRE_IRQ);
129  BSP_irq_set_priority(ABRT_IRQ,1);
130  BSP_enable_irq_at_pic(ABRT_IRQ);
131  discovery_pic_set_debug_irq(1);
132  while (!aloops)
133        ;
134  discovery_pic_set_debug_irq(0);
135  sleep(2);
136  printf("    >>> disabling ABRT IRQ from isr %s\n", 1==aloops ? "SUCCESS":"FAILURE");
137  printf("        flashing  WIRE IRQ from isr %s\n", 1==wloops ? "SUCCESS":"FAILURE");
138
139 
140  testno++;
141  printf(" 3. Testing interrupt priorities\n");
142  BSP_irq_set_priority(ABRT_IRQ,2);
143  BSP_irq_set_priority(WIRE_IRQ,2);
144  BSP_enable_irq_at_pic(ABRT_IRQ);
145  BSP_enable_irq_at_pic(WIRE_IRQ);
146  printf("    Hit the ABORT key for this test\n");
147  fflush(stdout); sleep(1);
148  aloops = wloops = 0;
149  while (!aloops)
150        ;
151  sleep(2);
152  testno++;
153  printf("    Now we are raising the priority of the wire interrupt\n");
154  BSP_irq_set_priority(WIRE_IRQ,3);
155  BSP_enable_irq_at_pic(ABRT_IRQ);
156  printf("    Hit the ABORT key for this test\n");
157  fflush(stdout); sleep(1);
158  aloops = wloops = 0;
159  while (!aloops)
160        ;
161
162  sleep(2);
163  printf( "That's it; we're done...\n" );
164  exit( 0 );
165}
Note: See TracBrowser for help on using the repository browser.