[26] | 1 | /*
|
---|
| 2 | * TOPPERS/JSP Kernel
|
---|
| 3 | * Toyohashi Open Platform for Embedded Real-Time Systems/
|
---|
| 4 | * Just Standard Profile Kernel
|
---|
| 5 | *
|
---|
| 6 | * Copyright (C) 2003 by Embedded and Real-Time Systems Laboratory
|
---|
| 7 | * Toyohashi Univ. of Technology, JAPAN
|
---|
| 8 | * Copyright (C) 2004-2010 by Embedded and Real-Time Systems Laboratory
|
---|
| 9 | * Graduate School of Information Science, Nagoya Univ., JAPAN
|
---|
| 10 | *
|
---|
| 11 | * ä¸è¨èä½æ¨©è
|
---|
| 12 | ã¯ï¼ä»¥ä¸ã® (1)ã(4) ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
|
---|
| 13 | * ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ã使ç¨ã»è¤è£½ã»æ¹å¤ã»
|
---|
| 14 | * åé
|
---|
| 15 | å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
|
---|
| 16 | * (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½æ¨©
|
---|
| 17 | * 表示ï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼ã¹
|
---|
| 18 | * ã³ã¼ãä¸ã«å«ã¾ãã¦ãããã¨ï¼
|
---|
| 19 | * (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿ç¨
|
---|
| 20 | * ã§ããå½¢ã§åé
|
---|
| 21 | å¸ããå ´åã«ã¯ï¼åé
|
---|
| 22 | å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨è
|
---|
| 23 | ã
|
---|
| 24 | * ãã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿
|
---|
| 25 | * 証è¦å®ãæ²è¼ãããã¨ï¼
|
---|
| 26 | * (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿ç¨
|
---|
| 27 | * ã§ããªãå½¢ã§åé
|
---|
| 28 | å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºãããã¨ï¼
|
---|
| 29 | * (a) åé
|
---|
| 30 | å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨è
|
---|
| 31 | ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½
|
---|
| 32 | * 権表示ï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
|
---|
| 33 | * (b) åé
|
---|
| 34 | å¸ã®å½¢æ
|
---|
| 35 | ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSããã¸ã§ã¯ãã«å ±
|
---|
| 36 | * åãããã¨ï¼
|
---|
| 37 | * (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ害
|
---|
| 38 | * ãããï¼ä¸è¨èä½æ¨©è
|
---|
| 39 | ããã³TOPPERSããã¸ã§ã¯ããå
|
---|
| 40 | 責ãããã¨ï¼ã¾ãï¼
|
---|
| 41 | * æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãçç±ã«åºã¥
|
---|
| 42 | * ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
|
---|
| 43 | ããã³TOPPERSããã¸ã§ã¯ããå
|
---|
| 44 | 責ãããã¨ï¼
|
---|
| 45 | *
|
---|
| 46 | * æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
|
---|
| 47 | ãã
|
---|
| 48 | * ã³TOPPERSããã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®çã«å¯¾ã
|
---|
| 49 | * ãé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨
|
---|
| 50 | * ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ害ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè²
|
---|
| 51 | * ããªãï¼
|
---|
| 52 | */
|
---|
| 53 |
|
---|
| 54 | /*
|
---|
| 55 | * ã·ãªã¢ã«I/Oããã¤ã¹ï¼SIOï¼ãã©ã¤ãï¼Xstormy16ç¨ï¼
|
---|
| 56 | */
|
---|
| 57 |
|
---|
| 58 | #include <kernel.h>
|
---|
| 59 | #include <s_services.h>
|
---|
| 60 | #include <hw_serial.h>
|
---|
| 61 | #include <cpu_sfrs.h>
|
---|
| 62 |
|
---|
| 63 | /*
|
---|
| 64 | * éåæéä¿¡ã§ã®TxReadyã®ã¿ã¤ã ã¢ã¦ã
|
---|
| 65 | */
|
---|
| 66 | #define TXREADY_TIMEOUT 400
|
---|
| 67 |
|
---|
| 68 | /*
|
---|
| 69 | * SIOPCB*ãã§ãã¯ã®ããã®ãã¸ãã¯å¤
|
---|
| 70 | */
|
---|
| 71 | #define MAGIC_SIOPCB 0xabcd
|
---|
| 72 |
|
---|
| 73 | /*
|
---|
| 74 | * ã·ãªã¢ã«I/Oãã¼ã管çãããã¯ã®ã¨ãªã¢
|
---|
| 75 | */
|
---|
| 76 | static SIOPCB siopcb_table[TNUM_PORT] = {
|
---|
| 77 | { MAGIC_SIOPCB, __U0CR, 0x1400 },
|
---|
| 78 | { MAGIC_SIOPCB, __U1CR, 0x4800 },
|
---|
| 79 | } ;
|
---|
| 80 |
|
---|
| 81 | /*
|
---|
| 82 | * SIOãã©ã¤ãã®åæåã«ã¼ãã³
|
---|
| 83 | */
|
---|
| 84 | void sio_initialize(void)
|
---|
| 85 | {
|
---|
| 86 | /* nothing to do here */
|
---|
| 87 | }
|
---|
| 88 |
|
---|
| 89 | /*
|
---|
| 90 | * ã·ãªã¢ã«I/Oãã¼ãã®ãªã¼ãã³
|
---|
| 91 | */
|
---|
| 92 | SIOPCB *sio_opn_por(ID siopid, VP_INT exinf)
|
---|
| 93 | {
|
---|
| 94 | SIOPCB* siopcb ;
|
---|
| 95 | UH uhBase ;
|
---|
| 96 | /*
|
---|
| 97 | * ãªã¼ãã³åºæ¥ããã¼ããã®ãã§ãã¯
|
---|
| 98 | */
|
---|
| 99 | if ( siopid < 1 || siopid > TNUM_PORT ) return NULL ;
|
---|
| 100 | siopcb = &siopcb_table[siopid-1] ;
|
---|
| 101 | if ( siopcb->bNotExist ) return NULL ;
|
---|
| 102 | /*
|
---|
| 103 | * æ¢ã«ãªã¼ãã³æ¸ã¿ã®å ´å
|
---|
| 104 | */
|
---|
| 105 | if ( siopcb->bOpened ) {
|
---|
| 106 | siopcb->vpiExinf = exinf ;
|
---|
| 107 | return siopcb ;
|
---|
| 108 | }
|
---|
| 109 | /*
|
---|
| 110 | * SIOã®åæåã¨åå¨ã®ãã§ãã¯
|
---|
| 111 | */
|
---|
| 112 | uhBase = siopcb->uhBase ;
|
---|
| 113 | __SFR(uhBase) = __UxCR_RUN|__UxCR_TXEMPTY ;
|
---|
| 114 | if ( ( __SFR(uhBase) &
|
---|
| 115 | ( __UxCR_RUN|__UxCR_BAUDRATE|__UxCR_PARITY|__UxCR_TXIE|
|
---|
| 116 | __UxCR_RXIE) ) != __UxCR_RUN ) {
|
---|
| 117 | siopcb->bNotExist = TRUE ;
|
---|
| 118 | return NULL ;
|
---|
| 119 | }
|
---|
| 120 | /*
|
---|
| 121 | * 管çãã¼ãã«ã®åæå
|
---|
| 122 | */
|
---|
| 123 | siopcb->vpiExinf = exinf ;
|
---|
| 124 | siopcb->bOpened = TRUE ;
|
---|
| 125 | siopcb->bTxIe = FALSE ;
|
---|
| 126 | siopcb->bRxIe = FALSE ;
|
---|
| 127 | siopcb->bLastIsCr = FALSE ;
|
---|
| 128 | /*
|
---|
| 129 | * å²ãè¾¼ã¿ãã³ãã©ã®ç»é²ã¨è¨±å¯
|
---|
| 130 | */
|
---|
| 131 | define_inh( INHNO_SIO, sio_handler ) ;
|
---|
| 132 | __UNLOCK_EXCP() ;
|
---|
| 133 | __SFRW(__EXCPL) |= siopcb->uhExcpMask ;
|
---|
| 134 | __LOCK_EXCP() ;
|
---|
| 135 | return siopcb ;
|
---|
| 136 | }
|
---|
| 137 |
|
---|
| 138 | /*
|
---|
| 139 | * ã·ãªã¢ã«I/Oãã¼ãã®ã¯ãã¼ãº
|
---|
| 140 | */
|
---|
| 141 | void sio_cls_por(SIOPCB *siopcb)
|
---|
| 142 | {
|
---|
| 143 | /*
|
---|
| 144 | * ã¯ãã¼ãºåºæ¥ããã¼ããã®ãã§ãã¯
|
---|
| 145 | */
|
---|
| 146 | if ( !siopcb || siopcb->uhMagic != MAGIC_SIOPCB ||
|
---|
| 147 | siopcb->bNotExist || !siopcb->bOpened ) return ;
|
---|
| 148 | /*
|
---|
| 149 | * 管çãã¼ãã«ã®å¤æ´
|
---|
| 150 | */
|
---|
| 151 | siopcb->bOpened = FALSE ;
|
---|
| 152 | /*
|
---|
| 153 | * å²ãè¾¼ã¿ã®ç¦æ¢
|
---|
| 154 | */
|
---|
| 155 | __UNLOCK_EXCP() ;
|
---|
| 156 | __SFRW(__EXCPL) &= ~siopcb->uhExcpMask ;
|
---|
| 157 | __LOCK_EXCP() ;
|
---|
| 158 | /*
|
---|
| 159 | * SIOã®åæ¢
|
---|
| 160 | */
|
---|
| 161 | __SFR(siopcb->uhBase) = 0 ;
|
---|
| 162 | }
|
---|
| 163 |
|
---|
| 164 | /*
|
---|
| 165 | * SIOã®å²è¾¼ã¿ãã³ãã©
|
---|
| 166 | */
|
---|
| 167 | void sio_handler(void)
|
---|
| 168 | {
|
---|
| 169 | /*
|
---|
| 170 | * å
|
---|
| 171 | ¨ã¦ã®ãã¼ãã«ã¤ãã¦ãã§ãã¯
|
---|
| 172 | */
|
---|
| 173 | ID portid ;
|
---|
| 174 | for ( portid = 0 ; portid < TNUM_PORT ; portid++ ) {
|
---|
| 175 | SIOPCB *siopcb = &siopcb_table[portid] ;
|
---|
| 176 | UH uhBase = siopcb->uhBase ;
|
---|
| 177 | /*
|
---|
| 178 | * éä¿¡å®äºå²ãè¾¼ã¿ã
|
---|
| 179 | */
|
---|
| 180 | if ( ( __SFR(uhBase) & ( __UxCR_TXIE | __UxCR_TXEMPTY ) ) ==
|
---|
| 181 | ( __UxCR_TXIE | __UxCR_TXEMPTY ) ) {
|
---|
| 182 | sio_ierdy_snd( siopcb->vpiExinf ) ;
|
---|
| 183 | }
|
---|
| 184 | /*
|
---|
| 185 | * åä¿¡å²ãè¾¼ã¿ã
|
---|
| 186 | */
|
---|
| 187 | if ( ( __SFR(uhBase) & ( __UxCR_RXIE | __UxCR_RXREADY ) ) ==
|
---|
| 188 | ( __UxCR_RXIE | __UxCR_RXREADY ) ) {
|
---|
| 189 | sio_ierdy_rcv( siopcb->vpiExinf ) ;
|
---|
| 190 | }
|
---|
| 191 | }
|
---|
| 192 | }
|
---|
| 193 |
|
---|
| 194 | /*
|
---|
| 195 | * ã·ãªã¢ã«I/Oãã¼ãã¸ã®æåéä¿¡
|
---|
| 196 | */
|
---|
| 197 | BOOL sio_snd_chr(SIOPCB *siopcb, char c)
|
---|
| 198 | {
|
---|
| 199 | UH uhBase ;
|
---|
| 200 | /*
|
---|
| 201 | * æå¹ãªãã¼ããã©ããã®ãã§ãã¯
|
---|
| 202 | */
|
---|
| 203 | if ( !siopcb || siopcb->uhMagic != MAGIC_SIOPCB ||
|
---|
| 204 | siopcb->bNotExist || !siopcb->bOpened ) return FALSE ;
|
---|
| 205 | uhBase = siopcb->uhBase ;
|
---|
| 206 | /*
|
---|
| 207 | * éä¿¡å¯è½ãã©ããã®ãã§ãã¯
|
---|
| 208 | */
|
---|
| 209 | if ( ! ( __SFR(uhBase) & __UxCR_TXEMPTY ) ) return FALSE ;
|
---|
| 210 | /*
|
---|
| 211 | * éä¿¡ãã¼ã¿ã®æ¸ãè¾¼ã¿
|
---|
| 212 | */
|
---|
| 213 | __SFRW(uhBase+4) = __UxTX_STOPBIT | c ;
|
---|
| 214 | return TRUE ;
|
---|
| 215 | }
|
---|
| 216 |
|
---|
| 217 | /*
|
---|
| 218 | * ã·ãªã¢ã«I/Oãã¼ãããã®æååä¿¡
|
---|
| 219 | */
|
---|
| 220 | INT sio_rcv_chr(SIOPCB *siopcb)
|
---|
| 221 | {
|
---|
| 222 | UH uhBase ;
|
---|
| 223 | /*
|
---|
| 224 | * æå¹ãªãã¼ããã©ããã®ãã§ãã¯
|
---|
| 225 | */
|
---|
| 226 | if ( !siopcb || siopcb->uhMagic != MAGIC_SIOPCB ||
|
---|
| 227 | siopcb->bNotExist || !siopcb->bOpened ) return -1 ;
|
---|
| 228 | uhBase = siopcb->uhBase ;
|
---|
| 229 | /*
|
---|
| 230 | * åä¿¡ãã¼ã¿æç¡ã®ãã§ãã¯
|
---|
| 231 | */
|
---|
| 232 | if ( ! ( __SFR(uhBase) & __UxCR_RXREADY ) ) return -1 ;
|
---|
| 233 | /*
|
---|
| 234 | * åä¿¡ãã¼ã¿ã®åãåºã
|
---|
| 235 | */
|
---|
| 236 | return __SFRW(uhBase+2) & 0xff ;
|
---|
| 237 | }
|
---|
| 238 |
|
---|
| 239 | /*
|
---|
| 240 | * ã·ãªã¢ã«I/Oãã¼ãããã®ã³ã¼ã«ããã¯ã®è¨±å¯
|
---|
| 241 | */
|
---|
| 242 | void sio_ena_cbr(SIOPCB *siopcb, UINT cbrtn)
|
---|
| 243 | {
|
---|
| 244 | UH uhBase ;
|
---|
| 245 | /*
|
---|
| 246 | * æå¹ãªãã¼ããã©ããã®ãã§ãã¯
|
---|
| 247 | */
|
---|
| 248 | if ( !siopcb || siopcb->uhMagic != MAGIC_SIOPCB ||
|
---|
| 249 | siopcb->bNotExist || !siopcb->bOpened ) return ;
|
---|
| 250 | uhBase = siopcb->uhBase ;
|
---|
| 251 | /*
|
---|
| 252 | * éä¿¡å²ãè¾¼ã¿ã®è¨±å¯
|
---|
| 253 | */
|
---|
| 254 | if ( cbrtn == SIO_ERDY_SND ) {
|
---|
| 255 | __SFR(uhBase) |= __UxCR_TXIE ;
|
---|
| 256 | siopcb->bTxIe = TRUE ;
|
---|
| 257 | }
|
---|
| 258 | /*
|
---|
| 259 | * åä¿¡å²ãè¾¼ã¿ã®è¨±å¯
|
---|
| 260 | */
|
---|
| 261 | if ( cbrtn == SIO_ERDY_RCV ) {
|
---|
| 262 | __SFR(uhBase) |= __UxCR_RXIE ;
|
---|
| 263 | siopcb->bRxIe = TRUE ;
|
---|
| 264 | }
|
---|
| 265 | }
|
---|
| 266 |
|
---|
| 267 | /*
|
---|
| 268 | * ã·ãªã¢ã«I/Oãã¼ãããã®ã³ã¼ã«ããã¯ã®ç¦æ¢
|
---|
| 269 | */
|
---|
| 270 | void sio_dis_cbr(SIOPCB *siopcb, UINT cbrtn)
|
---|
| 271 | {
|
---|
| 272 | UH uhBase ;
|
---|
| 273 | /*
|
---|
| 274 | * æå¹ãªãã¼ããã©ããã®ãã§ãã¯
|
---|
| 275 | */
|
---|
| 276 | if ( !siopcb || siopcb->uhMagic != MAGIC_SIOPCB ||
|
---|
| 277 | siopcb->bNotExist || !siopcb->bOpened ) return ;
|
---|
| 278 | uhBase = siopcb->uhBase ;
|
---|
| 279 | /*
|
---|
| 280 | * éä¿¡å²ãè¾¼ã¿ã®ç¦æ¢
|
---|
| 281 | */
|
---|
| 282 | if ( cbrtn == SIO_ERDY_SND ) {
|
---|
| 283 | __SFR(uhBase) &= ~__UxCR_TXIE ;
|
---|
| 284 | siopcb->bTxIe = FALSE ;
|
---|
| 285 | }
|
---|
| 286 | /*
|
---|
| 287 | * åä¿¡å²ãè¾¼ã¿ã®ç¦æ¢
|
---|
| 288 | */
|
---|
| 289 | if ( cbrtn == SIO_ERDY_RCV ) {
|
---|
| 290 | __SFR(uhBase) &= ~__UxCR_RXIE ;
|
---|
| 291 | siopcb->bRxIe = FALSE ;
|
---|
| 292 | }
|
---|
| 293 | }
|
---|
| 294 |
|
---|
| 295 | /*
|
---|
| 296 | * ããã©ã«ãã®éä¿¡å¯è½ã³ã¼ã«ããã¯
|
---|
| 297 | */
|
---|
| 298 | void sio_ierdy_snd(VP_INT exinf) __attribute__((__weak__)) ;
|
---|
| 299 | void sio_ierdy_snd(VP_INT exinf)
|
---|
| 300 | {
|
---|
| 301 | }
|
---|
| 302 |
|
---|
| 303 | /*
|
---|
| 304 | * ããã©ã«ãã®åä¿¡éç¥ã³ã¼ã«ããã¯
|
---|
| 305 | */
|
---|
| 306 | void sio_ierdy_rcv(VP_INT exinf) __attribute__((__weak__)) ;
|
---|
| 307 | void sio_ierdy_rcv(VP_INT exinf)
|
---|
| 308 | {
|
---|
| 309 | }
|
---|
| 310 |
|
---|
| 311 | /*
|
---|
| 312 | * ã·ãªã¢ã«I/Oãã¼ãã¸ã®éåææååºå
|
---|
| 313 | */
|
---|
| 314 | void sio_asnd_chr( INT c )
|
---|
| 315 | {
|
---|
| 316 | SIOPCB* siopcb ;
|
---|
| 317 | UH uhBase ;
|
---|
| 318 | int i ;
|
---|
| 319 | /*
|
---|
| 320 | * CPUããã¯ç¶æ
|
---|
| 321 | ã«ãã
|
---|
| 322 | */
|
---|
| 323 | BOOL bLocked ;
|
---|
| 324 | if ( sns_loc() ) bLocked = TRUE ;
|
---|
| 325 | else {
|
---|
| 326 | bLocked = FALSE ;
|
---|
| 327 | if ( sns_ctx() ) iloc_cpu() ;
|
---|
| 328 | else loc_cpu() ;
|
---|
| 329 | }
|
---|
| 330 | /*
|
---|
| 331 | * éåæç¨ãã¼ããéã
|
---|
| 332 | */
|
---|
| 333 | if ( ( siopcb = sio_opn_por( LOGTASK_PORTID,
|
---|
| 334 | siopcb_table[LOGTASK_PORTID-1].vpiExinf ) ) != NULL ) {
|
---|
| 335 | uhBase = siopcb->uhBase ;
|
---|
| 336 | /*
|
---|
| 337 | * LFãªãã¾ãCRãéåº
|
---|
| 338 | */
|
---|
| 339 | if ( c == '\n' ) {
|
---|
| 340 | for ( i = 0 ; i < TXREADY_TIMEOUT ; i++ ) {
|
---|
| 341 | if ( __SFR(uhBase) & __UxCR_TXEMPTY ) break ;
|
---|
| 342 | }
|
---|
| 343 | if ( i < TXREADY_TIMEOUT ) {
|
---|
| 344 | __SFRW(uhBase+4) = __UxTX_STOPBIT | '\r' ;
|
---|
| 345 | }
|
---|
| 346 | }
|
---|
| 347 | /*
|
---|
| 348 | * ãã¼ã¿éåº
|
---|
| 349 | */
|
---|
| 350 | for ( i = 0 ; i < TXREADY_TIMEOUT ; i++ ) {
|
---|
| 351 | if ( __SFR(uhBase) & __UxCR_TXEMPTY ) break ;
|
---|
| 352 | }
|
---|
| 353 | if ( i < TXREADY_TIMEOUT ) {
|
---|
| 354 | __SFRW(uhBase+4) = __UxTX_STOPBIT | c ;
|
---|
| 355 | }
|
---|
| 356 | }
|
---|
| 357 | /*
|
---|
| 358 | * CPUããã¯ãå
|
---|
| 359 | ã«æ»ã
|
---|
| 360 | */
|
---|
| 361 | if ( !bLocked ) {
|
---|
| 362 | if ( sns_ctx() ) iunl_cpu() ;
|
---|
| 363 | else unl_cpu() ;
|
---|
| 364 | }
|
---|
| 365 | }
|
---|
| 366 |
|
---|
| 367 | /*
|
---|
| 368 | * ã·ãªã¢ã«I/Oãã¼ãããã®éåææåå
|
---|
| 369 | ¥å
|
---|
| 370 | */
|
---|
| 371 | INT sio_arcv_chr( void )
|
---|
| 372 | {
|
---|
| 373 | SIOPCB* siopcb ;
|
---|
| 374 | UH uhBase ;
|
---|
| 375 | INT c = -1 ;
|
---|
| 376 | /*
|
---|
| 377 | * ã¿ã¹ã¯ã³ã³ããã¹ãããã®ã¿ä½¿ç¨å¯
|
---|
| 378 | */
|
---|
| 379 | if ( sns_ctx() || sns_loc() || sns_dsp() ) return -1 ;
|
---|
| 380 | /*
|
---|
| 381 | * CPUããã¯ç¶æ
|
---|
| 382 | ã«ãã
|
---|
| 383 | */
|
---|
| 384 | loc_cpu() ;
|
---|
| 385 | /*
|
---|
| 386 | * éåæç¨ãã¼ããéã
|
---|
| 387 | */
|
---|
| 388 | if ( ( siopcb = sio_opn_por( LOGTASK_PORTID,
|
---|
| 389 | siopcb_table[LOGTASK_PORTID-1].vpiExinf ) ) != NULL ) {
|
---|
| 390 | uhBase = siopcb->uhBase ;
|
---|
| 391 | /*
|
---|
| 392 | * åä¿¡å¾
|
---|
| 393 | ã¡
|
---|
| 394 | */
|
---|
| 395 | while(1) {
|
---|
| 396 | if ( __SFR(uhBase) & __UxCR_RXREADY ) {
|
---|
| 397 | c = __SFRW(uhBase+2) & 0xff ;
|
---|
| 398 | if ( c == '\r' ) {
|
---|
| 399 | c = '\n' ;
|
---|
| 400 | siopcb->bLastIsCr = TRUE ;
|
---|
| 401 | }
|
---|
| 402 | else {
|
---|
| 403 | if ( c == '\n' && siopcb->bLastIsCr ) c = -1 ;
|
---|
| 404 | siopcb->bLastIsCr = FALSE ;
|
---|
| 405 | }
|
---|
| 406 | }
|
---|
| 407 | if ( c != -1 ) break ;
|
---|
| 408 | unl_cpu() ;
|
---|
| 409 | dly_tsk( 50 ) ;
|
---|
| 410 | loc_cpu() ;
|
---|
| 411 | }
|
---|
| 412 | }
|
---|
| 413 | /*
|
---|
| 414 | * CPUããã¯ã解é¤
|
---|
| 415 | */
|
---|
| 416 | unl_cpu() ;
|
---|
| 417 | return c ;
|
---|
| 418 | }
|
---|
| 419 |
|
---|