From e3e6104cfa1836a221308c57d7190b864298b158 Mon Sep 17 00:00:00 2001 From: acevest Date: Tue, 16 May 2023 15:53:57 +0800 Subject: [PATCH] =?utf8?q?=E5=BC=80=E4=B8=AD=E6=96=AD=E6=89=A7=E8=A1=8C?= =?utf8?q?=E4=B8=AD=E6=96=AD=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- kernel/irq.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/kernel/irq.c b/kernel/irq.c index b9ed8b8..ff12eb7 100644 --- a/kernel/irq.c +++ b/kernel/irq.c @@ -42,24 +42,29 @@ __attribute__((regparm(1))) void irq_handler(pt_regs_t *regs) { irq_action_t *action = p->action; - atomic_inc(&preempt_count); + // atomic_inc(&preempt_count); + preempt_count++; // 还没到多处理器,暂时不用atomic_inc + + p->chip->ack(irq); + + unsigned long irq_flags; + irq_save(irq_flags); + + enable_irq(); unsigned long esp; asm("movl %%esp, %%eax" : "=a"(esp)); printl(MPL_PREEMPT, "current %08x cr3 %08x preempt %d esp %08x", current, current->cr3, preempt_count, esp); - p->chip->ack(irq); - while (action && action->handler) { action->handler(irq, regs, action->dev_id); action = action->next; } - // sti(); - // .... - // cli(); - - atomic_dec(&preempt_count); + irq_restore(irq_flags); + // atomic_dec(&preempt_count); + preempt_count--; + enable_irq(); } int request_irq(unsigned int irq, void (*handler)(unsigned int, pt_regs_t *, void *), const char *devname, -- 2.44.0