Subversion Repositories shark

Compare Revisions

Ignore whitespace Rev 298 → Rev 299

/shark/trunk/oslib/kl/event.c
34,6 → 34,7
#include <ll/i386/hw-arch.h>
#include <ll/i386/pic.h>
#include <ll/i386/pit.h>
#include <ll/i386/apic.h>
#include <ll/i386/advtimer.h>
 
#include <ll/sys/ll/ll-data.h>
71,6 → 72,8
extern void (*evt_epil) (void);
 
extern unsigned char use_tsc;
extern unsigned char use_apic;
extern signed long long apic_clk_per_msec;
 
void event_setlasthandler(void *p)
{
207,22 → 210,31
void event_init(struct ll_initparms *l)
{
extern void ll_timer(void);
extern void ll_apic_timer(void);
int i;
BYTE mask;
TIME t;
DWORD apic_clk;
 
if (use_tsc) ll_init_advtimer();
 
IDT_place(0x40,ll_timer);
if (!use_apic)
IDT_place(0x40,ll_timer);
else
IDT_place(0x40,ll_apic_timer);
 
if (l->mode != LL_PERIODIC) {
message("One-shot mode\n");
t = 0;
/* Mode: Binary/Mode 4/16 bit Time_const/Counter 0 */
pit_init(0, TMR_MD4, 0xFFFF); /* Timer 0, Mode 4, constant 0xFFFF */
if (!use_apic) {
/* Mode: Binary/Mode 4/16 bit Time_const/Counter 0 */
pit_init(0, TMR_MD4, 0xFFFF); /* Timer 0, Mode 4, constant 0xFFFF */
} else
setup_APIC_LVTT(0xFFFFFFFF);
} else {
t = l->tick;
/* Translate the tick value in usec into a suitable time constant */
/* Translate the tick value in usec into a suitable time constant */
/* for 8254 timer chip; the chip is driven with a 1.19718 MHz */
/* frequency; then the effective frequency is given by the base */
/* frequency divided for the time constant; the tick is the inverse */
230,35 → 242,47
/* Time-Constant = f_base (MHz) * tick (usec) */
/* If T-C == 0 -> T-C = 65536 (Max available) */
ticksize = t;
t = (signed long long)(t) * 1193182 / 1000000;
 
/* Only for security! This should cause timer overrun */
/* While 0 would set maximum period on timer */
if (t == 0)
t = 1;
pit_time_const = (WORD) (t & 0xFFFF);
/* Mode: Binary/Mode 2/16 bit Time_const/Counter 0 */
pit_init(0, TMR_MD2, t); /* Timer 0, Mode 2, Time constant t */
if (!use_apic) {
t = (signed long long)(t) * 1193182 / 1000000;
 
/* Only for security! This should cause timer overrun */
/* While 0 would set maximum period on timer */
if (t == 0)
t = 1;
pit_time_const = (WORD) (t & 0xFFFF);
/* Mode: Binary/Mode 2/16 bit Time_const/Counter 0 */
pit_init(0, TMR_MD2, t); /* Timer 0, Mode 2, Time constant t */
} else {
 
apic_clk = (signed long long)(t) * apic_clk_per_msec / 1000;
 
setup_APIC_LVTT(apic_clk);
 
}
}
timermode = l->mode;
if (ll_arch.x86.cpu > 4) {
/* Timer1: mode 0, time const 0... */
if (!use_apic) {
if (ll_arch.x86.cpu > 4) {
/* Timer1: mode 0, time const 0... */
pit_init(1, TMR_MD0, 0);
frc = 1;
} else {
} else {
frc = 2;
pit_init(2, TMR_MD0, 0);
outp(0x61, 3);
}
 
mask = ll_in(0x21);
mask &= 0xFE; /* 0xFE = ~0x01 */
ll_out(0x21, mask);
}
 
mask = ll_in(0x21);
mask &= 0xFE; /* 0xFE = ~0x01 */
ll_out(0x21, mask);
 
 
/* Init the event list... */
for (i = 0; i < MAX_EVENT; i++) {
if (i < MAX_EVENT - 1) {
289,5 → 313,6
}
 
/* Last but not least... */
irq_unmask(0);
if (!use_apic) irq_unmask(0);
 
}