Ignore:
Timestamp:
2009-11-16T21:22:54Z (14 years ago)
Author:
Lenka Trochtova <trochtova.lenka@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
5ebdf94
Parents:
fcbd1be (diff), 9c70ed6 (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:

merged with head (unstable)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/console/console.c

    rfcbd1be r1787e527  
    7171
    7272/** Kernel log spinlock */
    73 SPINLOCK_INITIALIZE(klog_lock);
     73SPINLOCK_STATIC_INITIALIZE_NAME(klog_lock, "*klog_lock");
    7474
    7575/** Physical memory area used for klog buffer */
    7676static parea_t klog_parea;
     77
     78static indev_t stdin_sink;
     79static outdev_t stdout_source;
    7780
    7881static indev_operations_t stdin_ops = {
     
    8083};
    8184
     85static void stdout_write(outdev_t *dev, wchar_t ch, bool silent);
     86static void stdout_redraw(outdev_t *dev);
     87
     88static outdev_operations_t stdout_ops = {
     89        .write = stdout_write,
     90        .redraw = stdout_redraw
     91};
     92
    8293/** Silence output */
    8394bool silent = false;
     
    90101{
    91102        if (stdin == NULL) {
    92                 stdin = malloc(sizeof(indev_t), FRAME_ATOMIC);
    93                 if (stdin != NULL)
    94                         indev_initialize("stdin", stdin, &stdin_ops);
     103                indev_initialize("stdin", &stdin_sink, &stdin_ops);
     104                stdin = &stdin_sink;
    95105        }
    96106       
    97107        return stdin;
     108}
     109
     110void stdout_wire(outdev_t *outdev)
     111{
     112        if (stdout == NULL) {
     113                outdev_initialize("stdout", &stdout_source, &stdout_ops);
     114                stdout = &stdout_source;
     115        }
     116       
     117        list_append(&outdev->link, &stdout->list);
     118}
     119
     120static void stdout_write(outdev_t *dev, wchar_t ch, bool silent)
     121{
     122        link_t *cur;
     123       
     124        for (cur = dev->list.next; cur != &dev->list; cur = cur->next) {
     125                outdev_t *sink = list_get_instance(cur, outdev_t, link);
     126                if ((sink) && (sink->op->write))
     127                        sink->op->write(sink, ch, silent);
     128        }
     129}
     130
     131static void stdout_redraw(outdev_t *dev)
     132{
     133        link_t *cur;
     134       
     135        for (cur = dev->list.next; cur != &dev->list; cur = cur->next) {
     136                outdev_t *sink = list_get_instance(cur, outdev_t, link);
     137                if ((sink) && (sink->op->redraw))
     138                        sink->op->redraw(sink);
     139        }
    98140}
    99141
     
    128170       
    129171        silent = false;
    130         arch_grab_console();
     172        if ((stdout) && (stdout->op->redraw))
     173                stdout->op->redraw(stdout);
    131174       
    132175        /* Force the console to print the prompt */
     
    137180void release_console(void)
    138181{
     182        // FIXME arch_release_console
    139183        silent = true;
    140         arch_release_console();
    141184}
    142185
     
    276319       
    277320        if (size > PAGE_SIZE)
    278                 return ELIMIT;
     321                return (unative_t) ELIMIT;
    279322       
    280323        if (size > 0) {
    281324                data = (char *) malloc(size + 1, 0);
    282325                if (!data)
    283                         return ENOMEM;
     326                        return (unative_t) ENOMEM;
    284327               
    285328                rc = copy_from_uspace(data, buf, size);
    286329                if (rc) {
    287330                        free(data);
    288                         return rc;
     331                        return (unative_t) rc;
    289332                }
    290333                data[size] = 0;
Note: See TracChangeset for help on using the changeset viewer.