[61] | 1 | /*
|
---|
| 2 | * TOPPERS/ASP Kernel
|
---|
| 3 | * Toyohashi Open Platform for Embedded Real-Time Systems/
|
---|
| 4 | * Advanced Standard Profile Kernel
|
---|
| 5 | *
|
---|
| 6 | * Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
|
---|
| 7 | * Toyohashi Univ. of Technology, JAPAN
|
---|
| 8 | * Copyright (C) 2005-2009 by Embedded and Real-Time Systems Laboratory
|
---|
| 9 | * Graduate School of Information Science, Nagoya Univ., JAPAN
|
---|
| 10 | *
|
---|
| 11 | * ãLì ÒÍCȺÌ(1)`(4)Ìðð½·êÉÀèC{\tgEF
|
---|
| 12 | * Ai{\tgEFAðüϵ½àÌðÜÞDȺ¯¶jðgpE¡»Eü
|
---|
| 13 | * ÏEÄzziȺCpÆÄÔj·é±Æð³Åø·éD
|
---|
| 14 | * (1) {\tgEFAð\[XR[hÌ`Åp·éêÉÍCãLÌì
|
---|
| 15 | * \¦C±Ìpð¨æѺL̳ÛØKèªC»ÌÜÜÌ`Å\[
|
---|
| 16 | * XR[hÉÜÜêÄ¢é±ÆD
|
---|
| 17 | * (2) {\tgEFAðCCu`®ÈÇC¼Ì\tgEFAJÉg
|
---|
| 18 | * pÅ«é`ÅÄzz·éêÉÍCÄzzɺ¤hL
|
---|
| 19 | gip
|
---|
| 20 | * Ò}j
|
---|
| 21 | AÈÇjÉCãLÌì \¦C±Ìpð¨æѺL
|
---|
| 22 | * ̳ÛØKèðfÚ·é±ÆD
|
---|
| 23 | * (3) {\tgEFAðC@íÉgÝÞÈÇC¼Ì\tgEFAJÉg
|
---|
| 24 | * pÅ«È¢`ÅÄzz·éêÉÍCÌ¢¸ê©Ìðð½·±
|
---|
| 25 | * ÆD
|
---|
| 26 | * (a) Äzzɺ¤hL
|
---|
| 27 | gipÒ}j
|
---|
| 28 | AÈÇjÉCãLÌ
|
---|
| 29 | * ì \¦C±Ìpð¨æѺL̳ÛØKèðfÚ·é±ÆD
|
---|
| 30 | * (b) ÄzzÌ`ÔðCÊÉèßéû@ÉæÁÄCTOPPERSvWFNgÉ
|
---|
| 31 | * ñ·é±ÆD
|
---|
| 32 | * (4) {\tgEFAÌpÉæè¼ÚIܽÍÔÚIɶ¶é¢©Èé¹
|
---|
| 33 | * Q©çàCãLì Ò¨æÑTOPPERSvWFNgðÆÓ·é±ÆD
|
---|
| 34 | * ܽC{\tgEFAÌ[UܽÍGh[U©çÌ¢©Èé
|
---|
| 35 | * RÉîÿ©çàCãLì Ò¨æÑTOPPERSvWFNgð
|
---|
| 36 | * ÆÓ·é±ÆD
|
---|
| 37 | *
|
---|
| 38 | * {\tgEFAÍC³ÛØÅñ³êÄ¢éàÌÅ éDãLì Ò¨
|
---|
| 39 | * æÑTOPPERSvWFNgÍC{\tgEFAÉÖµÄCÁèÌgpÚI
|
---|
| 40 | * ÉηéK«àÜßÄC¢©ÈéÛØàsíÈ¢DܽC{\tgEF
|
---|
| 41 | * AÌpÉæè¼ÚIܽÍÔÚIɶ¶½¢©Èé¹QÉÖµÄàC»
|
---|
| 42 | * ÌÓCðíÈ¢D
|
---|
| 43 | *
|
---|
| 44 | * @(#) $Id: interrupt.c 2009 2010-12-31 12:43:54Z ertl-hiro $
|
---|
| 45 | */
|
---|
| 46 |
|
---|
| 47 | /*
|
---|
| 48 | * ÝÇ@\
|
---|
| 49 | */
|
---|
| 50 |
|
---|
| 51 | #include "kernel_impl.h"
|
---|
| 52 | #include "check.h"
|
---|
| 53 | #include "task.h"
|
---|
| 54 | #include "interrupt.h"
|
---|
| 55 |
|
---|
| 56 | /*
|
---|
| 57 | * g[XO}NÌftHgè`
|
---|
| 58 | */
|
---|
| 59 | #ifndef LOG_DIS_INT_ENTER
|
---|
| 60 | #define LOG_DIS_INT_ENTER(intno)
|
---|
| 61 | #endif /* LOG_DIS_INT_ENTER */
|
---|
| 62 |
|
---|
| 63 | #ifndef LOG_DIS_INT_LEAVE
|
---|
| 64 | #define LOG_DIS_INT_LEAVE(ercd)
|
---|
| 65 | #endif /* LOG_DIS_INT_LEAVE */
|
---|
| 66 |
|
---|
| 67 | #ifndef LOG_ENA_INT_ENTER
|
---|
| 68 | #define LOG_ENA_INT_ENTER(intno)
|
---|
| 69 | #endif /* LOG_ENA_INT_ENTER */
|
---|
| 70 |
|
---|
| 71 | #ifndef LOG_ENA_INT_LEAVE
|
---|
| 72 | #define LOG_ENA_INT_LEAVE(ercd)
|
---|
| 73 | #endif /* LOG_ENA_INT_LEAVE */
|
---|
| 74 |
|
---|
| 75 | #ifndef LOG_CHG_IPM_ENTER
|
---|
| 76 | #define LOG_CHG_IPM_ENTER(intpri)
|
---|
| 77 | #endif /* LOG_CHG_IPM_ENTER */
|
---|
| 78 |
|
---|
| 79 | #ifndef LOG_CHG_IPM_LEAVE
|
---|
| 80 | #define LOG_CHG_IPM_LEAVE(ercd)
|
---|
| 81 | #endif /* LOG_CHG_IPM_LEAVE */
|
---|
| 82 |
|
---|
| 83 | #ifndef LOG_GET_IPM_ENTER
|
---|
| 84 | #define LOG_GET_IPM_ENTER(p_intpri)
|
---|
| 85 | #endif /* LOG_GET_IPM_ENTER */
|
---|
| 86 |
|
---|
| 87 | #ifndef LOG_GET_IPM_LEAVE
|
---|
| 88 | #define LOG_GET_IPM_LEAVE(ercd, intpri)
|
---|
| 89 | #endif /* LOG_GET_IPM_LEAVE */
|
---|
| 90 |
|
---|
| 91 | /*
|
---|
| 92 | * ÝÇ@\Ìú»
|
---|
| 93 | */
|
---|
| 94 | #ifdef TOPPERS_intini
|
---|
| 95 | #ifndef OMIT_INITIALIZE_INTERRUPT
|
---|
| 96 |
|
---|
| 97 | void
|
---|
| 98 | initialize_interrupt(void)
|
---|
| 99 | {
|
---|
| 100 | uint_t i;
|
---|
| 101 | const INHINIB *p_inhinib;
|
---|
| 102 | const INTINIB *p_intinib;
|
---|
| 103 |
|
---|
| 104 | for (p_inhinib = inhinib_table, i = 0; i < tnum_inhno; p_inhinib++, i++) {
|
---|
| 105 | x_define_inh(p_inhinib->inhno, p_inhinib->int_entry);
|
---|
| 106 | }
|
---|
| 107 | for (p_intinib = intinib_table, i = 0; i < tnum_intno; p_intinib++, i++) {
|
---|
| 108 | x_config_int(p_intinib->intno, p_intinib->intatr, p_intinib->intpri);
|
---|
| 109 | }
|
---|
| 110 | }
|
---|
| 111 |
|
---|
| 112 | #endif /* OMIT_INITIALIZE_INTERRUPT */
|
---|
| 113 | #endif /* TOPPERS_intini */
|
---|
| 114 |
|
---|
| 115 | /*
|
---|
| 116 | * ÝÌÖ~
|
---|
| 117 | */
|
---|
| 118 | #ifdef TOPPERS_dis_int
|
---|
| 119 | #ifdef TOPPERS_SUPPORT_DIS_INT
|
---|
| 120 |
|
---|
| 121 | ER
|
---|
| 122 | dis_int(INTNO intno)
|
---|
| 123 | {
|
---|
| 124 | bool_t locked;
|
---|
| 125 | ER ercd;
|
---|
| 126 |
|
---|
| 127 | LOG_DIS_INT_ENTER(intno);
|
---|
| 128 | CHECK_TSKCTX();
|
---|
| 129 | CHECK_INTNO_DISINT(intno);
|
---|
| 130 |
|
---|
| 131 | locked = t_sense_lock();
|
---|
| 132 | if (!locked) {
|
---|
| 133 | t_lock_cpu();
|
---|
| 134 | }
|
---|
| 135 | if (t_disable_int(intno)) {
|
---|
| 136 | ercd = E_OK;
|
---|
| 137 | }
|
---|
| 138 | else {
|
---|
| 139 | ercd = E_OBJ;
|
---|
| 140 | }
|
---|
| 141 | if (!locked) {
|
---|
| 142 | t_unlock_cpu();
|
---|
| 143 | }
|
---|
| 144 |
|
---|
| 145 | error_exit:
|
---|
| 146 | LOG_DIS_INT_LEAVE(ercd);
|
---|
| 147 | return(ercd);
|
---|
| 148 | }
|
---|
| 149 |
|
---|
| 150 | #endif /* TOPPERS_SUPPORT_DIS_INT */
|
---|
| 151 | #endif /* TOPPERS_dis_int */
|
---|
| 152 |
|
---|
| 153 | /*
|
---|
| 154 | * ÝÌÂ
|
---|
| 155 | */
|
---|
| 156 | #ifdef TOPPERS_ena_int
|
---|
| 157 | #ifdef TOPPERS_SUPPORT_ENA_INT
|
---|
| 158 |
|
---|
| 159 | ER
|
---|
| 160 | ena_int(INTNO intno)
|
---|
| 161 | {
|
---|
| 162 | bool_t locked;
|
---|
| 163 | ER ercd;
|
---|
| 164 |
|
---|
| 165 | LOG_ENA_INT_ENTER(intno);
|
---|
| 166 | CHECK_TSKCTX();
|
---|
| 167 | CHECK_INTNO_DISINT(intno);
|
---|
| 168 |
|
---|
| 169 | locked = t_sense_lock();
|
---|
| 170 | if (!locked) {
|
---|
| 171 | t_lock_cpu();
|
---|
| 172 | }
|
---|
| 173 | if (t_enable_int(intno)) {
|
---|
| 174 | ercd = E_OK;
|
---|
| 175 | }
|
---|
| 176 | else {
|
---|
| 177 | ercd = E_OBJ;
|
---|
| 178 | }
|
---|
| 179 | if (!locked) {
|
---|
| 180 | t_unlock_cpu();
|
---|
| 181 | }
|
---|
| 182 |
|
---|
| 183 | error_exit:
|
---|
| 184 | LOG_ENA_INT_LEAVE(ercd);
|
---|
| 185 | return(ercd);
|
---|
| 186 | }
|
---|
| 187 |
|
---|
| 188 | #endif /* TOPPERS_SUPPORT_ENA_INT */
|
---|
| 189 | #endif /* TOPPERS_ena_int */
|
---|
| 190 |
|
---|
| 191 | /*
|
---|
| 192 | * ÝDæx}XNÌÏX
|
---|
| 193 | */
|
---|
| 194 | #ifdef TOPPERS_chg_ipm
|
---|
| 195 |
|
---|
| 196 | ER
|
---|
| 197 | chg_ipm(PRI intpri)
|
---|
| 198 | {
|
---|
| 199 | ER ercd;
|
---|
| 200 |
|
---|
| 201 | LOG_CHG_IPM_ENTER(intpri);
|
---|
| 202 | CHECK_TSKCTX_UNL();
|
---|
| 203 | CHECK_INTPRI_CHGIPM(intpri);
|
---|
| 204 |
|
---|
| 205 | t_lock_cpu();
|
---|
| 206 | t_set_ipm(intpri);
|
---|
| 207 | if (intpri == TIPM_ENAALL) {
|
---|
| 208 | ipmflg = true;
|
---|
| 209 | if (!disdsp) {
|
---|
| 210 | dspflg = true;
|
---|
| 211 | if (p_runtsk != p_schedtsk) {
|
---|
| 212 | dispatch();
|
---|
| 213 | }
|
---|
| 214 | }
|
---|
| 215 | if (p_runtsk->enatex && p_runtsk->texptn != 0U) {
|
---|
| 216 | call_texrtn();
|
---|
| 217 | }
|
---|
| 218 | }
|
---|
| 219 | else {
|
---|
| 220 | ipmflg = false;
|
---|
| 221 | dspflg = false;
|
---|
| 222 | }
|
---|
| 223 | ercd = E_OK;
|
---|
| 224 | t_unlock_cpu();
|
---|
| 225 |
|
---|
| 226 | error_exit:
|
---|
| 227 | LOG_CHG_IPM_LEAVE(ercd);
|
---|
| 228 | return(ercd);
|
---|
| 229 | }
|
---|
| 230 |
|
---|
| 231 | #endif /* TOPPERS_chg_ipm */
|
---|
| 232 |
|
---|
| 233 | /*
|
---|
| 234 | * ÝDæx}XNÌQÆ
|
---|
| 235 | */
|
---|
| 236 | #ifdef TOPPERS_get_ipm
|
---|
| 237 |
|
---|
| 238 | ER
|
---|
| 239 | get_ipm(PRI *p_intpri)
|
---|
| 240 | {
|
---|
| 241 | ER ercd;
|
---|
| 242 |
|
---|
| 243 | LOG_GET_IPM_ENTER(p_intpri);
|
---|
| 244 | CHECK_TSKCTX_UNL();
|
---|
| 245 |
|
---|
| 246 | t_lock_cpu();
|
---|
| 247 | *p_intpri = t_get_ipm();
|
---|
| 248 | ercd = E_OK;
|
---|
| 249 | t_unlock_cpu();
|
---|
| 250 |
|
---|
| 251 | error_exit:
|
---|
| 252 | LOG_GET_IPM_LEAVE(ercd, *p_intpri);
|
---|
| 253 | return(ercd);
|
---|
| 254 | }
|
---|
| 255 |
|
---|
| 256 | #endif /* TOPPERS_get_ipm */
|
---|