More timer fixes, fixes Trantor T128b.

This commit is contained in:
OBattler
2023-08-20 00:04:52 +02:00
parent 5b56f3a450
commit 13659d7a4c
2 changed files with 47 additions and 28 deletions

View File

@@ -378,7 +378,7 @@ const cpu_family_t cpu_families[] = {
}, {
.package = CPU_PKG_SOCKET1,
.manufacturer = "Intel",
.name = "i486SX (SL-Enhanced)",
.name = "i486SX-S",
.internal_name = "i486sx_slenh",
.cpus = (const CPU[]) {
{"25", CPU_i486SX_SLENH, fpus_486sx, 25000000, 1, 5000, 0x423, 0x423, 0, CPU_SUPPORTS_DYNAREC, 4, 4,3,3, 3},
@@ -409,7 +409,7 @@ const cpu_family_t cpu_families[] = {
}, {
.package = CPU_PKG_SOCKET1,
.manufacturer = "Intel",
.name = "i486DX (SL-Enhanced)",
.name = "i486DX-S",
.internal_name = "i486dx_slenh",
.cpus = (const CPU[]) {
{"33", CPU_i486DX_SLENH, fpus_internal, 33333333, 1, 5000, 0x414, 0x414, 0, CPU_SUPPORTS_DYNAREC, 6, 6,3,3, 4},
@@ -430,7 +430,7 @@ const cpu_family_t cpu_families[] = {
}, {
.package = CPU_PKG_SOCKET1,
.manufacturer = "Intel",
.name = "i486DX2 (SL-Enhanced)",
.name = "i486DX2-S",
.internal_name = "i486dx2_slenh",
.cpus = (const CPU[]) {
{"40", CPU_i486DX_SLENH, fpus_internal, 40000000, 2, 5000, 0x435, 0x435, 0, CPU_SUPPORTS_DYNAREC, 7, 7,6,6, 5},

View File

@@ -15,7 +15,9 @@ pc_timer_t *timer_head = NULL;
/* Are we initialized? */
int timer_inited = 0;
static void timer_advance_ex(pc_timer_t *timer);
static int timer_in_process = 0;
static void timer_advance_ex(pc_timer_t *timer, int start);
void
timer_enable(pc_timer_t *timer)
@@ -114,6 +116,8 @@ timer_process(void)
if (!timer_head)
return;
timer_in_process = 0;
while (1) {
timer = timer_head;
@@ -127,18 +131,18 @@ timer_process(void)
timer->next = timer->prev = NULL;
timer->flags &= ~TIMER_ENABLED;
timer->flags |= TIMER_PROCESS;
if (timer->flags & TIMER_SPLIT)
timer_advance_ex(timer); /* We're splitting a > 1 s period into
timer_advance_ex(timer, 0); /* We're splitting a > 1 s period into
multiple <= 1 s periods. */
else if (timer->callback != NULL) /* Make sure it's not NULL, so that we can
have a NULL callback when no operation
is needed. */
timer->callback(timer->priv);
timer->flags &= ~TIMER_PROCESS;
}
timer_target = timer_head->ts.ts32.integer;
timer_in_process = 1;
}
void
@@ -191,47 +195,62 @@ timer_stop(pc_timer_t *timer)
return;
timer->period = 0.0;
if (timer_is_enabled(timer))
timer_disable(timer);
timer_disable(timer);
timer->flags &= ~TIMER_SPLIT;
}
static void
timer_do_period(pc_timer_t *timer, uint64_t period)
timer_do_period(pc_timer_t *timer, uint64_t period, int start)
{
if (timer->flags & TIMER_PROCESS)
timer_advance_u64(timer, period);
else
if (!timer_inited || (timer == NULL))
return;
if (start)
timer_set_delay_u64(timer, period);
else
timer_advance_u64(timer, period);
}
static void
timer_advance_ex(pc_timer_t *timer)
timer_advance_ex(pc_timer_t *timer, int start)
{
double dusec = ((double) TIMER_USEC);
double period;
if (!timer_inited || (timer == NULL))
return;
period = (timer->period > MAX_USEC) ? MAX_USEC64 : timer->period;
if (timer->period > 0.0) {
timer_do_period(timer, (uint64_t) (period * dusec));
timer->period -= period;
timer->flags = (timer->flags & ~TIMER_SPLIT) | ((timer->period > MAX_USEC) ? TIMER_SPLIT : 0);
} else if (timer_is_enabled(timer)) {
timer_disable(timer);
if (timer->period > MAX_USEC) {
timer_do_period(timer, MAX_USEC64 * TIMER_USEC, start);
timer->period -= MAX_USEC;
timer->flags |= TIMER_SPLIT;
} else {
if (timer->period > 0.0)
timer_do_period(timer, (uint64_t) (timer->period * ((double) TIMER_USEC)), start);
else
timer_disable(timer);
timer->period = 0.0;
timer->flags &= ~TIMER_SPLIT;
}
}
static void
timer_on(pc_timer_t *timer, double period, int start)
{
if (!timer_inited || (timer == NULL))
return;
timer->period = period;
timer_advance_ex(timer, start);
}
void
timer_on_auto(pc_timer_t *timer, double period)
{
uint32_t *p = NULL;
if (!timer_inited || (timer == NULL))
return;
if (period > 0.0) {
timer->period = period;
timer_advance_ex(timer);
} else if (timer_is_on(timer))
if (period > 0.0)
timer_on(timer, period, !timer_in_process && (timer->period <= 0.0));
else
timer_stop(timer);
}