Changeset c2417bc in mainline for kernel/genarch/src/srln/srln.c


Ignore:
Timestamp:
2009-04-21T12:46:26Z (15 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f2d2c7ba
Parents:
44b7783
Message:

change the way how input devices are wired together according to ticket #44
(also the proposal http://lists.modry.cz/cgi-bin/private/helenos-devel/2009-March/002507.html)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/genarch/src/srln/srln.c

    r44b7783 rc2417bc  
    4242#include <string.h>
    4343
    44 static indev_t srlnout;
    45 
    46 indev_operations_t srlnout_ops = {
     44static indev_operations_t srln_raw_ops = {
    4745        .poll = NULL
    4846};
     
    5048static void ksrln(void *arg)
    5149{
    52         indev_t *in = (indev_t *) arg;
     50        srln_instance_t *instance = (srln_instance_t *) arg;
    5351        bool cr = false;
    5452        uint32_t escape = 0;
    5553       
    5654        while (true) {
    57                 wchar_t ch = _getc(in);
     55                wchar_t ch = indev_pop_character(&instance->raw);
    5856               
    5957                /* ANSI escape sequence processing */
     
    123121                        ch = '\b';
    124122               
    125                 indev_push_character(stdin, ch);
     123                indev_push_character(instance->sink, ch);
    126124        }
    127125}
    128126
    129 void srln_init(indev_t *devin)
     127srln_instance_t *srln_init(void)
    130128{
    131         indev_initialize("srln", &srlnout, &srlnout_ops);
    132         thread_t *thread
    133             = thread_create(ksrln, devin, TASK, 0, "ksrln", false);
     129        srln_instance_t *instance
     130            = malloc(sizeof(srln_instance_t), FRAME_ATOMIC);
     131        if (instance) {
     132                instance->thread
     133                        = thread_create(ksrln, (void *) instance, TASK, 0, "ksrln", false);
     134               
     135                if (!instance->thread) {
     136                        free(instance);
     137                        return NULL;
     138                }
     139               
     140                instance->sink = NULL;
     141                indev_initialize("srln", &instance->raw, &srln_raw_ops);
     142        }
    134143       
    135         if (thread) {
    136                 stdin = &srlnout;
    137                 thread_ready(thread);
    138         }
     144        return instance;
     145}
     146
     147indev_t *srln_wire(srln_instance_t *instance, indev_t *sink)
     148{
     149        ASSERT(instance);
     150        ASSERT(sink);
     151       
     152        instance->sink = sink;
     153        thread_ready(instance->thread);
     154       
     155        return &instance->raw;
    139156}
    140157
Note: See TracChangeset for help on using the changeset viewer.