Subversion Repositories HelenOS-historic

Rev

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

Rev 601 Rev 607
Line 32... Line 32...
32
#include <synch/waitq.h>
32
#include <synch/waitq.h>
33
#include <synch/spinlock.h>
33
#include <synch/spinlock.h>
34
#include <arch/types.h>
34
#include <arch/types.h>
35
#include <typedefs.h>
35
#include <typedefs.h>
36
#include <arch.h>
36
#include <arch.h>
-
 
37
#include <func.h>
-
 
38
#include <print.h>
37
 
39
 
38
/** Standard input character device. */
40
/** Standard input character device. */
39
chardev_t *stdin = NULL;
41
chardev_t *stdin = NULL;
40
chardev_t *stdout = NULL;
42
chardev_t *stdout = NULL;
41
 
43
 
Line 48... Line 50...
48
__u8 _getc(chardev_t *chardev)
50
__u8 _getc(chardev_t *chardev)
49
{
51
{
50
    __u8 ch;
52
    __u8 ch;
51
    ipl_t ipl;
53
    ipl_t ipl;
52
 
54
 
-
 
55
    if (haltstate) {
-
 
56
        /* If we are here, we are hopefully on the processor, that
-
 
57
         * issued the 'halt' command, so proceed to read the character
-
 
58
         * directly from input
-
 
59
         */
-
 
60
        if (chardev->op->read)
-
 
61
            return chardev->op->read(chardev);
-
 
62
        /* no other way of interacting with user, halt */
-
 
63
        printf("cpu: halted - no kconsole\n");
-
 
64
        cpu_halt();
-
 
65
    }
-
 
66
 
53
    waitq_sleep(&chardev->wq);
67
    waitq_sleep(&chardev->wq);
54
    ipl = interrupts_disable();
68
    ipl = interrupts_disable();
55
    spinlock_lock(&chardev->lock);
69
    spinlock_lock(&chardev->lock);
56
    ch = chardev->buffer[(chardev->index - chardev->counter) % CHARDEV_BUFLEN];
70
    ch = chardev->buffer[(chardev->index - chardev->counter) % CHARDEV_BUFLEN];
57
    chardev->counter--;
71
    chardev->counter--;
Line 112... Line 126...
112
    return ch;
126
    return ch;
113
}
127
}
114
 
128
 
115
void putchar(char c)
129
void putchar(char c)
116
{
130
{
-
 
131
    if (stdout->op->write)
117
    stdout->op->write(stdout, c);
132
        stdout->op->write(stdout, c);
118
}
133
}