Changeset 3a4ae6c in rtems for c/src/lib/libbsp/no_cpu/no_bsp
- 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/no_cpu/no_bsp
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
c/src/lib/libbsp/no_cpu/no_bsp/clock/ckinit.c
r5072b07 r3a4ae6c 61 61 rtems_isr_entry Old_ticker; 62 62 63 /* 64 * Reinstall_clock 65 * 66 * Install a clock tick handler without reprogramming the chip. This 67 * is used by the polling shared memory device driver. 68 */ 69 70 void ReInstall_clock( 71 rtems_isr_entry clock_isr 72 ) 73 { 74 rtems_unsigned32 isrlevel = 0; 75 76 /* 77 * Disable interrupts and install the clock ISR vector using the 78 * BSP dependent set_vector routine. In the below example, the clock 79 * ISR is on vector 4 and is an RTEMS interrupt. 80 */ 81 82 rtems_interrupt_disable( isrlevel ); 83 (void) set_vector( clock_isr, CLOCK_VECTOR, 1 ); 84 rtems_interrupt_enable( isrlevel ); 63 void Clock_exit( void ); 64 65 66 /* 67 * Isr Handler 68 */ 69 70 rtems_isr Clock_isr( 71 rtems_vector_number vector 72 ) 73 { 74 /* 75 * bump the number of clock driver ticks since initialization 76 * 77 * determine if it is time to announce the passing of tick as configured 78 * to RTEMS through the rtems_clock_tick directive 79 * 80 * perform any timer dependent tasks 81 */ 85 82 } 86 83 … … 125 122 126 123 /* 124 * Reinstall_clock 125 * 126 * Install a clock tick handler without reprogramming the chip. This 127 * is used by the polling shared memory device driver. 128 */ 129 130 void ReInstall_clock( 131 rtems_isr_entry clock_isr 132 ) 133 { 134 rtems_unsigned32 isrlevel = 0; 135 136 /* 137 * Disable interrupts and install the clock ISR vector using the 138 * BSP dependent set_vector routine. In the below example, the clock 139 * ISR is on vector 4 and is an RTEMS interrupt. 140 */ 141 142 rtems_interrupt_disable( isrlevel ); 143 (void) set_vector( clock_isr, CLOCK_VECTOR, 1 ); 144 rtems_interrupt_enable( isrlevel ); 145 } 146 147 /* 127 148 * Clean up before the application exits 128 149 */ … … 150 171 ) 151 172 { 152 Install_clock( (rtems_isr_entry) Clock_isr);153 173 Install_clock( Clock_isr ); 174 154 175 /* 155 176 * make major/minor avail to others such as shared memory driver 156 177 */ 178 157 179 rtems_clock_major = major; 158 159 180 rtems_clock_minor = minor; 181 160 182 return RTEMS_SUCCESSFUL; 161 183 } -
c/src/lib/libbsp/no_cpu/no_bsp/console/console.c
r5072b07 r3a4ae6c 15 15 #define NO_BSP_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 { 40 *status = RTEMS_SUCCESSFUL; 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; 41 49 } 42 50 … … 111 119 } 112 120 113 /* 114 * __read -- read bytes from the serial port. Ignore fd, since 115 * we only have stdin. 116 */ 117 118 int __read( 119 int fd, 120 char *buf, 121 int nbytes 122 ) 123 { 124 int i = 0; 125 126 for (i = 0; i < nbytes; i++) { 127 *(buf + i) = inbyte(); 128 if ((*(buf + i) == '\n') || (*(buf + i) == '\r')) { 129 (*(buf + i++)) = '\n'; 130 (*(buf + i)) = 0; 121 122 /* 123 * Open entry point 124 */ 125 126 rtems_device_driver console_open( 127 rtems_device_major_number major, 128 rtems_device_minor_number minor, 129 void * arg 130 ) 131 { 132 return RTEMS_SUCCESSFUL; 133 } 134 135 /* 136 * Close entry point 137 */ 138 139 rtems_device_driver console_close( 140 rtems_device_major_number major, 141 rtems_device_minor_number minor, 142 void * arg 143 ) 144 { 145 return RTEMS_SUCCESSFUL; 146 } 147 148 /* 149 * read bytes from the serial port. We only have stdin. 150 */ 151 152 rtems_device_driver console_read( 153 rtems_device_major_number major, 154 rtems_device_minor_number minor, 155 void * arg 156 ) 157 { 158 rtems_libio_rw_args_t *rw_args; 159 char *buffer; 160 int maximum; 161 int count = 0; 162 163 rw_args = (rtems_libio_rw_args_t *) arg; 164 165 buffer = rw_args->buffer; 166 maximum = rw_args->count; 167 168 for (count = 0; count < maximum; count++) { 169 buffer[ count ] = inbyte(); 170 if (buffer[ count ] == '\n' || buffer[ count ] == '\r') { 171 buffer[ count++ ] = '\n'; 172 buffer[ count ] = 0; 131 173 break; 132 174 } 133 175 } 134 return (i); 135 } 136 137 /* 138 * __write -- write bytes to the serial port. Ignore fd, since 139 * stdout and stderr are the same. Since we have no filesystem, 140 * open will only return an error. 141 */ 142 143 int __write( 144 int fd, 145 char *buf, 146 int nbytes 147 ) 148 { 149 int i; 150 151 for (i = 0; i < nbytes; i++) { 152 if (*(buf + i) == '\n') { 153 outbyte ('\r'); 176 177 rw_args->bytes_moved = count; 178 return (count >= 0) ? RTEMS_SUCCESSFUL : RTEMS_UNSATISFIED; 179 } 180 181 /* 182 * write bytes to the serial port. Stdout and stderr are the same. 183 */ 184 185 rtems_device_driver console_write( 186 rtems_device_major_number major, 187 rtems_device_minor_number minor, 188 void * arg 189 ) 190 { 191 int count; 192 int maximum; 193 rtems_libio_rw_args_t *rw_args; 194 char *buffer; 195 196 rw_args = (rtems_libio_rw_args_t *) arg; 197 198 buffer = rw_args->buffer; 199 maximum = rw_args->count; 200 201 for (count = 0; count < maximum; count++) { 202 if ( buffer[ count ] == '\n') { 203 outbyte('\r'); 154 204 } 155 outbyte (*(buf + i));205 outbyte( buffer[ count ] ); 156 206 } 157 return (nbytes); 158 } 207 return maximum; 208 } 209 210 /* 211 * IO Control entry point 212 */ 213 214 rtems_device_driver console_control( 215 rtems_device_major_number major, 216 rtems_device_minor_number minor, 217 void * arg 218 ) 219 { 220 return RTEMS_SUCCESSFUL; 221 } -
c/src/lib/libbsp/no_cpu/no_bsp/include/bsp.h
r5072b07 r3a4ae6c 24 24 25 25 #include <rtems.h> 26 #include <console.h> 26 27 #include <clockdrv.h> 27 28 … … 70 71 71 72 /* 72 * Console driver init73 * Device Driver Table Entries 73 74 */ 74 75 rtems_device_driver console_initialize( 76 rtems_device_major_number, rtems_device_minor_number minor, void *); 77 78 #define CONSOLE_DRIVER_TABLE_ENTRY \ 79 { console_initialize, NULL, NULL, NULL, NULL, NULL } 75 76 /* 77 * NOTE: Use the standard Console driver entry 78 */ 80 79 81 80 /* 82 81 * NOTE: Use the standard Clock driver entry 83 82 */ 83 84 /* 85 * How many libio files we want 86 */ 87 88 #define BSP_LIBIO_MAX_FDS 20 84 89 85 90 /* functions */ -
c/src/lib/libbsp/no_cpu/no_bsp/startup/bspstart.c
r5072b07 r3a4ae6c 21 21 */ 22 22 23 #include <rtems.h>24 23 #include <bsp.h> 25 #include <shm.h> 24 #include <rtems/libio.h> 25 26 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 27 34 28 35 /* … … 36 43 37 44 rtems_cpu_table Cpu_table; 45 46 char *rtems_progname; 38 47 39 48 /* Initialize whatever libc we are using … … 60 69 61 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(); 77 78 /* 62 79 * Set up for the libc handling. 63 80 */ … … 77 94 } 78 95 79 int bsp_start( 96 /* 97 * After drivers are setup, register some "filenames" 98 * and open stdin, stdout, stderr files 99 * 100 * Newlib will automatically associate the files with these 101 * (it hardcodes the numbers) 102 */ 103 104 void 105 bsp_postdriver_hook(void) 106 { 107 int stdin_fd, stdout_fd, stderr_fd; 108 109 if ((stdin_fd = __open("/dev/console", O_RDONLY, 0)) == -1) 110 rtems_fatal_error_occurred('STD0'); 111 112 if ((stdout_fd = __open("/dev/console", O_WRONLY, 0)) == -1) 113 rtems_fatal_error_occurred('STD1'); 114 115 if ((stderr_fd = __open("/dev/console", O_WRONLY, 0)) == -1) 116 rtems_fatal_error_occurred('STD2'); 117 118 if ((stdin_fd != 0) || (stdout_fd != 1) || (stderr_fd != 2)) 119 rtems_fatal_error_occurred('STIO'); 120 } 121 122 int main( 80 123 int argc, 81 124 char **argv, … … 83 126 ) 84 127 { 128 if ((argc > 0) && argv && argv[0]) 129 rtems_progname = argv[0]; 130 else 131 rtems_progname = "RTEMS"; 132 85 133 /* 86 134 * Allocate the memory for the RTEMS Work Space. This can come from … … 119 167 #endif 120 168 169 #ifdef STACK_CHECKER_ON 170 /* 171 * Add 1 extension for stack checker 172 */ 173 174 BSP_Configuration.maximum_extensions++; 175 #endif 176 177 /* 178 * Tell libio how many fd's we want and allow it to tweak config 179 */ 180 181 rtems_libio_config(&BSP_Configuration, BSP_LIBIO_MAX_FDS); 182 121 183 /* 122 184 * Need to "allocate" the memory for the RTEMS Workspace and … … 139 201 Cpu_table.predriver_hook = bsp_libc_init; /* RTEMS resources available */ 140 202 141 Cpu_table.postdriver_hook = NULL;203 Cpu_table.postdriver_hook = bsp_postdriver_hook; 142 204 143 205 Cpu_table.idle_task = NULL; /* do not override system IDLE task */
Note: See TracChangeset
for help on using the changeset viewer.