Changeset 3a4ae6c in rtems for c/src/lib/libbsp/m68k/idp
- 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/m68k/idp
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
c/src/lib/libbsp/m68k/idp/clock/ckinit.c
r5072b07 r3a4ae6c 27 27 #include <stdlib.h> 28 28 29 #include <rtems.h>30 #include <clockdrv.h>31 29 #include <bsp.h> 30 #include <rtems/libio.h> 32 31 33 32 rtems_unsigned32 Clock_isrs; /* ISRs until next tick */ … … 40 39 void Disable_clock(); 41 40 42 #define TIMER_VECTOR 0x4D 43 44 rtems_device_driver Clock_initialize( 45 rtems_device_major_number major, 46 rtems_device_minor_number minor, 47 void *pargp, 48 rtems_id tid, 49 rtems_unsigned32 *rval 41 #define CLOCK_VECTOR 0x4D 42 43 void Clock_exit( void ); 44 45 /* 46 * These are set by clock driver during its init 47 */ 48 49 rtems_device_major_number rtems_clock_major = ~0; 50 rtems_device_minor_number rtems_clock_minor; 51 52 53 /* 54 * ISR Handler 55 * 56 * 57 * ((1ms * 6.5 MHz) / 2^5) = 203.125) where 6.5 MHz is the clock rate of the 58 * MC68230, 2^5 is the prescaler factor, and 1ms is the common interrupt 59 * interval for the Clock_isr routine. 60 * Therefore, 203 (decimal) is the number to program into the CPRH-L registers 61 * of the MC68230 for countdown. However, I have found that 193 instead of 62 * 203 provides greater accuracy -- why? The crystal should be more accurate 63 * than that 64 */ 65 66 rtems_isr Clock_isr( 67 rtems_vector_number vector 50 68 ) 51 69 { 52 Install_clock( Clock_isr ); 53 } 54 55 void ReInstall_clock( clock_isr ) 56 rtems_isr_entry clock_isr; 57 { 58 rtems_unsigned32 isrlevel = 0 ; 59 60 rtems_interrupt_disable( isrlevel ); 61 (void) set_vector( clock_isr, TIMER_VECTOR, 1 ); 62 rtems_interrupt_enable( isrlevel ); 63 } 64 65 /* The following was added for debugging purposes */ 70 Clock_driver_ticks += 1; 71 /* acknowledge interrupt 72 TSR = 1; */ 73 MC68230_WRITE (TSR, 1); 74 75 if ( Clock_isrs == 1 ) { 76 rtems_clock_tick(); 77 /* Cast to an integer so that 68EC040 IDP which doesn't have an FPU doesn't 78 have a heart attack -- if you use newlib1.6 or greater and get 79 libgcc.a for gcc with software floating point support, this is not 80 a problem */ 81 Clock_isrs = 82 (int)(BSP_Configuration.microseconds_per_tick / 1000); 83 } 84 else 85 Clock_isrs -= 1; 86 } 87 66 88 void Disable_clock() 67 89 { … … 78 100 if ( Configuration.ticks_per_timeslice ) { 79 101 /* led_putnum('c'); * for debugging purposes */ 80 Old_ticker = (rtems_isr_entry) set_vector( clock_isr, TIMER_VECTOR, 1 );102 Old_ticker = (rtems_isr_entry) set_vector( clock_isr, CLOCK_VECTOR, 1 ); 81 103 82 104 /* Disable timer for initialization */ … … 86 108 file in this directory to understand why I use the values that I do */ 87 109 /* Set up the interrupt vector on the MC68230 chip: 88 TIVR = TIMER_VECTOR; */89 MC68230_WRITE (TIVR, TIMER_VECTOR);110 TIVR = CLOCK_VECTOR; */ 111 MC68230_WRITE (TIVR, CLOCK_VECTOR); 90 112 91 113 /* Set CPRH through CPRL to 193 (not 203) decimal for countdown--see ckisr.c … … 109 131 } 110 132 133 void ReInstall_clock( clock_isr ) 134 rtems_isr_entry clock_isr; 135 { 136 rtems_unsigned32 isrlevel = 0 ; 137 138 rtems_interrupt_disable( isrlevel ); 139 (void) set_vector( clock_isr, CLOCK_VECTOR, 1 ); 140 rtems_interrupt_enable( isrlevel ); 141 } 142 143 /* The following was added for debugging purposes */ 111 144 void Clock_exit( void ) 112 145 { … … 124 157 } 125 158 } 159 160 rtems_device_driver Clock_initialize( 161 rtems_device_major_number major, 162 rtems_device_minor_number minor, 163 void *pargp 164 ) 165 { 166 Install_clock( Clock_isr ); 167 168 /* 169 * make major/minor avail to others such as shared memory driver 170 */ 171 172 rtems_clock_major = major; 173 rtems_clock_minor = minor; 174 175 return RTEMS_SUCCESSFUL; 176 } 177 178 rtems_device_driver Clock_control( 179 rtems_device_major_number major, 180 rtems_device_minor_number minor, 181 void *pargp 182 ) 183 { 184 rtems_libio_ioctl_args_t *args = pargp; 185 186 if (args == 0) 187 goto done; 188 189 /* 190 * This is hokey, but until we get a defined interface 191 * to do this, it will just be this simple... 192 */ 193 194 if (args->command == rtems_build_name('I', 'S', 'R', ' ')) 195 { 196 Clock_isr(CLOCK_VECTOR); 197 } 198 else if (args->command == rtems_build_name('N', 'E', 'W', ' ')) 199 { 200 ReInstall_clock(args->buffer); 201 } 202 203 done: 204 return RTEMS_SUCCESSFUL; 205 } 206 -
c/src/lib/libbsp/m68k/idp/console/console.c
r5072b07 r3a4ae6c 12 12 #define MIDP_INIT 13 13 14 #include "rtems.h" 15 #include "console.h" 16 #include "bsp.h" 17 18 #include "ringbuf.h" 14 #include <bsp.h> 15 #include <rtems/libio.h> 16 17 #include <ringbuf.h> 19 18 20 19 Ring_buffer_t Buffer[ 2 ]; 21 20 22 21 rtems_isr C_Receive_ISR(rtems_vector_number vector); 23 24 22 25 23 /* console_initialize … … 37 35 rtems_device_major_number major, 38 36 rtems_device_minor_number minor, 39 void *arg, 40 rtems_id self, 41 rtems_unsigned32 *status 42 ) 43 { 37 void *arg 38 ) 39 { 40 rtems_status_code status; 44 41 45 42 Ring_buffer_Initialize( &Buffer[ 0 ] ); … … 48 45 init_pit(); 49 46 50 *status = RTEMS_SUCCESSFUL; 47 status = rtems_io_register_name( 48 "/dev/console", 49 major, 50 (rtems_device_minor_number) 0 51 ); 52 53 if (status != RTEMS_SUCCESSFUL) 54 rtems_fatal_error_occurred(status); 55 56 status = rtems_io_register_name( 57 "/dev/tty00", 58 major, 59 (rtems_device_minor_number) 0 60 ); 61 62 if (status != RTEMS_SUCCESSFUL) 63 rtems_fatal_error_occurred(status); 64 65 status = rtems_io_register_name( 66 "/dev/tty01", 67 major, 68 (rtems_device_minor_number) 1 69 ); 70 71 if (status != RTEMS_SUCCESSFUL) 72 rtems_fatal_error_occurred(status); 73 74 return RTEMS_SUCCESSFUL; 51 75 } 52 76 … … 152 176 153 177 /* 154 * __read -- read bytes from the serial port. Ignore fd, since 155 * we only have stdin. 156 */ 157 158 int __read( 159 int fd, 160 char *buf, 161 int nbytes 162 ) 163 { 164 int i = 0; 165 int port; 166 167 /* 168 * Map port A to stdin, stdout, and stderr. 169 * Map everything else to port B. 170 */ 171 172 if ( fd <= 2 ) port = 0; 173 else port = 1; 174 175 for (i = 0; i < nbytes; i++) { 176 *(buf + i) = inbyte( port ); 177 if ((*(buf + i) == '\n') || (*(buf + i) == '\r')) { 178 (*(buf + i++)) = '\n'; 179 (*(buf + i)) = 0; 178 * Open entry point 179 */ 180 181 rtems_device_driver console_open( 182 rtems_device_major_number major, 183 rtems_device_minor_number minor, 184 void * arg 185 ) 186 { 187 return RTEMS_SUCCESSFUL; 188 } 189 190 /* 191 * Close entry point 192 */ 193 194 rtems_device_driver console_close( 195 rtems_device_major_number major, 196 rtems_device_minor_number minor, 197 void * arg 198 ) 199 { 200 return RTEMS_SUCCESSFUL; 201 } 202 203 /* 204 * read bytes from the serial port. We only have stdin. 205 */ 206 207 rtems_device_driver console_read( 208 rtems_device_major_number major, 209 rtems_device_minor_number minor, 210 void * arg 211 ) 212 { 213 rtems_libio_rw_args_t *rw_args; 214 char *buffer; 215 int maximum; 216 int count = 0; 217 218 rw_args = (rtems_libio_rw_args_t *) arg; 219 220 buffer = rw_args->buffer; 221 maximum = rw_args->count; 222 223 if ( minor > 1 ) 224 return RTEMS_INVALID_NUMBER; 225 226 for (count = 0; count < maximum; count++) { 227 buffer[ count ] = inbyte( minor ); 228 if (buffer[ count ] == '\n' || buffer[ count ] == '\r') { 229 buffer[ count++ ] = '\n'; 230 buffer[ count ] = 0; 180 231 break; 181 232 } 182 233 } 183 return (i); 184 } 185 186 /* 187 * __write -- write bytes to the serial port. Ignore fd, since 188 * stdout and stderr are the same. Since we have no filesystem, 189 * open will only return an error. 190 */ 191 192 int __write( 193 int fd, 194 char *buf, 195 int nbytes 196 ) 197 { 198 int i; 199 int port; 200 201 /* 202 * Map port A to stdin, stdout, and stderr. 203 * Map everything else to port B. 204 */ 205 206 if ( fd <= 2 ) port = 0; 207 else port = 1; 208 209 for (i = 0; i < nbytes; i++) { 210 if (*(buf + i) == '\n') { 211 outbyte ('\r', port ); 234 235 rw_args->bytes_moved = count; 236 return (count >= 0) ? RTEMS_SUCCESSFUL : RTEMS_UNSATISFIED; 237 } 238 239 /* 240 * write bytes to the serial port. Stdout and stderr are the same. 241 */ 242 243 rtems_device_driver console_write( 244 rtems_device_major_number major, 245 rtems_device_minor_number minor, 246 void * arg 247 ) 248 { 249 int count; 250 int maximum; 251 rtems_libio_rw_args_t *rw_args; 252 char *buffer; 253 254 rw_args = (rtems_libio_rw_args_t *) arg; 255 256 buffer = rw_args->buffer; 257 maximum = rw_args->count; 258 259 if ( minor > 1 ) 260 return RTEMS_INVALID_NUMBER; 261 262 for (count = 0; count < maximum; count++) { 263 if ( buffer[ count ] == '\n') { 264 outbyte('\r', minor ); 212 265 } 213 outbyte (*(buf + i), port);266 outbyte( buffer[ count ], minor ); 214 267 } 215 return (nbytes); 216 } 268 return maximum; 269 } 270 271 /* 272 * IO Control entry point 273 */ 274 275 rtems_device_driver console_control( 276 rtems_device_major_number major, 277 rtems_device_minor_number minor, 278 void * arg 279 ) 280 { 281 return RTEMS_SUCCESSFUL; 282 } -
c/src/lib/libbsp/m68k/idp/include/bsp.h
r5072b07 r3a4ae6c 11 11 #include <rtems.h> 12 12 #include <console.h> 13 #include <clockdrv.h> 13 14 #include <mc68230.h> 14 15 #include <mc68681.h> … … 53 54 #endif 54 55 56 /* 57 * Device Driver Table Entries 58 */ 59 60 /* 61 * NOTE: Use the standard Console driver entry 62 */ 63 64 /* 65 * NOTE: Use the standard Clock driver entry 66 */ 67 68 /* 69 * How many libio files we want 70 */ 71 72 #define BSP_LIBIO_MAX_FDS 20 73 55 74 /* miscellaneous stuff assumed to exist */ 56 75 -
c/src/lib/libbsp/m68k/idp/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> 27 28 #include <string.h> 29 #include <fcntl.h> 30 31 #ifdef STACK_CHECKER_ON 32 #include <stackchk.h> 33 #endif 26 34 27 35 unsigned char *duart_base; … … 42 50 rtems_cpu_table Cpu_table; 43 51 52 char *rtems_progname; 53 44 54 /* Initialize whatever libc we are using 45 55 * called from postdriver hook … … 57 67 /* Create 64 KByte memory region for RTEMS executive */ 58 68 RTEMS_Malloc_Initialize((void *) heap_start, 64 * 1024, 0); 69 70 /* 71 * Init the RTEMS libio facility to provide UNIX-like system 72 * calls for use by newlib (ie: provide __open, __close, etc) 73 * Uses malloc() to get area for the iops, so must be after malloc init 74 */ 75 76 rtems_libio_init(); 59 77 60 78 /* … … 77 95 78 96 79 int bsp_start( 97 /* 98 * After drivers are setup, register some "filenames" 99 * and open stdin, stdout, stderr files 100 * 101 * Newlib will automatically associate the files with these 102 * (it hardcodes the numbers) 103 */ 104 105 void 106 bsp_postdriver_hook(void) 107 { 108 int stdin_fd, stdout_fd, stderr_fd; 109 110 if ((stdin_fd = __open("/dev/console", O_RDONLY, 0)) == -1) 111 rtems_fatal_error_occurred('STD0'); 112 113 if ((stdout_fd = __open("/dev/console", O_WRONLY, 0)) == -1) 114 rtems_fatal_error_occurred('STD1'); 115 116 if ((stderr_fd = __open("/dev/console", O_WRONLY, 0)) == -1) 117 rtems_fatal_error_occurred('STD2'); 118 119 if ((stdin_fd != 0) || (stdout_fd != 1) || (stderr_fd != 2)) 120 rtems_fatal_error_occurred('STIO'); 121 } 122 123 int main( 80 124 int argc, 81 125 char **argv, … … 86 130 int index; 87 131 132 if ((argc > 0) && argv && argv[0]) 133 rtems_progname = argv[0]; 134 else 135 rtems_progname = "RTEMS"; 136 88 137 duart_base = (unsigned char *)DUART_ADDR; 89 138 … … 122 171 Cpu_table.predriver_hook = bsp_libc_init; /* RTEMS resources available */ 123 172 124 Cpu_table.postdriver_hook = NULL;173 Cpu_table.postdriver_hook = bsp_postdriver_hook; 125 174 126 175 Cpu_table.idle_task = NULL; /* do not override system IDLE task */ … … 165 214 #endif 166 215 216 /* 217 * Tell libio how many fd's we want and allow it to tweak config 218 */ 219 220 rtems_libio_config(&BSP_Configuration, BSP_LIBIO_MAX_FDS); 221 167 222 /* led_putnum('e'); * for debugging purposes only */ 168 223 rtems_initialize_executive( &BSP_Configuration, &Cpu_table );/* does not return */
Note: See TracChangeset
for help on using the changeset viewer.