mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-10-27 12:48:22 +00:00
interrupt: split setipl into raiseipl and loweripl
This commit is contained in:
@@ -12,12 +12,12 @@ void interrupt_isr(int vec, context_t *ctx) {
|
||||
_panic("Unregistered interrupt", ctx);
|
||||
|
||||
if (_cpu()->ipl > isr->priority) {
|
||||
long oldipl = interrupt_setipl(isr->priority);
|
||||
long oldipl = interrupt_raiseipl(isr->priority);
|
||||
|
||||
isr->func(isr, ctx);
|
||||
interrupt_set(false);
|
||||
|
||||
interrupt_setipl(oldipl);
|
||||
interrupt_loweripl(oldipl);
|
||||
} else {
|
||||
isr->pending = true;
|
||||
}
|
||||
@@ -51,10 +51,11 @@ isr_t *interrupt_allocate(void (*func)(isr_t *self, context_t *ctx), void (*eoi)
|
||||
return isr;
|
||||
}
|
||||
|
||||
long interrupt_setipl(long ipl) {
|
||||
long interrupt_loweripl(long ipl) {
|
||||
bool oldintstatus = interrupt_set(false);
|
||||
long oldipl = _cpu()->ipl;
|
||||
_cpu()->ipl = ipl;
|
||||
if (oldipl > ipl)
|
||||
_cpu()->ipl = ipl;
|
||||
interrupt_set(oldintstatus);
|
||||
|
||||
// TODO do pending interrupts
|
||||
@@ -62,6 +63,15 @@ long interrupt_setipl(long ipl) {
|
||||
return oldipl;
|
||||
}
|
||||
|
||||
long interrupt_raiseipl(long ipl) {
|
||||
bool oldintstatus = interrupt_set(false);
|
||||
long oldipl = _cpu()->ipl;
|
||||
if (oldipl < ipl)
|
||||
_cpu()->ipl = ipl;
|
||||
interrupt_set(oldintstatus);
|
||||
return oldipl;
|
||||
}
|
||||
|
||||
void arch_interrupt_disable();
|
||||
void arch_interrupt_enable();
|
||||
|
||||
|
||||
@@ -69,18 +69,18 @@ void timer_resume(timer_t *timer) {
|
||||
}
|
||||
|
||||
void timer_stop(timer_t *timer) {
|
||||
long oldipl = interrupt_setipl(IPL_TIMER);
|
||||
long oldipl = interrupt_raiseipl(IPL_TIMER);
|
||||
spinlock_acquire(&timer->lock);
|
||||
|
||||
timer->tickcurrent += timer->stop(timer);
|
||||
timer->running = false;
|
||||
|
||||
spinlock_release(&timer->lock);
|
||||
interrupt_setipl(oldipl);
|
||||
interrupt_loweripl(oldipl);
|
||||
}
|
||||
|
||||
void timer_insert(timer_t *timer, timerentry_t* entry, time_t us) {
|
||||
long oldipl = interrupt_setipl(IPL_TIMER);
|
||||
long oldipl = interrupt_raiseipl(IPL_TIMER);
|
||||
spinlock_acquire(&timer->lock);
|
||||
|
||||
if (timer->running)
|
||||
@@ -95,7 +95,7 @@ void timer_insert(timer_t *timer, timerentry_t* entry, time_t us) {
|
||||
}
|
||||
|
||||
spinlock_release(&timer->lock);
|
||||
interrupt_setipl(oldipl);
|
||||
interrupt_loweripl(oldipl);
|
||||
}
|
||||
|
||||
timer_t *timer_new(time_t ticksperus, void (*arm)(time_t), time_t (*stop)()) {
|
||||
|
||||
Reference in New Issue
Block a user