Writing Device Drivers

dev_ops Structure

	int		devo_rev;
 	int		devo_refcnt;
 	int		(*devo_getinfo)(dev_info_t *dip,ddi_info_cmd_t infocmd,
 				void *arg, void **result);
 	int		(*devo_identify)(dev_info_t *dip);
 	int		(*devo_probe)(dev_info_t *dip);
 	int		(*devo_attach)(dev_info_t *dip, ddi_attach_cmd_t cmd);
 	int		(*devo_detach)(dev_info_t *dip, ddi_detach_cmd_t cmd);
 	int		(*devo_reset)(dev_info_t *dip, ddi_reset_cmd_t cmd);
 	int		(*devo_power)(dev_info_t *dip, int component,
 				int level);
 	struct cb_ops				*devo_cb_ops;
 	struct bus_ops				*devo_bus_ops;

The dev_ops(9S) structure allows the kernel to find the autoconfiguration entry points of the device driver. The devo_rev field identifies the revision number of the structure itself, and must be set to DEVO_REV. The devo_refcnt field must be initialized to zero. The function address fields should be filled in with the address of the appropriate driver entry point. Exceptions are:

The devo_cb_ops member should include the address of the cb_ops(9S) structure. The devo_bus_ops field must be set to NULL.