Changeset caeb33b2 in rtems
- Timestamp:
- 07/03/01 17:56:32 (22 years ago)
- Branches:
- 4.10, 4.11, 4.8, 4.9, 5, master
- Children:
- b8c8cab
- Parents:
- 6c5e3215
- Location:
- c/src/lib/libbsp/i386/shared
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
c/src/lib/libbsp/i386/shared/ChangeLog
r6c5e3215 rcaeb33b2 1 2 * comm/tty_drv.c, comm/uart.c, comm/uart.h: Adds the capability 3 to use task driven serial I/O to ti386 BSPs. This patch leaves thex 4 default I/O mode to be IRQ. If you want to use task I/O mode, 5 then the tty_drv.c file needs to be modified. Basically, all 6 you need to change is the data values of the termios callbacks 7 structure. This callback structure is used in the tty1_open 8 and tty2_open functions. The values you need to set are commented 9 out in the source code. 10 11 2001-06-19 Ralf Corsepius <corsepiu@faw.uni-ulm.de> 1 12 2 13 * comm/Makefile.am: Use *_HEADERS instead of *H_FILES. -
c/src/lib/libbsp/i386/shared/comm/tty_drv.c
r6c5e3215 rcaeb33b2 19 19 * 20 20 * $Log$ 21 * Revision 1.3 2000/12/05 16:37:38 joel 22 * 2000-12-01 Joel Sherrill <joel@OARcorp.com> 23 * 24 * * pc386/console/console.c, pc386/console/serial_mouse.c, 25 * pc386/console/vgainit.c, shared/comm/tty_drv.c: Remove warnings. 26 * 21 27 * Revision 1.2 2000/10/18 16:10:50 joel 22 28 * 2000-10-18 Charles-Antoine Gauthier <charles.gauthier@nrc.ca> … … 48 54 #include <irq.h> 49 55 #include <rtems/libio.h> 56 #include <rtems/termiostypes.h> 50 57 #include <termios.h> 51 58 #include <uart.h> … … 176 183 { 177 184 rtems_status_code status; 185 #ifndef USE_TASK_DRIVEN 178 186 static rtems_termios_callbacks cb = 179 187 { 180 NULL, 181 tty1_last_close, /* lastClose */182 NULL, /* poll read*/188 NULL, /* firstOpen */ 189 tty1_last_close, /* lastClose */ 190 NULL, /* poll read */ 183 191 BSP_uart_termios_write_com1, /* write */ 184 tty1_conSetAttr, 185 NULL, 186 NULL, 187 1/* outputUsesInterrupts */192 tty1_conSetAttr, /* setAttributes */ 193 NULL, /* stopRemoteTx */ 194 NULL, /* startRemoteTx */ 195 TERMIOS_IRQ_DRIVEN /* outputUsesInterrupts */ 188 196 }; 197 #else 198 static rtems_termios_callbacks cb = 199 { 200 NULL, /* firstOpen */ 201 tty1_last_close, /* lastClose */ 202 BSP_uart_termios_read_com1, /* poll read */ 203 BSP_uart_termios_write_com1, /* write */ 204 tty1_conSetAttr, /* setAttributes */ 205 NULL, /* stopRemoteTx */ 206 NULL, /* startRemoteTx */ 207 TERMIOS_TASK_DRIVEN /* outputUsesInterrupts */ 208 }; 209 #endif 189 210 190 211 status = rtems_termios_open( major, minor, arg, &cb ); … … 452 473 { 453 474 rtems_status_code status; 475 #ifndef USE_TASK_DRIVEN 454 476 static rtems_termios_callbacks cb = 455 477 { 456 NULL, 457 tty2_last_close, /* lastClose */458 NULL, /* poll read*/478 NULL, /* firstOpen */ 479 tty2_last_close, /* lastClose */ 480 NULL, /* poll read */ 459 481 BSP_uart_termios_write_com2, /* write */ 460 tty2_conSetAttr, 461 NULL, 462 NULL, 463 1/* outputUsesInterrupts */482 tty2_conSetAttr, /* setAttributes */ 483 NULL, /* stopRemoteTx */ 484 NULL, /* startRemoteTx */ 485 TERMIOS_IRQ_DRIVEN /* outputUsesInterrupts */ 464 486 }; 487 #else 488 static rtems_termios_callbacks cb = 489 { 490 NULL, /* firstOpen */ 491 tty2_last_close, /* lastClose */ 492 BSP_uart_termios_read_com2, /* poll read */ 493 BSP_uart_termios_write_com2, /* write */ 494 tty2_conSetAttr, /* setAttributes */ 495 NULL, /* stopRemoteTx */ 496 NULL, /* startRemoteTx */ 497 TERMIOS_TASK_DRIVEN /* outputUsesInterrupts */ 498 }; 499 #endif 465 500 466 501 status = rtems_termios_open (major, minor, arg, &cb); -
c/src/lib/libbsp/i386/shared/comm/uart.c
r6c5e3215 rcaeb33b2 8 8 */ 9 9 10 #include <stdio.h> 10 11 #include <bsp.h> 11 12 #include <irq.h> 12 13 #include <uart.h> 13 14 #include <rtems/libio.h> 15 #include <rtems/termiostypes.h> 16 #include <termios.h> 14 17 #include <assert.h> 15 18 … … 20 23 struct uart_data 21 24 { 25 int ioMode; 22 26 int hwFlow; 27 unsigned int ier; 23 28 unsigned long baud; 24 29 unsigned long databits; … … 233 238 BSP_uart_intr_ctrl(int uart, int cmd) 234 239 { 240 int iStatus = (int)INTERRUPT_DISABLE; 235 241 236 242 assert(uart == BSP_UART_COM1 || uart == BSP_UART_COM2); … … 238 244 switch(cmd) 239 245 { 240 case BSP_UART_INTR_CTRL_DISABLE:241 uwrite(uart, IER, INTERRUPT_DISABLE);242 break;243 246 case BSP_UART_INTR_CTRL_ENABLE: 244 if(uart_data[uart].hwFlow) 245 { 246 uwrite(uart, IER, 247 (RECEIVE_ENABLE | 248 TRANSMIT_ENABLE | 249 RECEIVER_LINE_ST_ENABLE | 250 MODEM_ENABLE 251 ) 252 ); 253 } 254 else 255 { 256 uwrite(uart, IER, 257 (RECEIVE_ENABLE | 258 TRANSMIT_ENABLE | 259 RECEIVER_LINE_ST_ENABLE 260 ) 261 ); 262 } 247 iStatus |= (RECEIVE_ENABLE | RECEIVER_LINE_ST_ENABLE | TRANSMIT_ENABLE); 248 if ( uart_data[uart].hwFlow ) { 249 iStatus |= MODEM_ENABLE; 250 } 263 251 break; 264 252 case BSP_UART_INTR_CTRL_TERMIOS: 265 if(uart_data[uart].hwFlow) 266 { 267 uwrite(uart, IER, 268 (RECEIVE_ENABLE | 269 RECEIVER_LINE_ST_ENABLE | 270 MODEM_ENABLE 271 ) 272 ); 273 } 274 else 275 { 276 uwrite(uart, IER, 277 (RECEIVE_ENABLE | 278 RECEIVER_LINE_ST_ENABLE 279 ) 280 ); 281 } 253 iStatus |= (RECEIVE_ENABLE | RECEIVER_LINE_ST_ENABLE); 254 if ( uart_data[uart].hwFlow ) { 255 iStatus |= MODEM_ENABLE; 256 } 282 257 break; 283 258 case BSP_UART_INTR_CTRL_GDB: 284 uwrite(uart, IER, RECEIVE_ENABLE);259 iStatus |= RECEIVE_ENABLE; 285 260 break; 286 default:287 assert(0); 288 break;289 }261 } 262 263 uart_data[uart].ier = iStatus; 264 uwrite(uart, IER, iStatus); 290 265 291 266 return; … … 495 470 BSP_uart_termios_set(int uart, void *ttyp) 496 471 { 472 struct rtems_termios_tty *p = (struct rtems_termios_tty *)ttyp; 497 473 unsigned char val; 498 474 assert(uart == BSP_UART_COM1 || uart == BSP_UART_COM2); … … 500 476 if(uart == BSP_UART_COM1) 501 477 { 478 uart_data[uart].ioMode = p->device.outputUsesInterrupts; 502 479 if(uart_data[uart].hwFlow) 503 480 { … … 517 494 else 518 495 { 496 uart_data[uart].ioMode = p->device.outputUsesInterrupts; 519 497 if(uart_data[uart].hwFlow) 520 498 { … … 537 515 538 516 int 517 BSP_uart_termios_read_com1(int uart) 518 { 519 int off = (int)0; 520 char buf[40]; 521 522 /* read bytes */ 523 while (( off < sizeof(buf) ) && ( uread(BSP_UART_COM1, LSR) & DR )) { 524 buf[off++] = uread(BSP_UART_COM1, RBR); 525 } 526 527 /* write out data */ 528 if ( off > 0 ) { 529 rtems_termios_enqueue_raw_characters(termios_ttyp_com1, buf, off); 530 } 531 532 /* enable receive interrupts */ 533 uart_data[BSP_UART_COM1].ier |= (RECEIVE_ENABLE | RECEIVER_LINE_ST_ENABLE); 534 uwrite(BSP_UART_COM1, IER, uart_data[BSP_UART_COM1].ier); 535 536 return ( EOF ); 537 } 538 539 int 540 BSP_uart_termios_read_com2(int uart) 541 { 542 int off = (int)0; 543 char buf[40]; 544 545 /* read current byte */ 546 while (( off < sizeof(buf) ) && ( uread(BSP_UART_COM1, LSR) & DR )) { 547 buf[off++] = uread(BSP_UART_COM1, RBR); 548 } 549 550 /* write out data */ 551 if ( off > 0 ) { 552 rtems_termios_enqueue_raw_characters(termios_ttyp_com2, buf, off); 553 } 554 555 /* enable receive interrupts */ 556 uart_data[BSP_UART_COM2].ier |= (RECEIVE_ENABLE | RECEIVER_LINE_ST_ENABLE); 557 uwrite(BSP_UART_COM2, IER, uart_data[BSP_UART_COM2].ier); 558 559 return ( EOF ); 560 } 561 562 int 539 563 BSP_uart_termios_write_com1(int minor, const char *buf, int len) 540 564 { … … 561 585 562 586 /* Enable interrupts if necessary */ 563 if(!termios_tx_active_com1 && uart_data[BSP_UART_COM1].hwFlow) 564 { 565 termios_tx_active_com1 = 1; 566 uwrite(BSP_UART_COM1, IER, 567 (RECEIVE_ENABLE | 568 TRANSMIT_ENABLE | 569 RECEIVER_LINE_ST_ENABLE | 570 MODEM_ENABLE 571 ) 572 ); 573 } 574 else if(!termios_tx_active_com1) 575 { 576 termios_tx_active_com1 = 1; 577 uwrite(BSP_UART_COM1, IER, 578 (RECEIVE_ENABLE | 579 TRANSMIT_ENABLE | 580 RECEIVER_LINE_ST_ENABLE 581 ) 582 ); 583 } 587 if ( !termios_tx_active_com1 ) { 588 termios_tx_active_com1 = 1; 589 uart_data[BSP_UART_COM1].ier |= TRANSMIT_ENABLE; 590 uwrite(BSP_UART_COM1, IER, uart_data[BSP_UART_COM1].ier); 591 } 584 592 585 593 return 0; … … 609 617 610 618 /* Write character */ 611 612 619 uwrite(BSP_UART_COM2, THR, *buf & 0xff); 613 620 614 621 /* Enable interrupts if necessary */ 615 if(!termios_tx_active_com2 && uart_data[BSP_UART_COM2].hwFlow) 616 { 617 termios_tx_active_com2 = 1; 618 uwrite(BSP_UART_COM2, IER, 619 (RECEIVE_ENABLE | 620 TRANSMIT_ENABLE | 621 RECEIVER_LINE_ST_ENABLE | 622 MODEM_ENABLE 623 ) 624 ); 625 } 626 else if(!termios_tx_active_com2) 627 { 628 termios_tx_active_com2 = 1; 629 uwrite(BSP_UART_COM2, IER, 630 (RECEIVE_ENABLE | 631 TRANSMIT_ENABLE | 632 RECEIVER_LINE_ST_ENABLE 633 ) 634 ); 635 } 622 if ( !termios_tx_active_com2 ) { 623 termios_tx_active_com2 = 1; 624 uart_data[BSP_UART_COM2].ier |= TRANSMIT_ENABLE; 625 uwrite(BSP_UART_COM2, IER, uart_data[BSP_UART_COM2].ier); 626 } 636 627 637 628 return 0; … … 698 689 */ 699 690 691 /* If nothing else to send disable interrupts */ 700 692 ret = rtems_termios_dequeue_characters(termios_ttyp_com1, 1); 701 702 /* If nothing else to send disable interrupts */ 703 if(ret == 0 && uart_data[BSP_UART_COM1].hwFlow) 704 { 705 uwrite(BSP_UART_COM1, IER, 706 (RECEIVE_ENABLE | 707 RECEIVER_LINE_ST_ENABLE | 708 MODEM_ENABLE 709 ) 710 ); 711 termios_tx_active_com1 = 0; 712 } 713 else if(ret == 0) 714 { 715 uwrite(BSP_UART_COM1, IER, 716 (RECEIVE_ENABLE | 717 RECEIVER_LINE_ST_ENABLE 718 ) 719 ); 720 termios_tx_active_com1 = 0; 721 } 693 if ( ret == 0 ) { 694 termios_tx_active_com1 = 0; 695 uart_data[BSP_UART_COM1].ier &= ~(TRANSMIT_ENABLE); 696 uwrite(BSP_UART_COM1, IER, uart_data[BSP_UART_COM1].ier); 697 } 722 698 break; 723 699 case RECEIVER_DATA_AVAIL : 724 700 case CHARACTER_TIMEOUT_INDICATION: 725 /* RX data ready */ 726 assert(off < sizeof(buf)); 727 buf[off++] = uread(BSP_UART_COM1, RBR); 701 if ( uart_data[BSP_UART_COM1].ioMode == TERMIOS_TASK_DRIVEN ) { 702 /* ensure interrupts are enabled */ 703 if ( uart_data[BSP_UART_COM1].ier & RECEIVE_ENABLE ) { 704 /* disable interrupts and notify termios */ 705 uart_data[BSP_UART_COM1].ier &= ~(RECEIVE_ENABLE | RECEIVER_LINE_ST_ENABLE); 706 uwrite(BSP_UART_COM1, IER, uart_data[BSP_UART_COM1].ier); 707 rtems_termios_rxirq_occured(termios_ttyp_com1); 708 } 709 } 710 else { 711 /* RX data ready */ 712 assert(off < sizeof(buf)); 713 buf[off++] = uread(BSP_UART_COM1, RBR); 714 } 728 715 break; 729 716 case RECEIVER_ERROR: … … 797 784 */ 798 785 786 /* If nothing else to send disable interrupts */ 799 787 ret = rtems_termios_dequeue_characters(termios_ttyp_com2, 1); 800 801 /* If nothing else to send disable interrupts */ 802 if(ret == 0 && uart_data[BSP_UART_COM2].hwFlow) 803 { 804 uwrite(BSP_UART_COM2, IER, 805 (RECEIVE_ENABLE | 806 RECEIVER_LINE_ST_ENABLE | 807 MODEM_ENABLE 808 ) 809 ); 810 termios_tx_active_com2 = 0; 811 } 812 else if(ret == 0) 813 { 814 uwrite(BSP_UART_COM2, IER, 815 (RECEIVE_ENABLE | 816 RECEIVER_LINE_ST_ENABLE 817 ) 818 ); 819 termios_tx_active_com2 = 0; 820 } 788 if ( ret == 0 ) { 789 termios_tx_active_com2 = 0; 790 uart_data[BSP_UART_COM2].ier &= ~(TRANSMIT_ENABLE); 791 uwrite(BSP_UART_COM2, IER, uart_data[BSP_UART_COM2].ier); 792 } 821 793 break; 822 794 case RECEIVER_DATA_AVAIL : 823 795 case CHARACTER_TIMEOUT_INDICATION: 824 /* RX data ready */ 825 assert(off < sizeof(buf)); 826 buf[off++] = uread(BSP_UART_COM2, RBR); 796 if ( uart_data[BSP_UART_COM2].ioMode == TERMIOS_TASK_DRIVEN ) { 797 /* ensure interrupts are enabled */ 798 if ( uart_data[BSP_UART_COM2].ier & RECEIVE_ENABLE ) { 799 /* disable interrupts and notify termios */ 800 uart_data[BSP_UART_COM2].ier &= ~(RECEIVE_ENABLE | RECEIVER_LINE_ST_ENABLE); 801 uwrite(BSP_UART_COM2, IER, uart_data[BSP_UART_COM2].ier); 802 rtems_termios_rxirq_occured(termios_ttyp_com2); 803 } 804 } 805 else { 806 /* RX data ready */ 807 assert(off < sizeof(buf)); 808 buf[off++] = uread(BSP_UART_COM2, RBR); 809 } 827 810 break; 828 811 case RECEIVER_ERROR: -
c/src/lib/libbsp/i386/shared/comm/uart.h
r6c5e3215 rcaeb33b2 21 21 int BSP_uart_polled_read(int uart); 22 22 void BSP_uart_termios_set(int uart, void *ttyp); 23 int BSP_uart_termios_read_com1(int uart); 24 int BSP_uart_termios_read_com2(int uart); 23 25 int BSP_uart_termios_write_com1(int minor, const char *buf, int len); 24 26 int BSP_uart_termios_write_com2(int minor, const char *buf, int len);
Note: See TracChangeset
for help on using the changeset viewer.