## device_map

Function - Establish the specified device's memory manager.

### SYNOPSIS

    #include< device/device.h>

    kern_return_t   device_map
                    (mach_port_t                             device,
                     vm_prot_t                                 prot,
                     vm_offset_t                             offset,
                     vm_size_t                                 size,
                     mach_port_t                          mem_obj_t,
                     boolean_t                                unmap);

### PARAMETERS

device
  [in device send right] A device port to the device to be mapped.

prot
  [in scalar] Protection for the device memory.

offset
  [in scalar] 15~Offset in memory object.

size
  [in scalar] The size of the device memory object.

pager
  [out memory-object send right] The returned memory object representative port to a memory manager that represents the device.

unmap
  Unused.

### DESCRIPTION

The device_map function establishes a memory manager that presents a memory object representing a device. The resulting port is suitable for use as the memory manager port in a vm_map call. This call is device dependent.

### NOTES

Port rights are maintained as follows:

- Memory object port: the device memory manager has all rights.
- Memory cache control port: the device memory manager has only send rights.

Regardless of how the object is created, the control port is created by the kernel and passed through the memory management interface.

If the device port used is restricted to use by a single identity, the generated representative port will be likewise restricted.

### CAUTIONS

The device memory manager assumes that access to its memory objects will not be propagated to more that one host, and therefore provides no consistency guarantees beyond those made by the kernel.

In the event that more than one host attempts to use a device memory object, the device memory manager will only record the last set of port names. Currently, the device memory manager assumes that its clients adhere to the initialization and termination protocols in the memory management interface; otherwise, port rights or out-of-line memory from erroneous messages may be allowed to accumulate.

### RETURN VALUES

D_DEVICE_DOWN
  Device has been shut down

D_NO_SUCH_DEVICE
  No device with that name, or the device is not operational.

D_READ_ONLY
  Data cannot be written to this device.

### RELATED INFORMATION

Functions: vm_map.