Ignore:
Timestamp:
2009-03-07T16:08:40Z (15 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
4c84368e
Parents:
e06da7e
Message:

Complete emancipation of kernel serial controller drivers (i8042, ns16550 and
z8530). Provide a common keyboard module for PC and Sun keyboards. The serial
line module is still to follow.

File:
1 moved

Legend:

Unmodified
Added
Removed
  • kernel/genarch/src/drivers/z8530/z8530.c

    re06da7e r411b6a6  
    3232/**
    3333 * @file
    34  * @brief       Zilog 8530 serial port driver.
     34 * @brief       Zilog 8530 serial controller driver.
    3535 */
    3636
    37 #include <genarch/kbd/z8530.h>
    38 #include <genarch/kbd/key.h>
    39 #include <genarch/kbd/scanc.h>
    40 #include <genarch/kbd/scanc_sun.h>
    41 #include <arch/drivers/kbd.h>
    42 #include <console/console.h>
     37#include <genarch/drivers/z8530/z8530.h>
    4338#include <console/chardev.h>
    4439#include <ddi/irq.h>
     
    6661}
    6762
    68 /*
    69  * These codes read from z8530 data register are silently ignored.
    70  */
    71 #define IGNORE_CODE     0x7f            /* all keys up */
    72 
    73 static void z8530_suspend(chardev_t *);
    74 static void z8530_resume(chardev_t *);
    75 
    76 static chardev_operations_t ops = {
    77         .suspend = z8530_suspend,
    78         .resume = z8530_resume,
    79 };
    80 
    8163/** Initialize z8530. */
    8264bool
    83 z8530_init(z8530_t *dev, devno_t devno, inr_t inr, cir_t cir, void *cir_arg)
     65z8530_init(z8530_t *dev, devno_t devno, inr_t inr, cir_t cir, void *cir_arg,
     66    chardev_t *devout)
    8467{
    8568        z8530_instance_t *instance;
    86 
    87         chardev_initialize("z8530_kbd", &kbrd, &ops);
    88         stdin = &kbrd;
    8969
    9070        instance = malloc(sizeof(z8530_instance_t), FRAME_ATOMIC);
     
    9474        instance->devno = devno;
    9575        instance->z8530 = dev;
     76        instance->devout = devout;
    9677
    9778        irq_initialize(&instance->irq);
     
    125106}
    126107
    127 /* Called from getc(). */
    128 void z8530_resume(chardev_t *d)
    129 {
    130 }
    131 
    132 /* Called from getc(). */
    133 void z8530_suspend(chardev_t *d)
    134 {
    135 }
    136 
    137108irq_ownership_t z8530_claim(irq_t *irq)
    138109{
     
    140111        z8530_t *dev = instance->z8530;
    141112
    142         return (z8530_read(&dev->ctl_a, RR0) & RR0_RCA);
     113        if (z8530_read(&dev->ctl_a, RR0) & RR0_RCA)
     114                return IRQ_ACCEPT;
     115        else
     116                return IRQ_DECLINE;
    143117}
    144118
     
    151125        if (z8530_read(&dev->ctl_a, RR0) & RR0_RCA) {
    152126                x = z8530_read(&dev->ctl_a, RR8);
    153                 if (x != IGNORE_CODE) {
    154                         if (x & KEY_RELEASE)
    155                                 key_released(x ^ KEY_RELEASE);
    156                         else
    157                                 key_pressed(x);
    158                 }
     127                if (instance->devout)
     128                        chardev_push_character(instance->devout, x);
    159129        }
    160130}
Note: See TracChangeset for help on using the changeset viewer.