- Timestamp:
- 2005-12-10T00:19:57Z (20 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- fcfac420
- Parents:
- 705b4149
- Location:
- generic
- Files:
-
- 2 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
generic/include/console/chardev.h
r705b4149 r973be64e 37 37 #define CHARDEV_BUFLEN 512 38 38 39 struct chardev; 40 39 41 /* Character device operations interface. */ 40 42 struct chardev_operations { 41 void (* suspend)(void); /**< Suspend pushing characters. */ 42 void (* resume)(void); /**< Resume pushing characters. */ 43 void (* suspend)(struct chardev *);/**< Suspend 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 … … 47 51 /** Character input device. */ 48 52 struct chardev { 53 char *name; 54 49 55 waitq_t wq; 50 56 spinlock_t lock; /**< Protects everything below. */ 51 57 __u8 buffer[CHARDEV_BUFLEN]; 52 58 count_t counter; 59 chardev_operations_t *op; /**< Implementation of chardev operations. */ 53 60 index_t index; 54 chardev_operations_t *op; /**< Implementation of chardev operations. */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 67 void chardev_push_character(chardev_t *chardev, __u8 ch); 59 68 -
generic/include/console/console.h
r705b4149 r973be64e 34 34 35 35 extern chardev_t *stdin; 36 extern chardev_t *stdout; 36 37 37 38 extern __u8 getc(chardev_t *chardev); 38 39 extern count_t gets(chardev_t *chardev, char *buf, size_t buflen); 40 extern void putchar(char c); 39 41 40 42 #endif /* __CHARDEV_H__ */ -
generic/include/print.h
r705b4149 r973be64e 37 37 #define INT64 8 38 38 39 extern void putchar(const char c);40 39 extern void printf(const char *fmt, ...); 41 40 -
generic/src/console/chardev.c
r705b4149 r973be64e 37 37 * @param op Implementation of character device operations. 38 38 */ 39 void chardev_initialize(chardev_t *chardev, chardev_operations_t *op) 39 void chardev_initialize(char *name,chardev_t *chardev, 40 chardev_operations_t *op) 40 41 { 42 chardev->name = name; 43 41 44 waitq_initialize(&chardev->wq); 42 45 spinlock_initialize(&chardev->lock, "chardev"); … … 57 60 if (chardev->counter == CHARDEV_BUFLEN - 1) { 58 61 /* buffer full => disable device interrupt */ 59 chardev->op->suspend( );62 chardev->op->suspend(chardev); 60 63 } 61 64 -
generic/src/console/console.c
r705b4149 r973be64e 38 38 /** Standard input character device. */ 39 39 chardev_t *stdin = NULL; 40 chardev_t *stdout = NULL; 40 41 41 42 /** Get string from character device. … … 85 86 interrupts_restore(ipl); 86 87 87 chardev->op->resume( );88 chardev->op->resume(chardev); 88 89 89 90 return ch; 90 91 } 92 93 void putchar(char c) 94 { 95 stdout->op->write(stdout, c); 96 }
Note:
See TracChangeset
for help on using the changeset viewer.