Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 411b6a6 in mainline


Ignore:
Timestamp:
2009-03-07T16:08:40Z (13 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master
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.

Files:
1 added
1 deleted
12 edited
12 moved

Legend:

Unmodified
Added
Removed
  • HelenOS.config

    re06da7e r411b6a6  
    261261! [PLATFORM=ia64|PLATFORM=sparc64] CONFIG_PAGE_HT (y)
    262262
     263% Software integer division support
     264! [PLATFORM=ia32|PLATFORM=arm32|PLATFORM=ia64|PLATFORM=mips32|PLATFORM=ppc32] CONFIG_SOFTINT (y)
     265
     266% ASID support
     267! [PLATFORM=ia64|PLATFORM=mips32|PLATFORM=ppc32|PLATFORM=sparc64] CONFIG_ASID (y)
     268
     269% ASID FIFO support
     270! [PLATFORM=ia64|PLATFORM=mips32|PLATFORM=ppc32|PLATFORM=sparc64] CONFIG_ASID_FIFO (y)
     271
     272% OpenFirmware tree support
     273! [PLATFORM=sparc64] CONFIG_OFW_TREE (y)
     274
     275% Multiboot standard support
     276! [PLATFORM=ia32|PLATFORM=amd64] CONFIG_MULTIBOOT (y)
     277
     278% FPU support
     279! [PLATFORM=ia32|PLATFORM=amd64|PLATFORM=ia64|PLATFORM=sparc64] CONFIG_FPU (y)
     280
     281% FPU support
     282! [PLATFORM=mips32&(MACHINE=lgxemul|MACHINE=bgxemul)] CONFIG_FPU (y)
     283
     284
     285## Kernel features options
     286
     287% Support for SMP
     288! [(PLATFORM=ia32&MACHINE!=athlon_xp)|PLATFORM=amd64|PLATFORM=sparc64|PLATFORM=ia64|(PLATFORM=mips32&MACHINE=msim)] CONFIG_SMP (y/n)
     289
     290% Improved support for hyperthreading
     291! [PLATFORM=amd64&CONFIG_SMP=y] CONFIG_HT (y/n)
     292
     293% Improved support for hyperthreading
     294! [PLATFORM=ia32&MACHINE!=athlon_xp&MACHINE!=athlon_mp&MACHINE!=pentium3&CONFIG_SMP=y] CONFIG_HT (y/n)
     295
     296% Lazy FPU context switching
     297! [CONFIG_FPU=y] CONFIG_FPU_LAZY (y/n)
     298
     299% Use VHPT
     300! [PLATFORM=ia64] CONFIG_VHPT (n/y)
     301
     302% Use TSB
     303! [PLATFORM=sparc64] CONFIG_TSB (y/n)
     304
    263305% i8042 controller support
    264 ! [PLATFORM=ia32|PLATFORM=amd64|(PLATFORM=ia64&MACHINE=i460GX)] CONFIG_I8042 (y)
     306! [PLATFORM=ia32|PLATFORM=amd64|(PLATFORM=ia64&MACHINE=i460GX)] CONFIG_I8042 (y/n)
     307
     308% Support for NS16550 serial port
     309! [PLATFORM=sparc64] CONFIG_NS16550 (y/n)
     310
     311% Support for NS16550 serial port
     312! [PLATFORM=ia64&MACHINE!=ski] CONFIG_NS16550 (n/y)
     313
     314% Support for Z8530 serial port
     315! [PLATFORM=sparc64] CONFIG_Z8530 (y/n)
     316
     317% Support for Serengeti console
     318! [PLATFORM=sparc64] CONFIG_SGCN (y/n)
     319
     320% PC keyboard support
     321! [PLATFORM=ia32|PLATFORM=amd64|(PLATFORM=ia64&MACHINE=i460GX)] CONFIG_PC_KBD (y/n)
    265322
    266323% Sun keyboard support
    267 ! [PLATFORM=sparc64] CONFIG_SUN_KBD (y)
     324! [PLATFORM=sparc64] CONFIG_SUN_KBD (y/n)
    268325
    269326% EGA support
    270327! [PLATFORM=ia32|PLATFORM=amd64|(PLATFORM=ia64&MACHINE=i460GX)] CONFIG_EGA (y)
    271 
    272 % Software integer division support
    273 ! [PLATFORM=ia32|PLATFORM=arm32|PLATFORM=ia64|PLATFORM=mips32|PLATFORM=ppc32] CONFIG_SOFTINT (y)
    274 
    275 % ASID support
    276 ! [PLATFORM=ia64|PLATFORM=mips32|PLATFORM=ppc32|PLATFORM=sparc64] CONFIG_ASID (y)
    277 
    278 % ASID FIFO support
    279 ! [PLATFORM=ia64|PLATFORM=mips32|PLATFORM=ppc32|PLATFORM=sparc64] CONFIG_ASID_FIFO (y)
    280 
    281 % OpenFirmware tree support
    282 ! [PLATFORM=sparc64] CONFIG_OFW_TREE (y)
    283 
    284 % Multiboot standard support
    285 ! [PLATFORM=ia32|PLATFORM=amd64] CONFIG_MULTIBOOT (y)
    286 
    287 % FPU support
    288 ! [PLATFORM=ia32|PLATFORM=amd64|PLATFORM=ia64|PLATFORM=sparc64] CONFIG_FPU (y)
    289 
    290 % FPU support
    291 ! [PLATFORM=mips32&(MACHINE=lgxemul|MACHINE=bgxemul)] CONFIG_FPU (y)
    292 
    293 
    294 ## Kernel features options
    295 
    296 % Support for SMP
    297 ! [(PLATFORM=ia32&MACHINE!=athlon_xp)|PLATFORM=amd64|PLATFORM=sparc64|PLATFORM=ia64|(PLATFORM=mips32&MACHINE=msim)] CONFIG_SMP (y/n)
    298 
    299 % Improved support for hyperthreading
    300 ! [PLATFORM=amd64&CONFIG_SMP=y] CONFIG_HT (y/n)
    301 
    302 % Improved support for hyperthreading
    303 ! [PLATFORM=ia32&MACHINE!=athlon_xp&MACHINE!=athlon_mp&MACHINE!=pentium3&CONFIG_SMP=y] CONFIG_HT (y/n)
    304 
    305 % Lazy FPU context switching
    306 ! [CONFIG_FPU=y] CONFIG_FPU_LAZY (y/n)
    307 
    308 % Use VHPT
    309 ! [PLATFORM=ia64] CONFIG_VHPT (n/y)
    310 
    311 % Use TSB
    312 ! [PLATFORM=sparc64] CONFIG_TSB (y/n)
    313 
    314 % Support for Z8530 serial port
    315 ! [PLATFORM=sparc64] CONFIG_Z8530 (y/n)
    316 
    317 % Support for NS16550 serial port
    318 ! [PLATFORM=sparc64] CONFIG_NS16550 (y/n)
    319 
    320 % Support for NS16550 serial port
    321 ! [PLATFORM=ia64&MACHINE!=ski] CONFIG_NS16550 (n/y)
    322 
    323 % Support for Serengeti console
    324 ! [PLATFORM=sparc64] CONFIG_SGCN (y/n)
    325328
    326329% IOSapic on default address support
  • kernel/arch/amd64/src/amd64.c

    re06da7e r411b6a6  
    4444#include <genarch/drivers/ega/ega.h>
    4545#include <arch/drivers/vesa.h>
    46 #include <genarch/kbd/i8042.h>
     46#include <genarch/drivers/i8042/i8042.h>
     47#include <genarch/kbrd/kbrd.h>
    4748#include <arch/drivers/i8254.h>
    4849#include <arch/drivers/i8259.h>
     
    190191{
    191192        devno_t devno = device_assign_devno();
    192         /* keyboard controller */
    193         (void) i8042_init((i8042_t *) I8042_BASE, devno, IRQ_KBD);
     193
     194        /*
     195         * Initialize the keyboard module and conect it to stdin. Then
     196         * initialize the i8042 controller and connect it to kbrdin. Enable
     197         * keyboard interrupts.
     198         */
     199        kbrd_init(stdin);
     200        (void) i8042_init((i8042_t *) I8042_BASE, devno, IRQ_KBD, &kbrdin);
     201        trap_virtual_enable_irqs(1 << IRQ_KBD);
    194202
    195203        /*
  • kernel/arch/ia32/src/ia32.c

    re06da7e r411b6a6  
    4545#include <genarch/drivers/ega/ega.h>
    4646#include <arch/drivers/vesa.h>
    47 #include <genarch/kbd/i8042.h>
     47#include <genarch/drivers/i8042/i8042.h>
     48#include <genarch/kbrd/kbrd.h>
    4849#include <arch/drivers/i8254.h>
    4950#include <arch/drivers/i8259.h>
     
    148149{
    149150        devno_t devno = device_assign_devno();
    150         /* keyboard controller */
    151         (void) i8042_init((i8042_t *) I8042_BASE, devno, IRQ_KBD);
     151
     152        /*
     153         * Initialize the keyboard module and conect it to stdin. Then
     154         * initialize the i8042 controller and connect it to kbrdin. Enable
     155         * keyboard interrupts.
     156         */
     157        kbrd_init(stdin);
     158        (void) i8042_init((i8042_t *) I8042_BASE, devno, IRQ_KBD, &kbrdin);
     159        trap_virtual_enable_irqs(1 << IRQ_KBD);
    152160
    153161        /*
  • kernel/arch/ia64/src/ia64.c

    re06da7e r411b6a6  
    5555#include <genarch/drivers/legacy/ia32/io.h>
    5656#include <genarch/drivers/ega/ega.h>
    57 #include <genarch/kbd/i8042.h>
     57#include <genarch/kbrd/kbrd.h>
     58#include <genarch/drivers/i8042/i8042.h>
    5859#include <genarch/kbd/ns16550.h>
    5960#include <smp/smp.h>
     
    178179#else
    179180        inr = IRQ_KBD;
    180         (void) i8042_init((i8042_t *)I8042_BASE, devno, inr);
     181        kbrd_init(stdin);
     182        (void) i8042_init((i8042_t *)I8042_BASE, devno, inr, &kbrdin);
     183        trap_virtual_enable_irqs(1 << inr);
    181184        sysinfo_set_item_val("kbd.type", NULL, KBD_LEGACY);
    182185        sysinfo_set_item_val("kbd.address.physical", NULL,
  • kernel/arch/ia64/src/smp/smp.c

    re06da7e r411b6a6  
    5353#include <ddi/device.h>
    5454#include <arch/bootinfo.h>
    55 #include <genarch/kbd/i8042.h>
    56 #include <genarch/kbd/ns16550.h>
    5755#include <smp/smp.h>
    5856#include <smp/ipi.h>
  • kernel/arch/sparc64/src/console.c

    re06da7e r411b6a6  
    4141#include <arch/drivers/sgcn.h>
    4242
    43 #ifdef CONFIG_Z8530
    44 #include <genarch/kbd/z8530.h>
    45 #endif
    46 #ifdef CONFIG_NS16550
    47 #include <genarch/kbd/ns16550.h>
    48 #endif
    49 
    5043#include <console/chardev.h>
    5144#include <console/console.h>
     
    7164{
    7265#ifdef CONFIG_FB
    73         stdin = NULL;
    74 
    7566        ofw_tree_property_t *prop;
    7667        ofw_tree_node_t *screen;
  • kernel/arch/sparc64/src/drivers/kbd.c

    re06da7e r411b6a6  
    3535#include <arch/drivers/kbd.h>
    3636#include <genarch/ofw/ofw_tree.h>
     37
     38#ifdef CONFIG_SUN_KBD
     39#include <genarch/kbrd/kbrd.h>
     40#endif
    3741#ifdef CONFIG_Z8530
    38 #include <genarch/kbd/z8530.h>
     42#include <genarch/drivers/z8530/z8530.h>
    3943#endif
    4044#ifdef CONFIG_NS16550
    41 #include <genarch/kbd/ns16550.h>
    42 #endif
     45#include <genarch/drivers/ns16550/ns16550.h>
     46#endif
     47
     48#include <console/console.h>
    4349#include <ddi/device.h>
    4450#include <ddi/irq.h>
     
    160166                z8530 = (z8530_t *) hw_map(aligned_addr, offset + size) +
    161167                    offset;
    162                 (void) z8530_init(z8530, devno, inr, cir, cir_arg);
     168                kbrd_init(stdin);
     169                (void) z8530_init(z8530, devno, inr, cir, cir_arg, &kbrdin);
    163170               
    164171                /*
     
    180187                ns16550 = (ns16550_t *) hw_map(aligned_addr, offset + size) +
    181188                    offset;
    182                 (void) ns16550_init(ns16550, devno, inr, cir, cir_arg);
     189                kbrd_init(stdin);
     190                (void) ns16550_init(ns16550, devno, inr, cir, cir_arg, &kbrdin);
    183191               
    184192                /*
  • kernel/arch/sparc64/src/sparc64.c

    re06da7e r411b6a6  
    9090                 */
    9191                irq_init(1 << 11, 128);
    92 
    93                 standalone_sparc64_console_init();
    9492        }
    9593}
     
    105103void arch_post_smp_init(void)
    106104{
    107         static thread_t *t = NULL;
     105        if (config.cpu_active == 1) {
     106                standalone_sparc64_console_init();
    108107
    109         if (!t) {
    110                 /*
    111                  * Create thread that polls keyboard.
    112                  */
    113                 t = thread_create(kkbdpoll, NULL, TASK, 0, "kkbdpoll", true);
     108                /* Create thread that polls keyboard.
     109                 * XXX: this is only used by sgcn now
     110                 */
     111                thread_t *t = thread_create(kkbdpoll, NULL, TASK, 0, "kkbdpoll",
     112                    true);
    114113                if (!t)
    115114                        panic("Cannot create kkbdpoll.");
  • kernel/genarch/Makefile.inc

    re06da7e r411b6a6  
    7171ifeq ($(CONFIG_I8042),y)
    7272        GENARCH_SOURCES += \
    73                 genarch/src/kbd/i8042.c \
    74                 genarch/src/kbd/key.c \
    75                 genarch/src/kbd/scanc_pc.c
     73                genarch/src/drivers/i8042/i8042.c
     74endif
     75
     76ifeq ($(CONFIG_NS16550),y)
     77        GENARCH_SOURCES += \
     78                genarch/src/drivers/ns16550/ns16550.c
     79endif
     80
     81ifeq ($(CONFIG_Z8530),y)
     82        GENARCH_SOURCES += \
     83                genarch/src/drivers/z8530/z8530.c
     84endif
     85
     86ifeq ($(CONFIG_PC_KBD),y)
     87        GENARCH_SOURCES += \
     88                genarch/src/kbrd/kbrd.c \
     89                genarch/src/kbrd/scanc_pc.c
    7690endif
    7791
    7892ifeq ($(CONFIG_SUN_KBD),y)
    7993        GENARCH_SOURCES += \
    80                 genarch/src/kbd/key.c \
    81                 genarch/src/kbd/scanc_sun.c
     94                genarch/src/kbrd/kbrd.c \
     95                genarch/src/kbrd/scanc_sun.c
    8296endif
    8397
    84 ifeq ($(CONFIG_Z8530),y)
    85         GENARCH_SOURCES += \
    86                 genarch/src/kbd/z8530.c
    87 endif
    88 
    89 ifeq ($(CONFIG_NS16550),y)
    90         GENARCH_SOURCES += \
    91                 genarch/src/kbd/ns16550.c
    92 endif
    93 
    94 ifeq ($(CONFIG_OFW_TREE), y)
     98ifeq ($(CONFIG_OFW_TREE),y)
    9599        GENARCH_SOURCES += \
    96100                genarch/src/ofw/ofw_tree.c \
  • kernel/genarch/include/drivers/i8042/i8042.h

    re06da7e r411b6a6  
    3838#include <ddi/irq.h>
    3939#include <arch/types.h>
     40#include <console/chardev.h>
    4041#include <typedefs.h>
    4142
     
    5152        irq_t irq;
    5253        i8042_t *i8042;
     54        chardev_t *devout;
    5355} i8042_instance_t;
    5456
    55 extern bool i8042_init(i8042_t *, devno_t, inr_t);
     57extern bool i8042_init(i8042_t *, devno_t, inr_t, chardev_t *);
    5658
    5759#endif
  • kernel/genarch/include/drivers/ns16550/ns16550.h

    re06da7e r411b6a6  
    3232/**
    3333 * @file
    34  * @brief       Headers for NS 16550 serial port / keyboard driver.
     34 * @brief       Headers for NS 16550 serial controller.
    3535 */
    3636
     
    4040#include <ddi/irq.h>
    4141#include <arch/types.h>
    42 #include <arch/drivers/kbd.h>
     42#include <console/chardev.h>
    4343
    4444#define IER_ERBFI       0x01    /** Enable Receive Buffer Full Interrupt. */
     
    6767        ns16550_t *ns16550;
    6868        irq_t irq;
     69        chardev_t *devout;
    6970} ns16550_instance_t;
    7071
    71 extern bool ns16550_init(ns16550_t *, devno_t, inr_t, cir_t, void *);
     72extern bool ns16550_init(ns16550_t *, devno_t, inr_t, cir_t, void *,
     73    chardev_t *);
    7274extern irq_ownership_t ns16550_claim(irq_t *);
    7375extern void ns16550_irq_handler(irq_t *);
  • kernel/genarch/include/drivers/z8530/z8530.h

    re06da7e r411b6a6  
    11/*
    2  * Copyright (c) 2001-2004 Jakub Jermar
     2 * Copyright (c) 2009 Jakub Jermar
    33 * All rights reserved.
    44 *
     
    3232/**
    3333 * @file
    34  * @brief       Headers for Zilog 8530 serial port / keyboard driver.
     34 * @brief       Headers for Zilog 8530 serial controller.
    3535 */
    3636
     
    4040#include <ddi/irq.h>
    4141#include <arch/types.h>
     42#include <console/chardev.h>
    4243
    4344#define WR0     0
     
    118119        irq_t irq;
    119120        z8530_t *z8530;
     121        chardev_t *devout;
    120122} z8530_instance_t;
    121123
    122 extern bool z8530_init(z8530_t *, devno_t, inr_t, cir_t, void *);
     124extern bool z8530_init(z8530_t *, devno_t, inr_t, cir_t, void *, chardev_t *);
    123125extern irq_ownership_t z8530_claim(irq_t *);
    124126extern void z8530_irq_handler(irq_t *);
  • kernel/genarch/include/kbrd/kbrd.h

    re06da7e r411b6a6  
    3434 */
    3535
    36 #ifndef KERN_KEY_H_
    37 #define KERN_KEY_H_
     36#ifndef KERN_KBD_H_
     37#define KERN_KBD_H_
    3838
    39 #include <arch/types.h>
    4039#include <console/chardev.h>
    4140
    42 #define KEY_RELEASE     0x80
     41extern chardev_t kbrdin;
    4342
    44 extern chardev_t kbrd;
    45 
    46 extern void key_released(uint8_t sc);
    47 extern void key_pressed(uint8_t sc);
    48 extern uint8_t active_read_buff_read(void);
    49 extern void active_read_buff_write(uint8_t ch);
    50 extern void active_read_key_pressed(uint8_t sc);
     43extern void kbrd_init(chardev_t *);
    5144
    5245#endif
  • kernel/genarch/src/drivers/i8042/i8042.c

    re06da7e r411b6a6  
    3232/**
    3333 * @file
    34  * @brief       i8042 processor driver.
     34 * @brief       i8042 processor driver
    3535 *
    36  * It takes care of low-level keyboard functions.
     36 * It takes care of the i8042 serial communication.
    3737 */
    3838
    39 #include <genarch/kbd/i8042.h>
    40 #include <arch/drivers/kbd.h>
    41 #include <genarch/kbd/key.h>
    42 #include <genarch/kbd/scanc.h>
    43 #include <genarch/kbd/scanc_pc.h>
     39#include <genarch/drivers/i8042/i8042.h>
    4440#include <genarch/drivers/legacy/ia32/io.h>
    45 #include <cpu.h>
    4641#include <arch/asm.h>
    47 #include <arch.h>
    4842#include <console/chardev.h>
    49 #include <console/console.h>
    50 #include <interrupt.h>
    51 
    52 /* Keyboard commands. */
    53 #define KBD_ENABLE      0xf4
    54 #define KBD_DISABLE     0xf5
    55 #define KBD_ACK         0xfa
    56 
    57 /*
    58  * 60  Write 8042 Command Byte: next data byte written to port 60h is
    59  *     placed in 8042 command register. Format:
    60  *
    61  *    |7|6|5|4|3|2|1|0|8042 Command Byte
    62  *     | | | | | | | `---- 1=enable output register full interrupt
    63  *     | | | | | | `----- should be 0
    64  *     | | | | | `------ 1=set status register system, 0=clear
    65  *     | | | | `------- 1=override keyboard inhibit, 0=allow inhibit
    66  *     | | | `-------- disable keyboard I/O by driving clock line low
    67  *     | | `--------- disable auxiliary device, drives clock line low
    68  *     | `---------- IBM scancode translation 0=AT, 1=PC/XT
    69  *     `----------- reserved, should be 0
    70  */
     43#include <mm/slab.h>
    7144
    7245#define i8042_SET_COMMAND       0x60
     
    7548#define i8042_BUFFER_FULL_MASK  0x01
    7649#define i8042_WAIT_MASK         0x02
    77 #define i8042_MOUSE_DATA        0x20
    78 
    79 static void i8042_suspend(chardev_t *);
    80 static void i8042_resume(chardev_t *);
    81 
    82 static chardev_operations_t ops = {
    83         .suspend = i8042_suspend,
    84         .resume = i8042_resume,
    85 };
    8650
    8751static irq_ownership_t i8042_claim(irq_t *irq)
     
    10670                data = pio_read_8(&dev->data);
    10771                       
    108                 if ((status & i8042_MOUSE_DATA))
    109                         return;
    110 
    111                 if (data & KEY_RELEASE)
    112                         key_released(data ^ KEY_RELEASE);
    113                 else
    114                         key_pressed(data);
     72                if (instance->devout)
     73                        chardev_push_character(instance->devout, data);
    11574        }
    11675}
     
    11877/** Initialize i8042. */
    11978bool
    120 i8042_init(i8042_t *dev, devno_t devno, inr_t inr)
     79i8042_init(i8042_t *dev, devno_t devno, inr_t inr, chardev_t *devout)
    12180{
    12281        i8042_instance_t *instance;
    12382
    124         chardev_initialize("i8042_kbd", &kbrd, &ops);
    125         stdin = &kbrd;
    126        
    12783        instance = malloc(sizeof(i8042_instance_t), FRAME_ATOMIC);
    12884        if (!instance)
     
    13187        instance->devno = devno;
    13288        instance->i8042 = dev;
     89        instance->devout = devout;
    13390       
    13491        irq_initialize(&instance->irq);
     
    13996        instance->irq.instance = instance;
    14097        irq_register(&instance->irq);
    141        
    142         trap_virtual_enable_irqs(1 << inr);
    14398       
    14499        /*
     
    151106}
    152107
    153 /* Called from getc(). */
    154 void i8042_resume(chardev_t *d)
    155 {
    156 }
    157 
    158 /* Called from getc(). */
    159 void i8042_suspend(chardev_t *d)
    160 {
    161 }
    162 
    163108/** @}
    164109 */
  • kernel/genarch/src/drivers/ns16550/ns16550.c

    re06da7e r411b6a6  
    3232/**
    3333 * @file
    34  * @brief       NS 16550 serial port / keyboard driver.
     34 * @brief       NS 16550 serial controller driver.
    3535 */
    3636
    37 #include <genarch/kbd/ns16550.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>
     37#include <genarch/drivers/ns16550/ns16550.h>
    4238#include <ddi/irq.h>
    43 #include <cpu.h>
    4439#include <arch/asm.h>
    45 #include <arch.h>
    4640#include <console/chardev.h>
    47 #include <console/console.h>
    48 #include <interrupt.h>
    49 #include <arch/interrupt.h>
    50 #include <synch/spinlock.h>
    5141#include <mm/slab.h>
    5242
    5343#define LSR_DATA_READY  0x01
    54 
    55 /*
    56  * These codes read from ns16550 data register are silently ignored.
    57  */
    58 #define IGNORE_CODE     0x7f            /* all keys up */
    59 
    60 static void ns16550_suspend(chardev_t *);
    61 static void ns16550_resume(chardev_t *);
    62 
    63 static chardev_operations_t ops = {
    64         .suspend = ns16550_suspend,
    65         .resume = ns16550_resume,
    66 };
    6744
    6845/** Initialize ns16550.
     
    7350 * @param cir           Clear interrupt function.
    7451 * @param cir_arg       First argument to cir.
     52 * @param devout        Output character device.
    7553 *
    7654 * @return              True on success, false on failure.
    7755 */
    7856bool
    79 ns16550_init(ns16550_t *dev, devno_t devno, inr_t inr, cir_t cir, void *cir_arg)
     57ns16550_init(ns16550_t *dev, devno_t devno, inr_t inr, cir_t cir, void *cir_arg,
     58    chardev_t *devout)
    8059{
    8160        ns16550_instance_t *instance;
    82 
    83         chardev_initialize("ns16550_kbd", &kbrd, &ops);
    84         stdin = &kbrd;
    8561       
    8662        instance = malloc(sizeof(ns16550_instance_t), FRAME_ATOMIC);
     
    9066        instance->devno = devno;
    9167        instance->ns16550 = dev;
     68        instance->devout = devout;
    9269       
    9370        irq_initialize(&instance->irq);
     
    11188}
    11289
    113 /* Called from getc(). */
    114 void ns16550_resume(chardev_t *d)
    115 {
    116 }
    117 
    118 /* Called from getc(). */
    119 void ns16550_suspend(chardev_t *d)
    120 {
    121 }
    122 
    12390irq_ownership_t ns16550_claim(irq_t *irq)
    12491{
    125         ns16550_instance_t *ns16550_instance = irq->instance;
    126         ns16550_t *dev = ns16550_instance->ns16550;
     92        ns16550_instance_t *instance = irq->instance;
     93        ns16550_t *dev = instance->ns16550;
    12794
    12895        if (pio_read_8(&dev->lsr) & LSR_DATA_READY)
     
    134101void ns16550_irq_handler(irq_t *irq)
    135102{
    136         ns16550_instance_t *ns16550_instance = irq->instance;
    137         ns16550_t *dev = ns16550_instance->ns16550;
     103        ns16550_instance_t *instance = irq->instance;
     104        ns16550_t *dev = instance->ns16550;
    138105
    139106        if (pio_read_8(&dev->lsr) & LSR_DATA_READY) {
     
    141108               
    142109                x = pio_read_8(&dev->rbr);
    143                
    144                 if (x != IGNORE_CODE) {
    145                         if (x & KEY_RELEASE)
    146                                 key_released(x ^ KEY_RELEASE);
    147                         else
    148                                 key_pressed(x);
    149                 }
     110                if (instance->devout)
     111                        chardev_push_character(instance->devout, x);
    150112        }
    151 
    152113}
    153114
  • 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}
  • kernel/genarch/src/kbrd/scanc_pc.c

    re06da7e r411b6a6  
    3535 */
    3636
    37 #include <genarch/kbd/scanc.h>
     37#include <genarch/kbrd/scanc.h>
    3838
    3939/** Primary meaning of scancodes. */
  • kernel/genarch/src/kbrd/scanc_sun.c

    re06da7e r411b6a6  
    3535 */
    3636
    37 #include <genarch/kbd/scanc.h>
     37#include <genarch/kbrd/scanc.h>
    3838
    3939/** Primary meaning of scancodes. */
  • kernel/generic/include/console/console.h

    re06da7e r411b6a6  
    4444extern bool silent;
    4545
     46extern void console_init(void);
     47
    4648extern void klog_init(void);
    4749extern void klog_update(void);
    4850
    4951extern uint8_t getc(chardev_t *chardev);
    50 uint8_t _getc(chardev_t *chardev);
     52extern uint8_t _getc(chardev_t *chardev);
    5153extern count_t gets(chardev_t *chardev, char *buf, size_t buflen);
    5254extern void putchar(char c);
  • kernel/generic/src/console/console.c

    re06da7e r411b6a6  
    107107}
    108108
     109static void stdin_suspend(chardev_t *d)
     110{
     111}
     112
     113static void stdin_resume(chardev_t *d)
     114{
     115}
     116
     117static chardev_operations_t stdin_ops = {
     118        .suspend = stdin_suspend,
     119        .resume = stdin_resume,
     120};
     121
    109122/** Standard input character device */
     123static chardev_t _stdin;
    110124chardev_t *stdin = NULL;
    111125chardev_t *stdout = &null_stdout;
     126
     127void console_init(void)
     128{
     129        chardev_initialize("stdin", &_stdin, &stdin_ops);
     130        stdin = &_stdin;
     131}
    112132
    113133/** Initialize kernel logging facility
  • kernel/generic/src/main/main.c

    re06da7e r411b6a6  
    257257        LOG_EXEC(ipc_init());
    258258        LOG_EXEC(klog_init());
     259        LOG_EXEC(console_init());
    259260       
    260261#ifdef CONFIG_KCONSOLE
Note: See TracChangeset for help on using the changeset viewer.