Changeset 8030f49 in mainline
- Timestamp:
- 2009-03-12T17:43:10Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- ac8e7a9
- Parents:
- 94a981a
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/include/console/chardev.h
r94a981a r8030f49 40 40 #include <synch/spinlock.h> 41 41 42 #define CHARDEV_BUFLEN51242 #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 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, bool silent);54 48 /** Read character directly from device, assume interrupts disabled. */ 55 char (* read)(struct chardev *);56 } chardev_operations_t;49 char (* poll)(struct indev *); 50 } indev_operations_t; 57 51 58 52 /** Character input device. */ 59 typedef struct chardev { 53 typedef struct indev { 54 char *name; 55 waitq_t wq; 56 57 /** Protects everything below. */ 58 SPINLOCK_DECLARE(lock); 59 uint8_t buffer[INDEV_BUFLEN]; 60 count_t counter; 61 62 /** Implementation of indev operations. */ 63 indev_operations_t *op; 64 index_t index; 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 *, char c, bool silent); 75 } outdev_operations_t; 76 77 /** Character input device. */ 78 typedef struct outdev { 60 79 char *name; 61 80 62 waitq_t wq;63 81 /** Protects everything below. */ 64 SPINLOCK_DECLARE(lock); 65 uint8_t buffer[CHARDEV_BUFLEN]; 66 count_t counter; 67 /** Implementation of chardev operations. */ 68 chardev_operations_t *op; 69 index_t index; 82 SPINLOCK_DECLARE(lock); 83 84 /** Implementation of outdev operations. */ 85 outdev_operations_t *op; 70 86 void *data; 71 } chardev_t;87 } outdev_t; 72 88 73 extern void chardev_initialize(char *name, chardev_t *chardev, 74 chardev_operations_t *op); 75 extern void chardev_push_character(chardev_t *chardev, uint8_t ch); 89 extern void indev_initialize(char *name, indev_t *indev, 90 indev_operations_t *op); 91 extern void indev_push_character(indev_t *indev, uint8_t ch); 92 93 extern void outdev_initialize(char *name, outdev_t *outdev, 94 outdev_operations_t *op); 76 95 77 96 #endif /* KERN_CHARDEV_H_ */
Note:
See TracChangeset
for help on using the changeset viewer.