conf.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /*
  2. * Mach Operating System
  3. * Copyright (c) 1993,1991,1990,1989 Carnegie Mellon University
  4. * All Rights Reserved.
  5. *
  6. * Permission to use, copy, modify and distribute this software and its
  7. * documentation is hereby granted, provided that both the copyright
  8. * notice and this permission notice appear in all copies of the
  9. * software, derivative works or modified versions, and any portions
  10. * thereof, and that both notices appear in supporting documentation.
  11. *
  12. * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
  13. * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
  14. * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
  15. *
  16. * Carnegie Mellon requests users of this software to return to
  17. *
  18. * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
  19. * School of Computer Science
  20. * Carnegie Mellon University
  21. * Pittsburgh PA 15213-3890
  22. *
  23. * any improvements or extensions that they make and grant Carnegie Mellon
  24. * the rights to redistribute these changes.
  25. */
  26. /*
  27. * Author: David B. Golub, Carnegie Mellon University
  28. * Date: 8/88
  29. */
  30. #ifndef _DEVICE_CONF_H_
  31. #define _DEVICE_CONF_H_
  32. #include <mach/machine/vm_types.h>
  33. #include <sys/types.h>
  34. #include <mach/port.h>
  35. #include <mach/vm_prot.h>
  36. struct io_req;
  37. typedef struct io_req *io_req_t;
  38. typedef int io_return_t;
  39. /*
  40. * Operations list for major device types.
  41. */
  42. struct dev_ops {
  43. char * d_name; /* name for major device */
  44. int (*d_open)(dev_t, int, io_req_t);/* open device */
  45. void (*d_close)(dev_t, int); /* close device */
  46. int (*d_read)(dev_t, io_req_t); /* read */
  47. int (*d_write)(dev_t, io_req_t); /* write */
  48. int (*d_getstat)(dev_t, int, int *, natural_t *); /* get status/control */
  49. int (*d_setstat)(dev_t, int, int *, natural_t); /* set status/control */
  50. int (*d_mmap)(dev_t, vm_offset_t, vm_prot_t); /* map memory */
  51. int (*d_async_in)(); /* asynchronous input setup */
  52. int (*d_reset)(); /* reset device */
  53. int (*d_port_death)(dev_t, mach_port_t);
  54. /* clean up reply ports */
  55. int d_subdev; /* number of sub-devices per
  56. unit */
  57. int (*d_dev_info)(); /* driver info for kernel */
  58. };
  59. typedef struct dev_ops *dev_ops_t;
  60. /*
  61. * Routines for null entries.
  62. */
  63. extern int nulldev(void); /* no operation - OK */
  64. extern int nulldev_open(dev_t dev, int flag, io_req_t ior);
  65. extern void nulldev_close(dev_t dev, int flags);
  66. extern int nulldev_read(dev_t dev, io_req_t ior);
  67. extern int nulldev_write(dev_t dev, io_req_t ior);
  68. extern io_return_t nulldev_getstat(dev_t dev, int flavor, int *data, natural_t *count);
  69. extern io_return_t nulldev_setstat(dev_t dev, int flavor, int *data, natural_t count);
  70. extern io_return_t nulldev_portdeath(dev_t dev, mach_port_t port);
  71. extern int nodev(void); /* no operation - error */
  72. extern int nomap(dev_t dev, vm_offset_t off, int prot); /* no operation - error */
  73. /*
  74. * Flavor constants for d_dev_info routine
  75. */
  76. #define D_INFO_BLOCK_SIZE 1
  77. /*
  78. * Head of list of attached devices
  79. */
  80. extern struct dev_ops dev_name_list[];
  81. extern int dev_name_count;
  82. /*
  83. * Macro to search device list
  84. */
  85. #define dev_search(dp) \
  86. for (dp = dev_name_list; \
  87. dp < &dev_name_list[dev_name_count]; \
  88. dp++)
  89. /*
  90. * Indirection vectors for certain devices.
  91. */
  92. struct dev_indirect {
  93. char * d_name; /* name for device */
  94. dev_ops_t d_ops; /* operations (major device) */
  95. int d_unit; /* and unit number */
  96. };
  97. typedef struct dev_indirect *dev_indirect_t;
  98. /*
  99. * List of indirect devices.
  100. */
  101. extern struct dev_indirect dev_indirect_list[];
  102. extern int dev_indirect_count;
  103. /*
  104. * Macro to search indirect list
  105. */
  106. #define dev_indirect_search(di) \
  107. for (di = dev_indirect_list; \
  108. di < &dev_indirect_list[dev_indirect_count]; \
  109. di++)
  110. #endif /* _DEVICE_CONF_H_ */