[BACK]Return to driver.h CVS log [TXT][DIR] Up to [local] / prex-old / dev / include

Diff for /prex-old/dev/include/driver.h between version 1.1.1.1.2.1 and 1.2

version 1.1.1.1.2.1, 2008/08/13 17:12:24 version 1.2, 2008/08/08 13:37:11
Line 37 
Line 37 
 #include <conf/config.h>  #include <conf/config.h>
 #include <sys/cdefs.h>  #include <sys/cdefs.h>
 #include <sys/param.h>  #include <sys/param.h>
   #include <sys/null.h>
 #include <sys/types.h>  #include <sys/types.h>
 #include <sys/errno.h>  #include <sys/errno.h>
 #include <sys/list.h>  #include <sys/list.h>
Line 49 
Line 50 
  */   */
 typedef unsigned long   device_t;  typedef unsigned long   device_t;
 typedef unsigned long   task_t;  typedef unsigned long   task_t;
 typedef unsigned long   irq_t;  
   
 #define DEVICE_NULL     ((device_t)0)  #define NULL_DEVICE     ((device_t)0)
 #define TASK_NULL       ((task_t)0)  #define NULL_TASK       ((task_t)0)
 #define IRQ_NULL        ((irq_t)0)  
   
   #ifndef CONFIG_AUTOCONF
   
   
 /*  /*
  * Driver structure   * Driver structure
  *   *
Line 66 
Line 68 
         const int       order;          /* Initialize order */          const int       order;          /* Initialize order */
         int             (*init)(void);  /* Initialize routine */          int             (*init)(void);  /* Initialize routine */
 };  };
   #else /* CONFIG_AUTOCONF */
   
   #define CONFIG_XNAMELEN 16      /* maximum name for device (name+unit) */
   
 /*  /*
    * Generic information that is held for every attached device.
    */
   struct device {
           void                    *dv_data;       /* private data */
           int                             dv_unit;        /* unit number (starting from 0) */
           char                    *dv_xname;      /* name */
           unsigned long   dv_flags;
   
           struct device   *dv_parent;     /* parent device */
   };
   
   /*
    * Data structure that describes device driver.
    */
   struct driver {
           char    *dr_name;       /* abstract name for a device */
           int             dr_datasize;/* sizeof private data structure */
   
           int             (*dr_match)(struct device *parent, void *aux);
           int             (*dr_attach)(struct device *parent, struct device *self, void *aux);
           int             (*dr_detach)(struct device *parent, struct device *self, void *aux);
           /* XXX dr_search() ? */
           int             dr_nunits;      /* number of attached units */
   };
   
   /*
    * Autoconf prototypes.
    */
   void    config_attach_rootdev(void);
   int     config_search_children(struct device *self, void *aux);
   struct driver   *config_find_driver(const char *name);
   struct device   *config_alloc_device(struct driver *drv);
   void    config_free_device(struct device *dev);
   
   /*
    * Attachment information.
    */
   struct attachment {
           const char      *at_childname;
           const char      *at_parentname;
           const int       at_parentunit;  /* -1 for ALL */
           const char      *at_helpername;
           const unsigned long     at_flags;
   };
   
   #endif /* !CONFIG_AUTOCONF */
   
   /*
  * Device I/O table   * Device I/O table
  */   */
 struct devio {  struct devio {
Line 75 
Line 128 
         int (*close)    (device_t dev);          int (*close)    (device_t dev);
         int (*read)     (device_t dev, char *buf, size_t *nbyte, int blkno);          int (*read)     (device_t dev, char *buf, size_t *nbyte, int blkno);
         int (*write)    (device_t dev, char *buf, size_t *nbyte, int blkno);          int (*write)    (device_t dev, char *buf, size_t *nbyte, int blkno);
         int (*ioctl)    (device_t dev, u_long arg, void *);          int (*ioctl)    (device_t dev, int cmd, u_long arg);
         int (*event)    (int event);          int (*event)    (int event);
 };  };
   
