Example #1
0
/* Прорецедура инициализации системного таймера. */
void init_timer(){
    
    outb(MODE_PORT, (COUNTER_0 | ACCESS_LOW | ACCESS_HIGH | MODE_3 | BINARY_COUNTER));
    outb(PORT_COUNTER_0, LOW_U8 (COUNTER_DIVISOR (ticks)));
    outb(PORT_COUNTER_0, HIGH_U8 (COUNTER_DIVISOR (ticks)));
    set_handler_irq(timer, 0);
    printf("Init Timer\n"); 
}
Example #2
0
void timer_init (void)
{
  /* Channel 0. */
  
  port_out_u8 (PIT_MODE_PORT, 
               (COUNTER_0_SELECT | ACCESS_LOW_COUNTER_U8 |
                ACCESS_HIGH_COUNTER_U8 | MODE_3_SELECT | BINARY_COUNTER));

  /* LSB first, then MSB. */

  port_out_u8 (PIT_COUNTER_DIVISOR, LOW_U8 (COUNTER_DIVISOR (hz)));
  port_out_u8 (PIT_COUNTER_DIVISOR, HIGH_U8 (COUNTER_DIVISOR (hz)));

  /* Channel 2. We use this to get a good timer. Or, more correctly,
     we should use it. ;) FIXME */

  port_out_u8 (PIT_MODE_PORT,
               (COUNTER_2_SELECT | ACCESS_LOW_COUNTER_U8 |
                ACCESS_HIGH_COUNTER_U8 | MODE_3_SELECT | BINARY_COUNTER));
  port_out_u8 (PIT_COUNTER_2, LOW_U8 (COUNTER_DIVISOR (1000)));
  port_out_u8 (PIT_COUNTER_2, HIGH_U8 (COUNTER_DIVISOR (1000)));
}