Changeset 7ae5125 in rtems
- Timestamp:
- 08/16/01 21:08:28 (22 years ago)
- Branches:
- 4.10, 4.11, 4.8, 4.9, 5, master
- Children:
- f30a0ca9
- Parents:
- ede9699c
- Location:
- c/src/lib/libcpu/sh/sh7045
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
c/src/lib/libcpu/sh/sh7045/ChangeLog
rede9699c r7ae5125 1 2001-08-10 Radzislaw Galler <rgaller@et.put.poznan.pl> 2 3 * score/cpu_asm.c (sh_set_irq_priority): Changed interrupt vector 4 number range check and handling of interrupt priority regs to 5 conform SH2 specs. 6 * sci/sci_termios.c: New file. 7 * include/sci_termios.h: New file. 8 * include/Makefile.am (EXTRA_DIST): Added sci_termios.h. 9 (include_sh_HEADERS): Added sci_termios.h. 10 * score/ispsh7045.c (isp): Calling an ISR with immediate argument 11 casued negative sign extension for vector numbers of 128 and 12 above. This was fixed. 13 * sci/sci.c: Cleaned initialization of SCI registers; added 14 necessary setup for new TERMIOS console cooperation 15 1 16 2001-02-18 Ralf Corsepiu <corsepius@faw.uni-ulm.de> 2 17 -
c/src/lib/libcpu/sh/sh7045/include/Makefile.am
rede9699c r7ae5125 10 10 include_rtems_scoredir = $(includedir)/rtems/score 11 11 12 include_sh_HEADERS = io_types.h sci.h sh7_pfc.h sh7_sci.h 12 include_sh_HEADERS = io_types.h sci.h sh7_pfc.h sh7_sci.h sci_termios.h 13 13 include_rtems_score_HEADERS = ispsh7045.h iosh7045.h 14 14 … … 28 28 all-local: $(TMPINSTALL_FILES) 29 29 30 EXTRA_DIST = io_types.h sci.h sh7_pfc.h sh7_sci.h 30 EXTRA_DIST = io_types.h sci.h sh7_pfc.h sh7_sci.h sci_termios.h 31 31 32 32 include $(top_srcdir)/../../../../../../automake/local.am -
c/src/lib/libcpu/sh/sh7045/include/sci.h
rede9699c r7ae5125 25 25 #ifndef _sh_sci_h 26 26 #define _sh_sci_h 27 28 #include <rtems/libio.h> 27 29 28 30 #ifdef __cplusplus … … 78 80 void * 79 81 ); 82 83 extern const rtems_termios_callbacks * sh_sci_get_termios_handlers( 84 rtems_boolean poll 85 ); 86 80 87 81 88 #ifdef __cplusplus -
c/src/lib/libcpu/sh/sh7045/sci/Makefile.am
rede9699c r7ae5125 7 7 PGM = $(ARCH)/sci.rel 8 8 9 C_FILES = sci.c 9 C_FILES = sci.c sci_termios.c 10 10 C_O_FILES = $(C_FILES:%.c=$(ARCH)/%.o) 11 11 … … 27 27 .PRECIOUS: $(PGM) 28 28 29 EXTRA_DIST = sci.c 29 EXTRA_DIST = sci.c sci_termios.c 30 30 31 31 include $(top_srcdir)/../../../../../../automake/local.am -
c/src/lib/libcpu/sh/sh7045/sci/sci.c
rede9699c r7ae5125 42 42 43 43 #include <rtems.h> 44 44 45 45 46 #include <stdlib.h> … … 213 214 temp = read8(SCI_SSR0) & ~SCI_RDRF; 214 215 write8(temp, SCI_SSR0); 216 /* Check for transmission errors */ 217 if(temp & (SCI_ORER | SCI_FER | SCI_PER)){ 218 /* TODO: report to RTEMS transmission error */ 219 220 /* clear error flags*/ 221 temp &= ~(SCI_ORER | SCI_FER | SCI_PER); 222 write8(temp, SCI_SSR0); 223 } 215 224 result = TRUE; 216 225 } … … 229 238 temp= read8(SCI_SSR1) & ~SCI_RDRF; 230 239 write8(temp, SCI_SSR1); 240 /* Check for transmission errors */ 241 if(temp & (SCI_ORER | SCI_FER | SCI_PER)){ 242 /* TODO: report to RTEMS transmission error */ 243 244 /* clear error flags*/ 245 temp &= ~(SCI_ORER | SCI_FER | SCI_PER); 246 write8(temp, SCI_SSR1); 247 } 231 248 result = TRUE; 232 249 } 233 250 return result; 234 251 } /* rdSCI1 */ … … 279 296 { 280 297 rtems_device_driver status ; 281 rtems_device_minor_number i; 298 rtems_device_minor_number i; 299 rtems_driver_name_t *driver = NULL; 300 282 301 283 302 /* 284 303 * register all possible devices. 285 304 * the initialization of the hardware is done by sci_open 305 * 306 * One of devices could be previously registered by console 307 * initialization therefore we check it everytime 286 308 */ 287 309 288 310 for ( i = 0 ; i < SCI_MINOR_DEVICES ; i++ ) 289 311 { 290 status = rtems_io_register_name( 291 sci_device[i].name, 292 major, 293 sci_device[i].minor ); 294 if (status != RTEMS_SUCCESSFUL) 295 rtems_fatal_error_occurred(status); 312 status = rtems_io_lookup_name( 313 sci_device[i].name, 314 &driver); 315 if( status != RTEMS_SUCCESSFUL ) 316 { 317 /* OK. We assume it is not registered yet. */ 318 status = rtems_io_register_name( 319 sci_device[i].name, 320 major, 321 sci_device[i].minor ); 322 if (status != RTEMS_SUCCESSFUL) 323 rtems_fatal_error_occurred(status); 324 } 296 325 } 297 326 … … 305 334 * Open entry point 306 335 * Sets up port and pins for selected sci. 307 * SCI0 setup is conditional on STANDALONE_EVB == 1308 336 */ 309 337 … … 333 361 /* set PFC registers to enable I/O pins */ 334 362 335 if ((minor == 0) && (STANDALONE_EVB == 1)) {363 if ((minor == 0)) { 336 364 temp16 = read16(PFC_PACRL2); /* disable SCK0, DMA, IRQ */ 337 365 temp16 &= ~(PA2MD1 | PA2MD0); … … 348 376 349 377 /* set up SCI registers */ 350 if ((minor != 0) || (STANDALONE_EVB == 1)) { 351 write8(0x00, sci_device[minor].addr + SCI_SCR); /* Clear SCR */ 378 write8(0x00, sci_device[minor].addr + SCI_SCR); /* Clear SCR */ 352 379 /* set SMR and BRR */ 353 380 _sci_set_cflags( &sci_device[minor], sci_device[minor].cflags ); … … 359 386 write8((SCI_RE | SCI_TE), /* enable async. Tx and Rx */ 360 387 sci_device[minor].addr + SCI_SCR); 361 temp8 = read8(sci_device[minor].addr + SCI_RDR); /* flush input */ 388 389 /* clear error flags */ 390 temp8 = read8(sci_device[minor].addr + SCI_SSR); 391 while(temp8 & (SCI_RDRF | SCI_ORER | SCI_FER | SCI_PER)){ 392 temp8 = read8(sci_device[minor].addr + SCI_RDR); /* flush input */ 393 temp8 = read8(sci_device[minor].addr + SCI_SSR); /* clear some flags */ 394 write8(temp8 & ~(SCI_RDRF | SCI_ORER | SCI_FER | SCI_PER), 395 sci_device[minor].addr + SCI_SSR); 396 temp8 = read8(sci_device[minor].addr + SCI_SSR); /* check if everything is OK */ 397 } 362 398 /* Clear RDRF flag */ 363 temp8= read8(sci_device[minor].addr + SCI_SSR) & ~SCI_RDRF;364 write8(temp8, sci_device[minor].addr + SCI_SSR);365 399 write8(0x00, sci_device[minor].addr + SCI_TDR); /* force output */ 366 400 /* Clear the TDRE bit */ … … 370 404 /* add interrupt setup if required */ 371 405 372 } 373 406 374 407 sci_device[minor].opened++ ; 375 408 … … 472 505 return RTEMS_SUCCESSFUL ; 473 506 } 507 508 /* 509 * Termios polled first open 510 */ 511 static int _sh_sci_poll_first_open(int major, int minor, void *arg) 512 { 513 return sh_sci_open(major, minor, arg); 514 } 515 516 /* 517 * Termios general last close 518 */ 519 static int _sh_sci_last_close(int major, int minor, void *arg) 520 { 521 return sh_sci_close(major, minor, arg); 522 } 523 524 /* 525 * Termios polled read 526 */ 527 static int _sh_sci_poll_read(int minor) 528 { 529 int value = -1; 530 char ch; 531 532 if( minor == 0 ){ 533 if( rdSCI0( &ch ) ) 534 value = (int) ch; 535 }else if( minor == 1 ){ 536 if( rdSCI1( &ch ) ) 537 value = (int) ch; 538 } 539 return value; 540 } 541 542 /* 543 * Termios polled write 544 */ 545 static int _sh_sci_poll_write(int minor, const char *buf, int len) 546 { 547 int count; 548 549 for(count = 0; count < len; count++) 550 outbyte( minor, buf[count] ); 551 return count; 552 } 553 554 /* 555 * Termios set attributes 556 */ 557 static int _sh_sci_set_attributes( int minor, const struct termios *t) 558 { 559 return _sci_set_cflags( &sci_device[ minor ], t->c_cflag); 560 } 561 562 563 const rtems_termios_callbacks sci_poll_callbacks = { 564 _sh_sci_poll_first_open, /* FirstOpen*/ 565 _sh_sci_last_close, /* LastClose*/ 566 _sh_sci_poll_read, /* PollRead */ 567 _sh_sci_poll_write, /* Write */ 568 _sh_sci_set_attributes, /* setAttributes */ 569 NULL, /* stopRemoteTX */ 570 NULL, /* StartRemoteTX */ 571 0 /* outputUsesInterrupts */ 572 }; 573 574 /* FIXME: not yet supported */ 575 const rtems_termios_callbacks sci_interrupt_callbacks; 576 577 const rtems_termios_callbacks* sh_sci_get_termios_handlers( rtems_boolean poll ) 578 { 579 return poll ? 580 &sci_poll_callbacks : 581 &sci_interrupt_callbacks; 582 } -
c/src/lib/libcpu/sh/sh7045/score/cpu_asm.c
rede9699c r7ae5125 82 82 * first check for valid interrupt 83 83 */ 84 if(( irq > 1 13) || (_Hardware_isr_Table[irq] == _dummy_isp))84 if(( irq > 156) || (irq < 64) || (_Hardware_isr_Table[irq] == _dummy_isp)) 85 85 return -1; 86 86 /* … … 103 103 case 1: { prioreg = INTC_IPRD; break;} 104 104 case 2: { prioreg = INTC_IPRE; break;} 105 case 3: { prioreg = INTC_IPRF; break;} 106 case 4: { prioreg = INTC_IPRG; break;} 107 case 5: { prioreg = INTC_IPRH; break;} 105 108 default: return -1; 106 109 } -
c/src/lib/libcpu/sh/sh7045/score/ispsh7045.c
rede9699c r7ae5125 124 124 " sts.l macl,@-r15 \n\t" \ 125 125 " mov r15,r14 \n\t" \ 126 " mov.l "Str(name)"_v, r2 \n\t" \ 126 127 " mov.l "Str(name)"_k, r1\n\t" \ 127 128 " jsr @r1 \n\t" \ 128 " mov #"Str(number)", r4\n\t" \129 " mov r2,r4 \n\t" \ 129 130 " mov r14,r15 \n\t" \ 130 131 " lds.l @r15+,macl \n\t" \ … … 144 145 " .align 2 \n\t" \ 145 146 #name"_k: \n\t" \ 146 ".long "Str(func)); 147 ".long "Str(func)"\n\t" \ 148 #name"_v: \n\t" \ 149 ".long "Str(number)); 147 150 148 151 /************************************************
Note: See TracChangeset
for help on using the changeset viewer.