Subversion Repositories HelenOS

Rev

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

Rev 2787 Rev 4377
Line 37... Line 37...
37
 
37
 
38
#include <arch/types.h>
38
#include <arch/types.h>
39
#include <synch/waitq.h>
39
#include <synch/waitq.h>
40
#include <synch/spinlock.h>
40
#include <synch/spinlock.h>
41
 
41
 
42
#define CHARDEV_BUFLEN 512
42
#define INDEV_BUFLEN  512
43
 
43
 
44
struct chardev;
44
struct indev;
45
 
45
 
46
/* Character device operations interface. */
46
/* Input character device operations interface. */
47
typedef struct {
47
typedef struct {
48
    /** Suspend pushing characters. */
-
 
49
    void (* suspend)(struct chardev *);
-
 
50
    /** Resume pushing characters. */
-
 
51
    void (* resume)(struct chardev *);
-
 
52
    /** Write character to stream. */
-
 
53
    void (* write)(struct chardev *, char c);
-
 
54
    /** Read character directly from device, assume interrupts disabled. */
48
    /** Read character directly from device, assume interrupts disabled. */
55
    char (* read)(struct chardev *);
49
    wchar_t (* poll)(struct indev *);
56
} chardev_operations_t;
50
} indev_operations_t;
57
 
51
 
58
/** Character input device. */
52
/** Character input device. */
59
typedef struct chardev {
53
typedef struct indev {
60
    char *name;
54
    char *name;
61
   
-
 
62
    waitq_t wq;
55
    waitq_t wq;
-
 
56
   
63
    /** Protects everything below. */
57
    /** Protects everything below. */
64
    SPINLOCK_DECLARE(lock);
58
    SPINLOCK_DECLARE(lock);
65
    uint8_t buffer[CHARDEV_BUFLEN];
59
    wchar_t buffer[INDEV_BUFLEN];
66
    count_t counter;
60
    count_t counter;
-
 
61
   
67
    /** Implementation of chardev operations. */
62
    /** Implementation of indev operations. */
68
    chardev_operations_t *op;
63
    indev_operations_t *op;
69
    index_t index;
64
    index_t index;
70
    void *data;
65
    void *data;
-
 
66
} indev_t;
-
 
67
 
-
 
68
 
-
 
69
struct outdev;
-
 
70
 
-
 
71
/* Output character device operations interface. */
-
 
72
typedef struct {
-
 
73
    /** Write character to output. */
-
 
74
    void (* write)(struct outdev *, wchar_t, bool);
-
 
75
} outdev_operations_t;
-
 
76
 
-
 
77
/** Character input device. */
-
 
78
typedef struct outdev {
-
 
79
    char *name;
-
 
80
   
-
 
81
    /** Protects everything below. */
-
 
82
    SPINLOCK_DECLARE(lock);
-
 
83
   
-
 
84
    /** Implementation of outdev operations. */
-
 
85
    outdev_operations_t *op;
-
 
86
    void *data;
71
} chardev_t;
87
} outdev_t;
-
 
88
 
-
 
89
extern void indev_initialize(char *name, indev_t *indev,
-
 
90
    indev_operations_t *op);
-
 
91
extern void indev_push_character(indev_t *indev, wchar_t ch);
-
 
92
extern wchar_t indev_pop_character(indev_t *indev);
-
 
93
 
-
 
94
extern void outdev_initialize(char *name, outdev_t *outdev,
-
 
95
    outdev_operations_t *op);
72
 
96
 
73
extern void chardev_initialize(char *name, chardev_t *chardev,
97
extern bool check_poll(indev_t *indev);
74
    chardev_operations_t *op);
-
 
75
extern void chardev_push_character(chardev_t *chardev, uint8_t ch);
-
 
76
 
98
 
77
#endif /* KERN_CHARDEV_H_ */
99
#endif /* KERN_CHARDEV_H_ */
78
 
100
 
79
/** @}
101
/** @}
80
 */
102
 */