Annotation of funnyos/sys/device.h, Revision 1.1
1.1 ! init 1: /*
! 2: * $Id: device.h,v 1.2 2007/10/12 12:16:47 init Exp $
! 3: */
! 4: #ifndef _SYS_DEVICE_H
! 5: #define _SYS_DEVICE_H
! 6: #include <sys/types.h>
! 7:
! 8: #define DVNAMELEN 8
! 9:
! 10: struct device {
! 11: // char dv_name[DVNAMELEN]; /* device name up to 7 chars */
! 12: char *dv_name;
! 13: uint8_t dv_minor; /* instance number starting from 0 */
! 14: int dv_active; /* is this device active? */
! 15:
! 16: void *dv_devdata; /* device data in driver */
! 17: void *dv_aux; /* varios data exposed by device */
! 18:
! 19: struct device *dv_parent; /* parent device; set in attach time */
! 20: };
! 21:
! 22:
! 23: struct driver {
! 24: uint32_t dr_ddsize; /* size of xxx_dd (devdata) */
! 25: int (*dr_attach)(struct device *self, uint32_t loc, uint8_t flags); /* attach subroutine */
! 26: int (*dr_detach)(struct device *self); /* detach subroutine */
! 27: // void (*dr_interrupt)(struct device *self); /* intr handler */
! 28: };
! 29:
! 30:
! 31: struct driverinfo {
! 32: /*
! 33: * Associate actual driver with device name.
! 34: */
! 35: char di_dname[DVNAMELEN]; /* device name */
! 36: struct driver *di_driverp; /* pointer to driver */
! 37: int8_t di_ninstances; /* number of already created devices; for dv_minor */
! 38: };
! 39:
! 40:
! 41: struct attachinfo {
! 42: /*
! 43: * Attach hint. Describes where to attach particular device.
! 44: * "child" at "parent" 0 loc 0x16000000 flags 0x00
! 45: */
! 46: char ai_cname[DVNAMELEN]; /* child device name */
! 47: char ai_pname[DVNAMELEN]; /* parent device name */
! 48: uint8_t ai_pminor; /* parent minor */
! 49: uint32_t ai_locator; /* location on parent (0 - default) */
! 50: // uint8_t ai_intrno; /* interrupt line */
! 51: uint8_t ai_flags; /* flags passed to dr_attach() */
! 52: };
! 53:
! 54:
! 55:
! 56: #define ATTACH(x) devlist[x].dv_parent
! 57: #define AT =
! 58: #define PARENT(y) &devlist[y]
! 59:
! 60: #endif /* _SYS_DEVICE_H */
! 61:
CVSweb