Writing Device Drivers


To enable a 64-bit driver and a 32-bit application to share memory, the binary layout generated by the 64-bit driver must be the same as consumed by the 32-bit application.

To determine whether there is a model mismatch, devmap(9E) uses the model parameter to pass the data model type expected by the application. model is set to one of the following:

Example F-2 shows the devmap(9E) model parameter being passed to the ddi_model_convert_from(9F) function.

Example F-2 devmap(9E)

struct data {
	int			len;
	caddr_t			addr;

xxdevmap(dev_t dev, devmap_cookie_t dhp, offset_t offset,
			size_t len, size_t *maplen, uint_t model);
	struct data dtc;  /* local copy for clash resolution */
	struct data *dp = (struct data *)shared_area;

	switch (ddi_model_convert_from(model)) {
	case DDI_MODEL_ILP32:
		struct data32 {
			int			len;
			uint32_t			*addr;
		} *da32p;

		da32p = (struct data32 *)shared_area;
		dp = &dtc;
		dp->len = da32p->len;
		dp->address = da32p->address;
#endif  /* _MULTI_DATAMODEL */
	/* continues along using dp */