Changeset 3a4ae6c in rtems for c/src/lib/libbsp/i386/force386
- Timestamp:
- 09/11/95 19:35:39 (27 years ago)
- Branches:
- 4.10, 4.11, 4.8, 4.9, 5, master
- Children:
- ced11f99
- Parents:
- 5072b07
- Location:
- c/src/lib/libbsp/i386/force386
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
c/src/lib/libbsp/i386/force386/clock/ckinit.c
r5072b07 r3a4ae6c 20 20 21 21 #include <bsp.h> 22 #include <clockdrv.h> 22 23 #include <rtems/libio.h> 24 23 25 #include <stdlib.h> 24 26 27 #define CLOCK_VECTOR 0x38 28 29 rtems_unsigned32 Clock_isrs; /* ISRs until next tick */ 30 25 31 volatile rtems_unsigned32 Clock_driver_ticks; 26 rtems_unsigned32 Clock_isrs; /* ISRs until next tick */ 32 27 33 rtems_isr_entry Old_ticker; 28 34 29 rtems_device_driver Clock_initialize( 30 rtems_device_major_number major, 31 rtems_device_minor_number minor, 32 void *pargp, 33 rtems_id tid, 34 rtems_unsigned32 *rval 35 void Clock_exit( void ); 36 37 /* 38 * These are set by clock driver during its init 39 */ 40 41 rtems_device_major_number rtems_clock_major = ~0; 42 rtems_device_major_number rtems_clock_minor = 0; 43 44 /* 45 * This is the ISR handler. 46 */ 47 48 rtems_isr Clock_isr( 49 rtems_vector_number vector 35 50 ) 36 51 { 37 Install_clock( Clock_isr ); 38 } 39 40 void ReInstall_clock( 41 rtems_isr_entry clock_isr 42 ) 43 { 44 rtems_unsigned32 isrlevel = 0; 45 46 rtems_interrupt_disable( isrlevel ); 47 (void) set_vector( clock_isr, 0x38, 1 ); 48 rtems_interrupt_enable( isrlevel ); 52 /* enable_tracing(); */ 53 Clock_driver_ticks += 1; 54 if ( Clock_isrs == 1 ) { 55 rtems_clock_tick(); 56 Clock_isrs = BSP_Configuration.microseconds_per_tick / 1000; 57 } 58 else 59 Clock_isrs -= 1; 49 60 } 50 61 … … 57 68 58 69 if ( BSP_Configuration.ticks_per_timeslice ) { 59 Old_ticker = ( rtems_isr_entry ) set_vector( clock_isr, 0x38, 1 );70 Old_ticker = ( rtems_isr_entry ) set_vector( clock_isr, CLOCK_VECTOR, 1 ); 60 71 outport_byte( TBCR, 0x14 ); /* reset it, delay mode, 50X */ 61 72 outport_byte( TBDR, 0x50 ); /* 1 millisecond */ … … 63 74 } 64 75 atexit( Clock_exit ); 76 } 77 78 void ReInstall_clock( 79 rtems_isr_entry clock_isr 80 ) 81 { 82 rtems_unsigned32 isrlevel = 0; 83 84 rtems_interrupt_disable( isrlevel ); 85 (void) set_vector( clock_isr, CLOCK_VECTOR, 1 ); 86 rtems_interrupt_enable( isrlevel ); 65 87 } 66 88 … … 74 96 } 75 97 98 rtems_device_driver Clock_initialize( 99 rtems_device_major_number major, 100 rtems_device_minor_number minor, 101 void *pargp 102 ) 103 { 104 Install_clock( Clock_isr ); 105 106 /* 107 * make major/minor avail to others such as shared memory driver 108 */ 109 110 rtems_clock_major = major; 111 rtems_clock_minor = minor; 112 113 return RTEMS_SUCCESSFUL; 114 } 115 116 rtems_device_driver Clock_control( 117 rtems_device_major_number major, 118 rtems_device_minor_number minor, 119 void *pargp 120 ) 121 { 122 rtems_libio_ioctl_args_t *args = pargp; 123 124 if (args == 0) 125 goto done; 126 127 /* 128 * This is hokey, but until we get a defined interface 129 * to do this, it will just be this simple... 130 */ 131 132 if (args->command == rtems_build_name('I', 'S', 'R', ' ')) 133 { 134 Clock_isr(CLOCK_VECTOR); 135 } 136 else if (args->command == rtems_build_name('N', 'E', 'W', ' ')) 137 { 138 ReInstall_clock(args->buffer); 139 } 140 141 done: 142 return RTEMS_SUCCESSFUL; 143 } -
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 -
c/src/lib/libbsp/i386/force386/include/bsp.h
r5072b07 r3a4ae6c 23 23 #include <rtems.h> 24 24 #include <iosupp.h> 25 #include <console.h> 26 #include <clockdrv.h> 25 27 26 28 /* … … 129 131 #endif 130 132 133 /* 134 * Device Driver Table Entries 135 */ 136 137 /* 138 * NOTE: Use the standard Console driver entry 139 */ 140 141 /* 142 * NOTE: Use the standard Clock driver entry 143 */ 144 145 /* 146 * How many libio files we want 147 */ 148 149 #define BSP_LIBIO_MAX_FDS 20 150 131 151 /* miscellaneous stuff assumed to exist */ 132 152 -
c/src/lib/libbsp/i386/force386/startup/bspstart.c
r5072b07 r3a4ae6c 21 21 */ 22 22 23 #include <rtems.h>24 23 #include <bsp.h> 24 #include <rtems/libio.h> 25 25 26 #include <libcsupport.h> 26 27 28 #include <fcntl.h> 29 30 #ifdef STACK_CHECKER_ON 27 31 #include <stackchk.h> 32 #endif 28 33 29 34 /* … … 36 41 37 42 rtems_cpu_table Cpu_table; 43 44 char *rtems_progname; 38 45 39 46 /* Initialize whatever libc we are using … … 51 58 52 59 RTEMS_Malloc_Initialize((void *) heap_start, 64 * 1024, 0); 60 61 /* 62 * Init the RTEMS libio facility to provide UNIX-like system 63 * calls for use by newlib (ie: provide __open, __close, etc) 64 * Uses malloc() to get area for the iops, so must be after malloc init 65 */ 66 67 rtems_libio_init(); 53 68 54 69 /* … … 71 86 } 72 87 73 int bsp_start( 88 /* 89 * After drivers are setup, register some "filenames" 90 * and open stdin, stdout, stderr files 91 * 92 * Newlib will automatically associate the files with these 93 * (it hardcodes the numbers) 94 */ 95 96 void 97 bsp_postdriver_hook(void) 98 { 99 int stdin_fd, stdout_fd, stderr_fd; 100 101 if ((stdin_fd = __open("/dev/console", O_RDONLY, 0)) == -1) 102 rtems_fatal_error_occurred('STD0'); 103 104 if ((stdout_fd = __open("/dev/console", O_WRONLY, 0)) == -1) 105 rtems_fatal_error_occurred('STD1'); 106 107 if ((stderr_fd = __open("/dev/console", O_WRONLY, 0)) == -1) 108 rtems_fatal_error_occurred('STD2'); 109 110 if ((stdin_fd != 0) || (stdout_fd != 1) || (stderr_fd != 2)) 111 rtems_fatal_error_occurred('STIO'); 112 } 113 114 int main( 74 115 int argc, 75 116 char **argv, … … 77 118 ) 78 119 { 120 121 if ((argc > 0) && argv && argv[0]) 122 rtems_progname = argv[0]; 123 else 124 rtems_progname = "RTEMS"; 125 79 126 /* 80 127 * FORCE documentation incorrectly states that the bus request … … 93 140 Cpu_table.predriver_hook = bsp_libc_init; /* RTEMS resources available */ 94 141 95 Cpu_table.postdriver_hook = NULL; /* Call our main() for constructors */142 Cpu_table.postdriver_hook = bsp_postdriver_hook; 96 143 97 144 Cpu_table.idle_task = NULL; /* do not override system IDLE task */ … … 138 185 #endif 139 186 187 /* 188 * Tell libio how many fd's we want and allow it to tweak config 189 */ 190 191 rtems_libio_config(&BSP_Configuration, BSP_LIBIO_MAX_FDS); 192 140 193 rtems_initialize_executive( &BSP_Configuration, &Cpu_table ); 141 194 /* does not return */
Note: See TracChangeset
for help on using the changeset viewer.