If a shutdown occurs while the machine is already shutdown, then keep
the original shutdown reason code.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
It's tricky to reschedule the timer irq correctly (due to race
conditions with the irq) and in practice it's very rarely needed.
Handle the special cases in the generic sched.c code so that the board
code doesn't have to handle it.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Introduce a dummy sentinel timer object that is always the last item
on timer_list. This optimizes the timer_list walking code as it no
longer needs to check for NULL when traversing the list.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Tweak the AVR register pressure optimization in reschedule_timer() to
optimize it further. This improves the performance of AVR timers when
there are several pending timers.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Some architectures are faster passing regular integers than 8bit
integers. Use uint_fast8_t so that the architecture chooses the
appropriate type.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
The AVR wants a uint8_t return type for irq_save(), but other
architectures will generally prefer int. Allow the board to configure
the size of the flag by introducing an irqstatus_t typedef.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>