Changeset 3e53ab7 in mainline


Ignore:
Timestamp:
2008-11-28T19:33:10Z (16 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
7905360
Parents:
4c4ddbe9
Message:

Initial support for interrupt driven driver for ns16550.

Location:
kernel
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • kernel/Makefile

    r4c4ddbe9 r3e53ab7  
    125125ifeq ($(CONFIG_NS16550),y)
    126126        DEFS += -DCONFIG_NS16550
     127endif
     128
     129ifeq ($(CONFIG_NS16550_INTERRUPT_DRIVEN),y)
     130        DEFS += -DCONFIG_NS16550_INTERRUPT_DRIVEN
    127131endif
    128132
  • kernel/arch/sparc64/src/console.c

    r4c4ddbe9 r3e53ab7  
    113113#endif
    114114
     115#ifdef CONFIG_NS16550
     116#ifdef CONFIG_NS16550_INTERRUPT_DRIVEN
     117        if (kbd_type == KBD_NS16550) {
     118                /*
     119                 * The ns16550 driver is interrupt-driven.
     120                 */
     121                return;
     122        }
     123#endif
     124#endif
    115125        while (1) {
    116126#ifdef CONFIG_NS16550
     127#ifndef CONFIG_NS16550_INTERRUPT_DRIVEN
    117128                if (kbd_type == KBD_NS16550)
    118129                        ns16550_poll();
     130#endif
    119131#endif
    120132                thread_usleep(KEYBOARD_POLL_PAUSE);
  • kernel/arch/sparc64/src/drivers/kbd.c

    r4c4ddbe9 r3e53ab7  
    104104        case KBD_Z8530:
    105105                size = ((ofw_fhc_reg_t *) prop->value)->size;
    106                 if (!ofw_fhc_apply_ranges(node->parent, ((ofw_fhc_reg_t *) prop->value) , &pa)) {
     106                if (!ofw_fhc_apply_ranges(node->parent,
     107                    ((ofw_fhc_reg_t *) prop->value), &pa)) {
    107108                        printf("Failed to determine keyboard address.\n");
    108109                        return;
    109110                }
    110                 if (!ofw_fhc_map_interrupt(node->parent, ((ofw_fhc_reg_t *) prop->value), interrupts, &inr)) {
     111                if (!ofw_fhc_map_interrupt(node->parent,
     112                    ((ofw_fhc_reg_t *) prop->value), interrupts, &inr)) {
    111113                        printf("Failed to determine keyboard interrupt.\n");
    112114                        return;
     
    116118        case KBD_NS16550:
    117119                size = ((ofw_ebus_reg_t *) prop->value)->size;
    118                 if (!ofw_ebus_apply_ranges(node->parent, ((ofw_ebus_reg_t *) prop->value) , &pa)) {
     120                if (!ofw_ebus_apply_ranges(node->parent,
     121                    ((ofw_ebus_reg_t *) prop->value), &pa)) {
    119122                        printf("Failed to determine keyboard address.\n");
    120123                        return;
    121124                }
    122                 if (!ofw_ebus_map_interrupt(node->parent, ((ofw_ebus_reg_t *) prop->value), interrupts, &inr)) {
     125                if (!ofw_ebus_map_interrupt(node->parent,
     126                    ((ofw_ebus_reg_t *) prop->value), interrupts, &inr)) {
    123127                        printf("Failed to determine keyboard interrupt.\n");
    124128                        return;
     
    152156#endif
    153157        default:
    154                 printf("Kernel is not compiled with the necessary keyboard driver this machine requires.\n");
     158                printf("Kernel is not compiled with the necessary keyboard "
     159                    "driver this machine requires.\n");
    155160        }
    156161}
  • kernel/genarch/include/kbd/ns16550.h

    r4c4ddbe9 r3e53ab7  
    5959#define FCR_REG         2       /** FIFO control register (write). */
    6060#define LCR_REG         3       /** Line Control register. */
     61#define MCR_REG         4       /** Modem Control Register. */
    6162#define LSR_REG         5       /** Line Status Register. */
    6263
     
    6566#define LCR_DLAB        0x80    /** Divisor Latch Access bit. */
    6667
     68#define MCR_OUT2        0x08    /** OUT2. */
     69
    6770/** Structure representing the ns16550 device. */
    6871typedef struct {
    6972        devno_t devno;
    70         volatile ioport_t io_port;      /** Memory mapped registers of the ns16550. */
     73        /** Memory mapped registers of the ns16550. */
     74        volatile ioport_t io_port;
    7175} ns16550_t;
    7276
    7377static inline uint8_t ns16550_rbr_read(ns16550_t *dev)
    7478{
    75         return inb(dev->io_port+RBR_REG);
     79        return inb(dev->io_port + RBR_REG);
    7680}
    7781static inline void ns16550_rbr_write(ns16550_t *dev, uint8_t v)
    7882{
    79         outb(dev->io_port+RBR_REG,v);
     83        outb(dev->io_port + RBR_REG, v);
    8084}
    8185
    8286static inline uint8_t ns16550_ier_read(ns16550_t *dev)
    8387{
    84         return inb(dev->io_port+IER_REG);
     88        return inb(dev->io_port + IER_REG);
    8589}
    8690
    8791static inline void ns16550_ier_write(ns16550_t *dev, uint8_t v)
    8892{
    89         outb(dev->io_port+IER_REG,v);
     93        outb(dev->io_port + IER_REG, v);
    9094}
    9195
    9296static inline uint8_t ns16550_iir_read(ns16550_t *dev)
    9397{
    94         return inb(dev->io_port+IIR_REG);
     98        return inb(dev->io_port + IIR_REG);
    9599}
    96100
    97101static inline void ns16550_fcr_write(ns16550_t *dev, uint8_t v)
    98102{
    99         outb(dev->io_port+FCR_REG,v);
     103        outb(dev->io_port + FCR_REG, v);
    100104}
    101105
    102106static inline uint8_t ns16550_lcr_read(ns16550_t *dev)
    103107{
    104         return inb(dev->io_port+LCR_REG);
     108        return inb(dev->io_port + LCR_REG);
    105109}
    106110
    107111static inline void ns16550_lcr_write(ns16550_t *dev, uint8_t v)
    108112{
    109         outb(dev->io_port+LCR_REG,v);
     113        outb(dev->io_port + LCR_REG, v);
    110114}
    111115
    112116static inline uint8_t ns16550_lsr_read(ns16550_t *dev)
    113117{
    114         return inb(dev->io_port+LSR_REG);
     118        return inb(dev->io_port + LSR_REG);
    115119}
    116120
     121static inline uint8_t ns16550_mcr_read(ns16550_t *dev)
     122{
     123        return inb(dev->io_port + MCR_REG);
     124}
    117125
     126static inline void ns16550_mcr_write(ns16550_t *dev, uint8_t v)
     127{
     128        outb(dev->io_port + MCR_REG, v);
     129}
    118130
    119131#endif
  • kernel/genarch/src/kbd/ns16550.c

    r4c4ddbe9 r3e53ab7  
    135135        sysinfo_set_item_val("kbd.address.virtual", NULL, port);
    136136
     137#ifdef CONFIG_NS16550_INTERRUPT_DRIVEN
     138        /* Enable interrupts */
     139        ns16550_ier_write(&ns16550, IER_ERBFI);
     140        ns16550_mcr_write(&ns16550, MCR_OUT2);
     141#endif
     142
    137143#ifdef ia64
    138144        uint8_t c;
     
    150156void ns16550_interrupt(void)
    151157{
    152         /* TODO
    153          *
    154          * ns16550 works in the polled mode so far.
    155          */
     158        ns16550_poll();
    156159}
    157160
     
    202205void ns16550_poll(void)
    203206{
     207#ifndef CONFIG_NS16550_INTERRUPT_DRIVEN
    204208        ipl_t ipl;
    205209
     
    221225        spinlock_unlock(&ns16550_irq.lock);
    222226        interrupts_restore(ipl);
     227#endif
    223228
    224229        while (ns16550_lsr_read(&ns16550) & LSR_DATA_READY) {
     
    252257void ns16550_irq_handler(irq_t *irq, void *arg, ...)
    253258{
    254         panic("Not yet implemented, ns16550 works in polled mode.\n");
     259        if (irq->notif_cfg.notify && irq->notif_cfg.answerbox)
     260                ipc_irq_send_notif(irq);
     261        else
     262                ns16550_interrupt();
    255263}
    256264
  • kernel/kernel.config

    r4c4ddbe9 r3e53ab7  
    142142! [ARCH=sparc64|ARCH=ia64] CONFIG_NS16550 (y/n)
    143143
     144# Interrupt-driven driver for NS16550?
     145! [CONFIG_NS16550=y] CONFIG_NS16550_INTERRUPT_DRIVEN (n/y)
    144146
    145147# Virtually indexed D-cache support
Note: See TracChangeset for help on using the changeset viewer.