Changeset 8030f49 in mainline


Ignore:
Timestamp:
2009-03-12T17:43:10Z (16 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
ac8e7a9
Parents:
94a981a
Message:

split chardev_t into indev_t and outdev_t
simplify and cleanup operations

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/include/console/chardev.h

    r94a981a r8030f49  
    4040#include <synch/spinlock.h>
    4141
    42 #define CHARDEV_BUFLEN 512
     42#define INDEV_BUFLEN 512
    4343
    44 struct chardev;
     44struct indev;
    4545
    46 /* Character device operations interface. */
     46/* Input character device operations interface. */
    4747typedef 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);
    5448        /** 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;
    5751
    5852/** Character input device. */
    59 typedef struct chardev {
     53typedef 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
     69struct outdev;
     70
     71/* Output character device operations interface. */
     72typedef struct {
     73        /** Write character to output. */
     74        void (* write)(struct outdev *, char c, bool silent);
     75} outdev_operations_t;
     76
     77/** Character input device. */
     78typedef struct outdev {
    6079        char *name;
    6180       
    62         waitq_t wq;
    6381        /** 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;
    7086        void *data;
    71 } chardev_t;
     87} outdev_t;
    7288
    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);
     89extern void indev_initialize(char *name, indev_t *indev,
     90    indev_operations_t *op);
     91extern void indev_push_character(indev_t *indev, uint8_t ch);
     92
     93extern void outdev_initialize(char *name, outdev_t *outdev,
     94    outdev_operations_t *op);
    7695
    7796#endif /* KERN_CHARDEV_H_ */
Note: See TracChangeset for help on using the changeset viewer.