source: rtems/bsps/powerpc/beatnik/irq/irq_test_app.c @ b82a4b4

5
Last change on this file since b82a4b4 was 8f8ccee, checked in by Sebastian Huber <sebastian.huber@…>, on 04/23/18 at 07:50:39

bsps: Move interrupt controller support to bsps

This patch is a part of the BSP source reorganization.

Update #3285.

  • 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.org/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#include <confdefs.h>
40
41#include <stdio.h>
42#include <stdlib.h>
43
44#include <bsp/irq.h>
45#include <rtems/bspIo.h>
46
47
48void noop(){}
49int  connected() {return 1;}
50
51rtems_irq_connect_data blah = { 0, 0, noop, noop, connected };
52extern void discovery_pic_set_debug_irq();
53
54#define WIRE_IRQ (BSP_IRQ_GPP_0 + 6)
55#define ABRT_IRQ (BSP_IRQ_GPP_0 + 2)
56
57static volatile int testno=0;
58static volatile int wloops =0;
59static volatile int aloops =0;
60
61void wire_hdl()
62{
63        if ( 1 == testno ) {
64                BSP_disable_irq_at_pic(WIRE_IRQ);
65        }
66
67        if ( 2 == testno || 3 == testno ) {
68                discovery_pic_set_debug_irq(0);
69                printk("WIRE -- this message should be printed %s\n", 3==testno ? "FIRST":"SECOND");
70        } else {
71        }
72
73        /* assume the driver checks for less than 1000 loops */
74        if ( ++wloops > 1000) {
75                printk("wire IRQ. FAILURE -- driver couldn't catch runaway ISR. Disabling IRQ source.\n");
76                discovery_pic_set_debug_irq(0);
77                BSP_disable_irq_at_pic(WIRE_IRQ);
78        }
79        /*
80        */
81}
82
83void abrt_hdl()
84{
85        aloops++;
86        if ( 2 == testno || 3 == testno ) {
87                discovery_pic_set_debug_irq(1);
88                printk("ABRT -- this message should be printed %s\n", 2==testno ? "FIRST":"SECOND");
89        } else
90                printk("ABRT IRQ\n");
91
92        if ( 1== testno ) {
93                BSP_enable_irq_at_pic(WIRE_IRQ);
94        }
95        BSP_disable_irq_at_pic(ABRT_IRQ);
96}
97
98
99rtems_task Init(
100  rtems_task_argument ignored
101)
102{
103  blah.name = WIRE_IRQ;
104  blah.hdl  = wire_hdl;
105  if (!BSP_install_rtems_irq_handler(&blah)) {
106        fprintf(stderr,"installing handler 1 failed\n");
107  }
108  blah.name = ABRT_IRQ;
109  blah.hdl  = abrt_hdl;
110  if (!BSP_install_rtems_irq_handler(&blah)) {
111        fprintf(stderr,"installing handler 2 failed\n");
112  }
113  printf("Hello, testing the ISR dispatcher...\n");
114  printf(" 1. Trying to catch runaway interrupt\n");
115  printf("    If the system freezes, the test failed!\n");
116  fflush(stdout); sleep(1);
117  aloops = wloops = 0;
118  discovery_pic_set_debug_irq(1);
119  printf("    >>> %s\n", wloops<1000 ? "SUCCESS" : "FAILED");
120  discovery_pic_set_debug_irq(0);
121
122  testno++;
123  printf(" 2. Testing enabling / disabling interrupt from ISR\n");
124  printf("    Hit the ABORT key for this test\n");
125  fflush(stdout); sleep(1);
126  aloops = wloops = 0;
127  BSP_disable_irq_at_pic(WIRE_IRQ);
128  BSP_irq_set_priority(ABRT_IRQ,1);
129  BSP_enable_irq_at_pic(ABRT_IRQ);
130  discovery_pic_set_debug_irq(1);
131  while (!aloops)
132        ;
133  discovery_pic_set_debug_irq(0);
134  sleep(2);
135  printf("    >>> disabling ABRT IRQ from isr %s\n", 1==aloops ? "SUCCESS":"FAILURE");
136  printf("        flashing  WIRE IRQ from isr %s\n", 1==wloops ? "SUCCESS":"FAILURE");
137
138 
139  testno++;
140  printf(" 3. Testing interrupt priorities\n");
141  BSP_irq_set_priority(ABRT_IRQ,2);
142  BSP_irq_set_priority(WIRE_IRQ,2);
143  BSP_enable_irq_at_pic(ABRT_IRQ);
144  BSP_enable_irq_at_pic(WIRE_IRQ);
145  printf("    Hit the ABORT key for this test\n");
146  fflush(stdout); sleep(1);
147  aloops = wloops = 0;
148  while (!aloops)
149        ;
150  sleep(2);
151  testno++;
152  printf("    Now we are raising the priority of the wire interrupt\n");
153  BSP_irq_set_priority(WIRE_IRQ,3);
154  BSP_enable_irq_at_pic(ABRT_IRQ);
155  printf("    Hit the ABORT key for this test\n");
156  fflush(stdout); sleep(1);
157  aloops = wloops = 0;
158  while (!aloops)
159        ;
160
161  sleep(2);
162  printf( "That's it; we're done...\n" );
163  exit( 0 );
164}
Note: See TracBrowser for help on using the repository browser.