34,6 → 34,7 |
#include <ll/i386/apic.h> |
#include <ll/i386/advtimer.h> |
#include <ll/i386/error.h> |
#include <ll/i386/64bit.h> |
|
#include <ll/sys/ll/ll-data.h> |
#include <ll/sys/ll/ll-func.h> |
57,12 → 58,8 |
extern void (*evt_prol) (void); |
extern void (*evt_epil) (void); |
|
extern unsigned char use_tsc; |
extern unsigned char use_apic; |
extern unsigned long long apic_clk_per_msec; |
extern unsigned int apic_clk_per_msec; |
|
#define barrier() __asm__ __volatile__("" ::: "memory"); |
|
/* Switched to timespec */ |
int oneshot_event_post(struct timespec time, void (*handler) (void *p), |
void *par) |
105,7 → 102,11 |
} else { |
firstevent = p; |
if (!activeEvent) { |
ll_gettime(TIME_NEW, &now); |
#ifndef __TSC__ |
ll_gettime(TIME_NEW, &now); |
#else |
ll_read_timespec(&now); |
#endif |
if (TIMESPEC_A_GT_B(&now, &(firstevent->time))) { |
NULL_TIMESPEC(&tmp); |
} else { |
112,13 → 113,13 |
SUBTIMESPEC(&(firstevent->time), &now, &tmp); |
} |
tnext = TIMESPEC2USEC(&tmp); |
if (!use_apic) { |
tnext = (signed long long)(tnext) * 1193182 / 1000000; |
pit_setconstant(0, tnext); |
} else { |
tnext = (signed long long)(tnext) * apic_clk_per_msec / 1000; |
#ifndef __APIC__ |
mul32div32to32(tnext,1197,1000,tnext); |
pit_setconstant(0, tnext); |
#else |
mul32div32to32(tnext,apic_clk_per_msec,1000,tnext); |
set_APIC_timer(tnext); |
} |
#endif |
} |
} |
p->next = p1; |
132,10 → 133,12 |
{ /* CHANGE the NAME, please... */ |
struct event *p = NULL, *pp; |
struct timespec now, ttmp; |
WORD tmp; |
#ifndef __TSC__ |
WORD tmp; |
#endif |
DWORD tnext; |
|
if (!use_tsc) { |
#ifndef __TSC__ |
|
tmp = pit_read(frc); |
ADDPITSPEC((WORD) (lastTime - tmp), &globalCounter); |
143,11 → 146,11 |
|
PITSPEC2TIMESPEC(&globalCounter, &now); |
|
} else { |
#else |
|
ll_read_timespec(&now); |
|
} |
#endif |
|
if (firstevent != NULL) { |
activeEvent = 1; |
176,9 → 179,7 |
activeInt--; |
} |
|
barrier(); |
|
if (!use_tsc) { |
#ifndef __TSC__ |
|
tmp = pit_read(frc); |
ADDPITSPEC((WORD) (lastTime - tmp), &globalCounter); |
186,11 → 187,11 |
|
PITSPEC2TIMESPEC(&globalCounter, &now); |
|
} else { |
#else |
|
ll_read_timespec(&now); |
|
} |
#endif |
|
|
if (TIMESPEC_A_GT_B(&now, &(firstevent->time))) { |
200,20 → 201,20 |
} |
/* SUBTIMESPEC(&(firstevent->time), &now, &ttmp); */ |
tnext = TIMESPEC2USEC(&ttmp); |
if (!use_apic) { |
tnext = (signed long long)(tnext) * 1193182 / 1000000; |
#ifndef __APIC__ |
mul32div32to32(tnext,1197,1000,tnext); |
pit_setconstant(0, tnext); |
} else { |
tnext = (signed long long)(tnext) * apic_clk_per_msec / 1000; |
#else |
mul32div32to32(tnext,apic_clk_per_msec,1000,tnext); |
set_APIC_timer(tnext); |
} |
#endif |
activeEvent = 0; |
} else { |
if (!use_apic) { |
#ifndef __APIC__ |
pit_setconstant(0, 0xFFFF); |
} else { |
#else |
set_APIC_timer(0xFFFFFFFF); |
} |
#endif |
} |
|
} |
247,14 → 248,18 |
|
if (!activeEvent) { |
if (firstevent == NULL) { |
if (!use_apic) { |
#ifndef __APIC__ |
pit_setconstant(0, 0xFFFF); |
} else { |
#else |
set_APIC_timer(0xFFFFFFFF); |
} |
#endif |
} else { |
if (firstdeleted) { |
ll_gettime(TIME_NEW, &now); |
#ifndef __TSC__ |
ll_gettime(TIME_NEW, &now); |
#else |
ll_read_timespec(&now); |
#endif |
if (TIMESPEC_A_GT_B(&now, &(firstevent->time))) { |
NULL_TIMESPEC(&tmp); |
} else { |
262,13 → 267,13 |
} |
/*SUBTIMESPEC(&now, &(firstevent->time), &tmp); */ |
tnext = TIMESPEC2USEC(&tmp); |
if (!use_apic) { |
tnext = (signed long long)(tnext) * 1193182 / 1000000; |
#ifndef __APIC__ |
mul32div32to32(tnext,1197,1000,tnext); |
pit_setconstant(0, tnext); |
} else { |
tnext = (signed long long)(tnext) * apic_clk_per_msec / 1000; |
#else |
mul32div32to32(tnext,apic_clk_per_msec,1000,tnext); |
set_APIC_timer(tnext); |
} |
#endif |
} |
} |
} |