Go to the documentation of this file.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
00049
00050
00051 #include <arch/arm.h>
00052 #include <dev/irqreg.h>
00053
00054 #if defined(SWIRQ_ID)
00055
00056 #ifndef NUT_IRQPRI_SWIRQ
00057 #define NUT_IRQPRI_SWIRQ 4
00058 #endif
00059
00060 static int SoftwareIrqCtl(int cmd, void *param);
00061
00062 IRQ_HANDLER sig_SWIRQ = {
00063 #ifdef NUT_PERFMON
00064 0,
00065 #endif
00066 NULL,
00067 NULL,
00068 SoftwareIrqCtl
00069 };
00070
00074 static void SoftwareIrqEntry(void) __attribute__ ((naked));
00075 void SoftwareIrqEntry(void)
00076 {
00077 IRQ_ENTRY();
00078 #ifdef NUT_PERFMON
00079 sig_SWIRQ.ir_count++;
00080 #endif
00081 if (sig_SWIRQ.ir_handler) {
00082 (sig_SWIRQ.ir_handler) (sig_SWIRQ.ir_arg);
00083 }
00084 IRQ_EXIT();
00085 }
00086
00102 static int SoftwareIrqCtl(int cmd, void *param)
00103 {
00104 int rc = 0;
00105 unsigned int *ival = (unsigned int *)param;
00106 int_fast8_t enabled = inr(AIC_IMR) & _BV(SWIRQ_ID);
00107
00108
00109 if (enabled) {
00110 outr(AIC_IDCR, _BV(SWIRQ_ID));
00111 }
00112
00113 switch(cmd) {
00114 case NUT_IRQCTL_INIT:
00115
00116 outr(AIC_SVR(SWIRQ_ID), (unsigned int)SoftwareIrqEntry);
00117
00118 outr(AIC_SMR(SWIRQ_ID), AIC_SRCTYPE_INT_EDGE_TRIGGERED | NUT_IRQPRI_SWIRQ);
00119
00120 outr(AIC_ICCR, _BV(SWIRQ_ID));
00121 break;
00122 case NUT_IRQCTL_STATUS:
00123 if (enabled) {
00124 *ival |= 1;
00125 }
00126 else {
00127 *ival &= ~1;
00128 }
00129 break;
00130 case NUT_IRQCTL_ENABLE:
00131 enabled = 1;
00132 break;
00133 case NUT_IRQCTL_DISABLE:
00134 enabled = 0;
00135 break;
00136 case NUT_IRQCTL_GETPRIO:
00137 *ival = inr(AIC_SMR(SWIRQ_ID)) & AIC_PRIOR;
00138 break;
00139 case NUT_IRQCTL_SETPRIO:
00140 outr(AIC_SMR(SWIRQ_ID), (inr(AIC_SMR(SWIRQ_ID)) & ~AIC_PRIOR) | *ival);
00141 break;
00142 #ifdef NUT_PERFMON
00143 case NUT_IRQCTL_GETCOUNT:
00144 *ival = (unsigned int)sig_SWIRQ.ir_count;
00145 sig_SWIRQ.ir_count = 0;
00146 break;
00147 #endif
00148 default:
00149 rc = -1;
00150 break;
00151 }
00152
00153
00154 if (enabled) {
00155 outr(AIC_IECR, _BV(SWIRQ_ID));
00156 }
00157 return rc;
00158 }
00159
00160 #endif