Changeset 3a4ae6c in rtems for c/src/lib/libbsp/i386/go32/clock


Ignore:
Timestamp:
09/11/95 19:35:39 (27 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, 5, master
Children:
ced11f99
Parents:
5072b07
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libbsp/i386/go32/clock/ckinit.c

    r5072b07 r3a4ae6c  
    1212
    1313#include <bsp.h>
    14 #include <clockdrv.h>
     14#include <rtems/libio.h>
     15
    1516#include <stdlib.h>
    1617
    1718volatile rtems_unsigned32 Clock_driver_ticks;
    18 rtems_unsigned32 Clock_isrs_per_tick;           /* ISRs per tick */
    19 rtems_unsigned32 Clock_isrs;                    /* ISRs until next tick */
     19rtems_unsigned32 Clock_isrs_per_tick;  /* ISRs per tick */
     20rtems_unsigned32 Clock_isrs;   /* ISRs until next tick */
    2021rtems_isr_entry  Old_ticker;
     22
     23#define CLOCK_VECTOR 0x8
     24
     25void Clock_exit( void );
     26
     27/*
     28 * These are set by clock driver during its init
     29 */
     30 
     31rtems_device_major_number rtems_clock_major = ~0;
     32rtems_device_minor_number rtems_clock_minor;
     33
     34rtems_isr Clock_isr(
     35  rtems_vector_number vector
     36)
     37{
     38    /* touch interrupt controller for irq0 (0x20+0) */
     39    outport_byte( 0x20, 0x20 );
     40
     41    Clock_driver_ticks += 1;
     42
     43#if 0 && defined(pentium)
     44    {
     45      extern long long Last_RDTSC;
     46      __asm __volatile( ".byte 0x0F, 0x31" : "=A" (Last_RDTSC) );
     47    }
     48#endif
     49
     50    if ( Clock_isrs == 1 ) {
     51      rtems_clock_tick();
     52      Clock_isrs = Clock_isrs_per_tick;
     53    } else {
     54      Clock_isrs -= 1;
     55    }
     56}
     57
     58void Install_clock(
     59  rtems_isr_entry clock_isr
     60)
     61{
     62    unsigned int microseconds_per_isr;
     63
     64#if 0
     65    /* Initialize clock from on-board real time clock.  This breaks the */
     66    /* test code which assumes which assumes the application will do it. */
     67    {
     68       rtems_time_of_day Now;
     69       extern void init_rtc( void );
     70       extern long rtc_read( rtems_time_of_day * tod );
     71       init_rtc();
     72       if ( rtc_read( &Now ) >= 0 )
     73         clock_set( &Now );
     74       }
     75#endif
     76
     77    /* Start by assuming hardware counter is large enough, then */
     78    /* scale it until it actually fits.    */
     79    Clock_driver_ticks = 0;
     80    Clock_isrs_per_tick = 1;
     81
     82    if ( BSP_Configuration.microseconds_per_tick == 0 )
     83       microseconds_per_isr = 10000; /* default 10 ms */
     84    else
     85       microseconds_per_isr = BSP_Configuration.microseconds_per_tick;
     86    while ( US_TO_TICK(microseconds_per_isr) > 65535 )  {
     87      Clock_isrs_per_tick  *= 10;
     88      microseconds_per_isr /= 10;
     89    }
     90
     91    /* Initialize count in ckisr.c */
     92    Clock_isrs = Clock_isrs_per_tick;
     93
     94#if 0
     95    /* This was dropped in the last revision.  Its a nice thing to know. */
     96    TICKS_PER_SECOND = 1000000 / (Clock_isrs_per_tick * microseconds_per_isr);
     97#endif
     98
     99    if ( BSP_Configuration.ticks_per_timeslice )  {
     100      /* 105/88 approximates TIMER_TICK*1e-6 */
     101      unsigned int count = US_TO_TICK( microseconds_per_isr );
     102
     103      Old_ticker = (rtems_isr_entry) set_vector( clock_isr, CLOCK_VECTOR, 1 );
     104      outport_byte( TIMER_MODE, TIMER_SEL0|TIMER_16BIT|TIMER_RATEGEN );
     105      outport_byte( TIMER_CNTR0, count >> 0 & 0xff );
     106      outport_byte( TIMER_CNTR0, count >> 8 & 0xff );
     107    }
     108    atexit( Clock_exit );
     109}
     110
     111void ReInstall_clock(
     112  rtems_isr_entry clock_isr
     113)
     114{
     115  rtems_unsigned32 isrlevel = 0;
     116
     117  rtems_interrupt_disable( isrlevel );
     118   (void) set_vector( clock_isr, CLOCK_VECTOR, 1 );
     119  rtems_interrupt_enable( isrlevel );
     120}
     121
     122void Clock_exit( void )
     123{
     124  if ( BSP_Configuration.ticks_per_timeslice ) {
     125 extern void rtc_set_dos_date( void );
     126
     127 /* reset to DOS value: */
     128 outport_byte( TIMER_MODE, TIMER_SEL0|TIMER_16BIT|TIMER_RATEGEN );
     129 outport_byte( TIMER_CNTR0, 0 );
     130 outport_byte( TIMER_CNTR0, 0 );
     131
     132 /* reset time-of-day */
     133 rtc_set_dos_date();
     134 
     135 /* re-enable old handler: assume it was one of ours */
     136 set_vector( (rtems_isr_entry)Old_ticker, CLOCK_VECTOR, 1 );
     137  }
     138}
    21139
    22140rtems_device_driver Clock_initialize(
    23141  rtems_device_major_number major,
    24142  rtems_device_minor_number minor,
    25   void *pargp,
    26   rtems_id tid,
    27   rtems_unsigned32 *rval
     143  void *pargp
    28144)
    29145{
    30146  Install_clock( Clock_isr );
    31 }
    32 
    33 void ReInstall_clock(
    34   rtems_isr_entry clock_isr
    35 )
    36 {
    37   rtems_unsigned32 isrlevel = 0;
    38 
    39   rtems_interrupt_disable( isrlevel );
    40    (void) set_vector( clock_isr, 0x8, 1 );
    41   rtems_interrupt_enable( isrlevel );
    42 }
    43 
    44 void Install_clock(
    45   rtems_isr_entry clock_isr
    46 )
    47 {
    48     unsigned int        microseconds_per_isr;
    49 
    50 #if 0
    51     /* Initialize clock from on-board real time clock.  This breaks the */
    52     /* test code which assumes which assumes the application will do it. */
    53     {
    54         rtems_time_of_day Now;
    55         extern void init_rtc( void );
    56         extern long rtc_read( rtems_time_of_day * tod );
    57         init_rtc();
    58         if ( rtc_read( &Now ) >= 0 )
    59             clock_set( &Now );
    60     }
    61 #endif
    62 
    63     /* Start by assuming hardware counter is large enough, then */
    64     /* scale it until it actually fits.                         */
    65     Clock_driver_ticks = 0;
    66     Clock_isrs_per_tick = 1;
    67 
    68     if ( BSP_Configuration.microseconds_per_tick == 0 )
    69         microseconds_per_isr = 10000;   /* default 10 ms */
    70     else
    71         microseconds_per_isr = BSP_Configuration.microseconds_per_tick;
    72     while ( US_TO_TICK(microseconds_per_isr) > 65535 )  {
    73         Clock_isrs_per_tick  *= 10;
    74         microseconds_per_isr /= 10;
    75     }
    76 
    77     /* Initialize count in ckisr.c */
    78     Clock_isrs = Clock_isrs_per_tick;
    79 
    80 #if 0
    81     /* This was dropped in the last revision.  Its a nice thing to know. */
    82     TICKS_PER_SECOND = 1000000 / (Clock_isrs_per_tick * microseconds_per_isr);
    83 #endif
    84 
    85     if ( BSP_Configuration.ticks_per_timeslice )  {
    86         /* 105/88 approximates TIMER_TICK*1e-6 */
    87         unsigned int count = US_TO_TICK( microseconds_per_isr );
    88 
    89         Old_ticker = (rtems_isr_entry) set_vector( clock_isr, 0x8, 1 );
    90         outport_byte( TIMER_MODE, TIMER_SEL0|TIMER_16BIT|TIMER_RATEGEN );
    91         outport_byte( TIMER_CNTR0, count >> 0 & 0xff );
    92         outport_byte( TIMER_CNTR0, count >> 8 & 0xff );
    93     }
    94     atexit( Clock_exit );
    95 }
    96 
    97 void Clock_exit( void )
    98 {
    99   if ( BSP_Configuration.ticks_per_timeslice ) {
    100         extern void rtc_set_dos_date( void );
    101 
    102         /* reset to DOS value: */
    103         outport_byte( TIMER_MODE, TIMER_SEL0|TIMER_16BIT|TIMER_RATEGEN );
    104         outport_byte( TIMER_CNTR0, 0 );
    105         outport_byte( TIMER_CNTR0, 0 );
    106 
    107         /* reset time-of-day */
    108         rtc_set_dos_date();
    109        
    110         /* re-enable old handler: assume it was one of ours */
    111         set_vector( (rtems_isr_entry)Old_ticker, 0x8, 1 );
    112   }
    113 }
    114 
     147 
     148  /*
     149   * make major/minor avail to others such as shared memory driver
     150   */
     151 
     152  rtems_clock_major = major;
     153  rtems_clock_minor = minor;
     154 
     155  return RTEMS_SUCCESSFUL;
     156}
     157 
     158rtems_device_driver Clock_control(
     159  rtems_device_major_number major,
     160  rtems_device_minor_number minor,
     161  void *pargp
     162)
     163{
     164    rtems_libio_ioctl_args_t *args = pargp;
     165 
     166    if (args == 0)
     167        goto done;
     168 
     169    /*
     170     * This is hokey, but until we get a defined interface
     171     * to do this, it will just be this simple...
     172     */
     173 
     174    if (args->command == rtems_build_name('I', 'S', 'R', ' '))
     175    {
     176        Clock_isr(CLOCK_VECTOR);
     177    }
     178    else if (args->command == rtems_build_name('N', 'E', 'W', ' '))
     179    {
     180        ReInstall_clock(args->buffer);
     181    }
     182 
     183done:
     184    return RTEMS_SUCCESSFUL;
     185}
    115186
    116187#if 0 && defined(pentium)
    117 /* This can be used to get extremely accurate timing on a pentium.      */
    118 /* It isn't supported. [bryce]                                          */
     188/* This can be used to get extremely accurate timing on a pentium. */
     189/* It isn't supported. [bryce]      */
    119190#define HZ 90.0
    120191volatile long long Last_RDTSC;
    121192#define RDTSC()\
    122193  ({ long long _now; __asm __volatile (".byte 0x0F,0x31":"=A"(_now)); _now; })
     194
    123195long long Kernel_Time_ns( void )
    124196{
     
    129201    disable_intr( flags );
    130202    now = 1e9 * Clock_driver_ticks / isrs_per_second
    131               + (RDTSC() - Last_RDTSC) * (1000.0/HZ);
     203       + (RDTSC() - Last_RDTSC) * (1000.0/HZ);
    132204    enable_intr( flags );
    133205    return now;
Note: See TracChangeset for help on using the changeset viewer.