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

Changeset bbc6277 in mainline


Ignore:
Timestamp:
2017-11-30T17:00:09Z (4 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master
Children:
b5abaf7
Parents:
7f345cd0
Message:

Chardev output needs buffering.

Location:
uspace/srv/hid/output
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/hid/output/ctl/serial.c

    r7f345cd0 rbbc6277  
    105105}
    106106
     107static void serial_flush(outdev_t *dev)
     108{
     109        vt100_state_t *state = (vt100_state_t *) dev->data;
     110
     111        vt100_flush(state);
     112}
     113
    107114static outdev_ops_t serial_ops = {
    108115        .yield = serial_yield,
     
    111118        .get_caps = serial_get_caps,
    112119        .cursor_update = serial_cursor_update,
    113         .char_update = serial_char_update
     120        .char_update = serial_char_update,
     121        .flush = serial_flush
    114122};
    115123
    116124int serial_init(vt100_putchar_t putchar_fn,
    117     vt100_control_puts_t control_puts_fn)
     125    vt100_control_puts_t control_puts_fn, vt100_flush_t flush_fn)
    118126{
    119127        vt100_state_t *state =
    120128            vt100_state_create(SERIAL_COLS, SERIAL_ROWS, putchar_fn,
    121             control_puts_fn);
     129            control_puts_fn, flush_fn);
    122130        if (state == NULL)
    123131                return ENOMEM;
  • uspace/srv/hid/output/ctl/serial.h

    r7f345cd0 rbbc6277  
    3636#include "../proto/vt100.h"
    3737
    38 extern int serial_init(vt100_putchar_t, vt100_control_puts_t);
     38extern int serial_init(vt100_putchar_t, vt100_control_puts_t, vt100_flush_t);
    3939
    4040#endif
  • uspace/srv/hid/output/output.c

    r7f345cd0 rbbc6277  
    219219                dev->ops.cursor_update(dev, prev_col, prev_row, col, row,
    220220                    visible);
     221                dev->ops.flush(dev);
     222
    221223        }
    222224       
     
    342344                        }
    343345                }
    344         }
     346               
     347                dev->ops.flush(dev);
     348        }
     349       
    345350       
    346351        async_answer_0(iid, EOK);
     
    380385                        }
    381386                }
    382         }
    383        
     387                dev->ops.flush(dev);
     388
     389        }
    384390        async_answer_0(iid, EOK);
    385391}
  • uspace/srv/hid/output/output.h

    r7f345cd0 rbbc6277  
    5252            sysarg_t prev_row, sysarg_t col, sysarg_t row, bool visible);
    5353        void (* char_update)(struct outdev *dev, sysarg_t col, sysarg_t row);
     54        void (* flush)(struct outdev *dev);
    5455} outdev_ops_t;
    5556
  • uspace/srv/hid/output/port/chardev.c

    r7f345cd0 rbbc6277  
    4646#include "chardev.h"
    4747
     48enum {
     49        chardev_buf_size = 4096
     50};
     51
    4852static char *console;
    4953
     
    5357static service_id_t console_cat_id;
    5458
     59static uint8_t chardev_buf[chardev_buf_size];
     60static size_t chardev_bused;
     61
    5562static FIBRIL_MUTEX_INITIALIZE(discovery_lock);
    5663static bool discovery_finished;
    5764static FIBRIL_CONDVAR_INITIALIZE(discovery_cv);
    5865
     66static void chardev_flush(void)
     67{
     68        size_t nwr;
     69
     70        if (chardev_bused == 0)
     71                return;
     72
     73        chardev_write(chardev, chardev_buf, chardev_bused, &nwr);
     74        /* XXX Handle error */
     75
     76        chardev_bused = 0;
     77}
     78
    5979static void chardev_putchar(wchar_t ch)
    6080{
    61         uint8_t byte = (uint8_t) ch;
    62         size_t nwr;
    63         chardev_write(chardev, &byte, 1, &nwr);
    64         /* XXX Handle error */
     81        if (chardev_bused == chardev_buf_size)
     82                chardev_flush();
     83        if (!ascii_check(ch))
     84                ch = '?';
     85        chardev_buf[chardev_bused++] = (uint8_t) ch;
    6586}
    6687
    6788static void chardev_control_puts(const char *str)
    6889{
    69         size_t nwr;
    70         chardev_write(chardev, (void *) str, str_size(str), &nwr);
    71         /* XXX Handle error */
     90        const char *p;
     91
     92        p = str;
     93        while (*p != '\0')
     94                chardev_putchar(*p++);
    7295}
    7396
     
    175198        }
    176199
    177         serial_init(chardev_putchar, chardev_control_puts);
     200        serial_init(chardev_putchar, chardev_control_puts, chardev_flush);
    178201
    179202        discovery_finished = true;
  • uspace/srv/hid/output/port/ega.c

    r7f345cd0 rbbc6277  
    169169}
    170170
     171static void ega_flush(outdev_t *dev)
     172{
     173}
     174
    171175static outdev_ops_t ega_ops = {
    172176        .yield = ega_yield,
     
    175179        .get_caps = ega_get_caps,
    176180        .cursor_update = ega_cursor_update,
    177         .char_update = ega_char_update
     181        .char_update = ega_char_update,
     182        .flush = ega_flush
    178183};
    179184
  • uspace/srv/hid/output/proto/vt100.c

    r7f345cd0 rbbc6277  
    139139
    140140vt100_state_t *vt100_state_create(sysarg_t cols, sysarg_t rows,
    141     vt100_putchar_t putchar_fn, vt100_control_puts_t control_puts_fn)
     141    vt100_putchar_t putchar_fn, vt100_control_puts_t control_puts_fn,
     142        vt100_flush_t flush_fn)
    142143{
    143144        vt100_state_t *state = malloc(sizeof(vt100_state_t));
     
    147148        state->putchar = putchar_fn;
    148149        state->control_puts = control_puts_fn;
     150        state->flush = flush_fn;
    149151       
    150152        state->cols = cols;
     
    228230}
    229231
     232void vt100_flush(vt100_state_t *state)
     233{
     234        state->flush();
     235}
     236
    230237/** @}
    231238 */
  • uspace/srv/hid/output/proto/vt100.h

    r7f345cd0 rbbc6277  
    3737typedef void (* vt100_putchar_t)(wchar_t ch);
    3838typedef void (* vt100_control_puts_t)(const char *str);
     39typedef void (* vt100_flush_t)(void);
    3940
    4041typedef struct {
     
    4849        vt100_putchar_t putchar;
    4950        vt100_control_puts_t control_puts;
     51        vt100_flush_t flush;
    5052} vt100_state_t;
    5153
    5254extern vt100_state_t *vt100_state_create(sysarg_t, sysarg_t, vt100_putchar_t,
    53     vt100_control_puts_t);
     55    vt100_control_puts_t, vt100_flush_t);
    5456extern void vt100_state_destroy(vt100_state_t *);
    5557
     
    6264extern void vt100_cursor_visibility(vt100_state_t *, bool);
    6365extern void vt100_putchar(vt100_state_t *, wchar_t);
     66extern void vt100_flush(vt100_state_t *);
    6467
    6568#endif
Note: See TracChangeset for help on using the changeset viewer.