Changeset 9e738b65 in rtems for c/src/lib/libbsp/i386


Ignore:
Timestamp:
Jul 20, 1995, 7:20:31 PM (25 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, 5, master
Children:
1690c6b
Parents:
3b170f5
Message:

updating go32 to make timer more accurate

Location:
c/src/lib/libbsp/i386
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libbsp/i386/force386/include/bsp.h

    r3b170f5 r9e738b65  
    4141 */
    4242
    43 #define MUST_WAIT_FOR_INTERRUTPT 0
     43#define MUST_WAIT_FOR_INTERRUPT 0
    4444
    4545#define Install_tm27_vector( handler ) set_vector( (handler), 0x90, 1 )
  • c/src/lib/libbsp/i386/go32/include/bsp.h

    r3b170f5 r9e738b65  
    3939 *  Define the interrupt mechanism for Time Test 27
    4040 *
    41  *  NOTE: Use a software interrupt for the i386.
     41 *  NOTE:  Use a software interrupt for the i386 family.
    4242 */
    43 #define MUST_WAIT_FOR_INTERRUTPT 0
     43#define MUST_WAIT_FOR_INTERRUPT 0
    4444#define Install_tm27_vector( handler ) set_vector( (handler), 0x90, 1 )
    4545#define Cause_tm27_intr()              asm volatile( "int $0x90" : : );
    4646#define Clear_tm27_intr()
    4747#define Lower_tm27_intr()
    48 
    4948
    5049/*
     
    106105#define         TIMER_BCD       0x01    /* count in BCD */
    107106
     107#define CLOCK_DISABLE() \
     108    ({ char mask; inport_byte( 0x21, mask ); outport_byte( 0x21, mask | 1 ); })
     109#define CLOCK_ENABLE()  \
     110    ({ char mask; inport_byte( 0x21, mask ); outport_byte( 0x21, mask & ~1); })
     111
    108112/*      The internal tick rate in ticks per second */
    109113#define         TIMER_TICK      1193182
     
    155159/* end of include file */
    156160
     161
  • c/src/lib/libbsp/i386/go32/startup/setvec.c

    r3b170f5 r9e738b65  
    3838
    3939  if ( type )  {
    40       rtems_interrupt_catch( handler, vector,
    41                              (rtems_isr_entry *) &previous_isr );
     40     rtems_interrupt_catch( handler, vector, (rtems_isr_entry *) &previous_isr);
    4241  } else {
    43       /* Interrupt goes straight to the supplied ISR.  This code is     */
    44       /* slightly different than that in _CPU_ISR_install_vector        */
    45       /* (which is eventually called by the above) in that this code    */
    46       /* returns the raw entry point as the old handler, while the      */
    47       /* other version returns the old entry point pointed at by the    */
    48       /* rtems ISR table.                                               */
    49       _go32_dpmi_seginfo        handler_info;
    50 
    51       /* get the address of the old handler */
    52       _go32_dpmi_get_protected_mode_interrupt_vector( vector, &handler_info);
    53 
    54       /* Notice how we're failing to save the pm_segment portion of the */
    55       /* structure here?  That means we might crash the system if we    */
    56       /* try to restore the ISR.  Can't fix this until i386_isr is      */
    57       /* redefined.  XXX [BHC].                                         */
    58       previous_isr = (i386_isr_entry) handler_info.pm_offset;
    59      
    60       /* install the IDT entry */
    61       handler_info.pm_offset   = (u_long)handler;
    62       handler_info.pm_selector = _go32_my_cs();
    63       _go32_dpmi_set_protected_mode_interrupt_vector( vector, &handler_info);
     42     _CPU_ISR_install_raw_handler( vector, handler, (proc_ptr *)&previous_isr);
    6443  }
    6544  return previous_isr;
  • c/src/lib/libbsp/i386/go32/timer/timer.c

    r3b170f5 r9e738b65  
    2121 */
    2222
    23 
    2423#include <rtems.h>
    2524#include <bsp.h>
     
    3635    return result;
    3736}
     37static void restore_timer( void )
     38{
     39    CLOCK_ENABLE();
     40}
    3841#else /* pentium */
    3942rtems_isr timerisr();
     
    4245void Timer_initialize()
    4346{
     47    static int First = 1;
    4448#if defined(pentium)
     49    if ( First )  {
     50        extern int atexit( void (*)(void) );
     51        First = 0;
     52        /* Disable the programmable timer. */
     53        CLOCK_DISABLE();
     54        /* Try not to hose the system on return to DOS. */
     55        atexit( restore_timer );
     56    }
    4557    Ttimer_val = rdtsc();
    4658#else /* pentium */
    47     static int First = 1;
     59
     60#define WAIT() \
     61  { \
     62    Ttimer_val = 0; \
     63    while ( Ttimer_val == 0 ) \
     64      continue; \
     65    Ttimer_val = 0; \
     66  }
     67
    4868    if ( First )  {
     69        First = 0;
     70
    4971        /* install ISR */
    5072        set_vector( timerisr, 0x8, 0 );
    5173
    52         /* Wait for ISR to be called at least once */
    53         Ttimer_val = 0;
    54         while ( Ttimer_val == 0 )
    55             continue;
     74       /* Wait for ISR to be called at least once */
     75       WAIT();
    5676
    57         /* load timer for 250 microsecond period */
    58         outport_byte( TIMER_MODE, TIMER_SEL0|TIMER_16BIT|TIMER_RATEGEN );
    59         outport_byte( TIMER_CNTR0, US_TO_TICK(250) >> 0 & 0xff);
    60         outport_byte( TIMER_CNTR0, US_TO_TICK(250) >> 8 & 0xff);
     77       /* load timer for 250 microsecond period */
     78       outport_byte( TIMER_MODE, TIMER_SEL0|TIMER_16BIT|TIMER_RATEGEN );
     79       outport_byte( TIMER_CNTR0, US_TO_TICK(250) >> 0 & 0xff);
     80       outport_byte( TIMER_CNTR0, US_TO_TICK(250) >> 8 & 0xff);
     81    }
    6182
    62         First = 0;
    63     }
    64     Ttimer_val = 0;                           /* clear timer ISR count */
     83    /* Wait for ISR to be called at least once */
     84    WAIT();
    6585#endif /* PENTIUM */
    6686}
     
    82102    inport_byte( TIMER_CNTR0, msb );
    83103    clicks = msb << 8 | lsb;
    84     total = Ttimer_val + 250 - TICK_TO_US( clicks );
     104    total = Ttimer_val + (250 - TICK_TO_US( clicks ));
    85105#endif /* pentium */
    86106
     
    105125  Timer_driver_Find_average_overhead = find_flag;
    106126}
     127
  • c/src/lib/libbsp/i386/go32/timer/timerisr.s

    r3b170f5 r9e738b65  
    2727        PUBLIC(timerisr)
    2828
    29 SYM (timerisr): 
    30         addl    $250,_Ttimer_val   # another 250 microseconds
    31         push    edx
    32         push    eax
    33         movw    $0x20,dx
    34         mov     edx,eax
    35         outb    al,(dx) # touch interrupt controller
    36         pop     eax
    37         pop     edx
    38         iret
     29SYM (timerisr): 
     30        addl    $250,_Ttimer_val   # another 250 microseconds
     31        push    edx
     32        push    eax
     33        movw    $0x20,dx
     34        mov     edx,eax
     35        outb    al,(dx) # touch interrupt controller
     36        pop     eax
     37        pop     edx
     38        iret
    3939
    4040END_CODE
Note: See TracChangeset for help on using the changeset viewer.