Subversion Repositories shark

Compare Revisions

Regard whitespace Rev 618 → Rev 619

/shark/trunk/oslib/kl/event.c
77,6 → 77,7
extern void (*evt_epil) (void);
 
extern unsigned int apic_clk_per_msec;
extern unsigned char use_apic, use_tsc;
 
void event_setlasthandler(void *p)
{
94,8 → 95,7
}
 
/* Switched to timespec */
int periodic_event_post(struct timespec time, void (*handler) (void *p),
void *par)
int periodic_event_post(struct timespec time, void (*handler) (void *p), void *par)
{
struct event *p;
struct event *p1, *t;
174,19 → 174,18
}
 
void periodic_wake_up(void)
{ /* CHANGE the NAME, please... */
{
/* CHANGE the NAME, please... */
struct event *p, *pp;
#ifndef __TSC__
WORD tmp;
#endif
 
TRACER_LOGEVENT(FTrace_EVT_timer_wakeup_start, 0, 0);
 
#ifndef __TSC__
if (use_tsc) {
tmp = pit_read(frc);
ADDPITSPEC((WORD) (lastTime - tmp), &globalCounter);
lastTime = tmp;
#endif
}
activeInt++;
if (activeInt == 1 && evt_prol != NULL) {
193,11 → 192,10
evt_prol();
}
 
#ifndef __TSC__
if (use_tsc)
ll_read_timespec(&actTime);
else
ADDNANO2TIMESPEC(nts, &actTime);
#else
ll_read_timespec(&actTime);
#endif
for (p = firstevent; p != NULL; p = pp) {
/*
223,7 → 221,6
activeInt--;
 
TRACER_LOGEVENT(FTrace_EVT_timer_wakeup_end, (unsigned short int)currCtx, 0);
 
}
 
void event_init(struct ll_initparms *l)
233,31 → 230,27
int i;
BYTE mask;
TIME t;
#ifdef __APIC__
DWORD apic_clk;
#endif
 
#ifdef __TSC__
if (use_tsc)
ll_init_advtimer();
#endif
 
#ifndef __APIC__
if (use_apic)
IDT_place(0x39,ll_apic_timer);
else
IDT_place(0x40,ll_timer);
#else
IDT_place(0x39,ll_apic_timer);
#endif
 
if (l->mode != LL_PERIODIC) {
message("One-shot mode\n");
t = 0;
#ifndef __APIC__
/* Mode: Binary/Mode 4/16 bit Time_const/Counter 0 */
pit_init(0, TMR_MD4, 0xFFFF); /* Timer 0, Mode 4, constant 0xFFFF */
#else
if (use_apic) {
set_APIC_timer(0xFFFFFFFF);
enable_APIC_timer();
#endif
} else {
/* Mode: Binary/Mode 4/16 bit Time_const/Counter 0 */
pit_init(0, TMR_MD4, 0xFFFF); /* Timer 0, Mode 4, constant 0xFFFF */
}
} else {
t = l->tick;
/* Translate the tick value in usec into a suitable time constant */
269,8 → 262,11
/* If T-C == 0 -> T-C = 65536 (Max available) */
ticksize = t;
 
#ifndef __APIC__
 
if (use_apic) {
mul32div32to32(t,apic_clk_per_msec,1000,apic_clk);
set_APIC_timer(apic_clk);
enable_APIC_timer();
} else {
mul32div32to32(t,1193182,1000000,t);
 
/* Only for security! This should cause timer overrun */
280,18 → 276,11
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
 
mul32div32to32(t,apic_clk_per_msec,1000,apic_clk);
set_APIC_timer(apic_clk);
enable_APIC_timer();
 
#endif
}
}
timermode = l->mode;
#ifndef __APIC__
if (!use_apic) {
if (ll_arch.x86.cpu > 4) {
/* Timer1: mode 0, time const 0... */
pit_init(1, TMR_MD0, 0);
301,7 → 290,7
pit_init(2, TMR_MD0, 0);
outp(0x61, 3);
}
#endif
}
 
mask = ll_in(0x21);
mask &= 0xFE; /* 0xFE = ~0x01 */
337,8 → 326,6
}
 
/* Last but not least... */
#ifndef __APIC__
if (!use_apic)
irq_unmask(0);
#endif
 
}