Writing Device Drivers


Because mmap(9E) does not have a parameter that can be used to pass data model information, the driver's mmap(9E) entry point should be written to use the new DDI function ddi_mmap_get_model(9F). This function returns one of the following values to indicate the application's data type model:

As with ioctl(9E) and devmap(9E), the model bits can be passed to ddi_model_convert_from(9F) to determine whether data conversion is necessary.

Example F-3 shows the use of ddi_mmap_get_model(9F).

Example F-3 mmap(9E)

struct data {
	int			len;
	caddr_t			addr

xxmmap(dev_t dev, off_t off, int prot)
	struct data dtc;  /* local copy for clash resolution */
	struct data *dp = (struct data *)shared_area;

	switch (ddi_model_convert_from(ddi_mmap_get_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 */