[97] | 1 | /*
|
---|
| 2 | ** Copyright 2012 by Kvaser AB, Mölndal, Sweden
|
---|
| 3 | ** http://www.kvaser.com
|
---|
| 4 | **
|
---|
| 5 | ** This software is dual licensed under the following two licenses:
|
---|
| 6 | ** BSD-new and GPLv2. You may use either one. See the included
|
---|
| 7 | ** COPYING file for details.
|
---|
| 8 | **
|
---|
| 9 | ** License: BSD-new
|
---|
| 10 | ** ===============================================================================
|
---|
| 11 | ** Redistribution and use in source and binary forms, with or without
|
---|
| 12 | ** modification, are permitted provided that the following conditions are met:
|
---|
| 13 | ** * Redistributions of source code must retain the above copyright
|
---|
| 14 | ** notice, this list of conditions and the following disclaimer.
|
---|
| 15 | ** * Redistributions in binary form must reproduce the above copyright
|
---|
| 16 | ** notice, this list of conditions and the following disclaimer in the
|
---|
| 17 | ** documentation and/or other materials provided with the distribution.
|
---|
| 18 | ** * Neither the name of the <organization> nor the
|
---|
| 19 | ** names of its contributors may be used to endorse or promote products
|
---|
| 20 | ** derived from this software without specific prior written permission.
|
---|
| 21 | **
|
---|
| 22 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
---|
| 23 | ** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
---|
| 24 | ** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
---|
| 25 | ** DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
|
---|
| 26 | ** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
---|
| 27 | ** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
---|
| 28 | ** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
---|
| 29 | ** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
| 30 | ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
---|
| 31 | ** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
| 32 | **
|
---|
| 33 | **
|
---|
| 34 | ** License: GPLv2
|
---|
| 35 | ** ===============================================================================
|
---|
| 36 | ** This program is free software; you can redistribute it and/or
|
---|
| 37 | ** modify it under the terms of the GNU General Public License
|
---|
| 38 | ** as published by the Free Software Foundation; either version 2
|
---|
| 39 | ** of the License, or (at your option) any later version.
|
---|
| 40 | **
|
---|
| 41 | ** This program is distributed in the hope that it will be useful,
|
---|
| 42 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 43 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 44 | ** GNU General Public License for more details.
|
---|
| 45 | **
|
---|
| 46 | ** You should have received a copy of the GNU General Public License
|
---|
| 47 | ** along with this program; if not, write to the Free Software
|
---|
| 48 | ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
---|
| 49 | **
|
---|
| 50 | ** ---------------------------------------------------------------------------
|
---|
| 51 | **/
|
---|
| 52 |
|
---|
| 53 | /* kcan_ioctl.h: ioctls()'s specific for Kvasers CAN drivers */
|
---|
| 54 |
|
---|
| 55 | #ifndef _KCAN_IOCTL_H
|
---|
| 56 | #define _KCAN_IOCTL_H
|
---|
| 57 |
|
---|
| 58 | //# include <linux/ioctl.h>
|
---|
| 59 | # include <asm/ioctl.h>
|
---|
| 60 |
|
---|
| 61 | # define KCAN_IOC_MAGIC 'k'
|
---|
| 62 |
|
---|
| 63 | // For compatibility with Windows #define:s below.
|
---|
| 64 | #define VCAN_DEVICE 0 // dummy
|
---|
| 65 | #define KCAN_IOCTL_START 0
|
---|
| 66 | #define METHOD_BUFFERED 0 // dummy
|
---|
| 67 | #define FILE_ANY_ACCESS 0
|
---|
| 68 |
|
---|
| 69 | // qqq This likely is not a good idea!
|
---|
| 70 |
|
---|
| 71 | #define CTL_CODE(x,i,y,z) _IO(KCAN_IOC_MAGIC, (i))
|
---|
| 72 |
|
---|
| 73 |
|
---|
| 74 | #define KCAN_IOCTL_OBJBUF_FREE_ALL CTL_CODE (VCAN_DEVICE, KCAN_IOCTL_START + 6, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
---|
| 75 | #define KCAN_IOCTL_OBJBUF_ALLOCATE CTL_CODE (VCAN_DEVICE, KCAN_IOCTL_START + 7, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
---|
| 76 | #define KCAN_IOCTL_OBJBUF_FREE CTL_CODE (VCAN_DEVICE, KCAN_IOCTL_START + 8, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
---|
| 77 | #define KCAN_IOCTL_OBJBUF_WRITE CTL_CODE (VCAN_DEVICE, KCAN_IOCTL_START + 9, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
---|
| 78 | #define KCAN_IOCTL_OBJBUF_SET_FILTER CTL_CODE (VCAN_DEVICE, KCAN_IOCTL_START + 10, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
---|
| 79 | #define KCAN_IOCTL_OBJBUF_SET_FLAGS CTL_CODE (VCAN_DEVICE, KCAN_IOCTL_START + 11, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
---|
| 80 | #define KCAN_IOCTL_OBJBUF_ENABLE CTL_CODE (VCAN_DEVICE, KCAN_IOCTL_START + 12, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
---|
| 81 | #define KCAN_IOCTL_OBJBUF_DISABLE CTL_CODE (VCAN_DEVICE, KCAN_IOCTL_START + 13, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
---|
| 82 |
|
---|
| 83 | #define KCAN_IOCTL_OBJBUF_SET_PERIOD CTL_CODE (VCAN_DEVICE, KCAN_IOCTL_START + 22, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
---|
| 84 | #define KCAN_IOCTL_OBJBUF_SEND_BURST CTL_CODE (VCAN_DEVICE, KCAN_IOCTL_START + 23, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
---|
| 85 |
|
---|
| 86 | #define KCAN_IOCTL_OBJBUF_SET_MSG_COUNT CTL_CODE (VCAN_DEVICE, KCAN_IOCTL_START + 34, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
---|
| 87 |
|
---|
| 88 | #define KCAN_IOCTL_CANFD CTL_CODE (VCAN_DEVICE, KCAN_IOCTL_START + 69, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
---|
| 89 |
|
---|
| 90 | #define KCAN_CARDFLAG_FIRMWARE_BETA 0x01 // Firmware is beta
|
---|
| 91 | #define KCAN_CARDFLAG_FIRMWARE_RC 0x02 // Firmware is release candidate
|
---|
| 92 | #define KCAN_CARDFLAG_AUTO_RESP_OBJBUFS 0x04 // Firmware supports auto-response object buffers
|
---|
| 93 | #define KCAN_CARDFLAG_REFUSE_TO_RUN 0x08 // Major problem detected
|
---|
| 94 | #define KCAN_CARDFLAG_REFUSE_TO_USE_CAN 0x10 // Major problem detected
|
---|
| 95 | #define KCAN_CARDFLAG_AUTO_TX_OBJBUFS 0x20 // Firmware supports periodic transmit object buffers
|
---|
| 96 |
|
---|
| 97 |
|
---|
| 98 | #define KCAN_DRVFLAG_BETA 0x01 // Driver is beta
|
---|
| 99 |
|
---|
| 100 | #if defined(DEVHND_DRIVER_IS_BETA)
|
---|
| 101 | CompilerAssert(KCAN_DRVFLAG_BETA == DEVHND_DRIVER_IS_BETA);
|
---|
| 102 | #endif
|
---|
| 103 |
|
---|
| 104 |
|
---|
| 105 | #define CAN_CANFD_SUCCESS 0
|
---|
| 106 | #define CAN_CANFD_MISMATCH -1
|
---|
| 107 | #define CAN_CANFD_NOT_IMPLEMENTED -2
|
---|
| 108 | #define CAN_CANFD_FAILURE -3
|
---|
| 109 | #define CANFD 1
|
---|
| 110 | #define CAN 0
|
---|
| 111 | #define CAN_CANFD_SET 1
|
---|
| 112 | #define CAN_CANFD_READ 2
|
---|
| 113 | #define CAN_CANFD_READ_VERSION 3
|
---|
| 114 |
|
---|
| 115 | typedef struct {
|
---|
| 116 | unsigned int fd; // CANFD, CAN
|
---|
| 117 | unsigned int action; // CAN_CANFD_SET, CAN_CANFD_READ
|
---|
| 118 | unsigned int reply; // reply from read?
|
---|
| 119 | int status; // CAN_CANFD_MATCHING, CAN_CANFD_MISMATCH
|
---|
| 120 | unsigned int unused[8];
|
---|
| 121 | } KCAN_IOCTL_CANFD_T;
|
---|
| 122 |
|
---|
| 123 |
|
---|
| 124 | #endif /* KCANIO_H */
|
---|
| 125 |
|
---|