File indexing completed on 2025-05-11 08:24:01
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 #include <rtems/score/percpu.h>
0034 #include <rtems/score/isr.h>
0035 #include <rtems/score/threaddispatch.h>
0036 #include <rtems/score/sh.h>
0037 #include <rtems/score/ispsh7032.h>
0038
0039 #include <rtems/score/ispsh7032.h>
0040 #include <rtems/score/iosh7032.h>
0041 #include <rtems/score/sh_io.h>
0042
0043 unsigned long *_old_stack_ptr;
0044
0045 register unsigned long *stack_ptr __asm__ ("r15");
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060 unsigned int sh_set_irq_priority(
0061 unsigned int irq,
0062 unsigned int prio )
0063 {
0064 uint32_t shiftcount;
0065 uint32_t prioreg;
0066 uint16_t temp16;
0067 ISR_Level level;
0068
0069
0070
0071
0072 if (( irq > 113) || (_Hardware_isr_Table[irq] == _dummy_isp))
0073 return -1;
0074
0075
0076
0077 if ( prio > 15 )
0078 return -1;
0079
0080
0081
0082
0083 if ( irq > 71)
0084 {
0085 irq = irq - 72;
0086 shiftcount = 12 - ((irq & ~0x03) % 16);
0087
0088 switch( irq / 16)
0089 {
0090 case 0: { prioreg = INTC_IPRC; break;}
0091 case 1: { prioreg = INTC_IPRD; break;}
0092 case 2: { prioreg = INTC_IPRE; break;}
0093 default: return -1;
0094 }
0095 }
0096 else
0097 {
0098 shiftcount = 12 - 4 * ( irq % 4);
0099 if ( irq > 67)
0100 prioreg = INTC_IPRB;
0101 else
0102 prioreg = INTC_IPRA;
0103 }
0104
0105
0106
0107
0108 _ISR_Local_disable( level );
0109
0110 temp16 = read16( prioreg);
0111 temp16 &= ~( 15 << shiftcount);
0112 temp16 |= prio << shiftcount;
0113 write16( temp16, prioreg);
0114
0115 _ISR_Local_enable( level );
0116
0117 return 0;
0118 }
0119
0120
0121
0122
0123
0124 void __ISR_Handler( uint32_t vector)
0125 {
0126 ISR_Level level;
0127
0128 _ISR_Local_disable( level );
0129
0130 _Thread_Dispatch_disable();
0131
0132 if ( _ISR_Nest_level == 0 )
0133 {
0134
0135 _old_stack_ptr = stack_ptr;
0136 stack_ptr = _CPU_Interrupt_stack_high;
0137 }
0138
0139 _ISR_Nest_level++;
0140
0141 _ISR_Local_enable( level );
0142
0143
0144 if ( _ISR_Vector_table[ vector])
0145 (*_ISR_Vector_table[ vector ])( vector );
0146
0147 _ISR_Local_disable( level );
0148
0149 _Thread_Dispatch_unnest( _Per_CPU_Get() );
0150
0151 _ISR_Nest_level--;
0152
0153 if ( _ISR_Nest_level == 0 )
0154
0155 stack_ptr = _old_stack_ptr;
0156
0157 _ISR_Local_enable( level );
0158
0159 if ( _ISR_Nest_level )
0160 return;
0161
0162 if ( !_Thread_Dispatch_is_enabled() ) {
0163 return;
0164 }
0165
0166 if ( _Thread_Dispatch_necessary ) {
0167 _Thread_Dispatch();
0168 }
0169 }