[363] | 1 | /*
|
---|
| 2 | * TOPPERS/JSP Kernel
|
---|
| 3 | * Toyohashi Open Platform for Embedded Real-Time Systems/
|
---|
| 4 | * Just Standard Profile Kernel
|
---|
| 5 | *
|
---|
| 6 | * Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
|
---|
| 7 | * Toyohashi Univ. of Technology, JAPAN
|
---|
| 8 | *
|
---|
| 9 | * ä¸è¨èä½æ¨©è
|
---|
| 10 | ã¯ï¼ä»¥ä¸ã® (1)ã(4) ã®æ¡ä»¶ãï¼Free Software Foundation
|
---|
| 11 | * ã«ãã£ã¦å
|
---|
| 12 | ¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
|
---|
| 13 | * è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
|
---|
| 14 | * ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ã使ç¨ã»è¤è£½ã»æ¹å¤ã»åé
|
---|
| 15 | å¸ï¼ä»¥ä¸ï¼
|
---|
| 16 | * å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
|
---|
| 17 | * (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
|
---|
| 18 | * 権表示ï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
|
---|
| 19 | * ã¹ã³ã¼ãä¸ã«å«ã¾ãã¦ãããã¨ï¼
|
---|
| 20 | * (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
|
---|
| 21 | * ç¨ã§ããå½¢ã§åé
|
---|
| 22 | å¸ããå ´åã«ã¯ï¼åé
|
---|
| 23 | å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨
|
---|
| 24 | * è
|
---|
| 25 | ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
|
---|
| 26 | * ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
|
---|
| 27 | * (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
|
---|
| 28 | * ç¨ã§ããªãå½¢ã§åé
|
---|
| 29 | å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
|
---|
| 30 | * ã¨ï¼
|
---|
| 31 | * (a) åé
|
---|
| 32 | å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨è
|
---|
| 33 | ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
|
---|
| 34 | * ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
|
---|
| 35 | * (b) åé
|
---|
| 36 | å¸ã®å½¢æ
|
---|
| 37 | ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSããã¸ã§ã¯ãã«
|
---|
| 38 | * å ±åãããã¨ï¼
|
---|
| 39 | * (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
|
---|
| 40 | * 害ãããï¼ä¸è¨èä½æ¨©è
|
---|
| 41 | ããã³TOPPERSããã¸ã§ã¯ããå
|
---|
| 42 | 責ãããã¨ï¼
|
---|
| 43 | *
|
---|
| 44 | * æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
|
---|
| 45 | ã
|
---|
| 46 | * ãã³TOPPERSããã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
|
---|
| 47 | * å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
|
---|
| 48 | * æ¥çã¾ãã¯éæ¥çã«çãããããªãæ害ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
|
---|
| 49 | *
|
---|
| 50 | * @(#) $Id: microblaze.c,v 1.8 2003/12/11 04:52:44 honda Exp $
|
---|
| 51 | */
|
---|
| 52 |
|
---|
| 53 | /* * Microblaze æ¨æºããªãã§ã©ã«ç¨ãã©ã¤ã
|
---|
| 54 | */
|
---|
| 55 | #include <s_services.h>
|
---|
| 56 | #include <microblaze.h>
|
---|
| 57 |
|
---|
| 58 |
|
---|
| 59 | /*
|
---|
| 60 | * UART Liteç¨ ç°¡æãã©ã¤ã
|
---|
| 61 | */
|
---|
| 62 |
|
---|
| 63 | /*
|
---|
| 64 | * ã·ãªã¢ã«I/Oãã¼ãåæåãããã¯
|
---|
| 65 | */
|
---|
| 66 | const SIOPINIB siopinib_table[TNUM_SIOP] = {{}};
|
---|
| 67 |
|
---|
| 68 | /*
|
---|
| 69 | * ã·ãªã¢ã«I/Oãã¼ã管çãããã¯ã®ã¨ãªã¢
|
---|
| 70 | */
|
---|
| 71 | SIOPCB siopcb_table[TNUM_SIOP];
|
---|
| 72 |
|
---|
| 73 | /*
|
---|
| 74 | * ã·ãªã¢ã«I/Oãã¼ãIDãã管çãããã¯ãåãåºãããã®ãã¯ã
|
---|
| 75 | */
|
---|
| 76 | #define INDEX_SIOP(siopid) ((UINT)((siopid) - 1))
|
---|
| 77 | #define get_siopcb(siopid) (&(siopcb_table[INDEX_SIOP(siopid)]))
|
---|
| 78 |
|
---|
| 79 | Inline void
|
---|
| 80 | uart_ena_int(void){
|
---|
| 81 | sil_wrw_mem((VP)UARTLITE_CTREG,
|
---|
| 82 | sil_rew_mem((VP)UARTLITE_CTREG) | UARTLITE_ENABLE_INTR);
|
---|
| 83 | }
|
---|
| 84 |
|
---|
| 85 | Inline void
|
---|
| 86 | uart_dis_int(void){
|
---|
| 87 | sil_wrw_mem((VP)UARTLITE_CTREG,
|
---|
| 88 | sil_rew_mem((VP)UARTLITE_CTREG) & ~UARTLITE_ENABLE_INTR);
|
---|
| 89 | }
|
---|
| 90 |
|
---|
| 91 | /*
|
---|
| 92 | * æåãåä¿¡ããã?
|
---|
| 93 | */
|
---|
| 94 | Inline BOOL
|
---|
| 95 | uart_getready(SIOPCB *siopcb)
|
---|
| 96 | {
|
---|
| 97 | return((sil_rew_mem((VP)UARTLITE_SRREG) &
|
---|
| 98 | UARTLITE_RX_FIFO_VALID_DATA) != 0);
|
---|
| 99 |
|
---|
| 100 | }
|
---|
| 101 |
|
---|
| 102 | /*
|
---|
| 103 | * æåãéä¿¡ã§ããã?
|
---|
| 104 | */
|
---|
| 105 | Inline BOOL
|
---|
| 106 | uart_putready(SIOPCB *siopcb)
|
---|
| 107 | {
|
---|
| 108 | return((sil_rew_mem((VP)UARTLITE_SRREG) & UARTLITE_TX_FIFO_FULL) == 0);
|
---|
| 109 | }
|
---|
| 110 |
|
---|
| 111 | /*
|
---|
| 112 | * åä¿¡ããæåã®åãåºã
|
---|
| 113 | */
|
---|
| 114 | Inline UB
|
---|
| 115 | uart_getchar(SIOPCB *siopcb)
|
---|
| 116 | {
|
---|
| 117 | return((UB)sil_rew_mem((VP)UARTLITE_RXREG));
|
---|
| 118 | }
|
---|
| 119 |
|
---|
| 120 | /*
|
---|
| 121 | * éä¿¡ããæåã®æ¸ãè¾¼ã¿
|
---|
| 122 | */
|
---|
| 123 | Inline void
|
---|
| 124 | uart_putchar(SIOPCB *siopcb, UB c)
|
---|
| 125 | {
|
---|
| 126 | sil_wrw_mem((VP)UARTLITE_TXREG, c);
|
---|
| 127 | }
|
---|
| 128 |
|
---|
| 129 | /*
|
---|
| 130 | * éä¿¡å¶å¾¡é¢æ°
|
---|
| 131 | * UART Lite ã«ã¯éä¿¡å²è¾¼ã¿ãåå¥ã«ç¦æ¢è¨±å¯ããæ©è½ã¯ãªã
|
---|
| 132 | * ãã®ããï¼éä¿¡çµäºæã«ã¯å¿
|
---|
| 133 | ã1åå²è¾¼ã¿ãå
|
---|
| 134 | ¥ã
|
---|
| 135 | */
|
---|
| 136 | /*
|
---|
| 137 | * éä¿¡å²è¾¼ã¿è¨±å¯
|
---|
| 138 | */
|
---|
| 139 | Inline void
|
---|
| 140 | uart_enable_send(SIOPCB *siopcb)
|
---|
| 141 | {
|
---|
| 142 |
|
---|
| 143 | }
|
---|
| 144 |
|
---|
| 145 | /*
|
---|
| 146 | * éä¿¡å²è¾¼ã¿ç¦æ¢
|
---|
| 147 | */
|
---|
| 148 | Inline void
|
---|
| 149 | uart_disable_send(SIOPCB *siopcb)
|
---|
| 150 | {
|
---|
| 151 |
|
---|
| 152 | }
|
---|
| 153 |
|
---|
| 154 |
|
---|
| 155 | /*
|
---|
| 156 | * SIOãã©ã¤ãã®åæåã«ã¼ãã³
|
---|
| 157 | * 1ãã¼ããããªãããï¼ãã¾ãæå³ã¯ãªã
|
---|
| 158 | */
|
---|
| 159 | void
|
---|
| 160 | uart_initialize()
|
---|
| 161 | {
|
---|
| 162 | SIOPCB *siopcb;
|
---|
| 163 | UINT i;
|
---|
| 164 |
|
---|
| 165 | /*
|
---|
| 166 | * ã·ãªã¢ã«I/Oãã¼ã管çãããã¯ã®åæå
|
---|
| 167 | */
|
---|
| 168 | for (siopcb = siopcb_table, i = 0; i < TNUM_SIOP; siopcb++, i++) {
|
---|
| 169 | siopcb->siopinib = &(siopinib_table[i]);
|
---|
| 170 | siopcb->openflag = FALSE;
|
---|
| 171 | siopcb->sendflag = FALSE;
|
---|
| 172 | }
|
---|
| 173 | }
|
---|
| 174 |
|
---|
| 175 |
|
---|
| 176 | SIOPCB *
|
---|
| 177 | uart_opn_por(ID siopid, VP_INT exinf){
|
---|
| 178 |
|
---|
| 179 | SIOPCB *siopcb;
|
---|
| 180 | const SIOPINIB *siopinib;
|
---|
| 181 |
|
---|
| 182 | siopcb = get_siopcb(siopid);
|
---|
| 183 | siopinib = siopcb->siopinib;
|
---|
| 184 |
|
---|
| 185 | /*
|
---|
| 186 | * éåä¿¡ãããã¡ã¯ãªã¢
|
---|
| 187 | */
|
---|
| 188 | sil_wrw_mem((VP)UARTLITE_CTREG, UARTLITE_RST_RX_FIFO
|
---|
| 189 | | UARTLITE_RST_TX_FIFO | UARTLITE_ENABLE_INTR);
|
---|
| 190 |
|
---|
| 191 | // sil_wrw_mem((VP)UARTLITE_CTREG, UARTLITE_RST_RX_FIFO
|
---|
| 192 | // | UARTLITE_RST_TX_FIFO );
|
---|
| 193 |
|
---|
| 194 | siopcb->exinf = exinf;
|
---|
| 195 | siopcb->getready = siopcb->putready = FALSE;
|
---|
| 196 | siopcb->openflag = TRUE;
|
---|
| 197 |
|
---|
| 198 | return(siopcb);
|
---|
| 199 | }
|
---|
| 200 |
|
---|
| 201 |
|
---|
| 202 | void
|
---|
| 203 | uart_cls_por(SIOPCB *siopcb){
|
---|
| 204 | sil_wrw_mem((VP)UARTLITE_CTREG, ~UARTLITE_ENABLE_INTR); /* å²è¾¼ã¿ç¦æ¢ */
|
---|
| 205 | siopcb->openflag = FALSE;
|
---|
| 206 | siopcb->sendflag = FALSE;
|
---|
| 207 | }
|
---|
| 208 |
|
---|
| 209 |
|
---|
| 210 |
|
---|
| 211 | /*
|
---|
| 212 | * ã·ãªã¢ã«I/Oãã¼ãã¸ã®æåéä¿¡
|
---|
| 213 | */
|
---|
| 214 | BOOL
|
---|
| 215 | uart_snd_chr(SIOPCB *siopcb, INT chr)
|
---|
| 216 | {
|
---|
| 217 | if(uart_putready(siopcb)){
|
---|
| 218 | uart_putchar(siopcb, (UB) chr);
|
---|
| 219 | return(TRUE);
|
---|
| 220 | }
|
---|
| 221 | return(FALSE);
|
---|
| 222 | }
|
---|
| 223 |
|
---|
| 224 |
|
---|
| 225 | /*
|
---|
| 226 | * ã·ãªã¢ã«I/Oãã¼ãããã®æååä¿¡
|
---|
| 227 | */
|
---|
| 228 | INT
|
---|
| 229 | uart_rcv_chr(SIOPCB *siopcb)
|
---|
| 230 | {
|
---|
| 231 | if (uart_getready(siopcb)) {
|
---|
| 232 | return((INT)(UB) uart_getchar(siopcb));
|
---|
| 233 | }
|
---|
| 234 | return(-1);
|
---|
| 235 | }
|
---|
| 236 |
|
---|
| 237 | /*
|
---|
| 238 | * OPB_UARTLITE ã¯éä¿¡ã¨åä¿¡å²è¾¼ã¿ãåå¥ã«è¨±å¯/ç¦æ¢ããæ©è½ã¯æããªã
|
---|
| 239 | */
|
---|
| 240 |
|
---|
| 241 | /*
|
---|
| 242 | * ã·ãªã¢ã«I/Oãã¼ãããã®ã³ã¼ã«ããã¯ã®è¨±å¯
|
---|
| 243 | */
|
---|
| 244 | void
|
---|
| 245 | uart_ena_cbr(SIOPCB *siopcb, UINT cbrtn)
|
---|
| 246 | {
|
---|
| 247 |
|
---|
| 248 | }
|
---|
| 249 |
|
---|
| 250 | /*
|
---|
| 251 | * ã·ãªã¢ã«I/Oãã¼ãããã®ã³ã¼ã«ããã¯ã®ç¦æ¢
|
---|
| 252 | */
|
---|
| 253 | void
|
---|
| 254 | uart_dis_cbr(SIOPCB *siopcb, UINT cbrtn)
|
---|
| 255 | {
|
---|
| 256 |
|
---|
| 257 | }
|
---|
| 258 |
|
---|
| 259 |
|
---|
| 260 | /*
|
---|
| 261 | * ã·ãªã¢ã«I/Oãã¼ãã«å¯¾ããå²è¾¼ã¿å¦ç
|
---|
| 262 | */
|
---|
| 263 | static void
|
---|
| 264 | uart_isr_siop(SIOPCB *siopcb)
|
---|
| 265 | {
|
---|
| 266 | /*
|
---|
| 267 | * ã¨ãã¸å²è¾¼ã¿ã®ããå²è¾¼ã¿å¦çåã«ACK
|
---|
| 268 | */
|
---|
| 269 | intc_ack_interrupt(1 << (UARTINTLVL - 1));
|
---|
| 270 |
|
---|
| 271 | if (uart_getready(siopcb)) {
|
---|
| 272 | /*
|
---|
| 273 | * åä¿¡éç¥ã³ã¼ã«ããã¯ã«ã¼ãã³ãå¼ã³åºãï¼
|
---|
| 274 | */
|
---|
| 275 | uart_ierdy_rcv(siopcb->exinf);
|
---|
| 276 | }
|
---|
| 277 |
|
---|
| 278 | if (uart_putready(siopcb)) {
|
---|
| 279 | /*
|
---|
| 280 | * éä¿¡å¯è½ã³ã¼ã«ããã¯ã«ã¼ãã³ãå¼ã³åºãï¼
|
---|
| 281 | */
|
---|
| 282 | uart_ierdy_snd(siopcb->exinf);
|
---|
| 283 | }
|
---|
| 284 | }
|
---|
| 285 |
|
---|
| 286 |
|
---|
| 287 | /*
|
---|
| 288 | * SIOã®å²è¾¼ã¿ãµã¼ãã¹ã«ã¼ãã³
|
---|
| 289 | */
|
---|
| 290 | void
|
---|
| 291 | uart_isr()
|
---|
| 292 | {
|
---|
| 293 | if (siopcb_table[0].openflag) {
|
---|
| 294 | uart_isr_siop(&(siopcb_table[0]));
|
---|
| 295 | }
|
---|
| 296 | }
|
---|
| 297 |
|
---|