Changeset 3a4ae6c in rtems for c/src/lib/libbsp/m68k/dmv152
- 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/dmv152
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
c/src/lib/libbsp/m68k/dmv152/clock/ckinit.c
r5072b07 r3a4ae6c 20 20 21 21 #include <stdlib.h> 22 23 #include <rtems.h> 22 24 23 #include <bsp.h> 25 #include < clockdrv.h>24 #include <rtems/libio.h> 26 25 27 26 rtems_unsigned32 Clock_isrs; /* ISRs until next tick */ … … 30 29 rtems_isr_entry Old_ticker; 31 30 32 rtems_device_driver Clock_initialize( 33 rtems_device_major_number major, 34 rtems_device_minor_number minor, 35 void *pargp, 36 rtems_id tid, 37 rtems_unsigned32 *rval 31 void Clock_exit( void ); 32 33 #define CLOCK_VECTOR TIMER_VECTOR 34 35 /* 36 * These are set by clock driver during its init 37 */ 38 39 rtems_device_major_number rtems_clock_major = ~0; 40 rtems_device_minor_number rtems_clock_minor; 41 42 /* 43 * ISR Handler 44 */ 45 46 rtems_isr Clock_isr( 47 rtems_vector_number vector 38 48 ) 39 49 { 40 Install_clock( Clock_isr ); 41 } 50 Clock_driver_ticks += 1; 42 51 43 void ReInstall_clock( 44 rtems_isr_entry clock_isr 45 ) 46 { 47 rtems_unsigned32 isrlevel = 0 ; 52 Z8x36_WRITE( TIMER, CT1_CMD_STATUS, 0xE2 ); 53 Z8x36_WRITE( TIMER, CT1_CMD_STATUS, 0x22 ); 54 Z8x36_WRITE( TIMER, CT1_CMD_STATUS, 0xC6 ); 48 55 49 rtems_interrupt_disable( isrlevel ); 50 (void) set_vector( clock_isr, TIMER_VECTOR, 1 ); 51 rtems_interrupt_enable( isrlevel ); 56 if ( Clock_isrs == 1 ) { 57 rtems_clock_tick(); 58 Clock_isrs = BSP_Configuration.microseconds_per_tick / 1000; 59 } 60 else 61 Clock_isrs -= 1; 52 62 } 53 63 … … 62 72 63 73 if ( BSP_Configuration.ticks_per_timeslice ) { 64 Old_ticker = (rtems_isr_entry) set_vector( clock_isr, TIMER_VECTOR, 1 );74 Old_ticker = (rtems_isr_entry) set_vector( clock_isr, CLOCK_VECTOR, 1 ); 65 75 66 76 Z8x36_WRITE( TIMER, MASTER_CFG, 0xd4 ); … … 70 80 Z8x36_WRITE( TIMER, CT1_TIME_CONST_LSB, 0xCE ); 71 81 Z8x36_WRITE( TIMER, CT1_MODE_SPEC, 0x83 ); 72 Z8x36_WRITE( TIMER, CNT_TMR_VECTOR, TIMER_VECTOR );82 Z8x36_WRITE( TIMER, CNT_TMR_VECTOR, CLOCK_VECTOR ); 73 83 Z8x36_WRITE( TIMER, CT1_CMD_STATUS, 0x20 ); 74 84 Z8x36_READ ( TIMER, MASTER_INTR, data ); … … 88 98 } 89 99 100 void ReInstall_clock( 101 rtems_isr_entry clock_isr 102 ) 103 { 104 rtems_unsigned32 isrlevel = 0 ; 105 106 rtems_interrupt_disable( isrlevel ); 107 (void) set_vector( clock_isr, CLOCK_VECTOR, 1 ); 108 rtems_interrupt_enable( isrlevel ); 109 } 110 90 111 void Clock_exit( void ) 91 112 { … … 100 121 } 101 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/dmv152/console/console.c
r5072b07 r3a4ae6c 15 15 #define D152_INIT 16 16 17 #include <rtems.h> 18 #include "console.h" 19 #include "bsp.h" 20 17 #include <bsp.h> 18 #include <rtems/libio.h> 19 21 20 /* console_initialize 22 21 * … … 29 28 * Return values: 30 29 */ 31 30 32 31 rtems_device_driver 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 { 40 *status = RTEMS_SUCCESSFUL; 41 } 42 34 void *arg 35 ) 36 { 37 rtems_status_code status; 38 39 status = rtems_io_register_name( 40 "/dev/console", 41 major, 42 (rtems_device_minor_number) 0 43 ); 44 45 if (status != RTEMS_SUCCESSFUL) 46 rtems_fatal_error_occurred(status); 47 48 return RTEMS_SUCCESSFUL; 49 } 43 50 44 51 /* is_character_ready … … 140 147 141 148 /* 142 * __read -- read bytes from the serial port. Ignore fd, since 143 * we only have stdin. 144 */ 145 146 int __read( 147 int fd, 148 char *buf, 149 int nbytes 150 ) 151 { 152 int i = 0; 153 154 for (i = 0; i < nbytes; i++) { 155 *(buf + i) = inbyte(); 156 if ((*(buf + i) == '\n') || (*(buf + i) == '\r')) { 157 (*(buf + i++)) = '\n'; 158 (*(buf + i)) = 0; 149 * Open entry point 150 */ 151 152 rtems_device_driver console_open( 153 rtems_device_major_number major, 154 rtems_device_minor_number minor, 155 void * arg 156 ) 157 { 158 return RTEMS_SUCCESSFUL; 159 } 160 161 /* 162 * Close entry point 163 */ 164 165 rtems_device_driver console_close( 166 rtems_device_major_number major, 167 rtems_device_minor_number minor, 168 void * arg 169 ) 170 { 171 return RTEMS_SUCCESSFUL; 172 } 173 174 /* 175 * read bytes from the serial port. We only have stdin. 176 */ 177 178 rtems_device_driver console_read( 179 rtems_device_major_number major, 180 rtems_device_minor_number minor, 181 void * arg 182 ) 183 { 184 rtems_libio_rw_args_t *rw_args; 185 char *buffer; 186 int maximum; 187 int count = 0; 188 189 rw_args = (rtems_libio_rw_args_t *) arg; 190 191 buffer = rw_args->buffer; 192 maximum = rw_args->count; 193 194 for (count = 0; count < maximum; count++) { 195 buffer[ count ] = inbyte(); 196 if (buffer[ count ] == '\n' || buffer[ count ] == '\r') { 197 buffer[ count++ ] = '\n'; 198 buffer[ count ] = 0; 159 199 break; 160 200 } 161 201 } 162 return (i); 163 } 164 165 /* 166 * __write -- write bytes to the serial port. Ignore fd, since 167 * stdout and stderr are the same. Since we have no filesystem, 168 * open will only return an error. 169 */ 170 171 int __write( 172 int fd, 173 char *buf, 174 int nbytes 175 ) 176 { 177 int i; 178 179 for (i = 0; i < nbytes; i++) { 180 if (*(buf + i) == '\n') { 181 outbyte ('\r'); 202 203 rw_args->bytes_moved = count; 204 return (count >= 0) ? RTEMS_SUCCESSFUL : RTEMS_UNSATISFIED; 205 } 206 207 /* 208 * write bytes to the serial port. Stdout and stderr are the same. 209 */ 210 211 rtems_device_driver console_write( 212 rtems_device_major_number major, 213 rtems_device_minor_number minor, 214 void * arg 215 ) 216 { 217 int count; 218 int maximum; 219 rtems_libio_rw_args_t *rw_args; 220 char *buffer; 221 222 rw_args = (rtems_libio_rw_args_t *) arg; 223 224 buffer = rw_args->buffer; 225 maximum = rw_args->count; 226 227 for (count = 0; count < maximum; count++) { 228 if ( buffer[ count ] == '\n') { 229 outbyte('\r'); 182 230 } 183 outbyte (*(buf + i)); 184 } 185 return (nbytes); 186 } 231 outbyte( buffer[ count ] ); 232 } 233 return maximum; 234 } 235 236 /* 237 * IO Control entry point 238 */ 239 240 rtems_device_driver console_control( 241 rtems_device_major_number major, 242 rtems_device_minor_number minor, 243 void * arg 244 ) 245 { 246 return RTEMS_SUCCESSFUL; 247 } -
c/src/lib/libbsp/m68k/dmv152/include/bsp.h
r5072b07 r3a4ae6c 22 22 23 23 #include <rtems.h> 24 #include <console.h> 25 #include <clockdrv.h> 24 26 #include <iosupp.h> 27 #include <vmeintr.h> 25 28 #include <z8530.h> 26 29 #include <z8536.h> … … 152 155 extern m68k_isr_entry M68Kvec[]; /* vector table address */ 153 156 157 /* 158 * Device Driver Table Entries 159 */ 160 161 /* 162 * NOTE: Use the standard Console driver entry 163 */ 164 165 /* 166 * NOTE: Use the standard Clock driver entry 167 */ 168 169 /* 170 * How many libio files we want 171 */ 172 173 #define BSP_LIBIO_MAX_FDS 20 174 154 175 /* functions */ 155 176 -
c/src/lib/libbsp/m68k/dmv152/startup/bspstart.c
r5072b07 r3a4ae6c 22 22 */ 23 23 24 #include <rtems.h>25 24 #include <bsp.h> 25 #include <rtems/libio.h> 26 26 27 #include <libcsupport.h> 27 #include <vmeintr.h> 28 28 29 #include <string.h> 30 #include <fcntl.h> 31 32 #ifdef STACK_CHECKER_ON 33 #include <stackchk.h> 34 #endif 29 35 /* 30 36 * The original table from the application and our copy of it with … … 36 42 37 43 rtems_cpu_table Cpu_table; 44 45 char *rtems_progname; 38 46 39 47 /* Initialize whatever libc we are using … … 53 61 54 62 /* 63 * Init the RTEMS libio facility to provide UNIX-like system 64 * calls for use by newlib (ie: provide __open, __close, etc) 65 * Uses malloc() to get area for the iops, so must be after malloc init 66 */ 67 68 rtems_libio_init(); 69 70 /* 55 71 * Set up for the libc handling. 56 72 */ … … 70 86 } 71 87 72 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( 73 115 int argc, 74 116 char **argv, … … 80 122 void *vbr; 81 123 124 if ((argc > 0) && argv && argv[0]) 125 rtems_progname = argv[0]; 126 else 127 rtems_progname = "RTEMS"; 128 82 129 monitors_vector_table = (m68k_isr_entry *)0; /* Monitor Vectors are at 0 */ 83 130 m68k_set_vbr( monitors_vector_table ); … … 116 163 Cpu_table.predriver_hook = bsp_libc_init; /* RTEMS resources available */ 117 164 118 Cpu_table.postdriver_hook = NULL; /* Call our main() for constructors */165 Cpu_table.postdriver_hook = bsp_postdriver_hook; 119 166 120 167 Cpu_table.idle_task = NULL; /* do not override system IDLE task */ … … 159 206 BSP_Configuration.maximum_extensions++; 160 207 #endif 208 209 /* 210 * Tell libio how many fd's we want and allow it to tweak config 211 */ 212 213 rtems_libio_config(&BSP_Configuration, BSP_LIBIO_MAX_FDS); 161 214 162 215 rtems_initialize_executive( &BSP_Configuration, &Cpu_table );
Note: See TracChangeset
for help on using the changeset viewer.