Rev 534 | Rev 586 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 534 | Rev 575 | ||
---|---|---|---|
Line 34... | Line 34... | ||
34 | #include <synch/waitq.h> |
34 | #include <synch/waitq.h> |
35 | #include <synch/spinlock.h> |
35 | #include <synch/spinlock.h> |
36 | 36 | ||
37 | #define CHARDEV_BUFLEN 512 |
37 | #define CHARDEV_BUFLEN 512 |
38 | 38 | ||
- | 39 | struct chardev; |
|
- | 40 | ||
39 | /* Character device operations interface. */ |
41 | /* Character device operations interface. */ |
40 | struct chardev_operations { |
42 | struct chardev_operations { |
41 | void (* suspend)(void); /**< Suspend pushing characters. */ |
43 | void (* suspend)(struct chardev *);/**< Suspend pushing characters. */ |
42 | void (* resume)(void); /**< Resume pushing characters. */ |
44 | void (* resume)(struct chardev *); /**< Resume pushing characters. */ |
- | 45 | /** Write character to stream */ |
|
- | 46 | void (* write)(struct chardev *, char c); |
|
43 | }; |
47 | }; |
44 | 48 | ||
45 | typedef struct chardev_operations chardev_operations_t; |
49 | typedef struct chardev_operations chardev_operations_t; |
46 | 50 | ||
47 | /** Character input device. */ |
51 | /** Character input device. */ |
48 | struct chardev { |
52 | struct chardev { |
- | 53 | char *name; |
|
- | 54 | ||
49 | waitq_t wq; |
55 | waitq_t wq; |
50 | spinlock_t lock; /**< Protects everything below. */ |
56 | spinlock_t lock; /**< Protects everything below. */ |
51 | __u8 buffer[CHARDEV_BUFLEN]; |
57 | __u8 buffer[CHARDEV_BUFLEN]; |
52 | count_t counter; |
58 | count_t counter; |
53 | index_t index; |
- | |
54 | chardev_operations_t *op; /**< Implementation of chardev operations. */ |
59 | chardev_operations_t *op; /**< Implementation of chardev operations. */ |
- | 60 | index_t index; |
|
- | 61 | void *data; |
|
55 | }; |
62 | }; |
56 | 63 | ||
57 | extern void chardev_initialize(chardev_t *chardev, chardev_operations_t *op); |
64 | extern void chardev_initialize(char *name, |
- | 65 | chardev_t *chardev, |
|
- | 66 | chardev_operations_t *op); |
|
58 | void chardev_push_character(chardev_t *chardev, __u8 ch); |
67 | void chardev_push_character(chardev_t *chardev, __u8 ch); |
59 | 68 | ||
60 | #endif /* __CHARDEV_H__ */ |
69 | #endif /* __CHARDEV_H__ */ |