Rewrote timer code.

The new code is based on timestamps, rather than delays. This eliminates the
need to update every timer in timer_process(), which cost a non-trivial amount
of CPU time on low-end machines.

This involved changes to every user of the timer code, so this change almost
certainly introduces bugs.
This commit is contained in:
SarahW 2018-08-02 22:06:10 +01:00
commit a7d006b637
79 changed files with 1050 additions and 1033 deletions

View file

@ -35,7 +35,7 @@ void serial_update_ints(SERIAL *serial)
stat = 1;
serial->iir = 6;
}
else if ((serial->ier & 1) && (serial->int_status & SERIAL_INT_RECEIVE)) /*Recieved data available*/
else if ((serial->ier & 1) && (serial->int_status & SERIAL_INT_RECEIVE)) /*Received data available*/
{
stat = 1;
serial->iir = 4;
@ -185,7 +185,7 @@ uint8_t serial_read(uint16_t addr, void *p)
serial_update_ints(serial);
temp = serial_read_fifo(serial);
if (serial->fifo_read != serial->fifo_write)
serial->recieve_delay = 1000 * TIMER_USEC;
timer_set_delay_u64(&serial->receive_timer, 1000 * TIMER_USEC);
break;
case 1:
if (serial->lcr & 0x80)
@ -234,12 +234,10 @@ uint8_t serial_read(uint16_t addr, void *p)
return temp;
}
void serial_recieve_callback(void *p)
void serial_receive_callback(void *p)
{
SERIAL *serial = (SERIAL *)p;
serial->recieve_delay = 0;
if (serial->fifo_read != serial->fifo_write)
{
serial->lsr |= 1;
@ -256,7 +254,7 @@ void serial1_init(uint16_t addr, int irq)
serial1.irq = irq;
serial1.addr = addr;
serial1.rcr_callback = NULL;
timer_add(serial_recieve_callback, &serial1.recieve_delay, &serial1.recieve_delay, &serial1);
timer_add(&serial1.receive_timer, serial_receive_callback, &serial1, 0);
}
void serial1_set(uint16_t addr, int irq)
{
@ -277,7 +275,7 @@ void serial2_init(uint16_t addr, int irq)
serial2.irq = irq;
serial2.addr = addr;
serial2.rcr_callback = NULL;
timer_add(serial_recieve_callback, &serial2.recieve_delay, &serial2.recieve_delay, &serial2);
timer_add(&serial2.receive_timer, serial_receive_callback, &serial2, 0);
}
void serial2_set(uint16_t addr, int irq)
{