📄 defs.h
字号:
/* * defs.h - can4linux CAN driver module, common definitions * * This file is subject to the terms and conditions of the GNU General Public * License. See the file "COPYING" in the main directory of this archive * for more details. * * Copyright (c) 2001-2008 port GmbH Halle/Saale *------------------------------------------------------------------ * $Header: /z2/cvsroot/products/0530/software/can4linux/src/defs.h,v 1.12 2008/11/23 12:05:29 oe Exp $ * *-------------------------------------------------------------------------- * * * *-------------------------------------------------------------------------- *//*** \file defs.h* \author Name, port GmbH* $Revision: 1.12 $* $Date: 2008/11/23 12:05:29 $** Module Description * see Doxygen Doc for all possibilites****//* needed for 2.4 */#ifndef NOMODULE# define __NO_VERSION__# ifndef MODULE# define MODULE# endif#endif#ifdef __KERNEL__#ifndef KERNEL_VERSION#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))#endif#ifdef __KERNEL__#include <linux/init.h>#include <linux/module.h>#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,19)# include <linux/config.h>#endif#include <linux/kernel.h>#include <linux/tty.h>#include <linux/errno.h>#include <linux/major.h>#include <linux/version.h>#if LINUX_VERSION_CODE > KERNEL_VERSION(2,4,12)# include <linux/slab.h>#else# include <linux/malloc.h>#endif#if LINUX_VERSION_CODE > KERNEL_VERSION(2,1,0)#include <linux/poll.h>#endif#include <asm/io.h>#include <asm/segment.h>#include <asm/system.h>#include <asm/irq.h>#include <asm/dma.h>#include <linux/mm.h>#include <linux/signal.h>#include <linux/timer.h>#include <asm/uaccess.h>#define __lddk_copy_from_user(a,b,c) _cnt = copy_from_user(a,b,c)#define __lddk_copy_to_user(a,b,c) _cnt =copy_to_user(a,b,c)#include <linux/ioport.h>#if !defined(__iomem)# define __iomem#endif#endif/* Unsigned value which later should be converted to an integer */#ifdef __x86_64__typedef unsigned long long upointer_t;#else typedef unsigned long upointer_t;#endif#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) # include <linux/interrupt.h> #else /* For 2.4.x compatibility, 2.4.x can use */typedef void irqreturn_t;#define IRQ_NONE#define IRQ_HANDLED#define IRQ_RETVAL(x)/* not available in k2.4.x */static inline unsigned iminor(struct inode *inode){ return MINOR(inode->i_rdev);}#endif#if CAN4LINUX_PCI# define _BUS_TYPE "PCI-"/* Since 2008 we hav two versions of the CPC PCIThe old one, using the SIemens PITA chip with up to two CAN controllersThe new one using A PLX PCI Bridge with up to 4 CAN controllersthe only one supported: EMS CPC-PCI *//* Old */# define PCI_VENDOR_CAN_EMS 0x110a# define PCI_DEVICE_CAN 0x2104/* PSB4610 PITA-2 bridge control registers */#define PITA2_ICR 0x00 /* Interrupt Control Register */#define PITA2_ICR_INT0 0x00000002 /* [RC] INT0 Active/Clear */#define PITA2_ICR_INT0_EN 0x00020000 /* [RW] Enable INT0 */#define PITA2_MISC 0x1c /* Miscellaneous Register */#define PITA2_MISC_CONFIG 0x04000000 /* Multiplexed parallel interface *//* New *//* #define PCI_VENDOR_ID_PLX : in pci_ids.h */#ifndef PCI_DEVICE_ID_PLX_9030#define PCI_DEVICE_ID_PLX_9030 0x9030#endif/* PLX 9030 PCI-to-IO Bridge control registers */#define PLX9030_ICR 0x4c /* Interrupt Control Register */#define PLX9030_ICR_CLEAR_IRQ0 0x400#define PLX9030_ICR_ENABLE_IRQ0 0x41/* and CANPCI manufactured by Contemporary Controls Inc. */# define PCI_VENDOR_CAN_CC 0x1571# define PCI_DEVICE_CC_MASK 0xC001# define PCI_DEVICE_CC_CANopen 0xC001# define PCI_DEVICE_CC_CANDnet 0xC002/* and PCICAN manufactured by Kvaser */# define PCI_VENDOR_CAN_KVASER 0x10e8# define PCI_DEVICE_CAN_KVASER 0x8406#elif CAN4LINUX_PCCARD# define _BUS_TYPE "PC-Card-"#elif SSV_MCP2515# define _BUS_TYPE "SPI-"#else# define _BUS_TYPE "ISA-"#endif#if defined(ATCANMINI_PELICAN) \ || defined(CCPC104) \ || defined(CPC_PCI) \ || defined(CC_CANPCI) \ || defined(IXXAT_PCI03) \ || defined(PCM3680) \ || defined(CPC104) \ || defined(CPC_PCM_104) \ || defined(CPC_CARD) \ || defined(KVASER_PCICAN) \ || defined(VCMA9) \ || defined(MMC_SJA1000) /* ---------------------------------------------------------------------- */# ifdef CAN_PORT_IO# define __CAN_TYPE__ _BUS_TYPE "PeliCAN-port I/O "# else# ifdef CAN_INDEXED_PORT_IO# define __CAN_TYPE__ _BUS_TYPE "PeliCAN-indexed port I/O "# else# define __CAN_TYPE__ _BUS_TYPE "PeliCAN-memory mapped "# endif# endif#elif defined(MCF5282)# define __CAN_TYPE__ _BUS_TYPE "FlexCAN "/* ---------------------------------------------------------------------- */#elif defined(UNCTWINCAN)# define __CAN_TYPE__ _BUS_TYPE "TwinCAN "/* ---------------------------------------------------------------------- */#elif defined(AD_BLACKFIN)# define __CAN_TYPE__ _BUS_TYPE "BlackFin-CAN "/* ---------------------------------------------------------------------- */#elif defined(ATMEL_SAM9)# define __CAN_TYPE__ _BUS_TYPE "Atmel-CAN "/* ---------------------------------------------------------------------- */#elif defined(SSV_MCP2515)# define __CAN_TYPE__ _BUS_TYPE "Microchip MCP2515 "/* ---------------------------------------------------------------------- */#else/* ---------------------------------------------------------------------- */#endif/* Length of the "version" string entry in /proc/.../version */#define PROC_VER_LENGTH 80/* Length of the "Chipset" string entry in /proc/.../version */#define PROC_CHIPSET_LENGTH 30/* kernels higher 2.3.x have a new kernel interface.* Since can4linux V3.x only kernel interfaces 2.4 an higher are supported.* This simplfies alot of things* ******************/#define __LDDK_WRITE_TYPE ssize_t#define __LDDK_CLOSE_TYPE int#define __LDDK_READ_TYPE ssize_t#define __LDDK_OPEN_TYPE int#define __LDDK_IOCTL_TYPE int#define __LDDK_SELECT_TYPE unsigned int#define __LDDK_FASYNC_TYPE int#define __LDDK_SEEK_PARAM struct file *file, loff_t off, size_t count#define __LDDK_READ_PARAM struct file *file, char *buffer, size_t count, \ loff_t *loff#define __LDDK_WRITE_PARAM struct file *file, const char *buffer, \ size_t count, loff_t *loff#define __LDDK_READDIR_PARAM struct file *file, void *dirent, filldir_t count#define __LDDK_SELECT_PARAM struct file *file, \ struct poll_table_struct *wait#define __LDDK_IOCTL_PARAM struct inode *inode, struct file *file, \ unsigned int cmd, unsigned long arg#define __LDDK_MMAP_PARAM struct file *file, struct vm_area_struct * vma#define __LDDK_OPEN_PARAM struct inode *inode, struct file *file #define __LDDK_FLUSH_PARAM struct file *file #define __LDDK_CLOSE_PARAM struct inode *inode, struct file *file #define __LDDK_FSYNC_PARAM struct file *file, struct dentry *dentry, \ int datasync#define __LDDK_FASYNC_PARAM int fd, struct file *file, int count #define __LDDK_CCHECK_PARAM kdev_t dev#define __LDDK_REVAL_PARAM kdev_t dev#define __LDDK_MINOR MINOR(file->f_dentry->d_inode->i_rdev)#define __LDDK_INO_MINOR MINOR(inode->i_rdev)#ifndef SLOW_DOWN_IO# define SLOW_DOWN_IO __SLOW_DOWN_IO#endif/************************************************************************/#include "debug.h"/************************************************************************/#ifdef __KERNEL__extern __LDDK_READ_TYPE can_read (__LDDK_READ_PARAM);extern __LDDK_WRITE_TYPE can_write (__LDDK_WRITE_PARAM);extern __LDDK_SELECT_TYPE can_select (__LDDK_SELECT_PARAM);extern __LDDK_IOCTL_TYPE can_ioctl (__LDDK_IOCTL_PARAM);extern __LDDK_OPEN_TYPE can_open (__LDDK_OPEN_PARAM);extern __LDDK_CLOSE_TYPE can_close (__LDDK_CLOSE_PARAM);extern __LDDK_FASYNC_TYPE can_fasync (__LDDK_FASYNC_PARAM);#endif /*---------- Default Outc and other value for some known boards * this depends on the transceiver configuration * some embedded CAN controllers even don't have this configuration option * * the AT-CAN-MINI board uses optocoupler configuration as denoted * in the Philips application notes, so the OUTC value is 0xfa * * CAN_OUTC_VAL - is a register value, mostly used for SJA1000 * IO_Modeli 'p' port IO * 'm' memory IO * 's' spi bus connected * 'i' indexed meory or indexed port access */#if defined(ATCANMINI_BASIC) || defined(ATCANMINI_PELICAN)# define CAN_OUTC_VAL 0xfa# define IO_MODEL 'p'# define STD_MASK 0xFFFFFFFF # include "sja1000.h"#elif defined(IME_SLIMLINE)# define CAN_OUTC_VAL 0xda# define IO_MODEL 'm'# define STD_MASK 0xFFFFFFFF # include "sja1000.h"#elif defined(CPC_PCI)# define CAN_OUTC_VAL 0xda# define IO_MODEL 'm'# define STD_MASK 0xFFFFFFFF # include "sja1000.h"# include "ems_pci.h"extern void board_clear_interrupts(int minor);#elif defined(KVASER_PCICAN)# define CAN_OUTC_VAL 0xda# define IO_MODEL 'p'# define STD_MASK 0xFFFFFFFF # include "sja1000.h"void disable_pci_interrupt(unsigned int base);#elif defined(IXXAT_PCI03)# define CAN_OUTC_VAL 0x5e# define IO_MODEL 'm'# define STD_MASK 0xFFFFFFFF # include "sja1000.h"#elif defined(PCM3680)# define CAN_OUTC_VAL 0x5e# define IO_MODEL 'm'
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -