Subversion Repositories HelenOS-historic

Rev

Rev 588 | Rev 1705 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 588 Rev 990
Line 53... Line 53...
53
 * @param chardev Character device.
53
 * @param chardev Character device.
54
 * @param ch Character being pushed.
54
 * @param ch Character being pushed.
55
 */
55
 */
56
void chardev_push_character(chardev_t *chardev, __u8 ch)
56
void chardev_push_character(chardev_t *chardev, __u8 ch)
57
{
57
{
58
        spinlock_lock(&chardev->lock);
58
    spinlock_lock(&chardev->lock);
59
    chardev->counter++;
59
    chardev->counter++;
60
    if (chardev->counter == CHARDEV_BUFLEN - 1) {
60
    if (chardev->counter == CHARDEV_BUFLEN - 1) {
61
        /* buffer full => disable device interrupt */
61
        /* buffer full => disable device interrupt */
62
        chardev->op->suspend(chardev);
62
        chardev->op->suspend(chardev);
63
    }
63
    }
64
 
64
   
65
        chardev->buffer[chardev->index++] = ch;
65
    chardev->buffer[chardev->index++] = ch;
66
        chardev->index = chardev->index % CHARDEV_BUFLEN; /* index modulo size of buffer */
66
    chardev->index = chardev->index % CHARDEV_BUFLEN; /* index modulo size of buffer */
67
        waitq_wakeup(&chardev->wq, WAKEUP_FIRST);
67
    waitq_wakeup(&chardev->wq, WAKEUP_FIRST);
68
        spinlock_unlock(&chardev->lock);
68
    spinlock_unlock(&chardev->lock);
69
}
69
}