usb_process.h revision 263799
1184610Salfred/* $FreeBSD: stable/10/sys/dev/usb/usb_process.h 263799 2014-03-27 06:59:56Z hselasky $ */ 2184610Salfred/*- 3184610Salfred * Copyright (c) 2008 Hans Petter Selasky. All rights reserved. 4184610Salfred * 5184610Salfred * Redistribution and use in source and binary forms, with or without 6184610Salfred * modification, are permitted provided that the following conditions 7184610Salfred * are met: 8184610Salfred * 1. Redistributions of source code must retain the above copyright 9184610Salfred * notice, this list of conditions and the following disclaimer. 10184610Salfred * 2. Redistributions in binary form must reproduce the above copyright 11184610Salfred * notice, this list of conditions and the following disclaimer in the 12184610Salfred * documentation and/or other materials provided with the distribution. 13184610Salfred * 14184610Salfred * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15184610Salfred * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16184610Salfred * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17184610Salfred * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18184610Salfred * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19184610Salfred * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20184610Salfred * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21184610Salfred * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22184610Salfred * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23184610Salfred * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24184610Salfred * SUCH DAMAGE. 25184610Salfred */ 26184610Salfred 27194230Sthompsa#ifndef _USB_PROCESS_H_ 28194230Sthompsa#define _USB_PROCESS_H_ 29184610Salfred 30246122Shselasky#ifndef USB_GLOBAL_INCLUDE_FILE 31217350Sjhb#include <sys/interrupt.h> 32184610Salfred#include <sys/priority.h> 33217350Sjhb#include <sys/runq.h> 34246122Shselasky#endif 35184610Salfred 36184610Salfred/* defines */ 37217350Sjhb#define USB_PRI_HIGH PI_SWI(SWI_NET) 38217350Sjhb#define USB_PRI_MED PI_SWI(SWI_CAMBIO) 39184610Salfred 40184610Salfred#define USB_PROC_WAIT_TIMEOUT 2 41184610Salfred#define USB_PROC_WAIT_DRAIN 1 42184610Salfred#define USB_PROC_WAIT_NORMAL 0 43184610Salfred 44184610Salfred/* structure prototypes */ 45184610Salfred 46192984Sthompsastruct usb_proc_msg; 47249795Shselaskystruct usb_device; 48184610Salfred 49184610Salfred/* 50184610Salfred * The following structure defines the USB process. 51184610Salfred */ 52192984Sthompsastruct usb_process { 53192984Sthompsa TAILQ_HEAD(, usb_proc_msg) up_qhead; 54184610Salfred struct cv up_cv; 55184610Salfred struct cv up_drain; 56184610Salfred 57196274Sthompsa#if (__FreeBSD_version >= 800000) 58196274Sthompsa struct thread *up_ptr; 59196274Sthompsa#else 60184610Salfred struct proc *up_ptr; 61196274Sthompsa#endif 62184610Salfred struct thread *up_curtd; 63184610Salfred struct mtx *up_mtx; 64184610Salfred 65193074Sthompsa usb_size_t up_msg_num; 66184610Salfred 67184610Salfred uint8_t up_prio; 68184610Salfred uint8_t up_gone; 69184610Salfred uint8_t up_msleep; 70184610Salfred uint8_t up_csleep; 71184610Salfred uint8_t up_dsleep; 72184610Salfred}; 73184610Salfred 74184610Salfred/* prototypes */ 75184610Salfred 76194228Sthompsauint8_t usb_proc_is_gone(struct usb_process *up); 77194228Sthompsaint usb_proc_create(struct usb_process *up, struct mtx *p_mtx, 78188411Sthompsa const char *pmesg, uint8_t prio); 79194228Sthompsavoid usb_proc_drain(struct usb_process *up); 80194228Sthompsavoid usb_proc_mwait(struct usb_process *up, void *pm0, void *pm1); 81194228Sthompsavoid usb_proc_free(struct usb_process *up); 82194228Sthompsavoid *usb_proc_msignal(struct usb_process *up, void *pm0, void *pm1); 83196498Salfredvoid usb_proc_rewakeup(struct usb_process *up); 84263799Shselaskyint usb_proc_is_called_from(struct usb_process *up); 85184610Salfred 86249795Shselaskyvoid usb_proc_explore_mwait(struct usb_device *, void *, void *); 87249795Shselaskyvoid *usb_proc_explore_msignal(struct usb_device *, void *, void *); 88249795Shselaskyvoid usb_proc_explore_lock(struct usb_device *); 89249795Shselaskyvoid usb_proc_explore_unlock(struct usb_device *); 90249795Shselasky 91194230Sthompsa#endif /* _USB_PROCESS_H_ */ 92