Changeset 3a4ae6c in rtems for c/src/lib/libbsp/m68k/gen68302
- 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
- Location:
- c/src/lib/libbsp/m68k/gen68302
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
c/src/lib/libbsp/m68k/gen68302/clock/ckinit.c
r5072b07 r3a4ae6c 21 21 #include <stdlib.h> /* for atexit() */ 22 22 23 #include <rtems.h>24 23 #include <bsp.h> 25 #include <clockdrv.h> 24 #include <rtems/libio.h> 25 26 26 #include "m68302.h" 27 27 28 #define CLOCK_VECTOR 137 28 29 29 30 #define TMR1_VAL ( RBIT_TMR_RST /* software reset the timer */\ … … 50 51 rtems_unsigned32 Clock_isrs; 51 52 53 void Clock_exit( void ); 54 55 /* 56 * These are set by clock driver during its init 57 */ 58 59 rtems_device_major_number rtems_clock_major = ~0; 60 rtems_device_minor_number rtems_clock_minor; 52 61 53 rtems_device_driver Clock_initialize( 54 rtems_device_major_number major,55 rtems_device_minor_number minor,56 void *pargp, 57 rtems_id tid, 58 rtems_ unsigned32 *rval62 /* 63 * ISR Handler 64 */ 65 66 rtems_isr Clock_isr( 67 rtems_vector_number vector 59 68 ) 60 69 { 61 Install_clock( Clock_isr ); 70 Clock_driver_ticks += 1; 71 72 m302.reg.isr = RBIT_ISR_TIMER1; /* clear in-service bit */ 73 m302.reg.ter1 = (RBIT_TER_REF | RBIT_TER_CAP); /* clear timer intr request */ 74 75 if ( Clock_isrs == 1 ) { 76 rtems_clock_tick(); 77 Clock_isrs = BSP_Configuration.microseconds_per_tick / 1000; 78 } 79 else 80 Clock_isrs -= 1; 62 81 } 63 64 82 65 83 void Install_clock( … … 72 90 73 91 if ( BSP_Configuration.ticks_per_timeslice ) { 74 /* set_vector( clock_isr, 137, 1 );*/92 /* set_vector( clock_isr, CLOCK_VECTOR, 1 );*/ 75 93 76 94 m302.reg.trr1 = TRR1_VAL; /* set timer reference register */ … … 85 103 } 86 104 105 void ReInstall_clock( 106 rtems_isr_entry clock_isr 107 ) 108 { 109 rtems_unsigned32 isrlevel; 110 111 rtems_interrupt_disable( isrlevel ); 112 /* (void) set_vector( clock_isr, CLOCK_VECTOR, 1 ); */ 113 rtems_interrupt_enable( isrlevel ); 114 } 87 115 88 116 void Clock_exit( void ) … … 93 121 } 94 122 } 123 124 rtems_device_driver Clock_initialize( 125 rtems_device_major_number major, 126 rtems_device_minor_number minor, 127 void *pargp 128 ) 129 { 130 Install_clock( Clock_isr ); 131 132 /* 133 * make major/minor avail to others such as shared memory driver 134 */ 135 136 rtems_clock_major = major; 137 rtems_clock_minor = minor; 138 139 return RTEMS_SUCCESSFUL; 140 } 141 142 rtems_device_driver Clock_control( 143 rtems_device_major_number major, 144 rtems_device_minor_number minor, 145 void *pargp 146 ) 147 { 148 rtems_libio_ioctl_args_t *args = pargp; 149 150 if (args == 0) 151 goto done; 152 153 /* 154 * This is hokey, but until we get a defined interface 155 * to do this, it will just be this simple... 156 */ 157 158 if (args->command == rtems_build_name('I', 'S', 'R', ' ')) 159 { 160 Clock_isr( CLOCK_VECTOR); 161 } 162 else if (args->command == rtems_build_name('N', 'E', 'W', ' ')) 163 { 164 ReInstall_clock(args->buffer); 165 } 166 167 done: 168 return RTEMS_SUCCESSFUL; 169 } 170 -
c/src/lib/libbsp/m68k/gen68302/console/console.c
r5072b07 r3a4ae6c 15 15 #define GEN68302_INIT 16 16 17 #include <rtems.h>18 #include "console.h"19 17 #include <bsp.h> 18 #include <rtems/libio.h> 20 19 21 20 #include "m68302.h" … … 35 34 rtems_device_major_number major, 36 35 rtems_device_minor_number minor, 37 void *arg, 38 rtems_id self, 39 rtems_unsigned32 *status 40 ) 41 { 36 void *arg 37 ) 38 { 39 rtems_status_code status; 42 40 volatile m302_dualPortRAM_t *p = &m302; 43 41 … … 82 80 p->reg.scc[1].scm = 0x01BD; 83 81 84 *status = RTEMS_SUCCESSFUL; 85 } 86 82 status = rtems_io_register_name( 83 "/dev/console", 84 major, 85 (rtems_device_minor_number) 0 86 ); 87 88 if (status != RTEMS_SUCCESSFUL) 89 rtems_fatal_error_occurred(status); 90 91 return RTEMS_SUCCESSFUL; 92 93 } 87 94 88 95 /* is_character_ready … … 195 202 196 203 /* 197 * __read -- read bytes from the serial port. Ignore fd, since 198 * we only have stdin. 199 */ 200 201 int __read( 202 int fd, 203 char *buf, 204 int nbytes 205 ) 206 { 207 int i = 0; 208 209 for (i = 0; i < nbytes; i++) { 210 *(buf + i) = inbyte(); 211 if ((*(buf + i) == '\n') || (*(buf + i) == '\r')) { 212 (*(buf + i++)) = '\n'; 213 (*(buf + i)) = 0; 204 * Open entry point 205 */ 206 207 rtems_device_driver console_open( 208 rtems_device_major_number major, 209 rtems_device_minor_number minor, 210 void * arg 211 ) 212 { 213 return RTEMS_SUCCESSFUL; 214 } 215 216 /* 217 * Close entry point 218 */ 219 220 rtems_device_driver console_close( 221 rtems_device_major_number major, 222 rtems_device_minor_number minor, 223 void * arg 224 ) 225 { 226 return RTEMS_SUCCESSFUL; 227 } 228 229 /* 230 * read bytes from the serial port. We only have stdin. 231 */ 232 233 rtems_device_driver console_read( 234 rtems_device_major_number major, 235 rtems_device_minor_number minor, 236 void * arg 237 ) 238 { 239 rtems_libio_rw_args_t *rw_args; 240 char *buffer; 241 int maximum; 242 int count = 0; 243 244 rw_args = (rtems_libio_rw_args_t *) arg; 245 246 buffer = rw_args->buffer; 247 maximum = rw_args->count; 248 249 for (count = 0; count < maximum; count++) { 250 buffer[ count ] = inbyte(); 251 if (buffer[ count ] == '\n' || buffer[ count ] == '\r') { 252 buffer[ count++ ] = '\n'; 253 buffer[ count ] = 0; 214 254 break; 215 255 } 216 256 } 217 return (i); 218 } 219 220 /* 221 * __write -- write bytes to the serial port. Ignore fd, since 222 * stdout and stderr are the same. Since we have no filesystem, 223 * open will only return an error. 224 */ 225 226 int __write( 227 int fd, 228 char *buf, 229 int nbytes 230 ) 231 { 232 int i; 233 234 for (i = 0; i < nbytes; i++) { 235 if (*(buf + i) == '\n') { 236 outbyte ('\r'); 257 258 rw_args->bytes_moved = count; 259 return (count >= 0) ? RTEMS_SUCCESSFUL : RTEMS_UNSATISFIED; 260 } 261 262 /* 263 * write bytes to the serial port. Stdout and stderr are the same. 264 */ 265 266 rtems_device_driver console_write( 267 rtems_device_major_number major, 268 rtems_device_minor_number minor, 269 void * arg 270 ) 271 { 272 int count; 273 int maximum; 274 rtems_libio_rw_args_t *rw_args; 275 char *buffer; 276 277 rw_args = (rtems_libio_rw_args_t *) arg; 278 279 buffer = rw_args->buffer; 280 maximum = rw_args->count; 281 282 for (count = 0; count < maximum; count++) { 283 if ( buffer[ count ] == '\n') { 284 outbyte('\r'); 237 285 } 238 outbyte (*(buf + i));286 outbyte( buffer[ count ] ); 239 287 } 240 return (nbytes); 241 } 288 return maximum; 289 } 290 291 /* 292 * IO Control entry point 293 */ 294 295 rtems_device_driver console_control( 296 rtems_device_major_number major, 297 rtems_device_minor_number minor, 298 void * arg 299 ) 300 { 301 return RTEMS_SUCCESSFUL; 302 } -
c/src/lib/libbsp/m68k/gen68302/include/bsp.h
r5072b07 r3a4ae6c 24 24 25 25 #include <rtems.h> 26 #include <console.h> 26 27 #include <iosupp.h> 28 #include <clockdrv.h> 27 29 28 30 /* … … 82 84 #endif 83 85 86 /* 87 * Device Driver Table Entries 88 */ 89 90 /* 91 * NOTE: Use the standard Console driver entry 92 */ 93 94 /* 95 * NOTE: Use the standard Clock driver entry 96 */ 97 98 /* 99 * How many libio files we want 100 */ 101 102 #define BSP_LIBIO_MAX_FDS 20 103 84 104 /* miscellaneous stuff assumed to exist */ 85 105 -
c/src/lib/libbsp/m68k/gen68302/start/start302.s
r5072b07 r3a4ae6c 228 228 #endif 229 229 230 jsr SYM (bsp_start) 230 move.l #0,a7@- | environp 231 move.l #0,a7@- | argv 232 move.l #0,a7@- | argc 233 jsr SYM (main) 231 234 232 235 nop -
c/src/lib/libbsp/m68k/gen68302/start302/start302.s
r5072b07 r3a4ae6c 228 228 #endif 229 229 230 jsr SYM (bsp_start) 230 move.l #0,a7@- | environp 231 move.l #0,a7@- | argv 232 move.l #0,a7@- | argc 233 jsr SYM (main) 231 234 232 235 nop -
c/src/lib/libbsp/m68k/gen68302/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 <string.h> 29 #include <fcntl.h> 30 31 #ifdef STACK_CHECKER_ON 32 #include <stackchk.h> 33 #endif 27 34 28 35 /* … … 35 42 36 43 rtems_cpu_table Cpu_table; 44 45 char *rtems_progname; 37 46 38 47 /* Initialize whatever libc we are using … … 59 68 60 69 /* 70 * Init the RTEMS libio facility to provide UNIX-like system 71 * calls for use by newlib (ie: provide __open, __close, etc) 72 * Uses malloc() to get area for the iops, so must be after malloc init 73 */ 74 75 rtems_libio_init(); 76 77 /* 61 78 * Set up for the libc handling. 62 79 */ … … 76 93 } 77 94 78 79 int bsp_start( 95 /* 96 * After drivers are setup, register some "filenames" 97 * and open stdin, stdout, stderr files 98 * 99 * Newlib will automatically associate the files with these 100 * (it hardcodes the numbers) 101 */ 102 103 void 104 bsp_postdriver_hook(void) 105 { 106 int stdin_fd, stdout_fd, stderr_fd; 107 108 if ((stdin_fd = __open("/dev/console", O_RDONLY, 0)) == -1) 109 rtems_fatal_error_occurred('STD0'); 110 111 if ((stdout_fd = __open("/dev/console", O_WRONLY, 0)) == -1) 112 rtems_fatal_error_occurred('STD1'); 113 114 if ((stderr_fd = __open("/dev/console", O_WRONLY, 0)) == -1) 115 rtems_fatal_error_occurred('STD2'); 116 117 if ((stdin_fd != 0) || (stdout_fd != 1) || (stderr_fd != 2)) 118 rtems_fatal_error_occurred('STIO'); 119 } 120 121 int main( 80 122 int argc, 81 123 char **argv, … … 83 125 ) 84 126 { 127 if ((argc > 0) && argv && argv[0]) 128 rtems_progname = argv[0]; 129 else 130 rtems_progname = "RTEMS"; 131 85 132 /* 86 133 * Allocate the memory for the RTEMS Work Space. This can come from … … 91 138 */ 92 139 #if 0 93 aCpu_table.interrupt_vector_table = (mc68000_isr *) 0/*&M68Kvec*/;140 Cpu_table.interrupt_vector_table = (mc68000_isr *) 0/*&M68Kvec*/; 94 141 #endif 95 142 … … 122 169 BSP_Configuration.maximum_extensions++; 123 170 #endif 171 172 /* 173 * Tell libio how many fd's we want and allow it to tweak config 174 */ 175 176 rtems_libio_config(&BSP_Configuration, BSP_LIBIO_MAX_FDS); 124 177 125 178 /* … … 144 197 Cpu_table.predriver_hook = bsp_libc_init; /* RTEMS resources available */ 145 198 146 Cpu_table.postdriver_hook = NULL;199 Cpu_table.postdriver_hook = bsp_postdriver_hook; 147 200 148 201 Cpu_table.idle_task = NULL; /* do not override system IDLE task */
Note: See TracChangeset
for help on using the changeset viewer.