Line 128 
Line 181 
         const char      *name;          /* pointer to event name string */          const char      *name;          /* pointer to event name string */
 };  };
   
   #define EVENT_INIT(event, evt_name) \
       { {&(event).sleepq, &(event).sleepq}, evt_name}
   
 #define event_init(event, evt_name) \  #define event_init(event, evt_name) \
     do { list_init(&(event)->sleepq); (event)->name = evt_name; } while (0)      do { list_init(&(event)->sleepq); (event)->name = evt_name; } while (0)
   
Line 179 
Line 235 
  */   */
 #define DUMP_THREAD     1  #define DUMP_THREAD     1
 #define DUMP_TASK       2  #define DUMP_TASK       2
 #define DUMP_VM         3  #define DUMP_OBJECT     3
   #define DUMP_TIMER      4
   #define DUMP_IRQ        5
   #define DUMP_DEVICE     6
   #define DUMP_VM         7
   #define DUMP_MSGLOG     8
   #define DUMP_TRACE      9
   
 __BEGIN_DECLS  __BEGIN_DECLS
 device_t device_create(struct devio *io, const char *name, int flags);  device_t device_create(struct devio *io, const char *name, int flags);
 int      device_destroy(device_t dev);  int      device_destroy(device_t dev);
 int      device_broadcast(int event, int force);  int      device_broadcast(int event, int force);
   
 int      umem_copyin(const void *uaddr, void *kaddr, size_t len);  int      umem_copyin(void *uaddr, void *kaddr, size_t len);
 int      umem_copyout(const void *kaddr, void *uaddr, size_t len);  int      umem_copyout(void *kaddr, void *uaddr, size_t len);
 int      umem_strnlen(const char *uaddr, size_t maxlen, size_t *len);  int      umem_strnlen(const char *uaddr, size_t maxlen, size_t *len);
   
 void    *kmem_alloc(size_t size);  void    *kmem_alloc(size_t size);
Line 195 
Line 257 
 void    *kmem_map(void *addr, size_t size);  void    *kmem_map(void *addr, size_t size);
   
 void    *page_alloc(size_t size);  void    *page_alloc(size_t size);
 void     page_free(void *paddr, size_t size);  void     page_free(void *addr, size_t size);
 int      page_reserve(void *paddr, size_t size);  int      page_reserve(void *addr, size_t size);
   
 irq_t    irq_attach(int irqno, int level, int shared, int (*isr)(int), void (*ist)(int));  int      irq_attach(int irqno, int level, int shared, int (*isr)(int), void (*ist)(int));
 void     irq_detach(irq_t irq);  void     irq_detach(int handle);
 void     irq_lock(void);  void     irq_lock(void);
 void     irq_unlock(void);  void     irq_unlock(void);
   
 void     timer_callout(struct timer *tmr, u_long msec, void (*func)(void *), void *arg);  void     timer_callout(struct timer *tmr, void (*func)(u_long), u_long arg, u_long msec);
 void     timer_stop(struct timer *tmr);  void     timer_stop(struct timer *tmr);
 u_long   timer_delay(u_long msec);  u_long   timer_delay(u_long msec);
 u_long   timer_count(void);  u_long   timer_count(void);
Line 229 
Line 291 
 void     debug_attach(void (*func)(char *));  void     debug_attach(void (*func)(char *));
 int      debug_dump(int index);  int      debug_dump(int index);
   
 void     printf(const char *fmt, ...);  
 void     panic(const char *msg);  
 #ifdef DEBUG  #ifdef DEBUG
   void     printk(const char *fmt, ...);
   void     panic(const char *fmt, ...);
 void     assert(const char *file, int line, const char *exp);  void     assert(const char *file, int line, const char *exp);
 #define ASSERT(exp) do { if (!(exp)) \  #define ASSERT(exp) do { if (!(exp)) \
                              assert(__FILE__, __LINE__, #exp); } while (0)          assert(__FILE__, __LINE__, #exp); } while (0)
 #else  #else
 #define ASSERT(exp) do {} while (0)  #define printk(fmt...)  do {} while (0)
   #define panic(fmt...)  do { for (;;) ; } while (0)
   #define ASSERT(exp)
 #endif  #endif
   
 void    driver_main(void);  
 __END_DECLS  __END_DECLS
   
 #endif /* !_DRIVER_H */  #endif /* !_DRIVER_H */

Legend:
Removed from v.1.1.1.1.2.1  
changed lines
  Added in v.1.2

CVSweb