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

Changeset b9c7425 in mainline


Ignore:
Timestamp:
2009-08-20T20:03:41Z (12 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master
Children:
bc7d44c
Parents:
e731b0d
Message:

prepare outdev_t devices (particularly stdout) to work as repreaters
stop messing with the stdout pointer directly, use stdout_wire() instead

Location:
kernel
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/ia64/src/drivers/ski.c

    re731b0d rb9c7425  
    129129       
    130130        outdev_initialize("skiout", &skiout, &skiout_ops);
    131         stdout = &skiout;
     131        stdout_wire(&skiout);
    132132       
    133133        sysinfo_set_item_val("fb", NULL, false);
  • kernel/arch/sparc64/src/drivers/sgcn.c

    re731b0d rb9c7425  
    380380        sysinfo_set_item_val("fb.kind", NULL, 4);
    381381
    382         outdev_initialize("sgcnout", &sgcnout, &sgcnout_ops);   
    383         stdout = &sgcnout;
     382        outdev_initialize("sgcnout", &sgcnout, &sgcnout_ops);
     383        stdout_wire(&sgcnout);
    384384}
    385385
  • kernel/genarch/src/drivers/dsrln/dsrlnout.c

    re731b0d rb9c7425  
    6666       
    6767        outdev_initialize("dsrlnout", &dsrlnout_console, &dsrlnout_ops);
    68         stdout = &dsrlnout_console;
     68        stdout_wire(&dsrlnout_console);
    6969       
    7070        sysinfo_set_item_val("fb", NULL, true);
  • kernel/genarch/src/drivers/ega/ega.c

    re731b0d rb9c7425  
    567567       
    568568        outdev_initialize("ega", &ega_console, &ega_ops);
    569         stdout = &ega_console;
     569        stdout_wire(&ega_console);
    570570       
    571571        sysinfo_set_item_val("fb", NULL, true);
  • kernel/genarch/src/fb/fb.c

    re731b0d rb9c7425  
    583583       
    584584        outdev_initialize("fb", &fb_console, &fb_ops);
    585         stdout = &fb_console;
     585        stdout_wire(&fb_console);
    586586       
    587587        return true;
  • kernel/generic/include/console/chardev.h

    re731b0d rb9c7425  
    3636#define KERN_CHARDEV_H_
    3737
     38#include <adt/list.h>
    3839#include <arch/types.h>
    3940#include <synch/waitq.h>
     
    7576} outdev_operations_t;
    7677
    77 /** Character input device. */
     78/** Character output device. */
    7879typedef struct outdev {
    7980        char *name;
     
    8182        /** Protects everything below. */
    8283        SPINLOCK_DECLARE(lock);
     84       
     85        /** Fields suitable for multiplexing. */
     86        link_t link;
     87        link_t list;
    8388       
    8489        /** Implementation of outdev operations. */
  • kernel/generic/include/console/console.h

    re731b0d rb9c7425  
    4444
    4545extern indev_t *stdin_wire(void);
     46extern void stdout_wire(outdev_t *outdev);
    4647extern void console_init(void);
    4748
  • kernel/generic/src/console/chardev.c

    re731b0d rb9c7425  
    3333 */
    3434
     35#include <adt/list.h>
    3536#include <console/chardev.h>
    3637#include <synch/waitq.h>
     
    134135        outdev->name = name;
    135136        spinlock_initialize(&outdev->lock, "outdev");
     137        link_initialize(&outdev->link);
     138        list_initialize(&outdev->list);
    136139        outdev->op = op;
    137140}
  • kernel/generic/src/console/console.c

    re731b0d rb9c7425  
    7676static parea_t klog_parea;
    7777
     78static indev_t stdin_sink;
     79static outdev_t stdout_source;
     80
    7881static indev_operations_t stdin_ops = {
    7982        .poll = NULL
    8083};
    8184
     85static void stdout_write(outdev_t *dev, wchar_t ch, bool silent);
     86
     87static outdev_operations_t stdout_ops = {
     88        .write = stdout_write
     89};
     90
    8291/** Silence output */
    8392bool silent = false;
     
    9099{
    91100        if (stdin == NULL) {
    92                 stdin = malloc(sizeof(indev_t), FRAME_ATOMIC);
    93                 if (stdin != NULL)
    94                         indev_initialize("stdin", stdin, &stdin_ops);
     101                indev_initialize("stdin", &stdin_sink, &stdin_ops);
     102                stdin = &stdin_sink;
    95103        }
    96104       
    97105        return stdin;
     106}
     107
     108void stdout_wire(outdev_t *outdev)
     109{
     110        if (stdout == NULL) {
     111                outdev_initialize("stdout", &stdout_source, &stdout_ops);
     112                stdout = &stdout_source;
     113        }
     114       
     115        list_append(&outdev->link, &stdout->list);
     116}
     117
     118static void stdout_write(outdev_t *dev, wchar_t ch, bool silent)
     119{
     120        link_t *cur;
     121       
     122        for (cur = dev->list.next; cur != &dev->list; cur = cur->next) {
     123                outdev_t *sink = list_get_instance(cur, outdev_t, link);
     124                sink->op->write(sink, ch, silent);
     125        }
    98126}
    99127
Note: See TracChangeset for help on using the changeset viewer.