diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 1995-09-11 19:35:39 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 1995-09-11 19:35:39 +0000 |
commit | 3a4ae6c210bcc37754767966f1128ae23c77b6af (patch) | |
tree | 8804983e5b92bec788d548df13db7513118d351d /c/src/lib/libbsp/i386/go32/clock/ckinit.c | |
parent | new file -- split from inlines (diff) | |
download | rtems-3a4ae6c210bcc37754767966f1128ae23c77b6af.tar.bz2 |
The word "RTEMS" almost completely removed from the core.
Configuration Table Template file added and all tests
modified to use this. All gvar.h and conftbl.h files
removed from test directories.
Configuration parameter maximum_devices added.
Core semaphore and mutex handlers added and RTEMS API Semaphore
Manager updated to reflect this.
Initialization sequence changed to invoke API specific initialization
routines. Initialization tasks table now owned by RTEMS Tasks Manager.
Added user extension for post-switch.
Utilized user extensions to implement API specific functionality
like signal dispatching.
Added extensions to the System Initialization Thread so that an
API can register a function to be invoked while the system
is being initialized. These are largely equivalent to the
pre-driver and post-driver hooks.
Added the Modules file oar-go32_p5, modified oar-go32, and modified
the file make/custom/go32.cfg to look at an environment varable which
determines what CPU model is being used.
All BSPs updated to reflect named devices and clock driver's IOCTL
used by the Shared Memory Driver. Also merged clock isr into
main file and removed ckisr.c where possible.
Updated spsize to reflect new and moved variables.
Makefiles for the executive source and include files updated to show
break down of files into Core, RTEMS API, and Neither.
Header and inline files installed into subdirectory based on whether
logically in the Core or a part of the RTEMS API.
Diffstat (limited to 'c/src/lib/libbsp/i386/go32/clock/ckinit.c')
-rw-r--r-- | c/src/lib/libbsp/i386/go32/clock/ckinit.c | 182 |
1 files changed, 127 insertions, 55 deletions
diff --git a/c/src/lib/libbsp/i386/go32/clock/ckinit.c b/c/src/lib/libbsp/i386/go32/clock/ckinit.c index 5ac1c10d98..fa6a8bf057 100644 --- a/c/src/lib/libbsp/i386/go32/clock/ckinit.c +++ b/c/src/lib/libbsp/i386/go32/clock/ckinit.c @@ -11,67 +11,81 @@ */ #include <bsp.h> -#include <clockdrv.h> +#include <rtems/libio.h> + #include <stdlib.h> volatile rtems_unsigned32 Clock_driver_ticks; -rtems_unsigned32 Clock_isrs_per_tick; /* ISRs per tick */ -rtems_unsigned32 Clock_isrs; /* ISRs until next tick */ +rtems_unsigned32 Clock_isrs_per_tick; /* ISRs per tick */ +rtems_unsigned32 Clock_isrs; /* ISRs until next tick */ rtems_isr_entry Old_ticker; -rtems_device_driver Clock_initialize( - rtems_device_major_number major, - rtems_device_minor_number minor, - void *pargp, - rtems_id tid, - rtems_unsigned32 *rval -) -{ - Install_clock( Clock_isr ); -} +#define CLOCK_VECTOR 0x8 -void ReInstall_clock( - rtems_isr_entry clock_isr +void Clock_exit( void ); + +/* + * These are set by clock driver during its init + */ + +rtems_device_major_number rtems_clock_major = ~0; +rtems_device_minor_number rtems_clock_minor; + +rtems_isr Clock_isr( + rtems_vector_number vector ) { - rtems_unsigned32 isrlevel = 0; + /* touch interrupt controller for irq0 (0x20+0) */ + outport_byte( 0x20, 0x20 ); - rtems_interrupt_disable( isrlevel ); - (void) set_vector( clock_isr, 0x8, 1 ); - rtems_interrupt_enable( isrlevel ); + Clock_driver_ticks += 1; + +#if 0 && defined(pentium) + { + extern long long Last_RDTSC; + __asm __volatile( ".byte 0x0F, 0x31" : "=A" (Last_RDTSC) ); + } +#endif + + if ( Clock_isrs == 1 ) { + rtems_clock_tick(); + Clock_isrs = Clock_isrs_per_tick; + } else { + Clock_isrs -= 1; + } } void Install_clock( rtems_isr_entry clock_isr ) { - unsigned int microseconds_per_isr; + unsigned int microseconds_per_isr; #if 0 - /* Initialize clock from on-board real time clock. This breaks the */ + /* Initialize clock from on-board real time clock. This breaks the */ /* test code which assumes which assumes the application will do it. */ { - rtems_time_of_day Now; - extern void init_rtc( void ); - extern long rtc_read( rtems_time_of_day * tod ); - init_rtc(); - if ( rtc_read( &Now ) >= 0 ) - clock_set( &Now ); - } + rtems_time_of_day Now; + extern void init_rtc( void ); + extern long rtc_read( rtems_time_of_day * tod ); + init_rtc(); + if ( rtc_read( &Now ) >= 0 ) + clock_set( &Now ); + } #endif - /* Start by assuming hardware counter is large enough, then */ - /* scale it until it actually fits. */ + /* Start by assuming hardware counter is large enough, then */ + /* scale it until it actually fits. */ Clock_driver_ticks = 0; Clock_isrs_per_tick = 1; if ( BSP_Configuration.microseconds_per_tick == 0 ) - microseconds_per_isr = 10000; /* default 10 ms */ + microseconds_per_isr = 10000; /* default 10 ms */ else - microseconds_per_isr = BSP_Configuration.microseconds_per_tick; + microseconds_per_isr = BSP_Configuration.microseconds_per_tick; while ( US_TO_TICK(microseconds_per_isr) > 65535 ) { - Clock_isrs_per_tick *= 10; - microseconds_per_isr /= 10; + Clock_isrs_per_tick *= 10; + microseconds_per_isr /= 10; } /* Initialize count in ckisr.c */ @@ -83,43 +97,101 @@ void Install_clock( #endif if ( BSP_Configuration.ticks_per_timeslice ) { - /* 105/88 approximates TIMER_TICK*1e-6 */ - unsigned int count = US_TO_TICK( microseconds_per_isr ); + /* 105/88 approximates TIMER_TICK*1e-6 */ + unsigned int count = US_TO_TICK( microseconds_per_isr ); - Old_ticker = (rtems_isr_entry) set_vector( clock_isr, 0x8, 1 ); - outport_byte( TIMER_MODE, TIMER_SEL0|TIMER_16BIT|TIMER_RATEGEN ); - outport_byte( TIMER_CNTR0, count >> 0 & 0xff ); - outport_byte( TIMER_CNTR0, count >> 8 & 0xff ); + Old_ticker = (rtems_isr_entry) set_vector( clock_isr, CLOCK_VECTOR, 1 ); + outport_byte( TIMER_MODE, TIMER_SEL0|TIMER_16BIT|TIMER_RATEGEN ); + outport_byte( TIMER_CNTR0, count >> 0 & 0xff ); + outport_byte( TIMER_CNTR0, count >> 8 & 0xff ); } atexit( Clock_exit ); } +void ReInstall_clock( + rtems_isr_entry clock_isr +) +{ + rtems_unsigned32 isrlevel = 0; + + rtems_interrupt_disable( isrlevel ); + (void) set_vector( clock_isr, CLOCK_VECTOR, 1 ); + rtems_interrupt_enable( isrlevel ); +} + void Clock_exit( void ) { if ( BSP_Configuration.ticks_per_timeslice ) { - extern void rtc_set_dos_date( void ); - - /* reset to DOS value: */ - outport_byte( TIMER_MODE, TIMER_SEL0|TIMER_16BIT|TIMER_RATEGEN ); - outport_byte( TIMER_CNTR0, 0 ); - outport_byte( TIMER_CNTR0, 0 ); - - /* reset time-of-day */ - rtc_set_dos_date(); - - /* re-enable old handler: assume it was one of ours */ - set_vector( (rtems_isr_entry)Old_ticker, 0x8, 1 ); + extern void rtc_set_dos_date( void ); + + /* reset to DOS value: */ + outport_byte( TIMER_MODE, TIMER_SEL0|TIMER_16BIT|TIMER_RATEGEN ); + outport_byte( TIMER_CNTR0, 0 ); + outport_byte( TIMER_CNTR0, 0 ); + + /* reset time-of-day */ + rtc_set_dos_date(); + + /* re-enable old handler: assume it was one of ours */ + set_vector( (rtems_isr_entry)Old_ticker, CLOCK_VECTOR, 1 ); } } +rtems_device_driver Clock_initialize( + rtems_device_major_number major, + rtems_device_minor_number minor, + void *pargp +) +{ + Install_clock( Clock_isr ); + + /* + * make major/minor avail to others such as shared memory driver + */ + + rtems_clock_major = major; + rtems_clock_minor = minor; + + return RTEMS_SUCCESSFUL; +} + +rtems_device_driver Clock_control( + rtems_device_major_number major, + rtems_device_minor_number minor, + void *pargp +) +{ + rtems_libio_ioctl_args_t *args = pargp; + + if (args == 0) + goto done; + + /* + * This is hokey, but until we get a defined interface + * to do this, it will just be this simple... + */ + + if (args->command == rtems_build_name('I', 'S', 'R', ' ')) + { + Clock_isr(CLOCK_VECTOR); + } + else if (args->command == rtems_build_name('N', 'E', 'W', ' ')) + { + ReInstall_clock(args->buffer); + } + +done: + return RTEMS_SUCCESSFUL; +} #if 0 && defined(pentium) -/* This can be used to get extremely accurate timing on a pentium. */ -/* It isn't supported. [bryce] */ +/* This can be used to get extremely accurate timing on a pentium. */ +/* It isn't supported. [bryce] */ #define HZ 90.0 volatile long long Last_RDTSC; #define RDTSC()\ ({ long long _now; __asm __volatile (".byte 0x0F,0x31":"=A"(_now)); _now; }) + long long Kernel_Time_ns( void ) { extern rtems_unsigned32 _TOD_Ticks_per_second; @@ -128,7 +200,7 @@ long long Kernel_Time_ns( void ) int flags; disable_intr( flags ); now = 1e9 * Clock_driver_ticks / isrs_per_second - + (RDTSC() - Last_RDTSC) * (1000.0/HZ); + + (RDTSC() - Last_RDTSC) * (1000.0/HZ); enable_intr( flags ); return now; } |