From owner-svn-src-user@FreeBSD.ORG Thu Oct 14 21:07:10 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 12B1E106564A; Thu, 14 Oct 2010 21:07:10 +0000 (UTC) (envelope-from weongyo@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0199B8FC08; Thu, 14 Oct 2010 21:07:10 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o9EL79Gs037077; Thu, 14 Oct 2010 21:07:09 GMT (envelope-from weongyo@svn.freebsd.org) Received: (from weongyo@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o9EL79x5037074; Thu, 14 Oct 2010 21:07:09 GMT (envelope-from weongyo@svn.freebsd.org) Message-Id: <201010142107.o9EL79x5037074@svn.freebsd.org> From: Weongyo Jeong Date: Thu, 14 Oct 2010 21:07:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r213854 - user/weongyo/usb/sys/dev/usb X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Oct 2010 21:07:10 -0000 Author: weongyo Date: Thu Oct 14 21:07:09 2010 New Revision: 213854 URL: http://svn.freebsd.org/changeset/base/213854 Log: Distinguishes the kernel and userland parts for usb_pf.h. Modified: user/weongyo/usb/sys/dev/usb/usb_pf.c user/weongyo/usb/sys/dev/usb/usb_pf.h Modified: user/weongyo/usb/sys/dev/usb/usb_pf.c ============================================================================== --- user/weongyo/usb/sys/dev/usb/usb_pf.c Thu Oct 14 20:50:33 2010 (r213853) +++ user/weongyo/usb/sys/dev/usb/usb_pf.c Thu Oct 14 21:07:09 2010 (r213854) @@ -95,63 +95,6 @@ MALLOC_DEFINE(M_USBPF, "USBPktFilter", " #endif /* - * The instruction encodings. - */ - -/* instruction classes */ -#define USBPF_CLASS(code) ((code) & 0x07) -#define USBPF_LD 0x00 -#define USBPF_LDX 0x01 -#define USBPF_ST 0x02 -#define USBPF_STX 0x03 -#define USBPF_ALU 0x04 -#define USBPF_JMP 0x05 -#define USBPF_RET 0x06 -#define USBPF_MISC 0x07 - -/* ld/ldx fields */ -#define USBPF_SIZE(code) ((code) & 0x18) -#define USBPF_W 0x00 -#define USBPF_H 0x08 -#define USBPF_B 0x10 -#define USBPF_MODE(code) ((code) & 0xe0) -#define USBPF_IMM 0x00 -#define USBPF_ABS 0x20 -#define USBPF_IND 0x40 -#define USBPF_MEM 0x60 -#define USBPF_LEN 0x80 -#define USBPF_MSH 0xa0 - -/* alu/jmp fields */ -#define USBPF_OP(code) ((code) & 0xf0) -#define USBPF_ADD 0x00 -#define USBPF_SUB 0x10 -#define USBPF_MUL 0x20 -#define USBPF_DIV 0x30 -#define USBPF_OR 0x40 -#define USBPF_AND 0x50 -#define USBPF_LSH 0x60 -#define USBPF_RSH 0x70 -#define USBPF_NEG 0x80 -#define USBPF_JA 0x00 -#define USBPF_JEQ 0x10 -#define USBPF_JGT 0x20 -#define USBPF_JGE 0x30 -#define USBPF_JSET 0x40 -#define USBPF_SRC(code) ((code) & 0x08) -#define USBPF_K 0x00 -#define USBPF_X 0x08 - -/* ret - USBPF_K and USBPF_X also apply */ -#define USBPF_RVAL(code) ((code) & 0x18) -#define USBPF_A 0x10 - -/* misc */ -#define USBPF_MISCOP(code) ((code) & 0xf8) -#define USBPF_TAX 0x00 -#define USBPF_TXA 0x80 - -/* * Number of scratch memory words (for USBPF_LD|USBPF_MEM and USBPF_ST). */ #define USBPF_MEMWORDS 16 Modified: user/weongyo/usb/sys/dev/usb/usb_pf.h ============================================================================== --- user/weongyo/usb/sys/dev/usb/usb_pf.h Thu Oct 14 20:50:33 2010 (r213853) +++ user/weongyo/usb/sys/dev/usb/usb_pf.h Thu Oct 14 21:07:09 2010 (r213854) @@ -37,10 +37,12 @@ #ifndef _DEV_USB_PF_H #define _DEV_USB_PF_H +#ifdef _KERNEL #include #include #include #include +#endif typedef int32_t usbpf_int32; typedef u_int32_t usbpf_u_int32; @@ -50,6 +52,63 @@ typedef u_int64_t usbpf_u_int64; struct usbpf_if; /* + * The instruction encodings. + */ + +/* instruction classes */ +#define USBPF_CLASS(code) ((code) & 0x07) +#define USBPF_LD 0x00 +#define USBPF_LDX 0x01 +#define USBPF_ST 0x02 +#define USBPF_STX 0x03 +#define USBPF_ALU 0x04 +#define USBPF_JMP 0x05 +#define USBPF_RET 0x06 +#define USBPF_MISC 0x07 + +/* ld/ldx fields */ +#define USBPF_SIZE(code) ((code) & 0x18) +#define USBPF_W 0x00 +#define USBPF_H 0x08 +#define USBPF_B 0x10 +#define USBPF_MODE(code) ((code) & 0xe0) +#define USBPF_IMM 0x00 +#define USBPF_ABS 0x20 +#define USBPF_IND 0x40 +#define USBPF_MEM 0x60 +#define USBPF_LEN 0x80 +#define USBPF_MSH 0xa0 + +/* alu/jmp fields */ +#define USBPF_OP(code) ((code) & 0xf0) +#define USBPF_ADD 0x00 +#define USBPF_SUB 0x10 +#define USBPF_MUL 0x20 +#define USBPF_DIV 0x30 +#define USBPF_OR 0x40 +#define USBPF_AND 0x50 +#define USBPF_LSH 0x60 +#define USBPF_RSH 0x70 +#define USBPF_NEG 0x80 +#define USBPF_JA 0x00 +#define USBPF_JEQ 0x10 +#define USBPF_JGT 0x20 +#define USBPF_JGE 0x30 +#define USBPF_JSET 0x40 +#define USBPF_SRC(code) ((code) & 0x08) +#define USBPF_K 0x00 +#define USBPF_X 0x08 + +/* ret - USBPF_K and USBPF_X also apply */ +#define USBPF_RVAL(code) ((code) & 0x18) +#define USBPF_A 0x10 + +/* misc */ +#define USBPF_MISCOP(code) ((code) & 0xf8) +#define USBPF_TAX 0x00 +#define USBPF_TXA 0x80 + +/* * The instruction data structure. */ struct usbpf_insn { @@ -59,6 +118,8 @@ struct usbpf_insn { usbpf_u_int32 k; }; +#ifdef _KERNEL + /* * Descriptor associated with each open uff file. */ @@ -133,6 +194,8 @@ struct usbpf_if { #define USBPFIF_LOCK(uif) mtx_lock(&(uif)->uif_mtx) #define USBPFIF_UNLOCK(uif) mtx_unlock(&(uif)->uif_mtx) +#endif + /* * Structure prepended to each packet. */ @@ -195,10 +258,13 @@ struct usbpf_program { #define UIOCVERSION _IOR('U', 113, struct usbpf_version) #define UIOCSETWF _IOW('B', 123, struct usbpf_program) -void usbpf_attach(struct usb_bus *, struct usbpf_if **); -void usbpf_detach(struct usb_bus *); #define USBPF_XFERTAP_SUBMIT 0 #define USBPF_XFERTAP_DONE 1 + +#ifdef _KERNEL +void usbpf_attach(struct usb_bus *, struct usbpf_if **); +void usbpf_detach(struct usb_bus *); void usbpf_xfertap(struct usb_xfer *, int); +#endif #endif