00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048 #include <arch/arm.h>
00049 #include <dev/irqreg.h>
00050
00051 #if defined(SWIRQ_ID)
00052
00053 #ifndef NUT_IRQPRI_SWIRQ
00054 #define NUT_IRQPRI_SWIRQ 4
00055 #endif
00056
00057 static int SoftwareIrqCtl(int cmd, void *param);
00058
00059 IRQ_HANDLER sig_SWIRQ = {
00060 #ifdef NUT_PERFMON
00061 0,
00062 #endif
00063 NULL,
00064 NULL,
00065 SoftwareIrqCtl
00066 };
00067
00071 static void SoftwareIrqEntry(void) __attribute__ ((naked));
00072 void SoftwareIrqEntry(void)
00073 {
00074 IRQ_ENTRY();
00075 #ifdef NUT_PERFMON
00076 sig_SWIRQ.ir_count++;
00077 #endif
00078 if (sig_SWIRQ.ir_handler) {
00079 (sig_SWIRQ.ir_handler) (sig_SWIRQ.ir_arg);
00080 }
00081 IRQ_EXIT();
00082 }
00083
00099 static int SoftwareIrqCtl(int cmd, void *param)
00100 {
00101 int rc = 0;
00102 u_int *ival = (u_int *)param;
00103 int enabled = inr(AIC_IMR) & _BV(SWIRQ_ID);
00104
00105
00106 if (enabled) {
00107 outr(AIC_IDCR, _BV(SWIRQ_ID));
00108 }
00109
00110 switch(cmd) {
00111 case NUT_IRQCTL_INIT:
00112
00113 outr(AIC_SVR(SWIRQ_ID), (unsigned int)SoftwareIrqEntry);
00114
00115 outr(AIC_SMR(SWIRQ_ID), AIC_SRCTYPE_INT_EDGE_TRIGGERED | NUT_IRQPRI_SWIRQ);
00116
00117 outr(AIC_ICCR, _BV(SWIRQ_ID));
00118 break;
00119 case NUT_IRQCTL_STATUS:
00120 if (enabled) {
00121 *ival |= 1;
00122 }
00123 else {
00124 *ival &= ~1;
00125 }
00126 break;
00127 case NUT_IRQCTL_ENABLE:
00128 enabled = 1;
00129 break;
00130 case NUT_IRQCTL_DISABLE:
00131 enabled = 0;
00132 break;
00133 case NUT_IRQCTL_GETPRIO:
00134 *ival = inr(AIC_SMR(SWIRQ_ID)) & AIC_PRIOR;
00135 break;
00136 case NUT_IRQCTL_SETPRIO:
00137 outr(AIC_SMR(SWIRQ_ID), (inr(AIC_SMR(SWIRQ_ID)) & ~AIC_PRIOR) | *ival);
00138 break;
00139 #ifdef NUT_PERFMON
00140 case NUT_IRQCTL_GETCOUNT:
00141 *ival = (u_int)sig_SWIRQ.ir_count;
00142 sig_SWIRQ.ir_count = 0;
00143 break;
00144 #endif
00145 default:
00146 rc = -1;
00147 break;
00148 }
00149
00150
00151 if (enabled) {
00152 outr(AIC_IECR, _BV(SWIRQ_ID));
00153 }
00154 return rc;
00155 }
00156
00157 #endif