File indexing completed on 2025-05-11 08:23:52
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043 #define CONFIGURE_INIT
0044
0045 #include <rtems.h>
0046
0047
0048 rtems_task Init(
0049 rtems_task_argument argument
0050 );
0051
0052
0053 #include <bsp.h> /* for device driver prototypes */
0054 #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
0055 #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
0056 #define CONFIGURE_MAXIMUM_TASKS 1
0057 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
0058 #include <confdefs.h>
0059
0060 #include <stdio.h>
0061 #include <stdlib.h>
0062
0063 #include <bsp/irq.h>
0064 #include <rtems/bspIo.h>
0065
0066
0067 void noop(){}
0068 int connected() {return 1;}
0069
0070 rtems_irq_connect_data blah = { 0, 0, noop, noop, connected };
0071 extern void discovery_pic_set_debug_irq();
0072
0073 #define WIRE_IRQ (BSP_IRQ_GPP_0 + 6)
0074 #define ABRT_IRQ (BSP_IRQ_GPP_0 + 2)
0075
0076 static volatile int testno=0;
0077 static volatile int wloops =0;
0078 static volatile int aloops =0;
0079
0080 void wire_hdl()
0081 {
0082 if ( 1 == testno ) {
0083 BSP_disable_irq_at_pic(WIRE_IRQ);
0084 }
0085
0086 if ( 2 == testno || 3 == testno ) {
0087 discovery_pic_set_debug_irq(0);
0088 printk("WIRE -- this message should be printed %s\n", 3==testno ? "FIRST":"SECOND");
0089 } else {
0090 }
0091
0092
0093 if ( ++wloops > 1000) {
0094 printk("wire IRQ. FAILURE -- driver couldn't catch runaway ISR. Disabling IRQ source.\n");
0095 discovery_pic_set_debug_irq(0);
0096 BSP_disable_irq_at_pic(WIRE_IRQ);
0097 }
0098
0099
0100 }
0101
0102 void abrt_hdl()
0103 {
0104 aloops++;
0105 if ( 2 == testno || 3 == testno ) {
0106 discovery_pic_set_debug_irq(1);
0107 printk("ABRT -- this message should be printed %s\n", 2==testno ? "FIRST":"SECOND");
0108 } else
0109 printk("ABRT IRQ\n");
0110
0111 if ( 1== testno ) {
0112 BSP_enable_irq_at_pic(WIRE_IRQ);
0113 }
0114 BSP_disable_irq_at_pic(ABRT_IRQ);
0115 }
0116
0117
0118 rtems_task Init(
0119 rtems_task_argument ignored
0120 )
0121 {
0122 blah.name = WIRE_IRQ;
0123 blah.hdl = wire_hdl;
0124 if (!BSP_install_rtems_irq_handler(&blah)) {
0125 fprintf(stderr,"installing handler 1 failed\n");
0126 }
0127 blah.name = ABRT_IRQ;
0128 blah.hdl = abrt_hdl;
0129 if (!BSP_install_rtems_irq_handler(&blah)) {
0130 fprintf(stderr,"installing handler 2 failed\n");
0131 }
0132 printf("Hello, testing the ISR dispatcher...\n");
0133 printf(" 1. Trying to catch runaway interrupt\n");
0134 printf(" If the system freezes, the test failed!\n");
0135 fflush(stdout); sleep(1);
0136 aloops = wloops = 0;
0137 discovery_pic_set_debug_irq(1);
0138 printf(" >>> %s\n", wloops<1000 ? "SUCCESS" : "FAILED");
0139 discovery_pic_set_debug_irq(0);
0140
0141 testno++;
0142 printf(" 2. Testing enabling / disabling interrupt from ISR\n");
0143 printf(" Hit the ABORT key for this test\n");
0144 fflush(stdout); sleep(1);
0145 aloops = wloops = 0;
0146 BSP_disable_irq_at_pic(WIRE_IRQ);
0147 BSP_irq_set_priority(ABRT_IRQ,1);
0148 BSP_enable_irq_at_pic(ABRT_IRQ);
0149 discovery_pic_set_debug_irq(1);
0150 while (!aloops)
0151 ;
0152 discovery_pic_set_debug_irq(0);
0153 sleep(2);
0154 printf(" >>> disabling ABRT IRQ from isr %s\n", 1==aloops ? "SUCCESS":"FAILURE");
0155 printf(" flashing WIRE IRQ from isr %s\n", 1==wloops ? "SUCCESS":"FAILURE");
0156
0157
0158 testno++;
0159 printf(" 3. Testing interrupt priorities\n");
0160 BSP_irq_set_priority(ABRT_IRQ,2);
0161 BSP_irq_set_priority(WIRE_IRQ,2);
0162 BSP_enable_irq_at_pic(ABRT_IRQ);
0163 BSP_enable_irq_at_pic(WIRE_IRQ);
0164 printf(" Hit the ABORT key for this test\n");
0165 fflush(stdout); sleep(1);
0166 aloops = wloops = 0;
0167 while (!aloops)
0168 ;
0169 sleep(2);
0170 testno++;
0171 printf(" Now we are raising the priority of the wire interrupt\n");
0172 BSP_irq_set_priority(WIRE_IRQ,3);
0173 BSP_enable_irq_at_pic(ABRT_IRQ);
0174 printf(" Hit the ABORT key for this test\n");
0175 fflush(stdout); sleep(1);
0176 aloops = wloops = 0;
0177 while (!aloops)
0178 ;
0179
0180 sleep(2);
0181 printf( "That's it; we're done...\n" );
0182 exit( 0 );
0183 }