Changeset a75c783 in rtems
- Timestamp:
- Oct 21, 1997, 5:03:18 PM (23 years ago)
- Branches:
- 4.10, 4.11, 4.8, 4.9, 5, master
- Children:
- 97faafa5
- Parents:
- 55e1322
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
c/src/exec/libcsupport/src/termios.c
r55e1322 ra75c783 24 24 #include <termios.h> 25 25 #include <unistd.h> 26 #include <ringbuf.h> 26 27 27 28 /* … … 29 30 */ 30 31 #define CBUFSIZE 256 31 32 /*33 * The size of the raw input message queue34 */35 #define RAW_MESSAGE_QUEUE_COUNT 1036 #define RAW_MESSAGE_QUEUE_SIZE 1637 32 38 33 /* … … 86 81 * Raw character buffer 87 82 */ 88 rtems_id rawInputQueue; 89 char rawBuf[RAW_MESSAGE_QUEUE_SIZE]; 90 int rawBufCount; 91 int rawBufIndex; 83 rtems_id rawInputSem; 84 Ring_buffer_t rawInputBuffer; 85 92 86 rtems_unsigned32 rawMessageOptions; 93 87 rtems_interval rawMessageTimeout; … … 98 92 */ 99 93 int (*lastClose)(int major, int minor, void *arg); 100 int (*read)(int minor, char *buf /*, int len */);94 int (*read)(int minor, char *buf ); 101 95 int (*write)(int minor, char *buf, int len); 102 96 }; … … 195 189 tty->lastClose = deviceLastClose; 196 190 if ((tty->read = deviceRead) == NULL) { 197 sc = rtems_ message_queue_create (198 rtems_build_name ('T', 'R', ' i', c),199 RAW_MESSAGE_QUEUE_COUNT,200 R AW_MESSAGE_QUEUE_SIZE,201 RTEMS_ FIFO | RTEMS_LOCAL,202 &tty->rawInput Queue);191 sc = rtems_semaphore_create ( 192 rtems_build_name ('T', 'R', 'r', c), 193 0, 194 RTEMS_COUNTING_SEMAPHORE | RTEMS_FIFO | RTEMS_LOCAL, 195 RTEMS_NO_PRIORITY, 196 &tty->rawInputSem); 203 197 if (sc != RTEMS_SUCCESSFUL) 204 198 rtems_fatal_error_occurred (sc); 205 tty->rawBufCount = tty->rawBufIndex = 0;206 199 } 207 200 … … 276 269 rtems_semaphore_delete (tty->osem); 277 270 if (tty->read == NULL) 278 rtems_ message_queue_delete (tty->rawInputQueue);271 rtems_semaphore_delete (tty->rawInputSem); 279 272 free (tty); 280 273 } … … 669 662 rtems_interval timeout = tty->rawMessageFirstTimeout; 670 663 rtems_status_code sc; 671 rtems_unsigned 32 msgSize;664 rtems_unsigned8 c; 672 665 673 666 for (;;) { 674 /*675 * Process characters read from raw queue676 */677 while (tty->rawBufIndex < tty->rawBufCount) {678 unsigned char c = tty->rawBuf[tty->rawBufIndex++];679 if (tty->termios.c_lflag & ICANON) {680 if (siproc (c, tty))681 return RTEMS_SUCCESSFUL;682 }683 else {684 siproc (c, tty);685 if (tty->ccount >= tty->termios.c_cc[VMIN])686 return RTEMS_SUCCESSFUL;687 }688 }689 667 690 668 /* 691 669 * Read characters from raw queue 692 670 */ 693 msgSize = RAW_MESSAGE_QUEUE_SIZE; 694 sc = rtems_message_queue_receive (tty->rawInputQueue, 695 tty->rawBuf, 696 &msgSize, 671 sc = rtems_semaphore_obtain (tty->rawInputSem, 697 672 tty->rawMessageOptions, 698 673 timeout); 699 674 if (sc != RTEMS_SUCCESSFUL) 700 675 break; 701 tty->rawBufIndex = 0; 702 tty->rawBufCount = msgSize; 676 Ring_buffer_Remove_character( &tty->rawInputBuffer, c ); 677 678 /* 679 * Process characters read from raw queue 680 */ 681 if (tty->termios.c_lflag & ICANON) { 682 if (siproc (c, tty)) 683 return RTEMS_SUCCESSFUL; 684 } 685 else { 686 siproc (c, tty); 687 if (tty->ccount >= tty->termios.c_cc[VMIN]) 688 return RTEMS_SUCCESSFUL; 689 } 690 703 691 timeout = tty->rawMessageTimeout; 704 692 } … … 745 733 { 746 734 struct rtems_termios_tty *tty = ttyp; 747 int ncopy;748 735 749 736 while (len) { 750 if (len < RAW_MESSAGE_QUEUE_SIZE) 751 ncopy = len; 752 else 753 ncopy = RAW_MESSAGE_QUEUE_SIZE; 754 if (rtems_message_queue_send (tty->rawInputQueue, buf, ncopy) != RTEMS_SUCCESSFUL) 755 break; 756 len -= ncopy; 757 buf += ncopy; 758 } 759 } 760 737 if (Ring_buffer_Is_full(&tty->rawInputBuffer)) 738 break; 739 Ring_buffer_Add_character(&tty->rawInputBuffer, *buf); 740 if (rtems_semaphore_release(tty->rawInputSem) != RTEMS_SUCCESSFUL) 741 break; 742 len -= 1; 743 buf += 1; 744 } 745 } 746 -
c/src/lib/libc/termios.c
r55e1322 ra75c783 24 24 #include <termios.h> 25 25 #include <unistd.h> 26 #include <ringbuf.h> 26 27 27 28 /* … … 29 30 */ 30 31 #define CBUFSIZE 256 31 32 /*33 * The size of the raw input message queue34 */35 #define RAW_MESSAGE_QUEUE_COUNT 1036 #define RAW_MESSAGE_QUEUE_SIZE 1637 32 38 33 /* … … 86 81 * Raw character buffer 87 82 */ 88 rtems_id rawInputQueue; 89 char rawBuf[RAW_MESSAGE_QUEUE_SIZE]; 90 int rawBufCount; 91 int rawBufIndex; 83 rtems_id rawInputSem; 84 Ring_buffer_t rawInputBuffer; 85 92 86 rtems_unsigned32 rawMessageOptions; 93 87 rtems_interval rawMessageTimeout; … … 98 92 */ 99 93 int (*lastClose)(int major, int minor, void *arg); 100 int (*read)(int minor, char *buf /*, int len */);94 int (*read)(int minor, char *buf ); 101 95 int (*write)(int minor, char *buf, int len); 102 96 }; … … 195 189 tty->lastClose = deviceLastClose; 196 190 if ((tty->read = deviceRead) == NULL) { 197 sc = rtems_ message_queue_create (198 rtems_build_name ('T', 'R', ' i', c),199 RAW_MESSAGE_QUEUE_COUNT,200 R AW_MESSAGE_QUEUE_SIZE,201 RTEMS_ FIFO | RTEMS_LOCAL,202 &tty->rawInput Queue);191 sc = rtems_semaphore_create ( 192 rtems_build_name ('T', 'R', 'r', c), 193 0, 194 RTEMS_COUNTING_SEMAPHORE | RTEMS_FIFO | RTEMS_LOCAL, 195 RTEMS_NO_PRIORITY, 196 &tty->rawInputSem); 203 197 if (sc != RTEMS_SUCCESSFUL) 204 198 rtems_fatal_error_occurred (sc); 205 tty->rawBufCount = tty->rawBufIndex = 0;206 199 } 207 200 … … 276 269 rtems_semaphore_delete (tty->osem); 277 270 if (tty->read == NULL) 278 rtems_ message_queue_delete (tty->rawInputQueue);271 rtems_semaphore_delete (tty->rawInputSem); 279 272 free (tty); 280 273 } … … 669 662 rtems_interval timeout = tty->rawMessageFirstTimeout; 670 663 rtems_status_code sc; 671 rtems_unsigned 32 msgSize;664 rtems_unsigned8 c; 672 665 673 666 for (;;) { 674 /*675 * Process characters read from raw queue676 */677 while (tty->rawBufIndex < tty->rawBufCount) {678 unsigned char c = tty->rawBuf[tty->rawBufIndex++];679 if (tty->termios.c_lflag & ICANON) {680 if (siproc (c, tty))681 return RTEMS_SUCCESSFUL;682 }683 else {684 siproc (c, tty);685 if (tty->ccount >= tty->termios.c_cc[VMIN])686 return RTEMS_SUCCESSFUL;687 }688 }689 667 690 668 /* 691 669 * Read characters from raw queue 692 670 */ 693 msgSize = RAW_MESSAGE_QUEUE_SIZE; 694 sc = rtems_message_queue_receive (tty->rawInputQueue, 695 tty->rawBuf, 696 &msgSize, 671 sc = rtems_semaphore_obtain (tty->rawInputSem, 697 672 tty->rawMessageOptions, 698 673 timeout); 699 674 if (sc != RTEMS_SUCCESSFUL) 700 675 break; 701 tty->rawBufIndex = 0; 702 tty->rawBufCount = msgSize; 676 Ring_buffer_Remove_character( &tty->rawInputBuffer, c ); 677 678 /* 679 * Process characters read from raw queue 680 */ 681 if (tty->termios.c_lflag & ICANON) { 682 if (siproc (c, tty)) 683 return RTEMS_SUCCESSFUL; 684 } 685 else { 686 siproc (c, tty); 687 if (tty->ccount >= tty->termios.c_cc[VMIN]) 688 return RTEMS_SUCCESSFUL; 689 } 690 703 691 timeout = tty->rawMessageTimeout; 704 692 } … … 745 733 { 746 734 struct rtems_termios_tty *tty = ttyp; 747 int ncopy;748 735 749 736 while (len) { 750 if (len < RAW_MESSAGE_QUEUE_SIZE) 751 ncopy = len; 752 else 753 ncopy = RAW_MESSAGE_QUEUE_SIZE; 754 if (rtems_message_queue_send (tty->rawInputQueue, buf, ncopy) != RTEMS_SUCCESSFUL) 755 break; 756 len -= ncopy; 757 buf += ncopy; 758 } 759 } 760 737 if (Ring_buffer_Is_full(&tty->rawInputBuffer)) 738 break; 739 Ring_buffer_Add_character(&tty->rawInputBuffer, *buf); 740 if (rtems_semaphore_release(tty->rawInputSem) != RTEMS_SUCCESSFUL) 741 break; 742 len -= 1; 743 buf += 1; 744 } 745 } 746 -
cpukit/libcsupport/src/termios.c
r55e1322 ra75c783 24 24 #include <termios.h> 25 25 #include <unistd.h> 26 #include <ringbuf.h> 26 27 27 28 /* … … 29 30 */ 30 31 #define CBUFSIZE 256 31 32 /*33 * The size of the raw input message queue34 */35 #define RAW_MESSAGE_QUEUE_COUNT 1036 #define RAW_MESSAGE_QUEUE_SIZE 1637 32 38 33 /* … … 86 81 * Raw character buffer 87 82 */ 88 rtems_id rawInputQueue; 89 char rawBuf[RAW_MESSAGE_QUEUE_SIZE]; 90 int rawBufCount; 91 int rawBufIndex; 83 rtems_id rawInputSem; 84 Ring_buffer_t rawInputBuffer; 85 92 86 rtems_unsigned32 rawMessageOptions; 93 87 rtems_interval rawMessageTimeout; … … 98 92 */ 99 93 int (*lastClose)(int major, int minor, void *arg); 100 int (*read)(int minor, char *buf /*, int len */);94 int (*read)(int minor, char *buf ); 101 95 int (*write)(int minor, char *buf, int len); 102 96 }; … … 195 189 tty->lastClose = deviceLastClose; 196 190 if ((tty->read = deviceRead) == NULL) { 197 sc = rtems_ message_queue_create (198 rtems_build_name ('T', 'R', ' i', c),199 RAW_MESSAGE_QUEUE_COUNT,200 R AW_MESSAGE_QUEUE_SIZE,201 RTEMS_ FIFO | RTEMS_LOCAL,202 &tty->rawInput Queue);191 sc = rtems_semaphore_create ( 192 rtems_build_name ('T', 'R', 'r', c), 193 0, 194 RTEMS_COUNTING_SEMAPHORE | RTEMS_FIFO | RTEMS_LOCAL, 195 RTEMS_NO_PRIORITY, 196 &tty->rawInputSem); 203 197 if (sc != RTEMS_SUCCESSFUL) 204 198 rtems_fatal_error_occurred (sc); 205 tty->rawBufCount = tty->rawBufIndex = 0;206 199 } 207 200 … … 276 269 rtems_semaphore_delete (tty->osem); 277 270 if (tty->read == NULL) 278 rtems_ message_queue_delete (tty->rawInputQueue);271 rtems_semaphore_delete (tty->rawInputSem); 279 272 free (tty); 280 273 } … … 669 662 rtems_interval timeout = tty->rawMessageFirstTimeout; 670 663 rtems_status_code sc; 671 rtems_unsigned 32 msgSize;664 rtems_unsigned8 c; 672 665 673 666 for (;;) { 674 /*675 * Process characters read from raw queue676 */677 while (tty->rawBufIndex < tty->rawBufCount) {678 unsigned char c = tty->rawBuf[tty->rawBufIndex++];679 if (tty->termios.c_lflag & ICANON) {680 if (siproc (c, tty))681 return RTEMS_SUCCESSFUL;682 }683 else {684 siproc (c, tty);685 if (tty->ccount >= tty->termios.c_cc[VMIN])686 return RTEMS_SUCCESSFUL;687 }688 }689 667 690 668 /* 691 669 * Read characters from raw queue 692 670 */ 693 msgSize = RAW_MESSAGE_QUEUE_SIZE; 694 sc = rtems_message_queue_receive (tty->rawInputQueue, 695 tty->rawBuf, 696 &msgSize, 671 sc = rtems_semaphore_obtain (tty->rawInputSem, 697 672 tty->rawMessageOptions, 698 673 timeout); 699 674 if (sc != RTEMS_SUCCESSFUL) 700 675 break; 701 tty->rawBufIndex = 0; 702 tty->rawBufCount = msgSize; 676 Ring_buffer_Remove_character( &tty->rawInputBuffer, c ); 677 678 /* 679 * Process characters read from raw queue 680 */ 681 if (tty->termios.c_lflag & ICANON) { 682 if (siproc (c, tty)) 683 return RTEMS_SUCCESSFUL; 684 } 685 else { 686 siproc (c, tty); 687 if (tty->ccount >= tty->termios.c_cc[VMIN]) 688 return RTEMS_SUCCESSFUL; 689 } 690 703 691 timeout = tty->rawMessageTimeout; 704 692 } … … 745 733 { 746 734 struct rtems_termios_tty *tty = ttyp; 747 int ncopy;748 735 749 736 while (len) { 750 if (len < RAW_MESSAGE_QUEUE_SIZE) 751 ncopy = len; 752 else 753 ncopy = RAW_MESSAGE_QUEUE_SIZE; 754 if (rtems_message_queue_send (tty->rawInputQueue, buf, ncopy) != RTEMS_SUCCESSFUL) 755 break; 756 len -= ncopy; 757 buf += ncopy; 758 } 759 } 760 737 if (Ring_buffer_Is_full(&tty->rawInputBuffer)) 738 break; 739 Ring_buffer_Add_character(&tty->rawInputBuffer, *buf); 740 if (rtems_semaphore_release(tty->rawInputSem) != RTEMS_SUCCESSFUL) 741 break; 742 len -= 1; 743 buf += 1; 744 } 745 } 746
Note: See TracChangeset
for help on using the changeset viewer.