Changeset 3a4ae6c in rtems for c/src/lib/libbsp/m68k/mvme136
- 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/mvme136
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
c/src/lib/libbsp/m68k/mvme136/clock/ckinit.c
r5072b07 r3a4ae6c 21 21 #include <stdlib.h> 22 22 23 #include <rtems.h>24 23 #include <bsp.h> 25 #include < clockdrv.h>24 #include <rtems/libio.h> 26 25 #include <z8036.h> 27 26 … … 36 35 /* and trigger countdown */ 37 36 37 #define TIMER 0xfffb0000 38 #define RELOAD 0x24 /* clr IP & IUS,allow countdown */ 39 40 #define CLOCK_VECTOR 66 41 38 42 rtems_unsigned32 Clock_isrs; /* ISRs until next tick */ 39 volatile rtems_unsigned32 Clock_driver_ticks; 40 /* ticks since initialization */ 43 44 volatile rtems_unsigned32 Clock_driver_ticks; /* ticks since initialization */ 45 41 46 rtems_isr_entry Old_ticker; 42 47 43 rtems_device_driver Clock_initialize( 44 rtems_device_major_number major, 45 rtems_device_minor_number minor, 46 void *pargp, 47 rtems_id tid, 48 rtems_unsigned32 *rval 48 void Clock_exit( void ); 49 50 /* 51 * These are set by clock driver during its init 52 */ 53 54 rtems_device_major_number rtems_clock_major = ~0; 55 rtems_device_minor_number rtems_clock_minor; 56 57 /* 58 * ISR Handler 59 */ 60 61 rtems_isr Clock_isr( 62 rtems_vector_number vector 49 63 ) 50 64 { 51 Install_clock( Clock_isr );52 } 65 Clock_driver_ticks += 1; 66 ((volatile struct z8036_map *) TIMER)->CT1_CMD_STATUS = RELOAD; 53 67 54 void ReInstall_clock( 55 rtems_isr_entry clock_isr 56 ) 57 { 58 rtems_unsigned32 isrlevel; 59 60 rtems_interrupt_disable( isrlevel ); 61 (void) set_vector( clock_isr, 66, 1 ); 62 rtems_interrupt_enable( isrlevel ); 68 if ( Clock_isrs == 1 ) { 69 rtems_clock_tick(); 70 Clock_isrs = BSP_Configuration.microseconds_per_tick / 1000; 71 } 72 else 73 Clock_isrs -= 1; 63 74 } 64 75 … … 73 84 74 85 if ( BSP_Configuration.ticks_per_timeslice ) { 75 Old_ticker = (rtems_isr_entry) set_vector( clock_isr, 66, 1 );86 Old_ticker = (rtems_isr_entry) set_vector( clock_isr, CLOCK_VECTOR, 1 ); 76 87 timer = (struct z8036_map *) 0xfffb0000; 77 88 timer->MASTER_INTR = MICRVAL; 78 89 timer->CT1_MODE_SPEC = T1MSRVAL; 79 90 80 *((rtems_unsigned16 *)0xfffb0016) = MS_COUNT; /* write countdown value */ 81 /* 82 timer->CT1_TIME_CONST_MSB = (MS_COUNT >> 8); 83 timer->CT1_TIME_CONST_LSB = (MS_COUNT & 0xff); 84 */ 91 *((rtems_unsigned16 *)0xfffb0016) = MS_COUNT; /* write countdown value */ 92 93 /* 94 * timer->CT1_TIME_CONST_MSB = (MS_COUNT >> 8); 95 * timer->CT1_TIME_CONST_LSB = (MS_COUNT & 0xff); 96 */ 97 85 98 timer->MASTER_CFG = MCCRVAL; 86 99 timer->CT1_CMD_STATUS = T1CSRVAL; 87 100 88 /*89 * Enable interrupt via VME interrupt mask register90 */101 /* 102 * Enable interrupt via VME interrupt mask register 103 */ 91 104 (*(rtems_unsigned8 *)0xfffb0038) &= 0xfd; 92 93 105 94 106 atexit( Clock_exit ); 95 107 } 96 108 109 } 110 111 void ReInstall_clock( 112 rtems_isr_entry clock_isr 113 ) 114 { 115 rtems_unsigned32 isrlevel; 116 117 rtems_interrupt_disable( isrlevel ); 118 (void) set_vector( clock_isr, CLOCK_VECTOR, 1 ); 119 rtems_interrupt_enable( isrlevel ); 97 120 } 98 121 … … 110 133 } 111 134 } 135 136 rtems_device_driver Clock_initialize( 137 rtems_device_major_number major, 138 rtems_device_minor_number minor, 139 void *pargp 140 ) 141 { 142 Install_clock( Clock_isr ); 143 144 /* 145 * make major/minor avail to others such as shared memory driver 146 */ 147 148 rtems_clock_major = major; 149 rtems_clock_minor = minor; 150 151 return RTEMS_SUCCESSFUL; 152 } 153 154 rtems_device_driver Clock_control( 155 rtems_device_major_number major, 156 rtems_device_minor_number minor, 157 void *pargp 158 ) 159 { 160 rtems_libio_ioctl_args_t *args = pargp; 161 162 if (args == 0) 163 goto done; 164 165 /* 166 * This is hokey, but until we get a defined interface 167 * to do this, it will just be this simple... 168 */ 169 170 if (args->command == rtems_build_name('I', 'S', 'R', ' ')) 171 { 172 Clock_isr(CLOCK_VECTOR); 173 } 174 else if (args->command == rtems_build_name('N', 'E', 'W', ' ')) 175 { 176 ReInstall_clock(args->buffer); 177 } 178 179 done: 180 return RTEMS_SUCCESSFUL; 181 } 182 -
c/src/lib/libbsp/m68k/mvme136/console/console.c
r5072b07 r3a4ae6c 15 15 #define M136_INIT 16 16 17 #include <rtems.h> 18 #include "console.h" 19 #include "bsp.h" 17 #include <bsp.h> 18 #include <rtems/libio.h> 20 19 21 20 /* console_initialize … … 33 32 rtems_device_major_number major, 34 33 rtems_device_minor_number minor, 35 void *arg ,36 rtems_id self, 37 rtems_unsigned32 *status 38 ) 39 { 34 void *arg 35 ) 36 { 37 rtems_status_code status; 38 40 39 _Write_m681 = ( struct w_m681_info * ) M681ADDR; 41 40 _Read_m681 = ( struct r_m681_info * ) M681ADDR; 42 *status = RTEMS_SUCCESSFUL; 41 42 status = rtems_io_register_name( 43 "/dev/console", 44 major, 45 (rtems_device_minor_number) 0 46 ); 47 48 if (status != RTEMS_SUCCESSFUL) 49 rtems_fatal_error_occurred(status); 50 51 return RTEMS_SUCCESSFUL; 43 52 } 44 53 … … 113 122 114 123 /* 115 * __read -- read bytes from the serial port. Ignore fd, since 116 * we only have stdin. 117 */ 118 119 int __read( 120 int fd, 121 char *buf, 122 int nbytes 123 ) 124 { 125 int i = 0; 126 127 for (i = 0; i < nbytes; i++) { 128 *(buf + i) = inbyte(); 129 if ((*(buf + i) == '\n') || (*(buf + i) == '\r')) { 130 (*(buf + i++)) = '\n'; 131 (*(buf + i)) = 0; 124 * Open entry point 125 */ 126 127 rtems_device_driver console_open( 128 rtems_device_major_number major, 129 rtems_device_minor_number minor, 130 void * arg 131 ) 132 { 133 return RTEMS_SUCCESSFUL; 134 } 135 136 /* 137 * Close entry point 138 */ 139 140 rtems_device_driver console_close( 141 rtems_device_major_number major, 142 rtems_device_minor_number minor, 143 void * arg 144 ) 145 { 146 return RTEMS_SUCCESSFUL; 147 } 148 149 /* 150 * read bytes from the serial port. We only have stdin. 151 */ 152 153 rtems_device_driver console_read( 154 rtems_device_major_number major, 155 rtems_device_minor_number minor, 156 void * arg 157 ) 158 { 159 rtems_libio_rw_args_t *rw_args; 160 char *buffer; 161 int maximum; 162 int count = 0; 163 164 rw_args = (rtems_libio_rw_args_t *) arg; 165 166 buffer = rw_args->buffer; 167 maximum = rw_args->count; 168 169 for (count = 0; count < maximum; count++) { 170 buffer[ count ] = inbyte(); 171 if (buffer[ count ] == '\n' || buffer[ count ] == '\r') { 172 buffer[ count++ ] = '\n'; 173 buffer[ count ] = 0; 132 174 break; 133 175 } 134 176 } 135 return (i); 136 } 137 138 /* 139 * __write -- write bytes to the serial port. Ignore fd, since 140 * stdout and stderr are the same. Since we have no filesystem, 141 * open will only return an error. 142 */ 143 144 int __write( 145 int fd, 146 char *buf, 147 int nbytes 148 ) 149 { 150 int i; 151 152 for (i = 0; i < nbytes; i++) { 153 if (*(buf + i) == '\n') { 154 outbyte ('\r'); 177 178 rw_args->bytes_moved = count; 179 return (count >= 0) ? RTEMS_SUCCESSFUL : RTEMS_UNSATISFIED; 180 } 181 182 /* 183 * write bytes to the serial port. Stdout and stderr are the same. 184 */ 185 186 rtems_device_driver console_write( 187 rtems_device_major_number major, 188 rtems_device_minor_number minor, 189 void * arg 190 ) 191 { 192 int count; 193 int maximum; 194 rtems_libio_rw_args_t *rw_args; 195 char *buffer; 196 197 rw_args = (rtems_libio_rw_args_t *) arg; 198 199 buffer = rw_args->buffer; 200 maximum = rw_args->count; 201 202 for (count = 0; count < maximum; count++) { 203 if ( buffer[ count ] == '\n') { 204 outbyte('\r'); 155 205 } 156 outbyte (*(buf + i));206 outbyte( buffer[ count ] ); 157 207 } 158 return (nbytes); 159 } 208 return maximum; 209 } 210 211 /* 212 * IO Control entry point 213 */ 214 215 rtems_device_driver console_control( 216 rtems_device_major_number major, 217 rtems_device_minor_number minor, 218 void * arg 219 ) 220 { 221 return RTEMS_SUCCESSFUL; 222 } -
c/src/lib/libbsp/m68k/mvme136/include/bsp.h
r5072b07 r3a4ae6c 22 22 23 23 #include <rtems.h> 24 #include <clockdrv.h> 25 #include <console.h> 24 26 #include <iosupp.h> 25 27 … … 125 127 extern m68k_isr_entry M68Kvec[]; /* vector table address */ 126 128 129 /* 130 * Device Driver Table Entries 131 */ 132 133 /* 134 * NOTE: Use the standard Console driver entry 135 */ 136 137 /* 138 * NOTE: Use the standard Clock driver entry 139 */ 140 141 /* 142 * How many libio files we want 143 */ 144 145 #define BSP_LIBIO_MAX_FDS 20 146 127 147 /* functions */ 128 148 -
c/src/lib/libbsp/m68k/mvme136/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 #include <z8036.h> 27 28 28 #include "stackchk.h" 29 #include <string.h> 30 #include <fcntl.h> 31 32 #ifdef STACK_CHECKER_ON 33 #include <stackchk.h> 34 #endif 29 35 30 36 /* … … 37 43 38 44 rtems_cpu_table Cpu_table; 45 46 char *rtems_progname; 39 47 40 48 /* Initialize whatever libc we are using … … 47 55 rtems_unsigned32 heap_start; 48 56 57 #ifdef RTEMS_DEBUG 58 rtems_debug_enable( RTEMS_DEBUG_ALL_MASK ); 59 #endif 60 49 61 heap_start = (rtems_unsigned32) &end; 50 62 if (heap_start & (CPU_ALIGNMENT-1)) … … 52 64 53 65 RTEMS_Malloc_Initialize((void *) heap_start, 64 * 1024, 0); 66 67 /* 68 * Init the RTEMS libio facility to provide UNIX-like system 69 * calls for use by newlib (ie: provide __open, __close, etc) 70 * Uses malloc() to get area for the iops, so must be after malloc init 71 */ 72 73 rtems_libio_init(); 54 74 55 75 /* … … 71 91 } 72 92 73 int bsp_start( 93 /* 94 * After drivers are setup, register some "filenames" 95 * and open stdin, stdout, stderr files 96 * 97 * Newlib will automatically associate the files with these 98 * (it hardcodes the numbers) 99 */ 100 101 void 102 bsp_postdriver_hook(void) 103 { 104 int stdin_fd, stdout_fd, stderr_fd; 105 106 if ((stdin_fd = __open("/dev/console", O_RDONLY, 0)) == -1) 107 rtems_fatal_error_occurred('STD0'); 108 109 if ((stdout_fd = __open("/dev/console", O_WRONLY, 0)) == -1) 110 rtems_fatal_error_occurred('STD1'); 111 112 if ((stderr_fd = __open("/dev/console", O_WRONLY, 0)) == -1) 113 rtems_fatal_error_occurred('STD2'); 114 115 if ((stdin_fd != 0) || (stdout_fd != 1) || (stderr_fd != 2)) 116 rtems_fatal_error_occurred('STIO'); 117 } 118 119 120 int main( 74 121 int argc, 75 122 char **argv, … … 80 127 int index; 81 128 129 if ((argc > 0) && argv && argv[0]) 130 rtems_progname = argv[0]; 131 else 132 rtems_progname = "RTEMS"; 133 82 134 monitors_vector_table = (m68k_isr_entry *)0; /* 135Bug Vectors are at 0 */ 83 135 m68k_set_vbr( monitors_vector_table ); … … 105 157 Cpu_table.predriver_hook = bsp_libc_init; /* RTEMS resources available */ 106 158 107 Cpu_table.postdriver_hook = NULL;159 Cpu_table.postdriver_hook = bsp_postdriver_hook; 108 160 109 161 Cpu_table.idle_task = NULL; /* do not override system IDLE task */ … … 148 200 #endif 149 201 202 /* 203 * Tell libio how many fd's we want and allow it to tweak config 204 */ 205 206 rtems_libio_config(&BSP_Configuration, BSP_LIBIO_MAX_FDS); 207 150 208 rtems_initialize_executive( &BSP_Configuration, &Cpu_table ); 151 209 /* does not return */
Note: See TracChangeset
for help on using the changeset viewer.