Subversion Repositories HelenOS

Rev

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

Rev 510 Rev 511
Line 32... Line 32...
32
#include <typedefs.h>
32
#include <typedefs.h>
33
#include <arch/types.h>
33
#include <arch/types.h>
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 10
37
#define CHARDEV_BUFLEN 512
38
 
38
 
-
 
39
/* Character device operations interface. */
-
 
40
struct chardev_operations {
-
 
41
    void (* suspend)(void);     /**< Suspend pushing characters. */
-
 
42
    void (* resume)(void);      /**< Resume pushing characters. */
-
 
43
};
-
 
44
 
39
typedef void (* ready_func_t)(void);
45
typedef struct chardev_operations chardev_operations_t;
40
 
46
 
41
/** Character input device. */
47
/** Character input device. */
42
struct chardev {
48
struct chardev {
43
    waitq_t wq;
49
    waitq_t wq;
44
    spinlock_t lock;        /**< Protects everything below. */
50
    spinlock_t lock;        /**< Protects everything below. */
45
    __u8 buffer[CHARDEV_BUFLEN];
51
    __u8 buffer[CHARDEV_BUFLEN];
46
    count_t counter;
52
    count_t counter;
47
    index_t index;
53
    index_t index;
48
    ready_func_t ready_func;    /**< Function to re-enable input from the device. */
54
    chardev_operations_t *op;   /**< Implementation of chardev operations. */
49
};
55
};
50
 
56
 
51
extern void chardev_initialize(chardev_t *chardev, ready_func_t r);
57
extern void chardev_initialize(chardev_t *chardev, chardev_operations_t *op);
-
 
58
void chardev_push_character(chardev_t *chardev, __u8 ch);
52
 
59
 
53
#endif /* __CHARDEV_H__ */
60
#endif /* __CHARDEV_H__ */