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

Changeset 3da166f0 in mainline


Ignore:
Timestamp:
2014-12-08T19:34:48Z (6 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
master
Children:
f42adef
Parents:
7785ebd7 (diff), 21b6307 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge from lp:~martin-sucha/helenos/kernel-serial

Files:
9 edited

Legend:

Unmodified
Added
Removed
  • HelenOS.config

    r7785ebd7 r3da166f0  
    472472
    473473% PC keyboard support
    474 ! [CONFIG_HID_IN=generic&(PLATFORM=ia32|PLATFORM=amd64)] CONFIG_PC_KBD (y/n)
     474! [(CONFIG_HID_IN=generic|CONFIG_HID_IN=keyboard)&(PLATFORM=ia32|PLATFORM=amd64)] CONFIG_PC_KBD (y/n)
    475475
    476476% PC keyboard support
     
    498498! [(CONFIG_HID_OUT=generic|CONFIG_HID_OUT=serial)&PLATFORM=arm32&(MACHINE=integratorcp|MACHINE=raspberrypi)] CONFIG_PL011_UART (y/n)
    499499
     500% Support for NS16550 controller (kernel console)
     501! [(CONFIG_HID_IN=generic|CONFIG_HID_IN=serial|CONFIG_HID_OUT=generic|CONFIG_HID_OUT=serial)&(PLATFORM=ia32|PLATFORM=amd64)] CONFIG_NS16550_KCON (y/n)
     502
     503% Use NS16550 controller as serial input (kernel console)
     504! [(CONFIG_HID_IN=generic|CONFIG_HID_IN=serial)&(PLATFORM=ia32|PLATFORM=amd64)&CONFIG_NS16550_KCON=y] CONFIG_NS16550 (y)
     505
     506% Use NS16550 controller as dummy serial output (kernel console)
     507! [(CONFIG_HID_OUT=generic|CONFIG_HID_OUT=serial)&(PLATFORM=ia32|PLATFORM=amd64)&CONFIG_NS16550_KCON=y] CONFIG_NS16550_OUT (y)
     508
    500509% Support for Samsung S3C24XX on-chip UART
    501510! [(CONFIG_HID_OUT=generic|CONFIG_HID_OUT=serial)&PLATFORM=arm32&MACHINE=gta02] CONFIG_S3C24XX_UART (y/n)
     
    538547
    539548% Serial line input module
    540 ! [CONFIG_DSRLNIN=y|(PLATFORM=sparc32)|(PLATFORM=arm32&MACHINE=gta02)|(PLATFORM=arm32&MACHINE=integratorcp&CONFIG_PL011_UART=y)|(PLATFORM=arm32&MACHINE=beaglebone&CONFIG_OMAP_UART=y)|(PLATFORM=arm32&MACHINE=beagleboardxm&CONFIG_OMAP_UART=y)|(PLATFORM=ia64&MACHINE=i460GX&CONFIG_NS16550=y)|(PLATFORM=ia64&MACHINE=ski)|(PLATFORM=sparc64&PROCESSOR=sun4v)|(PLATFORM=arm32&MACHINE=raspberrypi&CONFIG_PL011_UART=y)] CONFIG_SRLN (y)
     549! [CONFIG_DSRLNIN=y|(PLATFORM=sparc32)|(PLATFORM=arm32&MACHINE=gta02)|(PLATFORM=arm32&MACHINE=integratorcp&CONFIG_PL011_UART=y)|(PLATFORM=arm32&MACHINE=beaglebone&CONFIG_OMAP_UART=y)|(PLATFORM=arm32&MACHINE=beagleboardxm&CONFIG_OMAP_UART=y)|(PLATFORM=ia64&MACHINE=i460GX&CONFIG_NS16550=y)|(PLATFORM=ia64&MACHINE=ski)|(PLATFORM=sparc64&PROCESSOR=sun4v)|(PLATFORM=arm32&MACHINE=raspberrypi&CONFIG_PL011_UART=y)|(PLATFORM=ia32&CONFIG_NS16550=y)|(PLATFORM=amd64&CONFIG_NS16550=y)] CONFIG_SRLN (y)
    541550
    542551% EGA support
  • kernel/arch/amd64/include/arch/interrupt.h

    r7785ebd7 r3da166f0  
    5353#define IRQ_KBD       1
    5454#define IRQ_PIC1      2
     55/* NS16550 at COM1 */
     56#define IRQ_NS16550   4
    5557#define IRQ_PIC_SPUR  7
    5658#define IRQ_MOUSE     12
  • kernel/arch/amd64/src/amd64.c

    r7785ebd7 r3da166f0  
    4949#include <genarch/drivers/ega/ega.h>
    5050#include <genarch/drivers/i8042/i8042.h>
     51#include <genarch/drivers/ns16550/ns16550.h>
    5152#include <genarch/drivers/legacy/ia32/io.h>
    5253#include <genarch/fb/bfb.h>
    5354#include <genarch/kbrd/kbrd.h>
     55#include <genarch/srln/srln.h>
    5456#include <genarch/multiboot/multiboot.h>
    5557#include <genarch/multiboot/multiboot2.h>
     
    212214        }
    213215#endif
     216
     217#if (defined(CONFIG_NS16550) || defined(CONFIG_NS16550_OUT))
     218        /*
     219         * Initialize the ns16550 controller.
     220         */
     221#ifdef CONFIG_NS16550_OUT
     222        outdev_t *ns16550_out;
     223        outdev_t **ns16550_out_ptr = &ns16550_out;
     224#else
     225        outdev_t **ns16550_out_ptr = NULL;
     226#endif
     227        ns16550_instance_t *ns16550_instance
     228            = ns16550_init((ns16550_t *) NS16550_BASE, IRQ_NS16550, NULL, NULL,
     229            ns16550_out_ptr);
     230        if (ns16550_instance) {
     231#ifdef CONFIG_NS16550
     232                srln_instance_t *srln_instance = srln_init();
     233                if (srln_instance) {
     234                        indev_t *sink = stdin_wire();
     235                        indev_t *srln = srln_wire(srln_instance, sink);
     236                        ns16550_wire(ns16550_instance, srln);
     237                        trap_virtual_enable_irqs(1 << IRQ_NS16550);
     238                }
     239#endif
     240#ifdef CONFIG_NS16550_OUT
     241                if (ns16550_out) {
     242                        stdout_wire(ns16550_out);
     243                }
     244#endif
     245        }
     246#endif
    214247       
    215248        if (irqs_info != NULL)
  • kernel/arch/ia32/include/arch/interrupt.h

    r7785ebd7 r3da166f0  
    5353#define IRQ_KBD       1
    5454#define IRQ_PIC1      2
     55/* NS16550 at COM1 */
     56#define IRQ_NS16550   4
    5557#define IRQ_PIC_SPUR  7
    5658#define IRQ_MOUSE     12
  • kernel/arch/ia32/src/ia32.c

    r7785ebd7 r3da166f0  
    5050#include <genarch/drivers/ega/ega.h>
    5151#include <genarch/drivers/i8042/i8042.h>
     52#include <genarch/drivers/ns16550/ns16550.h>
    5253#include <genarch/drivers/legacy/ia32/io.h>
    5354#include <genarch/fb/bfb.h>
    5455#include <genarch/kbrd/kbrd.h>
     56#include <genarch/srln/srln.h>
    5557#include <genarch/multiboot/multiboot.h>
    5658#include <genarch/multiboot/multiboot2.h>
     
    166168        }
    167169#endif
     170
     171#if (defined(CONFIG_NS16550) || defined(CONFIG_NS16550_OUT))
     172        /*
     173         * Initialize the ns16550 controller.
     174         */
     175#ifdef CONFIG_NS16550_OUT
     176        outdev_t *ns16550_out;
     177        outdev_t **ns16550_out_ptr = &ns16550_out;
     178#else
     179        outdev_t **ns16550_out_ptr = NULL;
     180#endif
     181        ns16550_instance_t *ns16550_instance
     182            = ns16550_init((ns16550_t *) NS16550_BASE, IRQ_NS16550, NULL, NULL,
     183            ns16550_out_ptr);
     184        if (ns16550_instance) {
     185#ifdef CONFIG_NS16550
     186                srln_instance_t *srln_instance = srln_init();
     187                if (srln_instance) {
     188                        indev_t *sink = stdin_wire();
     189                        indev_t *srln = srln_wire(srln_instance, sink);
     190                        ns16550_wire(ns16550_instance, srln);
     191                        trap_virtual_enable_irqs(1 << IRQ_NS16550);
     192                }
     193#endif
     194#ifdef CONFIG_NS16550_OUT
     195                if (ns16550_out) {
     196                        stdout_wire(ns16550_out);
     197                }
     198#endif
     199        }
     200#endif
    168201       
    169202        if (irqs_info != NULL)
  • kernel/arch/ia64/src/ia64.c

    r7785ebd7 r3da166f0  
    173173#ifdef CONFIG_NS16550
    174174        ns16550_instance_t *ns16550_instance
    175             = ns16550_init((ns16550_t *) NS16550_BASE, NS16550_IRQ, NULL, NULL);
     175            = ns16550_init((ns16550_t *) NS16550_BASE, NS16550_IRQ, NULL, NULL,
     176            NULL);
    176177        if (ns16550_instance) {
    177178                srln_instance_t *srln_instance = srln_init();
  • kernel/arch/sparc64/src/drivers/kbd.c

    r7785ebd7 r3da166f0  
    122122       
    123123        ns16550_instance_t *ns16550_instance = ns16550_init(ns16550, inr, cir,
    124             cir_arg);
     124            cir_arg, NULL);
    125125        if (ns16550_instance) {
    126126                kbrd_instance_t *kbrd_instance = kbrd_init();
  • kernel/genarch/include/genarch/drivers/ns16550/ns16550.h

    r7785ebd7 r3da166f0  
    3838#define KERN_NS16550_H_
    3939
     40#include <ddi/ddi.h>
    4041#include <ddi/irq.h>
    4142#include <typedefs.h>
     
    5051/** NS16550 registers. */
    5152typedef struct {
    52         ioport8_t rbr;      /**< Receiver Buffer Register. */
     53        union {
     54                ioport8_t rbr;      /**< Receiver Buffer Register (read). */
     55                ioport8_t thr;      /**< Transmitter Holder Register (write). */
     56        } __attribute__ ((packed));
    5357        ioport8_t ier;      /**< Interrupt Enable Register. */
    5458        union {
     
    6569        irq_t irq;
    6670        ns16550_t *ns16550;
    67         indev_t *kbrdin;
     71        indev_t *input;
     72        outdev_t *output;
     73        parea_t parea;
    6874} ns16550_instance_t;
    6975
    70 extern ns16550_instance_t *ns16550_init(ns16550_t *, inr_t, cir_t, void *);
     76extern ns16550_instance_t *ns16550_init(ns16550_t *, inr_t, cir_t, void *,
     77    outdev_t **);
    7178extern void ns16550_wire(ns16550_instance_t *, indev_t *);
    7279
  • kernel/genarch/src/drivers/ns16550/ns16550.c

    r7785ebd7 r3da166f0  
    4141#include <mm/slab.h>
    4242#include <ddi/device.h>
     43#include <str.h>
    4344
    4445#define LSR_DATA_READY  0x01
     46#define LSR_TH_READY    0x20
    4547
    4648static irq_ownership_t ns16550_claim(irq_t *irq)
     
    6264        if (pio_read_8(&dev->lsr) & LSR_DATA_READY) {
    6365                uint8_t data = pio_read_8(&dev->rbr);
    64                 indev_push_character(instance->kbrdin, data);
     66                indev_push_character(instance->input, data);
    6567        }
    6668}
     
    7375}
    7476
     77static void ns16550_sendb(ns16550_t *dev, uint8_t byte)
     78{
     79        while (!(pio_read_8(&dev->lsr) & LSR_TH_READY))
     80                ;
     81        pio_write_8(&dev->thr, byte);
     82}
     83
     84static void ns16550_putchar(outdev_t *dev, wchar_t ch)
     85{
     86        ns16550_instance_t *instance = (ns16550_instance_t *) dev->data;
     87       
     88        if ((!instance->parea.mapped) || (console_override)) {
     89                if (ascii_check(ch))
     90                        ns16550_sendb(instance->ns16550, (uint8_t) ch);
     91                else
     92                        ns16550_sendb(instance->ns16550, U_SPECIAL);
     93        }
     94}
     95
     96static outdev_operations_t ns16550_ops = {
     97        .write = ns16550_putchar,
     98        .redraw = NULL
     99};
     100
    75101/** Initialize ns16550.
    76102 *
    77103 * @param dev      Addrress of the beginning of the device in I/O space.
    78  * @param devno    Device number.
    79104 * @param inr      Interrupt number.
    80105 * @param cir      Clear interrupt function.
    81106 * @param cir_arg  First argument to cir.
     107 * @param output   Where to store pointer to the output device
     108 *                 or NULL if the caller is not interested in
     109 *                 writing to the serial port.
    82110 *
    83111 * @return Keyboard instance or NULL on failure.
    84112 *
    85113 */
    86 ns16550_instance_t *ns16550_init(ns16550_t *dev, inr_t inr, cir_t cir, void *cir_arg)
     114ns16550_instance_t *ns16550_init(ns16550_t *dev, inr_t inr, cir_t cir,
     115    void *cir_arg, outdev_t **output)
    87116{
    88117        ns16550_instance_t *instance
     
    90119        if (instance) {
    91120                instance->ns16550 = dev;
    92                 instance->kbrdin = NULL;
     121                instance->input = NULL;
     122                instance->output = NULL;
     123               
     124                if (output) {
     125                        instance->output = malloc(sizeof(outdev_t),
     126                            FRAME_ATOMIC);
     127                        if (!instance->output) {
     128                                free(instance);
     129                                return NULL;
     130                        }
     131                       
     132                        outdev_initialize("ns16550", instance->output,
     133                            &ns16550_ops);
     134                        instance->output->data = instance;
     135                        *output = instance->output;
     136                }
    93137               
    94138                irq_initialize(&instance->irq);
     
    100144                instance->irq.cir = cir;
    101145                instance->irq.cir_arg = cir_arg;
     146               
     147                instance->parea.pbase = (uintptr_t) dev;
     148                instance->parea.frames = 1;
     149                instance->parea.unpriv = false;
     150                instance->parea.mapped = false;
     151                ddi_parea_register(&instance->parea);
    102152        }
    103153       
     
    105155}
    106156
    107 void ns16550_wire(ns16550_instance_t *instance, indev_t *kbrdin)
     157void ns16550_wire(ns16550_instance_t *instance, indev_t *input)
    108158{
    109159        ASSERT(instance);
    110         ASSERT(kbrdin);
     160        ASSERT(input);
    111161       
    112         instance->kbrdin = kbrdin;
     162        instance->input = input;
    113163        irq_register(&instance->irq);
    114164       
Note: See TracChangeset for help on using the changeset viewer.