Changeset 3a4ae6c in rtems for c/src/lib/libbsp/m68k/mvme162
- 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/mvme162
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
c/src/lib/libbsp/m68k/mvme162/clock/ckinit.c
r5072b07 r3a4ae6c 28 28 #include <stdlib.h> 29 29 30 #include <rtems.h>31 30 #include <bsp.h> 32 #include < clockdrv.h>31 #include <rtems/libio.h> 33 32 34 33 #define MS_COUNT 1000 /* T2's countdown constant (1 ms) */ … … 39 38 rtems_isr_entry Old_ticker; 40 39 41 rtems_device_driver Clock_initialize( 42 rtems_device_major_number major, 43 rtems_device_minor_number minor, 44 void *pargp, 45 rtems_id tid, 46 rtems_unsigned32 *rval 47 ) 40 void Clock_exit( void ); 41 42 #define CLOCK_VECTOR (VBR0 * 0x10 + 0x9) 43 /* 44 * These are set by clock driver during its init 45 */ 46 47 rtems_device_major_number rtems_clock_major = ~0; 48 rtems_device_minor_number rtems_clock_minor; 49 50 51 /* 52 * ISR Handler 53 */ 54 55 rtems_isr Clock_isr(rtems_vector_number vector) 48 56 { 49 Install_clock( Clock_isr ); 50 } 57 Clock_driver_ticks += 1; 58 lcsr->timer_cnt_2 = 0; /* clear counter */ 59 lcsr->intr_clear |= 0x02000000; 51 60 52 void ReInstall_clock(rtems_isr_entry clock_isr) 53 { 54 rtems_unsigned32 isrlevel; 55 56 rtems_interrupt_disable( isrlevel ); 57 (void) set_vector( clock_isr, VBR0 * 0x10 + 0x9, 1 ); 58 rtems_interrupt_enable( isrlevel ); 61 if ( Clock_isrs == 1 ) { 62 rtems_clock_tick(); 63 Clock_isrs = BSP_Configuration.microseconds_per_tick / 1000; 64 } 65 else 66 Clock_isrs -= 1; 59 67 } 60 68 … … 67 75 if ( BSP_Configuration.ticks_per_timeslice ) { 68 76 Old_ticker = 69 (rtems_isr_entry) set_vector( clock_isr, VBR0 * 0x10 + 0x9, 1 );77 (rtems_isr_entry) set_vector( clock_isr, CLOCK_VECTOR, 1 ); 70 78 lcsr->vector_base |= MASK_INT; /* unmask VMEchip2 interrupts */ 71 79 lcsr->to_ctl = 0xE7; /* prescaler to 1 MHz (see Appendix A1) */ … … 80 88 atexit( Clock_exit ); 81 89 } 90 } 82 91 92 void ReInstall_clock(rtems_isr_entry clock_isr) 93 { 94 rtems_unsigned32 isrlevel; 95 96 rtems_interrupt_disable( isrlevel ); 97 (void) set_vector( clock_isr, CLOCK_VECTOR, 1 ); 98 rtems_interrupt_enable( isrlevel ); 83 99 } 84 100 … … 87 103 /* Dummy for now. See other m68k BSP's for code examples */ 88 104 } 105 106 rtems_device_driver Clock_initialize( 107 rtems_device_major_number major, 108 rtems_device_minor_number minor, 109 void *pargp 110 ) 111 { 112 Install_clock( Clock_isr ); 113 114 /* 115 * make major/minor avail to others such as shared memory driver 116 */ 117 118 rtems_clock_major = major; 119 rtems_clock_minor = minor; 120 121 return RTEMS_SUCCESSFUL; 122 } 123 124 rtems_device_driver Clock_control( 125 rtems_device_major_number major, 126 rtems_device_minor_number minor, 127 void *pargp 128 ) 129 { 130 rtems_libio_ioctl_args_t *args = pargp; 131 132 if (args == 0) 133 goto done; 134 135 /* 136 * This is hokey, but until we get a defined interface 137 * to do this, it will just be this simple... 138 */ 139 140 if (args->command == rtems_build_name('I', 'S', 'R', ' ')) 141 { 142 Clock_isr(CLOCK_VECTOR); 143 } 144 else if (args->command == rtems_build_name('N', 'E', 'W', ' ')) 145 { 146 ReInstall_clock(args->buffer); 147 } 148 149 done: 150 return RTEMS_SUCCESSFUL; 151 } 152 -
c/src/lib/libbsp/m68k/mvme162/console/console.c
r5072b07 r3a4ae6c 22 22 #define M162_INIT 23 23 24 #include <rtems.h> 25 #include "console.h" 26 #include "bsp.h" 27 #include "ringbuf.h" 24 #include <bsp.h> 25 #include <rtems/libio.h> 26 #include <ringbuf.h> 28 27 29 28 Ring_buffer_t Buffer[2]; … … 55 54 rtems_device_major_number major, 56 55 rtems_device_minor_number minor, 57 void *arg, 58 rtems_id self, 59 rtems_unsigned32 *status 56 void *arg 60 57 ) 61 58 { 62 59 int i; 60 rtems_status_code status; 63 61 64 62 /* … … 80 78 mcchip->SCC_int_ctl = 0x13; /* SCC IEN, IPL3 */ 81 79 82 *status = RTEMS_SUCCESSFUL; 80 status = rtems_io_register_name( 81 "/dev/console", 82 major, 83 (rtems_device_minor_number) 0 84 ); 85 86 if (status != RTEMS_SUCCESSFUL) 87 rtems_fatal_error_occurred(status); 88 89 status = rtems_io_register_name( 90 "/dev/tty00", 91 major, 92 (rtems_device_minor_number) 0 93 ); 94 95 if (status != RTEMS_SUCCESSFUL) 96 rtems_fatal_error_occurred(status); 97 98 status = rtems_io_register_name( 99 "/dev/tty01", 100 major, 101 (rtems_device_minor_number) 0 102 ); 103 104 if (status != RTEMS_SUCCESSFUL) 105 rtems_fatal_error_occurred(status); 106 107 return RTEMS_SUCCESSFUL; 83 108 } 84 109 … … 101 126 */ 102 127 103 char char_wait(int port)128 char inbyte(int port) 104 129 { 105 130 unsigned char tmp_char; … … 114 139 */ 115 140 116 void char_put(int port, char ch)141 void outbyte(int port, char ch) 117 142 { 118 143 while (1) { … … 123 148 124 149 /* 125 * Map port A (1) to stdin, stdout, and stderr. 126 * Map everything else to port B (0). 127 */ 128 129 int __read(int fd, char *buf, int nbytes) 130 { 131 int i, port; 132 133 if ( fd <= 2 ) port = 1; 134 else port = 0; 135 136 for (i = 0; i < nbytes; i++) { 137 *(buf + i) = char_wait(port); 138 if ((*(buf + i) == '\n') || (*(buf + i) == '\r')) { 139 (*(buf + i++)) = '\n'; 140 (*(buf + i)) = 0; 150 * Open entry point 151 */ 152 153 rtems_device_driver console_open( 154 rtems_device_major_number major, 155 rtems_device_minor_number minor, 156 void * arg 157 ) 158 { 159 return RTEMS_SUCCESSFUL; 160 } 161 162 /* 163 * Close entry point 164 */ 165 166 rtems_device_driver console_close( 167 rtems_device_major_number major, 168 rtems_device_minor_number minor, 169 void * arg 170 ) 171 { 172 return RTEMS_SUCCESSFUL; 173 } 174 175 /* 176 * read bytes from the serial port. We only have stdin. 177 */ 178 179 rtems_device_driver console_read( 180 rtems_device_major_number major, 181 rtems_device_minor_number minor, 182 void * arg 183 ) 184 { 185 rtems_libio_rw_args_t *rw_args; 186 char *buffer; 187 int maximum; 188 int count = 0; 189 190 rw_args = (rtems_libio_rw_args_t *) arg; 191 192 buffer = rw_args->buffer; 193 maximum = rw_args->count; 194 195 if ( minor > 1 ) 196 return RTEMS_INVALID_NUMBER; 197 198 for (count = 0; count < maximum; count++) { 199 buffer[ count ] = inbyte( minor ); 200 if (buffer[ count ] == '\n' || buffer[ count ] == '\r') { 201 buffer[ count++ ] = '\n'; 202 buffer[ count ] = 0; 141 203 break; 142 204 } 143 205 } 144 return (i); 145 } 146 147 /* 148 * Map port A (1) to stdin, stdout, and stderr. 149 * Map everything else to port B (0). 150 */ 151 152 int __write(int fd, char *buf, int nbytes) 153 { 154 int i, port; 155 156 if ( fd <= 2 ) port = 1; 157 else port = 0; 158 159 for (i = 0; i < nbytes; i++) { 160 if (*(buf + i) == '\n') { 161 char_put (port, '\r'); 206 207 rw_args->bytes_moved = count; 208 return (count >= 0) ? RTEMS_SUCCESSFUL : RTEMS_UNSATISFIED; 209 } 210 211 /* 212 * write bytes to the serial port. Stdout and stderr are the same. 213 */ 214 215 rtems_device_driver console_write( 216 rtems_device_major_number major, 217 rtems_device_minor_number minor, 218 void * arg 219 ) 220 { 221 int count; 222 int maximum; 223 rtems_libio_rw_args_t *rw_args; 224 char *buffer; 225 226 rw_args = (rtems_libio_rw_args_t *) arg; 227 228 buffer = rw_args->buffer; 229 maximum = rw_args->count; 230 231 if ( minor > 1 ) 232 return RTEMS_INVALID_NUMBER; 233 234 for (count = 0; count < maximum; count++) { 235 if ( buffer[ count ] == '\n') { 236 outbyte('\r', minor ); 162 237 } 163 char_put (port, *(buf + i)); 164 } 165 return (nbytes); 166 } 238 outbyte( buffer[ count ], minor ); 239 } 240 return maximum; 241 } 242 243 /* 244 * IO Control entry point 245 */ 246 247 rtems_device_driver console_control( 248 rtems_device_major_number major, 249 rtems_device_minor_number minor, 250 void * arg 251 ) 252 { 253 return RTEMS_SUCCESSFUL; 254 } -
c/src/lib/libbsp/m68k/mvme162/include/bsp.h
r5072b07 r3a4ae6c 29 29 30 30 #include <rtems.h> 31 #include <clockdrv.h> 32 #include <console.h> 31 33 #include <iosupp.h> 32 34 … … 249 251 #endif 250 252 253 /* 254 * Device Driver Table Entries 255 */ 256 257 /* 258 * NOTE: Use the standard Console driver entry 259 */ 260 261 /* 262 * NOTE: Use the standard Clock driver entry 263 */ 264 265 /* 266 * How many libio files we want 267 */ 268 269 #define BSP_LIBIO_MAX_FDS 20 270 251 271 /* miscellaneous stuff assumed to exist */ 252 272 -
c/src/lib/libbsp/m68k/mvme162/startup/bspstart.c
r5072b07 r3a4ae6c 28 28 */ 29 29 30 #include <rtems.h>31 30 #include <bsp.h> 31 #include <rtems/libio.h> 32 32 33 #include <libcsupport.h> 33 #include <z8036.h> 34 35 #include <string.h> 36 #include <fcntl.h> 37 38 #ifdef STACK_CHECKER_ON 39 #include <stackchk.h> 40 #endif 34 41 35 42 /* … … 42 49 43 50 rtems_cpu_table Cpu_table; 51 52 char *rtems_progname; 44 53 45 54 /* 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 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( 79 122 int argc, 80 123 char **argv, … … 85 128 int index; 86 129 130 if ((argc > 0) && argv && argv[0]) 131 rtems_progname = argv[0]; 132 else 133 rtems_progname = "RTEMS"; 134 87 135 /* 88 136 * 162Bug Vectors are at 0xFFE00000 … … 122 170 Cpu_table.predriver_hook = bsp_libc_init; /* RTEMS resources available */ 123 171 124 Cpu_table.postdriver_hook = NULL; /* Call our main() for constructors */172 Cpu_table.postdriver_hook = bsp_postdriver_hook; 125 173 126 174 Cpu_table.idle_task = NULL; /* do not override system IDLE task */ … … 162 210 #endif 163 211 212 /* 213 * Tell libio how many fd's we want and allow it to tweak config 214 */ 215 216 rtems_libio_config(&BSP_Configuration, BSP_LIBIO_MAX_FDS); 217 164 218 BSP_Configuration.work_space_start = (void *) 165 219 (RAM_END - BSP_Configuration.work_space_size);
Note: See TracChangeset
for help on using the changeset viewer.