mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-11-01 23:18:21 +00:00
interrupt: split setipl into raiseipl and loweripl
This commit is contained in:
@@ -11,10 +11,11 @@
|
|||||||
#error Unsupported architecture!
|
#error Unsupported architecture!
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define IPL_MAX -1
|
#define IPL_EXCEPT -1
|
||||||
#define IPL_NONE 0
|
#define IPL_MAX 0
|
||||||
#define IPL_TIMER 1
|
#define IPL_TIMER 1
|
||||||
#define IPL_BASE 1000
|
#define IPL_KEYBOARD 2
|
||||||
|
#define IPL_NORMAL 1000
|
||||||
|
|
||||||
struct _isr_t;
|
struct _isr_t;
|
||||||
typedef struct _isr_t {
|
typedef struct _isr_t {
|
||||||
@@ -27,7 +28,8 @@ typedef struct _isr_t {
|
|||||||
|
|
||||||
void interrupt_register(int vector, void (*func)(isr_t *self, context_t *ctx), void (*eoi)(isr_t *self), long priority);
|
void interrupt_register(int vector, void (*func)(isr_t *self, context_t *ctx), void (*eoi)(isr_t *self), long priority);
|
||||||
isr_t *interrupt_allocate(void (*func)(isr_t *self, context_t *ctx), void (*eoi)(isr_t *self), long priority);
|
isr_t *interrupt_allocate(void (*func)(isr_t *self, context_t *ctx), void (*eoi)(isr_t *self), long priority);
|
||||||
long interrupt_setipl(long newipl);
|
long interrupt_loweripl(long newipl);
|
||||||
|
long interrupt_raiseipl(long ipl);
|
||||||
bool interrupt_set(bool status);
|
bool interrupt_set(bool status);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -12,12 +12,12 @@ void interrupt_isr(int vec, context_t *ctx) {
|
|||||||
_panic("Unregistered interrupt", ctx);
|
_panic("Unregistered interrupt", ctx);
|
||||||
|
|
||||||
if (_cpu()->ipl > isr->priority) {
|
if (_cpu()->ipl > isr->priority) {
|
||||||
long oldipl = interrupt_setipl(isr->priority);
|
long oldipl = interrupt_raiseipl(isr->priority);
|
||||||
|
|
||||||
isr->func(isr, ctx);
|
isr->func(isr, ctx);
|
||||||
interrupt_set(false);
|
interrupt_set(false);
|
||||||
|
|
||||||
interrupt_setipl(oldipl);
|
interrupt_loweripl(oldipl);
|
||||||
} else {
|
} else {
|
||||||
isr->pending = true;
|
isr->pending = true;
|
||||||
}
|
}
|
||||||
@@ -51,9 +51,10 @@ isr_t *interrupt_allocate(void (*func)(isr_t *self, context_t *ctx), void (*eoi)
|
|||||||
return isr;
|
return isr;
|
||||||
}
|
}
|
||||||
|
|
||||||
long interrupt_setipl(long ipl) {
|
long interrupt_loweripl(long ipl) {
|
||||||
bool oldintstatus = interrupt_set(false);
|
bool oldintstatus = interrupt_set(false);
|
||||||
long oldipl = _cpu()->ipl;
|
long oldipl = _cpu()->ipl;
|
||||||
|
if (oldipl > ipl)
|
||||||
_cpu()->ipl = ipl;
|
_cpu()->ipl = ipl;
|
||||||
interrupt_set(oldintstatus);
|
interrupt_set(oldintstatus);
|
||||||
|
|
||||||
@@ -62,6 +63,15 @@ long interrupt_setipl(long ipl) {
|
|||||||
return oldipl;
|
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_disable();
|
||||||
void arch_interrupt_enable();
|
void arch_interrupt_enable();
|
||||||
|
|
||||||
|
|||||||
@@ -69,18 +69,18 @@ void timer_resume(timer_t *timer) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void timer_stop(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);
|
spinlock_acquire(&timer->lock);
|
||||||
|
|
||||||
timer->tickcurrent += timer->stop(timer);
|
timer->tickcurrent += timer->stop(timer);
|
||||||
timer->running = false;
|
timer->running = false;
|
||||||
|
|
||||||
spinlock_release(&timer->lock);
|
spinlock_release(&timer->lock);
|
||||||
interrupt_setipl(oldipl);
|
interrupt_loweripl(oldipl);
|
||||||
}
|
}
|
||||||
|
|
||||||
void timer_insert(timer_t *timer, timerentry_t* entry, time_t us) {
|
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);
|
spinlock_acquire(&timer->lock);
|
||||||
|
|
||||||
if (timer->running)
|
if (timer->running)
|
||||||
@@ -95,7 +95,7 @@ void timer_insert(timer_t *timer, timerentry_t* entry, time_t us) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
spinlock_release(&timer->lock);
|
spinlock_release(&timer->lock);
|
||||||
interrupt_setipl(oldipl);
|
interrupt_loweripl(oldipl);
|
||||||
}
|
}
|
||||||
|
|
||||||
timer_t *timer_new(time_t ticksperus, void (*arm)(time_t), time_t (*stop)()) {
|
timer_t *timer_new(time_t ticksperus, void (*arm)(time_t), time_t (*stop)()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user