Copyright 2014 Garrett D'Amore <garrett@damore.org>
Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
int ddi_dmae_alloc(dev_info_t *dip, int chnl, int (*callback) (caddr_t), caddr_t arg);
int ddi_dmae_release(dev_info_t *dip, int chnl);
int ddi_dmae_prog(dev_info_t *dip, struct ddi_dmae_req *dmaereqp, ddi_dma_cookie_t *cookiep, int chnl);
int ddi_dmae_disable(dev_info_t *dip, int chnl);
int ddi_dmae_enable(dev_info_t *dip, int chnl);
int ddi_dmae_stop(dev_info_t *dip, int chnl);
int ddi_dmae_getcnt(dev_info_t *dip, int chnl, int *countp);
int ddi_dmae_1stparty(dev_info_t *dip, int chnl);
int ddi_dmae_getattr(dev_info_t *dip, ddi_dma_attr_t *attrp);
A dev_info pointer that identifies the device.
A DMA channel number. On ISA buses this number must be 0, 1, 2, 3, 5, 6, or 7.
The address of a function to call back later if resources are not currently available. The following special function addresses may also be used: DDI_DMA_SLEEP
Wait until resources are available.
Do not wait until resources are available and do not schedule a callback.
Argument to be passed to the callback function, if specified.
A pointer to a DMA engine request structure. See ddi_dmae_req(9S).
A pointer to a ddi_dma_cookie(9S) object, which contains the address and count.
A pointer to an integer that will receive the count of the number of bytes not yet transferred upon completion of a DMA operation.
A pointer to a DMA attribute structure. See ddi_dma_attr(9S).
If the device is capable of acting as a true bus master, then the driver should program the device's DMA registers directly and not make use of the DMA engine functions described here. The driver should obtain the DMA address and count from ddi_dma_cookie(9S).
This method uses the system DMA engine that is resident on the main system board. In this model, the device cooperates with the system's DMA engine to effect the data transfers between the device and memory. The driver uses the functions documented here, except ddi_dmae_1stparty(), to initialize and program the DMA engine. For each DMA data transfer, the driver programs the DMA engine and then gives the device a command to initiate the transfer in cooperation with that engine.
Using this method, the device uses its own DMA bus cycles, but requires a channel from the system's DMA engine. After allocating the DMA channel, the ddi_dmae_1stparty() function may be used to perform whatever configuration is necessary to enable this mode.
If the requested channel is not immediately available, the value of callback determines what action will be taken. If the value of callback is DDI_DMA_DONTWAIT, ddi_dmae_alloc() will return immediately. The value DDI_DMA_SLEEP will cause the thread to sleep and not return until the channel has been acquired. Any other value is assumed to be a callback function address. In that case, ddi_dmae_alloc() returns immediately, and when resources might have become available, the callback function is called (with the argument arg) from interrupt context. When the callback function is called, it should attempt to allocate the DMA channel again. If it succeeds or no longer needs the channel, it must return the value DDI_DMA_CALLBACK_DONE. If it tries to allocate the channel but fails to do so, it must return the value DDI_DMA_CALLBACK_RUNOUT. In this case, the callback function is put back on a list to be called again later.
Before using ddi_dmae_prog(), you must allocate system DMA resources using DMA setup functions such as ddi_dma_mem_alloc(9F). ddi_dma_addr_bind_handle(9F) can then be used to retrieve a cookie which contains the address and count. Then this cookie is passed to ddi_dmae_prog().
When operating in ddi_dmae_1stparty() mode, the DMA channel must first be allocated using ddi_dmae_alloc() and then configured using ddi_dmae_1stparty(). The driver then programs the device to perform the I/O, including the necessary DMA address and count values obtained from the ddi_dma_cookie(9S).
Upon success, for all of these routines.
May be returned due to invalid arguments.
May be returned by ddi_dmae_alloc() if the requested resources are not available and the value of dmae_waitfp is not DDI_DMA_SLEEP.
ATTRIBUTE TYPE ATTRIBUTE VALUE |
Architecture x86 |