Ignore:
Timestamp:
2019-04-04T18:08:51Z (5 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
5d97627
Parents:
e064102
Message:

Reorganize interrupt and IRQ handling on mips32

This allows msim to use MIPS CPU interrupt numbers as IRQ numbers and
Malta to use ISA IRQ numbers as IRQ numbers. Common code can still
register MIPS CPU interrupts by their respective numbers.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/mips32/src/mach/malta/malta.c

    re064102 r124bc22  
    4242#include <genarch/srln/srln.h>
    4343#include <arch/interrupt.h>
     44#include <stdbool.h>
     45#include <byteorder.h>
     46#include <log.h>
    4447
    4548static void malta_init(void);
     
    6871#endif
    6972
    70 #ifdef CONFIG_NS16550
    71 static void tty_clear_interrupt(void *arg, inr_t inr)
     73static void malta_isa_irq_handler(unsigned int i)
    7274{
    73         (void) pio_read_8((ioport8_t *) GT64120_PCI0_INTACK);
     75        uint8_t isa_irq = host2uint32_t_le(pio_read_32(GT64120_PCI0_INTACK));
     76        irq_t *irq = irq_dispatch_and_lock(isa_irq);
     77        if (irq) {
     78                irq->handler(irq);
     79                irq_spinlock_unlock(&irq->lock, false);
     80        } else {
     81#ifdef CONFIG_DEBUG
     82                log(LF_ARCH, LVL_DEBUG, "cpu%u: spurious IRQ (irq=%u)",
     83                    CPU->id, isa_irq);
     84#endif
     85        }
    7486        pic_eoi();
    7587}
    76 #endif
    7788
    7889void malta_init(void)
    7990{
     91        irq_init(16, 16);
     92
    8093        i8259_init((i8259_t *) PIC0_BASE, (i8259_t *) PIC1_BASE, 2, 0, 8);
     94
     95        int_handler[INT_HW0] = malta_isa_irq_handler;
     96        cp0_unmask_int(INT_HW0);
    8197
    8298#if (defined(CONFIG_NS16550) || defined(CONFIG_NS16550_OUT))
     
    86102        outdev_t **tty_out_ptr = NULL;
    87103#endif
    88         tty_instance = ns16550_init((ioport8_t *) TTY_BASE, 0, TTY_CPU_INT,
    89             tty_clear_interrupt, NULL, tty_out_ptr);
     104        tty_instance = ns16550_init((ioport8_t *) TTY_BASE, 0, TTY_ISA_IRQ,
     105            NULL, NULL, tty_out_ptr);
    90106#endif
    91107}
     
    121137                        ns16550_wire(tty_instance, srln);
    122138                        pic_enable_irqs(1 << TTY_ISA_IRQ);
    123                         cp0_unmask_int(TTY_CPU_INT);
    124139                }
    125140        }
Note: See TracChangeset for help on using the changeset viewer.