Changeset 91ecaa10 in mainline


Ignore:
Timestamp:
2012-08-12T23:14:48Z (12 years ago)
Author:
Martin Sucha <sucha14@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
58a369e
Parents:
6e09bee
Message:

Make ns8250 read blocking.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/char/ns8250/ns8250.c

    r6e09bee r91ecaa10  
    179179        /** The fibril mutex for synchronizing the access to the device. */
    180180        fibril_mutex_t mutex;
     181        /** Indicates that some data has become available */
     182        fibril_condvar_t input_buffer_available;
    181183        /** True if device is removed. */
    182184        bool removed;
     
    238240{
    239241        ns8250_t *ns = NS8250(fun);
    240         int ret = EOK;
     242        int ret = 0;
     243       
     244        if (count == 0) return 0;
    241245       
    242246        fibril_mutex_lock(&ns->mutex);
     247        while (buf_is_empty(&ns->input_buffer))
     248                fibril_condvar_wait(&ns->input_buffer_available, &ns->mutex);
    243249        while (!buf_is_empty(&ns->input_buffer) && (size_t)ret < count) {
    244250                buf[ret] = (char)buf_pop_front(&ns->input_buffer);
     
    739745                       
    740746                        if (ns->client_connected) {
     747                                bool buf_was_empty = buf_is_empty(&ns->input_buffer);
    741748                                if (!buf_push_back(&ns->input_buffer, val)) {
    742749                                        ddf_msg(LVL_WARN, "Buffer overflow on "
     
    746753                                            "to the buffer of %s.",
    747754                                            val, ns->dev->name);
     755                                        if (buf_was_empty)
     756                                                fibril_condvar_broadcast(&ns->input_buffer_available);
    748757                                }
    749758                        }
     
    811820       
    812821        fibril_mutex_initialize(&ns->mutex);
     822        fibril_condvar_initialize(&ns->input_buffer_available);
    813823        ns->dev = dev;
    814824       
Note: See TracChangeset for help on using the changeset viewer.