Changeset 3a4ae6c in rtems for c/src/lib/libbsp/i386/force386/console
- Timestamp:
- 09/11/95 19:35:39 (28 years ago)
- Branches:
- 4.10, 4.11, 4.8, 4.9, 5, master
- Children:
- ced11f99
- Parents:
- 5072b07
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
c/src/lib/libbsp/i386/force386/console/console.c
r5072b07 r3a4ae6c 15 15 #define F386_INIT 16 16 17 #include <bsp.h> 18 #include <rtems/libio.h> 19 17 20 #include <stdlib.h> 18 19 #include <rtems.h>20 #include "console.h"21 #include "bsp.h"22 21 23 22 /* console_cleanup … … 62 61 rtems_device_major_number major, 63 62 rtems_device_minor_number minor, 64 void *arg, 65 rtems_id self, 66 rtems_unsigned32 *status 67 ) 68 { 69 /* 70 * flush the console now and at exit. Just in case. 71 */ 72 73 console_cleanup(); 74 75 atexit( console_cleanup ); 63 void *arg 64 ) 65 { 66 rtems_status_code status; 67 68 /* 69 * flush the console now and at exit. Just in case. 70 */ 71 72 console_cleanup(); 73 74 status = rtems_io_register_name( 75 "/dev/console", 76 major, 77 (rtems_device_minor_number) 0 78 ); 79 80 if (status != RTEMS_SUCCESSFUL) 81 rtems_fatal_error_occurred(status); 82 83 atexit( console_cleanup ); 84 85 return RTEMS_SUCCESSFUL; 76 86 } 77 87 … … 173 183 174 184 /* 175 * __read -- read bytes from the serial port. Ignore fd, since 176 * we only have stdin. 177 */ 178 179 int __read( 180 int fd, 181 char *buf, 182 int nbytes 183 ) 184 { 185 int i = 0; 186 187 for (i = 0; i < nbytes; i++) { 188 *(buf + i) = inbyte(); 189 if ((*(buf + i) == '\n') || (*(buf + i) == '\r')) { 190 (*(buf + i++)) = '\n'; 191 (*(buf + i)) = 0; 185 * Open entry point 186 */ 187 188 rtems_device_driver console_open( 189 rtems_device_major_number major, 190 rtems_device_minor_number minor, 191 void * arg 192 ) 193 { 194 return RTEMS_SUCCESSFUL; 195 } 196 197 /* 198 * Close entry point 199 */ 200 201 rtems_device_driver console_close( 202 rtems_device_major_number major, 203 rtems_device_minor_number minor, 204 void * arg 205 ) 206 { 207 return RTEMS_SUCCESSFUL; 208 } 209 210 /* 211 * read bytes from the serial port. We only have stdin. 212 */ 213 214 rtems_device_driver console_read( 215 rtems_device_major_number major, 216 rtems_device_minor_number minor, 217 void * arg 218 ) 219 { 220 rtems_libio_rw_args_t *rw_args; 221 char *buffer; 222 int maximum; 223 int count = 0; 224 225 rw_args = (rtems_libio_rw_args_t *) arg; 226 227 buffer = rw_args->buffer; 228 maximum = rw_args->count; 229 230 for (count = 0; count < maximum; count++) { 231 buffer[ count ] = inbyte(); 232 if (buffer[ count ] == '\n' || buffer[ count ] == '\r') { 233 buffer[ count++ ] = '\n'; 234 buffer[ count ] = 0; 192 235 break; 193 236 } 194 237 } 195 return (i); 196 } 197 198 /* 199 * __write -- write bytes to the serial port. Ignore fd, since 200 * stdout and stderr are the same. Since we have no filesystem, 201 * open will only return an error. 202 */ 203 204 int __write( 205 int fd, 206 char *buf, 207 int nbytes 208 ) 209 { 210 int i; 211 212 for (i = 0; i < nbytes; i++) { 213 if (*(buf + i) == '\n') { 214 outbyte ('\r'); 238 239 rw_args->bytes_moved = count; 240 return (count >= 0) ? RTEMS_SUCCESSFUL : RTEMS_UNSATISFIED; 241 } 242 243 /* 244 * write bytes to the serial port. Stdout and stderr are the same. 245 */ 246 247 rtems_device_driver console_write( 248 rtems_device_major_number major, 249 rtems_device_minor_number minor, 250 void * arg 251 ) 252 { 253 int count; 254 int maximum; 255 rtems_libio_rw_args_t *rw_args; 256 char *buffer; 257 258 rw_args = (rtems_libio_rw_args_t *) arg; 259 260 buffer = rw_args->buffer; 261 maximum = rw_args->count; 262 263 for (count = 0; count < maximum; count++) { 264 if ( buffer[ count ] == '\n') { 265 outbyte('\r'); 215 266 } 216 outbyte (*(buf + i)); 217 } 218 return (nbytes); 219 } 267 outbyte( buffer[ count ] ); 268 } 269 return maximum; 270 } 271 272 /* 273 * IO Control entry point 274 */ 275 276 rtems_device_driver console_control( 277 rtems_device_major_number major, 278 rtems_device_minor_number minor, 279 void * arg 280 ) 281 { 282 return RTEMS_SUCCESSFUL; 283 } 284
Note: See TracChangeset
for help on using the changeset viewer.