Writing Device Drivers

devmap_callback_ctl Structure

The device driver must allocate and initialize a devmap_callback_ctl(9S) structure to inform the system of its device context management entry point routines. This structure contains the following fields:

	struct devmap_callback_ctl {	
 		int devmap_rev;
 		int (*devmap_map)(devmap_cookie_t dhp, dev_t dev,
 			u_int flags, offset_t off, size_t len, void **pvtp);
 		int (*devmap_access)(devmap_cookie_t dhp, void *pvtp,
 			offset_t off, size_t len, u_int type, u_int rw);
 		int (*devmap_dup)(devmap_cookie_t dhp, void *pvtp,
 			devmap_cookie_t new_dhp, void **new_pvtp);
 		void (*devmap_unmap)(devmap_cookie_t dhp, void *pvtp,
 			offset_t off, size_t len, devmap_cookie_t new_dhp1,
 			void **new_pvtp1, devmap_cookie_t new_dhp2,
 			void **new_pvtp2);
 	};

devmap_rev is the version number of the devmap_callback_ctl(9S) structure. It must be set to DEVMAP_OPS_REV.

devmap_map must be set to the address of the driver's devmap_map(9E) entry point.

devmap_access must be set to the address of the driver's devmap_access(9E) entry point.

devmap_dup must be set to the address of the driver's devmap_dup(9E) entry point.

devmap_unmap must be set to the address of the driver's devmap_unmap(9E) entry point.