Changeset b06e68ef in rtems for c/src/lib/libbsp/unix/posix/clock
- Timestamp:
- 08/17/95 19:51:51 (28 years ago)
- Branches:
- 4.10, 4.11, 4.8, 4.9, 5, master
- Children:
- 95fbca1
- Parents:
- 3b438fa
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
c/src/lib/libbsp/unix/posix/clock/clock.c
r3b438fa rb06e68ef 1 1 /* Clock 2 2 * 3 * This routine initializes the interval timer on the4 * PA-RISC CPU.The tick frequency is specified by the bsp.3 * This routine generates clock ticks using standard POSIX services. 4 * The tick frequency is specified by the bsp. 5 5 * 6 6 * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994. … … 16 16 17 17 #include <rtems.h> 18 #include <rtems/libio.h> 19 #include <bsp.h> 18 20 21 /* 22 * In order to get the types and prototypes used in this file under 23 * Solaris 2.3, it is necessary to pull the following magic. 24 */ 25 26 #if defined(solaris) 27 #warning "Ignore the undefining __STDC__ warning" 28 #undef __STDC__ 29 #define __STDC__ 0 30 #undef _POSIX_C_SOURCE 31 #endif 32 19 33 #include <stdlib.h> 20 34 #include <stdio.h> 21 35 #include <signal.h> 22 36 #include <time.h> 23 #include <sys/time.h>24 37 25 38 extern rtems_configuration_table Configuration; 26 extern sigset_t UNIX_SIGNAL_MASK;27 39 28 /* 29 * Function prototypes 30 */ 31 32 void Install_clock(); 33 void Clock_isr(); 34 void Clock_exit(); 35 36 /* 37 * CPU_HPPA_CLICKS_PER_TICK is either a #define or an rtems_unsigned32 38 * allocated and set by bsp_start() 39 */ 40 41 #ifndef CPU_HPPA_CLICKS_PER_TICK 42 extern rtems_unsigned32 CPU_HPPA_CLICKS_PER_TICK; 43 #endif 40 void Clock_exit(void); 44 41 45 42 volatile rtems_unsigned32 Clock_driver_ticks; 46 43 47 struct itimerval new; 44 /* 45 * These are set by clock driver during its init 46 */ 48 47 49 rtems_device_driver 50 Clock_initialize( 51 rtems_device_major_number major, 52 rtems_device_minor_number minor, 53 void *pargp, 54 rtems_id tid, 55 rtems_unsigned32 *rval 56 ) 57 { 58 Install_clock(Clock_isr); 59 } 60 61 void 62 ReInstall_clock(rtems_isr_entry new_clock_isr) 63 { 64 rtems_unsigned32 isrlevel = 0; 65 66 rtems_interrupt_disable(isrlevel); 67 (void)set_vector(new_clock_isr, SIGALRM, 1); 68 rtems_interrupt_enable(isrlevel); 69 } 48 rtems_device_major_number rtems_clock_major = ~0; 49 rtems_device_minor_number rtems_clock_minor; 70 50 71 51 void 72 52 Install_clock(rtems_isr_entry clock_isr) 73 53 { 54 struct itimerval new; 55 74 56 Clock_driver_ticks = 0; 75 57 … … 87 69 88 70 void 71 ReInstall_clock(rtems_isr_entry new_clock_isr) 72 { 73 rtems_unsigned32 isrlevel = 0; 74 75 rtems_interrupt_disable(isrlevel); 76 (void)set_vector(new_clock_isr, SIGALRM, 1); 77 rtems_interrupt_enable(isrlevel); 78 } 79 80 void 89 81 Clock_isr(int vector) 90 82 { 91 83 Clock_driver_ticks++; 92 93 84 rtems_clock_tick(); 94 85 } … … 102 93 Clock_exit(void) 103 94 { 95 struct itimerval new; 104 96 struct sigaction act; 105 97 … … 122 114 (void)set_vector(0, SIGALRM, 1); 123 115 } 116 117 rtems_device_driver 118 Clock_initialize( 119 rtems_device_major_number major, 120 rtems_device_minor_number minor, 121 void *pargp 122 ) 123 { 124 Install_clock((rtems_isr_entry) Clock_isr); 125 126 /* 127 * make major/minor avail to others such as shared memory driver 128 */ 129 rtems_clock_major = major; 130 rtems_clock_minor = minor; 131 132 return RTEMS_SUCCESSFUL; 133 } 134 135 rtems_device_driver Clock_control( 136 rtems_device_major_number major, 137 rtems_device_minor_number minor, 138 void *pargp 139 ) 140 { 141 rtems_libio_ioctl_args_t *args = pargp; 142 143 if (args == 0) 144 goto done; 145 146 /* 147 * This is hokey, but until we get a defined interface 148 * to do this, it will just be this simple... 149 */ 150 151 if (args->command == rtems_build_name('I', 'S', 'R', ' ')) 152 { 153 Clock_isr(SIGALRM); 154 } 155 else if (args->command == rtems_build_name('N', 'E', 'W', ' ')) 156 { 157 ReInstall_clock(args->buffer); 158 } 159 160 done: 161 return RTEMS_SUCCESSFUL; 162 }
Note: See TracChangeset
for help on using the changeset viewer.