Changeset edd1329f in rtems
- Timestamp:
- Oct 23, 1997, 3:11:27 PM (23 years ago)
- Branches:
- 4.10, 4.11, 4.8, 4.9, 5, master
- Children:
- 5993d02
- Parents:
- b628637
- Location:
- c/src/lib/libbsp/m68k/dmv152
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
c/src/lib/libbsp/m68k/dmv152/console/console.c
rb628637 redd1329f 1 1 /* 2 * This file contains the DMV152 console IO package. 2 * This file contains the TTY driver for the serial ports on the DMV152. 3 * The serial ports use a Zilog Z8530. 4 * 5 * NOTE: This driver uses the termios pseudo driver. 6 * This driver is polled only. 3 7 * 4 8 * COPYRIGHT (c) 1989-1997. … … 13 17 */ 14 18 15 #define D152_INIT16 17 19 #include <bsp.h> 18 20 #include <rtems/libio.h> 19 20 /* console_initialize 21 * 22 * This routine initializes the console IO driver. 23 * 24 * Input parameters: NONE 21 #include <stdlib.h> 22 #include <assert.h> 23 24 /* 25 * console_outbyte_polled 26 * 27 * This routine transmits a character using polling. 28 */ 29 30 void console_outbyte_polled( 31 int port, 32 char ch 33 ) 34 { 35 rtems_unsigned32 control; 36 rtems_unsigned32 data; 37 rtems_unsigned8 rr_0; 38 39 if ( port == 0 ) { 40 control = CONSOLE_CONTROL_A; 41 data = CONSOLE_DATA_A; 42 } else { 43 control = CONSOLE_CONTROL_B; 44 data = CONSOLE_DATA_B; 45 } 46 47 for ( ; ; ) { 48 Z8x30_READ_CONTROL( control, RR_0, rr_0 ); 49 if ( (rr_0 & RR_0_TX_BUFFER_EMPTY) != 0 ) 50 break; 51 } 52 53 Z8x30_WRITE_DATA( control, ch ); 54 } 55 56 /* 57 * console_inbyte_nonblocking 58 * 59 * This routine polls for a character. 60 */ 61 62 int console_inbyte_nonblocking( 63 int port, 64 char *c 65 ) 66 { 67 rtems_unsigned32 control; 68 rtems_unsigned32 data; 69 rtems_unsigned8 rr_0; 70 char ch; 71 72 if ( port == 0 ) { 73 control = CONSOLE_CONTROL_A; 74 data = CONSOLE_DATA_A; 75 } else { 76 control = CONSOLE_CONTROL_B; 77 data = CONSOLE_DATA_B; 78 } 79 80 Z8x30_READ_CONTROL( control, RR_0, rr_0 ); 81 if ( !(rr_0 & RR_0_RX_DATA_AVAILABLE) ) 82 return 0; 83 84 Z8x30_READ_DATA( data, ch ); 85 return ch; 86 } 87 88 /* 89 * DEBUG_puts 90 * 91 * This should be safe in the event of an error. It attempts to insure 92 * that no TX empty interrupts occur while it is doing polled IO. Then 93 * it restores the state of that external interrupt. 94 * 95 * Input parameters: 96 * string - pointer to debug output string 25 97 * 26 98 * Output parameters: NONE 27 99 * 28 * Return values: 100 * Return values: NONE 101 */ 102 103 void DEBUG_puts( 104 char *string 105 ) 106 { 107 char *s; 108 109 /* should disable interrupts here */ 110 for ( s = string ; *s ; s++ ) 111 console_outbyte_polled( 0, *s ); 112 113 console_outbyte_polled( 0, '\r' ); 114 console_outbyte_polled( 0, '\n' ); 115 /* should enable interrupts here */ 116 } 117 118 119 /* 120 * Console Termios Support Entry Points 121 * 122 */ 123 124 int console_write_support (int minor, char *buf, int len) 125 { 126 int nwrite = 0; 127 128 while (nwrite < len) { 129 console_outbyte_polled( minor, *buf++ ); 130 nwrite++; 131 } 132 return nwrite; 133 } 134 135 void console_reserve_resources( 136 rtems_configuration_table *configuration 137 ) 138 { 139 rtems_termios_reserve_resources( configuration, 2 ); 140 } 141 142 /* 143 * Console Device Driver Entry Points 144 * 29 145 */ 30 146 … … 35 151 ) 36 152 { 37 rtems_status_code status; 38 39 status = rtems_io_register_name( 40 "/dev/console", 41 major, 42 (rtems_device_minor_number) 0 43 ); 44 153 rtems_status_code status; 154 rtems_device_minor_number console_minor; 155 156 rtems_termios_initialize(); 157 158 /* 159 * Register Device Names 160 */ 161 162 #if (USE_CHANNEL_A == 1) 163 console_minor = 0; 164 #elif (USE_CHANNEL_B == 1) 165 console_minor = 1; 166 #else 167 #error "DMV152 Console Driver -- no console port configured!!!" 168 #endif 169 170 status = rtems_io_register_name( "/dev/console", major, console_minor ); 45 171 if (status != RTEMS_SUCCESSFUL) 46 172 rtems_fatal_error_occurred(status); 173 174 status = rtems_io_register_name( "/dev/console_a", major, 0 ); 175 if (status != RTEMS_SUCCESSFUL) 176 rtems_fatal_error_occurred(status); 177 178 status = rtems_io_register_name( "/dev/console_b", major, 1 ); 179 if (status != RTEMS_SUCCESSFUL) 180 rtems_fatal_error_occurred(status); 181 182 /* 183 * Initialize Hardware 184 */ 47 185 48 186 return RTEMS_SUCCESSFUL; 49 187 } 50 188 51 /* inbyte52 *53 * This routine reads a character from the SCC.54 *55 * Input parameters: NONE56 *57 * Output parameters: NONE58 *59 * Return values:60 * character read from SCC61 */62 63 char inbyte( void )64 {65 rtems_unsigned8 rr_0;66 char ch;67 68 for ( ; ; ) {69 Z8x30_READ_CONTROL( CONSOLE_CONTROL, RR_0, rr_0 );70 if ( (rr_0 & RR_0_RX_DATA_AVAILABLE) != 0 )71 break;72 }73 74 Z8x30_READ_DATA( CONSOLE_DATA, ch );75 return ( ch );76 }77 78 /* outbyte79 *80 * This routine transmits a character out the SCC. It supports81 * XON/XOFF flow control.82 *83 * Input parameters:84 * ch - character to be transmitted85 *86 * Output parameters: NONE87 */88 89 void outbyte(90 char ch91 )92 {93 rtems_unsigned8 rr_0;94 char flow_control;95 96 for ( ; ; ) {97 Z8x30_READ_CONTROL( CONSOLE_CONTROL, RR_0, rr_0 );98 if ( (rr_0 & RR_0_TX_BUFFER_EMPTY) != 0 )99 break;100 }101 102 for ( ; ; ) {103 Z8x30_READ_CONTROL( CONSOLE_CONTROL, RR_0, rr_0 );104 if ( (rr_0 & RR_0_RX_DATA_AVAILABLE) == 0 )105 break;106 107 Z8x30_READ_DATA( CONSOLE_DATA, flow_control );108 109 if ( flow_control == XOFF )110 do {111 do {112 Z8x30_READ_CONTROL( CONSOLE_CONTROL, RR_0, rr_0 );113 } while ( (rr_0 & RR_0_RX_DATA_AVAILABLE) == 0 );114 Z8x30_READ_DATA( CONSOLE_DATA, flow_control );115 } while ( flow_control != XON );116 }117 118 Z8x30_WRITE_DATA( CONSOLE_DATA, ch );119 }120 121 /*122 * Open entry point123 */124 125 189 rtems_device_driver console_open( 126 190 rtems_device_major_number major, … … 129 193 ) 130 194 { 195 rtems_status_code sc; 196 197 assert( minor <= 1 ); 198 if ( minor > 2 ) 199 return RTEMS_INVALID_NUMBER; 200 201 sc = rtems_termios_open (major, minor, arg, 202 NULL, 203 NULL, 204 console_inbyte_nonblocking, 205 console_write_support); 206 131 207 return RTEMS_SUCCESSFUL; 132 208 } 133 209 134 /*135 * Close entry point136 */137 138 210 rtems_device_driver console_close( 139 211 rtems_device_major_number major, … … 142 214 ) 143 215 { 144 return RTEMS_SUCCESSFUL; 145 } 146 147 /* 148 * read bytes from the serial port. We only have stdin. 149 */ 150 216 return rtems_termios_close (arg); 217 } 218 151 219 rtems_device_driver console_read( 152 220 rtems_device_major_number major, … … 155 223 ) 156 224 { 157 rtems_libio_rw_args_t *rw_args; 158 char *buffer; 159 int maximum; 160 int count = 0; 161 162 rw_args = (rtems_libio_rw_args_t *) arg; 163 164 buffer = rw_args->buffer; 165 maximum = rw_args->count; 166 167 for (count = 0; count < maximum; count++) { 168 buffer[ count ] = inbyte(); 169 if (buffer[ count ] == '\n' || buffer[ count ] == '\r') { 170 buffer[ count++ ] = '\n'; 171 break; 172 } 173 } 174 175 rw_args->bytes_moved = count; 176 return (count >= 0) ? RTEMS_SUCCESSFUL : RTEMS_UNSATISFIED; 177 } 178 179 /* 180 * write bytes to the serial port. Stdout and stderr are the same. 181 */ 182 225 return rtems_termios_read (arg); 226 } 227 183 228 rtems_device_driver console_write( 184 229 rtems_device_major_number major, … … 187 232 ) 188 233 { 189 int count; 190 int maximum; 191 rtems_libio_rw_args_t *rw_args; 192 char *buffer; 193 194 rw_args = (rtems_libio_rw_args_t *) arg; 195 196 buffer = rw_args->buffer; 197 maximum = rw_args->count; 198 199 for (count = 0; count < maximum; count++) { 200 if ( buffer[ count ] == '\n') { 201 outbyte('\r'); 202 } 203 outbyte( buffer[ count ] ); 204 } 205 206 rw_args->bytes_moved = maximum; 207 return 0; 208 } 209 210 /* 211 * IO Control entry point 212 */ 213 234 return rtems_termios_write (arg); 235 } 236 214 237 rtems_device_driver console_control( 215 238 rtems_device_major_number major, … … 218 241 ) 219 242 { 220 return RTEMS_SUCCESSFUL; 221 } 243 return rtems_termios_ioctl (arg); 244 } 245 -
c/src/lib/libbsp/m68k/dmv152/include/bsp.h
rb628637 redd1329f 128 128 #define TIMER_VECTOR 0x4D 129 129 130 #if (USE_CHANNEL_A == 1) 131 #define CONSOLE_CONTROL 0x0C800005 132 #define CONSOLE_DATA 0x0C800007 133 #elif (USE_CHANNEL_B == 1) 134 #define CONSOLE_CONTROL 0x0C800001 135 #define CONSOLE_DATA 0x0C800003 136 #endif 130 #define CONSOLE_CONTROL_A 0x0C800005 131 #define CONSOLE_DATA_A 0x0C800007 132 #define CONSOLE_CONTROL_B 0x0C800001 133 #define CONSOLE_DATA_B 0x0C800003 137 134 138 135 /* Structures */ 139 136 140 #ifdef D152_INIT 141 #undef EXTERN 142 #define EXTERN 143 #else 144 #undef EXTERN 145 #define EXTERN extern 146 #endif 137 /* none */ 147 138 148 139 /* miscellaneous stuff assumed to exist */ -
c/src/lib/libbsp/m68k/dmv152/startup/bspstart.c
rb628637 redd1329f 220 220 221 221 /* 222 * Account for the console's resources 223 */ 224 225 console_reserve_resources( &BSP_Configuration ); 226 227 /* 222 228 * Add 1 extension for newlib libc 223 229 */
Note: See TracChangeset
for help on using the changeset viewer.