/* $FreeBSD$ */
/*-
* Copyright (c) 2013 Hans Petter Selasky. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <bsd_global.h>
#if USB_HAVE_BUSDMA
#endif
/*------------------------------------------------------------------------*
* usbd_get_page - lookup DMA-able memory for the given offset
*
* NOTE: Only call this function when the "page_cache" structure has
* been properly initialized !
*------------------------------------------------------------------------*/
void
struct usb_page_search *res)
{
#if USB_HAVE_BUSDMA
if (pc->page_start) {
/* Case 1 - something has been loaded into DMA */
/* Case 1a - Kernel Virtual Address */
}
/* compute destination page */
if (pc->ismultiseg) {
offset %= USB_PAGE_SIZE;
} else {
}
/* Case 1b - Non Kernel Virtual Address */
}
return;
}
#endif
/* Case 2 - Plain PIO */
#if USB_HAVE_BUSDMA
#endif
}
/*------------------------------------------------------------------------*
* usbd_copy_in - copy directly to DMA-able memory
*------------------------------------------------------------------------*/
void
{
while (len != 0) {
}
}
}
/*------------------------------------------------------------------------*
* usbd_copy_out - copy directly from DMA-able memory
*------------------------------------------------------------------------*/
void
{
while (len != 0) {
}
}
}
/*------------------------------------------------------------------------*
* usbd_frame_zero - zero DMA-able memory
*------------------------------------------------------------------------*/
void
{
while (len != 0) {
}
}
}
#if USB_HAVE_BUSDMA
/*------------------------------------------------------------------------*
* usb_pc_common_mem_cb - BUS-DMA callback function
*------------------------------------------------------------------------*/
static void
{
if (length == 0)
nseg = 1;
else
pg++;
}
}
/*------------------------------------------------------------------------*
* usb_pc_alloc_mem - allocate DMA'able memory
*
* Returns:
* 0: Success
* Else: Failure
*------------------------------------------------------------------------*/
{
void *ptr;
/* allocate zeroed memory */
if (align != 1) {
goto error;
} else {
goto error;
rem = 0;
}
/* setup page cache */
pc->page_offset_buf = 0;
/* compute physical address */
return (0);
/* reset most of the page cache */
pc->page_offset_buf = 0;
pc->page_offset_end = 0;
return (1);
}
/*------------------------------------------------------------------------*
* usb_pc_free_mem - free DMA memory
*
* This function is NULL safe.
*------------------------------------------------------------------------*/
void
{
}
}
/*------------------------------------------------------------------------*
* usb_pc_load_mem - load virtual memory into DMA
*
* Return values:
* 0: Success
* Else: Error
*------------------------------------------------------------------------*/
{
/* setup page cache */
pc->page_offset_buf = 0;
if (size > 0) {
/* compute physical address */
}
if (sync == 0) {
/*
* Call callback so that refcount is decremented
* properly:
*/
}
return (0);
}
/*------------------------------------------------------------------------*
* usb_pc_cpu_invalidate - invalidate CPU cache
*------------------------------------------------------------------------*/
void
{
/* nothing has been loaded into this page cache! */
return;
}
/* NOP */
}
/*------------------------------------------------------------------------*
* usb_pc_cpu_flush - flush CPU cache
*------------------------------------------------------------------------*/
void
{
/* nothing has been loaded into this page cache! */
return;
}
/* NOP */
}
/*------------------------------------------------------------------------*
* usb_pc_dmamap_create - create a DMA map
*
* Returns:
* 0: Success
* Else: Failure
*------------------------------------------------------------------------*/
{
return (0); /* NOP, success */
}
/*------------------------------------------------------------------------*
* usb_pc_dmamap_destroy
*
* This function is NULL safe.
*------------------------------------------------------------------------*/
void
{
/* NOP */
}
/*------------------------------------------------------------------------*
* usb_dma_tag_setup - initialise USB DMA tags
*------------------------------------------------------------------------*/
void
{
/* sanity checking */
if ((nudt == 0) ||
(ndmabits == 0) ||
/* something is corrupt */
return;
}
/* initialise condition variable */
/* store some information */
while (nudt--) {
udt++;
}
}
/*------------------------------------------------------------------------*
* usb_bus_tag_unsetup - factored out code
*------------------------------------------------------------------------*/
void
{
while (nudt--) {
udt++;
}
/* destroy the condition variable */
}
}
/*------------------------------------------------------------------------*
* usb_bdma_work_loop
*
* This function handles loading of virtual buffers into DMA and is
* only called when "dma_refcount" is zero.
*------------------------------------------------------------------------*/
void
{
/* some error happened */
usbd_transfer_done(xfer, 0);
return;
}
/* reset BUS-DMA load state */
/* only one frame buffer */
nframes = 1;
} else {
/* can be multiple frame buffers */
}
/*
* Set DMA direction first. This is needed to
* select the correct cache invalidate and cache
* flush operations.
*/
/* special case */
/* The device controller writes to memory */
} else {
/* The host controller reads from memory */
}
} else {
/* default case */
}
/*
* Setup the "page_start" pointer which points to an array of
* USB pages where information about the physical address of a
* page will be stored. Also initialise the "isread" field of
* the USB page caches.
*/
info->dma_currframe = 0;
pg += 2;
while (--nframes > 0) {
pg += 2;
}
}
return;
}
if (info->dma_currframe == 0) {
/* special case */
info->dma_frlength_0, 0);
} else {
/* default case */
}
/* advance frame index */
info->dma_currframe++;
return;
}
/* go ahead */
/* start loading next USB transfer, if any */
/* finally start the hardware */
}
/*------------------------------------------------------------------------*
* usb_bdma_done_event
*
* This function is called when the BUS-DMA has loaded virtual memory
* into DMA, if any.
*------------------------------------------------------------------------*/
void
{
/* copy error */
/* enter workloop again */
}
/*------------------------------------------------------------------------*
* usb_bdma_pre_sync
*
* This function handles DMA synchronisation that must be done before
* an USB transfer is started.
*------------------------------------------------------------------------*/
void
{
/* only one frame buffer */
nframes = 1;
} else {
/* can be multiple frame buffers */
}
while (nframes--) {
} else {
}
pc++;
}
}
/*------------------------------------------------------------------------*
* usb_bdma_post_sync
*
* This function handles DMA synchronisation that must be done after
* an USB transfer is complete.
*------------------------------------------------------------------------*/
void
{
/* only one frame buffer */
nframes = 1;
} else {
/* can be multiple frame buffers */
}
while (nframes--) {
}
pc++;
}
}
#endif