Subversion Repositories HelenOS

Rev

Rev 2071 | Rev 2218 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2071 Rev 2107
Line 66... Line 66...
66
    return IRQ_ACCEPT;
66
    return IRQ_ACCEPT;
67
}
67
}
68
 
68
 
69
static void i8254_irq_handler(irq_t *irq, void *arg, ...)
69
static void i8254_irq_handler(irq_t *irq, void *arg, ...)
70
{
70
{
-
 
71
    /*
-
 
72
     * This IRQ is responsible for kernel preemption.
-
 
73
     * Nevertheless, we are now holding a spinlock which prevents
-
 
74
     * preemption. For this particular IRQ, we don't need the
-
 
75
     * lock. We just release it, call clock() and then reacquire it again.
-
 
76
     */
-
 
77
    spinlock_unlock(&irq->lock);
71
    clock();
78
    clock();
-
 
79
    spinlock_lock(&irq->lock);
72
}
80
}
73
 
81
 
74
void i8254_init(void)
82
void i8254_init(void)
75
{
83
{
76
    irq_initialize(&i8254_irq);
84
    irq_initialize(&i8254_irq);
Line 134... Line 142...
134
 
142
 
135
    outb(CLK_PORT4, 0xd2);
143
    outb(CLK_PORT4, 0xd2);
136
    o2 = inb(CLK_PORT1);
144
    o2 = inb(CLK_PORT1);
137
    o2 |= inb(CLK_PORT1) << 8;
145
    o2 |= inb(CLK_PORT1) << 8;
138
 
146
 
-
 
147
    CPU->delay_loop_const =
-
 
148
        ((MAGIC_NUMBER * LOOPS) / 1000) / ((t1 - t2) - (o1 - o2)) +
139
    CPU->delay_loop_const = ((MAGIC_NUMBER*LOOPS)/1000) / ((t1-t2)-(o1-o2)) + (((MAGIC_NUMBER*LOOPS)/1000) % ((t1-t2)-(o1-o2)) ? 1 : 0);
149
        (((MAGIC_NUMBER * LOOPS) / 1000) % ((t1 - t2) - (o1 - o2)) ? 1 : 0);
140
 
150
 
141
    clk1 = get_cycle();
151
    clk1 = get_cycle();
142
    delay(1 << SHIFT);
152
    delay(1 << SHIFT);
143
    clk2 = get_cycle();
153
    clk2 = get_cycle();
144
   
154