├── ToDo ├── kernel_modules_drivers ├── pclta │ ├── Readme.txt │ ├── load_pclta │ ├── pclta.h │ └── makefile ├── gesytec-2.06 │ ├── lpctest │ ├── lwafw.lwa │ ├── sysdep.h │ ├── kdebug.h │ ├── Makefile │ ├── lpclinux.h │ ├── driverdata.c │ ├── driverentry.c │ ├── Plx9050.h │ ├── analyzer.c │ └── lpctest.c ├── gesytec-2.08 │ ├── lpctest │ ├── lwafw.lwa │ ├── sysdep.h │ ├── kdebug.h │ ├── Makefile │ ├── lpclinux.h │ ├── driverdata.c │ ├── driverentry.c │ ├── Plx9050.h │ └── analyzer.c ├── gesytec-2.09 │ ├── lpctest │ ├── lwafw.lwa │ ├── sysdep.h │ ├── kdebug.h │ ├── Makefile │ ├── lpclinux.h │ ├── driverdata.c │ ├── driverentry.c │ ├── Plx9050.h │ └── analyzer.c └── gesytec-2.12 │ ├── lwafw.lwa │ ├── 25-easylon.rules │ ├── sysdep.h │ ├── kdebug.h │ ├── driverdata.c │ ├── lpclinux.h │ ├── Makefile │ ├── Plx9050.h │ ├── analyzer.c │ └── driverentry.c ├── ni └── makefile ├── application_messaging ├── makefile ├── applmsg.h └── ni_typedef_msg.h └── ldv ├── makefile ├── ldv.h └── ldv.cpp /ToDo: -------------------------------------------------------------------------------- 1 | * General code cleanup 2 | * remove C++ code so this works in pure C99 3 | -------------------------------------------------------------------------------- /kernel_modules_drivers/pclta/Readme.txt: -------------------------------------------------------------------------------- 1 | This is the driver for the old Lonworks ISA 16 bit card PCLTA from Echelon 2 | -------------------------------------------------------------------------------- /kernel_modules_drivers/gesytec-2.06/lpctest: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/karlhiramoto/lon4linux/HEAD/kernel_modules_drivers/gesytec-2.06/lpctest -------------------------------------------------------------------------------- /kernel_modules_drivers/gesytec-2.06/lwafw.lwa: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/karlhiramoto/lon4linux/HEAD/kernel_modules_drivers/gesytec-2.06/lwafw.lwa -------------------------------------------------------------------------------- /kernel_modules_drivers/gesytec-2.08/lpctest: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/karlhiramoto/lon4linux/HEAD/kernel_modules_drivers/gesytec-2.08/lpctest -------------------------------------------------------------------------------- /kernel_modules_drivers/gesytec-2.08/lwafw.lwa: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/karlhiramoto/lon4linux/HEAD/kernel_modules_drivers/gesytec-2.08/lwafw.lwa -------------------------------------------------------------------------------- /kernel_modules_drivers/gesytec-2.09/lpctest: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/karlhiramoto/lon4linux/HEAD/kernel_modules_drivers/gesytec-2.09/lpctest -------------------------------------------------------------------------------- /kernel_modules_drivers/gesytec-2.09/lwafw.lwa: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/karlhiramoto/lon4linux/HEAD/kernel_modules_drivers/gesytec-2.09/lwafw.lwa -------------------------------------------------------------------------------- /kernel_modules_drivers/gesytec-2.12/lwafw.lwa: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/karlhiramoto/lon4linux/HEAD/kernel_modules_drivers/gesytec-2.12/lwafw.lwa -------------------------------------------------------------------------------- /kernel_modules_drivers/gesytec-2.12/25-easylon.rules: -------------------------------------------------------------------------------- 1 | # /etc/udev/rules.d/25-easylon.rules 2 | 3 | # Easylon 4 | KERNEL=="lpcdrv*", NAME="lon/%k", GROUP="tty", MODE="666" 5 | KERNEL=="lppdrv*", NAME="lon/%k", GROUP="tty", MODE="666" 6 | KERNEL=="lonusb*", NAME="lon/%k", GROUP="tty", MODE="666", OPTIONS="last_rule" 7 | 8 | #KERNEL=="pty[pqrstuvwxyzabcdef][0123456789abcdef]", NAME="%k", GROUP="tty", MODE="666", OPTIONS="last_rule" 9 | #KERNEL=="tty[0-9]*", NAME="%k", GROUP="tty", MODE="620", OPTIONS="last_rule" 10 | #KERNEL=="ptmx", NAME="%k", GROUP="tty", MODE="666" 11 | -------------------------------------------------------------------------------- /kernel_modules_drivers/pclta/load_pclta: -------------------------------------------------------------------------------- 1 | module="./pclta.o" 2 | device="pclta" 3 | group="root" 4 | mode="766" 5 | 6 | /sbin/rmmod ${device} 7 | #/sbin/insmod ${module} base_address=0x340,0xD800,0xD400 interrupt=9,10,10 verbose=1 8 | /sbin/insmod ${module} base_address=0x360 pclta_interrupt=5 pclta_verbose=0 9 | #/sbin/insmod ${module} base_address=0x340 interrupt=5 verbose=0 10 | 11 | rm -f /dev/${device}[0-3] 12 | 13 | 14 | major="254" 15 | 16 | mknod /dev/${device}0 c ${major} 0 17 | #mknod /dev/${device}1 c ${major} 1 18 | #mknod /dev/${device}2 c ${major} 2 19 | #mknod /dev/${device}3 c ${major} 3 20 | 21 | chgrp $group /dev/${device}? 22 | chmod $mode /dev/${device}? 23 | 24 | -------------------------------------------------------------------------------- /ni/makefile: -------------------------------------------------------------------------------- 1 | ######################################################### 2 | #makefile for NI project 3 | 4 | 5 | .SUFFIXES: .C .cpp .o .c 6 | 7 | 8 | VPATH = ../ni/. 9 | 10 | CC = g++ 11 | CPP = g++ 12 | CC_FLAGS = -g -Wall 13 | CPP_FLAGS = -g -Wall 14 | CPP_INCLUDES = -I../../include -I../ldv 15 | LINKER = ar 16 | ni_OBJECTS = ni_msg.o 17 | 18 | all: libni.a 19 | 20 | libni.a: $(ni_OBJECTS) 21 | $(LINKER) -r libni.a $(LINKER_ENTRY) $(LINKER_FLAGS) $(ni_OBJECTS) $(ni_LIBS) 22 | 23 | 24 | .c.o: 25 | $(CPP) -c $< $(CPP_FLAGS) $(CPP_DEFINES) $(CPP_INCLUDES) 26 | .cpp.o: 27 | $(CPP) -c $< $(CPP_FLAGS) $(CPP_DEFINES) $(CPP_INCLUDES) 28 | 29 | ni_msg.o: ../ldv/ldv.h ni_msg.h 30 | 31 | clean: 32 | rm -f *.o 33 | rm -f libni.a 34 | 35 | -------------------------------------------------------------------------------- /application_messaging/makefile: -------------------------------------------------------------------------------- 1 | INCLUDES=-I. -I../../include -I../ldv -I../ni -I../../database2 -I/usr/include/mysql -I/usr/local/mysql/include -I/usr/local/mysql/include/mysql 2 | LIBDIR=-L. -L../../libs -L../../low_level_hardware_interface/serial -L../../database2 3 | LIBS= -lni 4 | CPU_TYPE=`uname -m` 5 | FLAGS= -g -Wall -O2 -march=$(CPU_TYPE) -L/usr/local/mysql/lib/mysql -L/usr/local/mysql/lib -L/usr/lib/mysql 6 | CC=g++ 7 | LINKER=g++ 8 | 9 | all: libApplMsg.a 10 | 11 | clean: 12 | rm -f *.o 13 | rm -f *.a 14 | rm -f core* 15 | 16 | 17 | applmsg.o: applmsg.cpp 18 | $(CC) applmsg.cpp -c $(INCLUDES) $(FLAGS) 19 | 20 | applmsg_degc_products.o: applmsg_degc_products.cpp 21 | $(CC) applmsg_degc_products.cpp -c $(INCLUDES) $(FLAGS) 22 | 23 | 24 | libApplMsg.a: applmsg.o applmsg_degc_products.o 25 | ar -r libApplMsg.a applmsg.o applmsg_degc_products.o 26 | 27 | -------------------------------------------------------------------------------- /ldv/makefile: -------------------------------------------------------------------------------- 1 | ######################################################### 2 | 3 | 4 | .SUFFIXES: .cc .cxx .C .o .cpp 5 | 6 | 7 | VPATH = ./ 8 | 9 | 10 | YACC = bison 11 | LEX = flex 12 | JAVA = gcj 13 | CC = gcc 14 | LINKER = ar 15 | CPP = g++ 16 | CPP_FLAGS = -g 17 | CC_INCLUDES = -I../../include 18 | CPP_INCLUDES = -I. -I../../include 19 | ldv-lib_OBJECTS = ldv.o 20 | 21 | all: libLDV.a 22 | 23 | libLDV.a: $(ldv-lib_OBJECTS) 24 | $(LINKER) -r libLDV.a $(LINKER_ENTRY) $(LINKER_FLAGS) $(ldv-lib_OBJECTS) $(ldv-lib_LIBS) 25 | 26 | .cpp.o: 27 | $(CPP) -c $< $(CPP_FLAGS) $(CPP_DEFINES) $(CPP_INCLUDES) 28 | .C.o: 29 | $(CPP) -c $< $(CPP_FLAGS) $(CPP_DEFINES) $(CPP_INCLUDES) 30 | .cc.o: 31 | $(CPP) -c $< $(CPP_FLAGS) $(CPP_DEFINES) $(CPP_INCLUDES) 32 | .cxx.o: 33 | $(CPP) -c $< $(CPP_FLAGS) $(CPP_DEFINES) $(CPP_INCLUDES) 34 | 35 | 36 | ldv.o: ldv.h ldv.cpp 37 | 38 | clean: 39 | rm -f *.o 40 | rm -f *.a 41 | -------------------------------------------------------------------------------- /kernel_modules_drivers/gesytec-2.06/sysdep.h: -------------------------------------------------------------------------------- 1 | #ifndef _SYSDEP_ 2 | #define _SYSDEP_ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | //=================================================================== 9 | // some Windows types 10 | //=================================================================== 11 | 12 | #ifndef CONST 13 | #define CONST const 14 | #endif 15 | 16 | // Basics 17 | #ifndef VOID 18 | #define VOID void 19 | typedef void *PVOID; 20 | 21 | typedef char CHAR; 22 | typedef short SHORT; 23 | typedef long LONG; 24 | #endif 25 | 26 | 27 | // Pointer to Basics 28 | typedef CHAR *PCHAR; 29 | typedef CHAR *LPSTR, *PSTR; 30 | typedef CONST CHAR *LPCSTR, *PCSTR; 31 | typedef SHORT *PSHORT; // winnt 32 | typedef LONG *PLONG; // winnt 33 | 34 | // Unsigned Basics 35 | typedef unsigned char UCHAR; 36 | typedef unsigned short USHORT; 37 | typedef unsigned long ULONG; 38 | 39 | // Pointer to Unsigned Basics 40 | typedef UCHAR *PUCHAR; 41 | typedef USHORT *PUSHORT; 42 | typedef ULONG *PULONG; 43 | 44 | typedef UCHAR BOOLEAN; // winnt 45 | typedef BOOLEAN *PBOOLEAN; // winnt 46 | #ifndef FALSE 47 | #define FALSE 0 48 | #define TRUE 1 49 | #endif 50 | 51 | 52 | 53 | //=================================================================== 54 | // Compatibility with older Linux versions 55 | //=================================================================== 56 | 57 | #if LINUX_VERSION_CODE < 0x020500 58 | 59 | #define irqreturn_t void 60 | #define IRQ_HANDLED 61 | #define IRQ_NONE 62 | 63 | #define iminor(inode) MINOR(inode->i_rdev) 64 | 65 | #endif 66 | 67 | 68 | #ifdef __cplusplus 69 | } 70 | #endif 71 | 72 | 73 | #endif // _SYSDEP_ 74 | -------------------------------------------------------------------------------- /kernel_modules_drivers/gesytec-2.08/sysdep.h: -------------------------------------------------------------------------------- 1 | #ifndef _SYSDEP_ 2 | #define _SYSDEP_ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | //=================================================================== 9 | // some Windows types 10 | //=================================================================== 11 | 12 | #ifndef CONST 13 | #define CONST const 14 | #endif 15 | 16 | // Basics 17 | #ifndef VOID 18 | #define VOID void 19 | typedef void *PVOID; 20 | 21 | typedef char CHAR; 22 | typedef short SHORT; 23 | typedef long LONG; 24 | #endif 25 | 26 | 27 | // Pointer to Basics 28 | typedef CHAR *PCHAR; 29 | typedef CHAR *LPSTR, *PSTR; 30 | typedef CONST CHAR *LPCSTR, *PCSTR; 31 | typedef SHORT *PSHORT; // winnt 32 | typedef LONG *PLONG; // winnt 33 | 34 | // Unsigned Basics 35 | typedef unsigned char UCHAR; 36 | typedef unsigned short USHORT; 37 | typedef unsigned long ULONG; 38 | 39 | // Pointer to Unsigned Basics 40 | typedef UCHAR *PUCHAR; 41 | typedef USHORT *PUSHORT; 42 | typedef ULONG *PULONG; 43 | 44 | typedef UCHAR BOOLEAN; // winnt 45 | typedef BOOLEAN *PBOOLEAN; // winnt 46 | #ifndef FALSE 47 | #define FALSE 0 48 | #define TRUE 1 49 | #endif 50 | 51 | 52 | 53 | //=================================================================== 54 | // Compatibility with older Linux versions 55 | //=================================================================== 56 | 57 | #if LINUX_VERSION_CODE < 0x020500 58 | 59 | #define irqreturn_t void 60 | #define IRQ_HANDLED 61 | #define IRQ_NONE 62 | 63 | #define iminor(inode) MINOR(inode->i_rdev) 64 | 65 | #endif 66 | 67 | 68 | #ifdef __cplusplus 69 | } 70 | #endif 71 | 72 | 73 | #endif // _SYSDEP_ 74 | -------------------------------------------------------------------------------- /kernel_modules_drivers/gesytec-2.09/sysdep.h: -------------------------------------------------------------------------------- 1 | #ifndef _SYSDEP_ 2 | #define _SYSDEP_ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | //=================================================================== 9 | // some Windows types 10 | //=================================================================== 11 | 12 | #ifndef CONST 13 | #define CONST const 14 | #endif 15 | 16 | // Basics 17 | #ifndef VOID 18 | #define VOID void 19 | typedef void *PVOID; 20 | 21 | typedef char CHAR; 22 | typedef short SHORT; 23 | typedef long LONG; 24 | #endif 25 | 26 | 27 | // Pointer to Basics 28 | typedef CHAR *PCHAR; 29 | typedef CHAR *LPSTR, *PSTR; 30 | typedef CONST CHAR *LPCSTR, *PCSTR; 31 | typedef SHORT *PSHORT; // winnt 32 | typedef LONG *PLONG; // winnt 33 | 34 | // Unsigned Basics 35 | typedef unsigned char UCHAR; 36 | typedef unsigned short USHORT; 37 | typedef unsigned long ULONG; 38 | 39 | // Pointer to Unsigned Basics 40 | typedef UCHAR *PUCHAR; 41 | typedef USHORT *PUSHORT; 42 | typedef ULONG *PULONG; 43 | 44 | typedef UCHAR BOOLEAN; // winnt 45 | typedef BOOLEAN *PBOOLEAN; // winnt 46 | #ifndef FALSE 47 | #define FALSE 0 48 | #define TRUE 1 49 | #endif 50 | 51 | 52 | 53 | //=================================================================== 54 | // Compatibility with older Linux versions 55 | //=================================================================== 56 | 57 | #if LINUX_VERSION_CODE < 0x020500 58 | 59 | #define irqreturn_t void 60 | #define IRQ_HANDLED 61 | #define IRQ_NONE 62 | 63 | #define iminor(inode) MINOR(inode->i_rdev) 64 | 65 | #endif 66 | 67 | 68 | #ifdef __cplusplus 69 | } 70 | #endif 71 | 72 | 73 | #endif // _SYSDEP_ 74 | -------------------------------------------------------------------------------- /kernel_modules_drivers/pclta/pclta.h: -------------------------------------------------------------------------------- 1 | #ifndef _PCLTA_ 2 | #define _PCLTA_ 3 | 4 | //---------------------------------------------------------------------------- 5 | // communication protocol 6 | 7 | // network command and network buffer masks 8 | #define NI_Q_CMD 0xf0 9 | #define NI_QUEUE 0x0f 10 | 11 | // output buffer required commands 12 | #define niCOMM 0x10 13 | #define niNETMGMT 0x20 14 | #define niSERVICE 0xE6 15 | 16 | // output buffer NOT required commands 17 | #define niRESET 0x50 18 | #define niFLUSH_CANCEL 0x60 19 | #define niFLUSH_COMPLETE 0x60 20 | #define niONLINE 0x70 21 | #define niOFFLINE 0x80 22 | #define niFLUSH 0x90 23 | #define niFLUSH_IGN 0xA0 24 | #define niSLEEP 0xB0 25 | #define niSSTATUS 0xE0 26 | #define niIRQENA 0xE5 27 | 28 | // output queues 29 | #define niTQ 0x02 30 | #define niTQ_P 0x03 31 | #define niNTQ 0x04 32 | #define niNTQ_P 0x05 33 | #define niPRIORITY 0x01 34 | 35 | // input queues 36 | #define niRESPONSE 0x06 37 | #define niINCOMING 0x08 38 | 39 | 40 | //---------------------------------------------------------------------------- 41 | // insmod command errors 42 | 43 | #define PCLTA_IOPERM 1 /* I/O ports permission denied */ 44 | #define PCLTA_HSHK 2 /* hardware handshake failed */ 45 | #define PCLTA_LRESET 3 /* node did'n leave RESET state */ 46 | #define PCLTA_RESP 4 /* no response after reset */ 47 | #define PCLTA_IRQPERM 5 /* IRQ permission denied */ 48 | #define PCLTA_STAT 6 /* no response on status message */ 49 | #define PCLTA_TSCV 7 /* transciever not supported */ 50 | #define PCLTA_MAJOR 8 /* major number permission denied */ 51 | #define PCLTA_CDEV 9 /* create device failure */ 52 | 53 | 54 | #endif //__PCLTA 55 | -------------------------------------------------------------------------------- /kernel_modules_drivers/pclta/makefile: -------------------------------------------------------------------------------- 1 | ######################################################### 2 | # Makefile auto generated by Cygnus Source Navigator. 3 | # Target: driver Date: Aug 01 2001 Time: 05:12:13 PM 4 | # 5 | 6 | 7 | .SUFFIXES: .cc .class .java .cxx .C .cpp .o .c .l .y 8 | 9 | 10 | VPATH = /root/lonworks/pclta/. 11 | 12 | 13 | YACC = bison 14 | LEX = flex 15 | JAVA = gcj 16 | CC = gcc 17 | CPP = g++ 18 | YACC_FLAGS = 19 | LEX_FLAGS = 20 | JAVA_FLAGS = 21 | CC_FLAGS = -O2 -Wall 22 | CPP_FLAGS = 23 | YACC_INCLUDES = 24 | LEX_INCLUDES = 25 | JAVA_INCLUDES = 26 | CC_INCLUDES = -I/usr/include -I/usr/src/linux/include 27 | CPP_INCLUDES = 28 | YACC_DEFINES = 29 | LEX_DEFINES = 30 | JAVA_DEFINES = 31 | CC_DEFINES = -DMODULE -D__KERNEL__ 32 | CPP_DEFINES = 33 | driver_LIBS = 34 | LINKER = gcc 35 | LINKER_FLAGS = -r -m elf_i386 -s 36 | LINKER_ENTRY = 37 | driver_OBJECTS = pclta.o 38 | 39 | all: driver 40 | 41 | driver: $(driver_OBJECTS) 42 | $(LINKER) -o driver $(LINKER_ENTRY) $(LINKER_FLAGS) $(driver_OBJECTS) $(driver_LIBS) 43 | 44 | .y.c: 45 | $(YACC) $< $(YACC_FLAGS) $(YACC_DEFINES) $(YACC_INCLUDES) 46 | 47 | 48 | .l.c: 49 | $(LEX) $< $(LEX_FLAGS) $(LEX_DEFINES) $(LEX_INCLUDES) 50 | 51 | 52 | .java.o: 53 | $(JAVA) -c $< $(JAVA_FLAGS) $(JAVA_DEFINES) $(JAVA_INCLUDES) 54 | .class: 55 | $(JAVA) -c $< $(JAVA_FLAGS) $(JAVA_DEFINES) $(JAVA_INCLUDES) 56 | 57 | 58 | .c.o: 59 | $(CC) -c $< $(CC_FLAGS) $(CC_DEFINES) $(CC_INCLUDES) 60 | 61 | 62 | .cpp.o: 63 | $(CPP) -c $< $(CPP_FLAGS) $(CPP_DEFINES) $(CPP_INCLUDES) 64 | .C.o: 65 | $(CPP) -c $< $(CPP_FLAGS) $(CPP_DEFINES) $(CPP_INCLUDES) 66 | .cc.o: 67 | $(CPP) -c $< $(CPP_FLAGS) $(CPP_DEFINES) $(CPP_INCLUDES) 68 | .cxx.o: 69 | $(CPP) -c $< $(CPP_FLAGS) $(CPP_DEFINES) $(CPP_INCLUDES) 70 | 71 | 72 | pclta.o: /usr/include/errno.h /usr/include/malloc.h /usr/include/poll.h /root/lonworks/pclta/pclta.h 73 | 74 | clean: 75 | rm -f *.o 76 | rm -f driver 77 | 78 | -------------------------------------------------------------------------------- /ldv/ldv.h: -------------------------------------------------------------------------------- 1 | /*********** 2 | 3 | Copyright (c) 2000-2005 Karl Hiramoto 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 6 | documentation files (the "Software"), to deal in the Software without restriction, including without limitation the 7 | rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the 11 | Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 14 | WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS 15 | OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 16 | OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 17 | **********/ 18 | 19 | /////////////// 20 | #if !defined LDV_DEFINED 21 | #define LDV_DEFINED 22 | 23 | #define MAX_NI_DATA 256 24 | 25 | typedef int LNI; 26 | typedef enum 27 | { 28 | LDV_OK = 0, 29 | LDV_NOT_FOUND, 30 | LDV_ALREADY_OPEN, 31 | LDV_DEVICE_ERR, 32 | LDV_INVALID_DEVICE_ID, 33 | LDV_DEVICE_BUSY, 34 | LDV_NO_MSG_AVAIL, 35 | LDV_NO_BUF_AVAIL, 36 | LDV_NO_RESOURCES, 37 | LDV_INVALID_BUF_LEN 38 | } LDVCode; 39 | 40 | extern bool network_flag; 41 | 42 | LDVCode ldv_open( const char *device_name, LNI *pHandle ); 43 | LDVCode ldv_close( LNI handle ); 44 | LDVCode ldv_read( LNI handle, void *pMsg, unsigned length ); 45 | LDVCode ldv_write( LNI handle, void *pMsg, unsigned length ); 46 | 47 | #if defined SLTA_2 48 | 49 | /***************************************************/ 50 | /* slta-2 specific not standard functions and data */ 51 | /***************************************************/ 52 | 53 | void ldv_post_events( void ); 54 | 55 | extern int auto_baud_feature; 56 | extern int alert_ack_prtcl; 57 | extern int ldv_buffers; 58 | extern unsigned int baud_rate; 59 | 60 | 61 | #endif /* SLTA_2 */ 62 | 63 | #endif /* LDV_DEFINED */ 64 | -------------------------------------------------------------------------------- /kernel_modules_drivers/gesytec-2.12/sysdep.h: -------------------------------------------------------------------------------- 1 | #ifndef _SYSDEP_ 2 | #define _SYSDEP_ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | //=================================================================== 9 | // some Windows types 10 | //=================================================================== 11 | 12 | #ifndef CONST 13 | #define CONST const 14 | #endif 15 | 16 | // Basics 17 | #ifndef VOID 18 | #define VOID void 19 | typedef void *PVOID; 20 | 21 | typedef char CHAR; 22 | typedef short SHORT; 23 | typedef long LONG; 24 | #endif 25 | 26 | 27 | // Pointer to Basics 28 | typedef CHAR *PCHAR; 29 | typedef CHAR *LPSTR, *PSTR; 30 | typedef CONST CHAR *LPCSTR, *PCSTR; 31 | typedef SHORT *PSHORT; // winnt 32 | typedef LONG *PLONG; // winnt 33 | 34 | // Unsigned Basics 35 | typedef unsigned char BYTE; 36 | typedef unsigned char UCHAR; 37 | typedef unsigned short USHORT; 38 | typedef unsigned long ULONG; 39 | 40 | // Pointer to Unsigned Basics 41 | typedef UCHAR *PUCHAR; 42 | typedef USHORT *PUSHORT; 43 | typedef ULONG *PULONG; 44 | 45 | typedef UCHAR BOOLEAN; // winnt 46 | typedef BOOLEAN *PBOOLEAN; // winnt 47 | #ifndef FALSE 48 | #define FALSE 0 49 | #endif 50 | #ifndef TRUE 51 | #define TRUE 1 52 | #endif 53 | 54 | 55 | //typedef LONG NTSTATUS, *PNTSTATUS; 56 | typedef int NTSTATUS, *PNTSTATUS; 57 | 58 | #ifndef min 59 | #define min(a,b) ((a) > (b) ? (b) : (a)) 60 | #endif 61 | 62 | 63 | 64 | //=================================================================== 65 | // Compatibility with older Linux versions 66 | //=================================================================== 67 | 68 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) 69 | // Kernel 2.4 70 | 71 | #define irqreturn_t void 72 | #define IRQ_HANDLED 73 | #define IRQ_NONE 74 | 75 | #define iminor(inode) MINOR(inode->i_rdev) 76 | #define pci_name(pdev) (pdev->slot_name) 77 | #define pm_message_t u32 78 | 79 | #define USB_SUBMIT_URB(urb, mem_flags) usb_submit_urb(urb) 80 | 81 | #else 82 | // Kernel 2.6 83 | 84 | #define USB_SUBMIT_URB(urb, mem_flags) usb_submit_urb(urb, mem_flags) 85 | 86 | 87 | /* Basic class macros */ 88 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,15) 89 | typedef struct class class_t; 90 | #define CLASS_DEVICE_CREATE(cls, devt, device, fmt, arg...) class_device_create(cls, NULL, devt, device, fmt, ## arg) 91 | #else /* LINUX 2.6.0 - 2.6.14 */ 92 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,13) /* LINUX 2.6.13 - 2.6.14 */ 93 | typedef struct class class_t; 94 | #define CLASS_DEVICE_CREATE class_device_create 95 | #else /* LINUX 2.6.0 - 2.6.12, class_simple */ 96 | typedef struct class_simple class_t; 97 | #define CLASS_DEVICE_CREATE class_simple_device_add 98 | #define class_create class_simple_create 99 | #define class_destroy class_simple_destroy 100 | #define class_device_destroy(a, b) class_simple_device_remove(b) 101 | #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,13) */ 102 | #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,15) */ 103 | 104 | #endif 105 | 106 | 107 | #ifdef __cplusplus 108 | } 109 | #endif 110 | 111 | 112 | #endif // _SYSDEP_ 113 | -------------------------------------------------------------------------------- /application_messaging/applmsg.h: -------------------------------------------------------------------------------- 1 | /*********** 2 | 3 | Copyright (c) 2000-2005 Karl Hiramoto 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 6 | documentation files (the "Software"), to deal in the Software without restriction, including without limitation the 7 | rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the 11 | Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 14 | WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS 15 | OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 16 | OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 17 | **********/ 18 | 19 | 20 | 21 | #ifndef _APPLMSG_H 22 | #define _APPLMSG_H 1 23 | 24 | 25 | 26 | #define NUM_NVS 8 27 | /* Number of Network Variable table entries on this node */ 28 | 29 | 30 | #define MAX_NETWORK_NODES 255 31 | 32 | #define NO_CHECK 0x20 /* do not check response code */ 33 | 34 | #include "dbfunc.h" 35 | 36 | #include "ni_msg.h" 37 | #include "ni_typedef_msg.h" 38 | 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | 45 | #include 46 | #include 47 | 48 | #include "applmsg_degc_products.h" 49 | 50 | // sorry for the global variables 51 | 52 | extern FILE *lon_msg_log; // log messsages here for protocol dubugging 53 | 54 | 55 | // Function headers 56 | 57 | void get_node_service_msg(NeuronCalibrationItem *); 58 | void print_neuron_status_struct(status_struct *SS); 59 | 60 | bool update_address(SendAddrDtl *send_addr,NM_update_addr_request_struct *NewAddr); 61 | bool update_NV_config(SendAddrDtl *send_addr,NM_update_nv_cnfg_request *NVUpdate); 62 | int read_neuron_NV(NeuronCalibrationItem*, byte ,long long*); 63 | bool write_neuron_NV(NeuronCalibrationItem*, byte ,long long ); 64 | bool read_neuron_NV_float(NeuronCalibrationItem*, byte ,float*); 65 | bool write_neuron_NV_float(NeuronCalibrationItem*, byte ,float); 66 | long long read_neuron_memory_long_long(NeuronCalibrationItem *,nm_mem_mode,word offset,byte count); 67 | 68 | bool program_NEIFile_to_neuron(NeuronCalibrationItem *CTSPtr,const char * NEIFile,int subnet, int node); 69 | 70 | bool program_neuron_common_features(NeuronCalibrationItem *CTSPtr,const char * ImageFile,byte subnet, byte node); 71 | void setup_NID_addrress(SendAddrDtl *send_addr,NeuronCalibrationItem *CT); 72 | void convert_int_to_byte_array(long long, byte* ,byte); 73 | bool query_status(SendAddrDtl *send_addr, status_struct *NeuronStatusPtr ); 74 | bool set_neuron_appless_unconfig_offline(NeuronCalibrationItem *CTSPtr); 75 | bool set_node_online(NeuronCalibrationItem *CTSPtr); 76 | bool get_num_net_vars(NeuronCalibrationItem *NCIPtr,int *num); 77 | bool Get_NV_Config(NeuronCalibrationItem *NCIPtr, byte nv_index, nv_struct *nvStructData); 78 | bool Reset_Neuron(NeuronCalibrationItem *CTSPtr); 79 | 80 | 81 | #endif 82 | -------------------------------------------------------------------------------- /kernel_modules_drivers/gesytec-2.12/kdebug.h: -------------------------------------------------------------------------------- 1 | #ifndef _KDEBUG_ 2 | #define _KDEBUG_ 3 | 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | #define DEBUG_DUMP1 0x0001 10 | #define DEBUG_DUMP2 0x0002 11 | #define DEBUG_DUMP_WATCHER 0x0004 12 | #define DEBUG_OPEN_CLOSE 0x0008 13 | #define DEBUG_OPEN_IOCTL 0x0010 14 | #define DEBUG_REGISTER 0x0100 15 | #define DEBUG_DISPATCH_READ 0x0200 16 | #define DEBUG_DISPATCH_WRITE 0x0400 17 | 18 | #if 0 19 | // queue.c queuec.c queuei.c queued.c 20 | struct tomqueue 21 | { 22 | uint datalen; 23 | uint wrp; /* write pointer */ 24 | uint rdp; /* read pointer */ 25 | uint count; /* number of free chars */ 26 | 27 | // uint stop:1; /* nicht verwendet */ 28 | // uint xoffsend:1; /* XON / XOFF gesendet */ 29 | // uint reserved:14; 30 | 31 | unsigned char data[1]; /* raw data */ 32 | } ; 33 | typedef struct tomqueue * QUEUE; 34 | #define sizeofQUEUE (sizeof(struct tomqueue)) 35 | #define qempty(QUEUE) (QUEUE->wrp == QUEUE->rdp) 36 | #define qcontent(QUEUE) (QUEUE->datalen - QUEUE->count) 37 | #define QSIZE(QUEUE) (QUEUE->datalen) 38 | #define qfree(QUEUE) (QUEUE->count) 39 | 40 | void qflush (QUEUE qptr); 41 | int qwrite (QUEUE qptr,void* buffer,int anzbytes); 42 | int qwritec(QUEUE qptr,char writeval); 43 | int qwritei(QUEUE qptr,int writeval); 44 | int qwrited(QUEUE qptr,void *ptr); 45 | int qread (QUEUE qptr,void* buffer,int anzbytes); 46 | int qreadc (QUEUE qptr); 47 | int qreadi (QUEUE qptr); 48 | void *qreadd (QUEUE qptr); 49 | 50 | // queueopn.c queueshm.c 51 | QUEUE qopen (int queue_length_in_bytes); 52 | QUEUE qopen_shm (int queue_length_in_bytes); 53 | void qclose (QUEUE qptr); 54 | 55 | // queuestr.c 56 | int qwritestr(QUEUE q, char *buff); 57 | int qreadstr(QUEUE q, char *buff); 58 | 59 | 60 | 61 | int DbgInit(void); 62 | void DbgExit(void); 63 | void DbgFlush(void); 64 | 65 | asmlinkage int DbgPrint(const char *fmt, ...); 66 | #endif 67 | 68 | /* Use our own dbg macro */ 69 | #undef dbg 70 | #define dbg(format, arg...) do { if (debug) { \ 71 | struct timeval tv; do_gettimeofday(&tv); \ 72 | printk(KERN_DEBUG /*__FILE__*/ DRIVER_MOD_NAME "%2u.%06u: " format "\n", (int)(tv.tv_sec % 10), (int)tv.tv_usec, ## arg); } } while (0) 73 | 74 | #if 0 75 | #define dbg1(format, arg...) do { if (debug & 0x10) dbg(format, ## arg); } while (0) 76 | #define dbg2(format, arg...) do { if (debug & 0x20) dbg(format, ## arg); } while (0) 77 | #define dbg4(format, arg...) do { if (debug & 0x40) dbg(format, ## arg); } while (0) 78 | #define dbg8(format, arg...) do { if (debug & 0x80) dbg(format, ## arg); } while (0) 79 | #else 80 | #define dbg1(format, arg...) do { if (debug & 0x01) printk(KERN_DEBUG __FILE__ ": " format "\n" , ## arg); } while (0) 81 | #define dbg2(format, arg...) do { if (debug & 0x02) printk(KERN_DEBUG __FILE__ ": " format "\n" , ## arg); } while (0) 82 | #define dbg4(format, arg...) do { if (debug & 0x04) printk(KERN_DEBUG __FILE__ ": " format "\n" , ## arg); } while (0) 83 | #define dbg8(format, arg...) do { if (debug & 0x08) printk(KERN_DEBUG __FILE__ ": " format "\n" , ## arg); } while (0) 84 | #endif 85 | 86 | 87 | inline void DumpBuffer(PCHAR Prefix, PVOID pvBuffer, ULONG length) 88 | //static inline void lonusb_debug_data (const char *function, int size, const unsigned char *data) 89 | { 90 | int i; 91 | unsigned char *data = pvBuffer; 92 | 93 | // if (!debug) return; 94 | 95 | printk (KERN_DEBUG "%s ", Prefix); 96 | for (i = 0; i < length; ++i) 97 | { 98 | printk ("%.2X ", data[i]); 99 | } 100 | printk ("\n"); 101 | } 102 | 103 | 104 | #ifdef __cplusplus 105 | } 106 | #endif 107 | 108 | 109 | #endif // _KDEBUG_ 110 | -------------------------------------------------------------------------------- /kernel_modules_drivers/gesytec-2.06/kdebug.h: -------------------------------------------------------------------------------- 1 | #ifndef _KDEBUG_ 2 | #define _KDEBUG_ 3 | 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | #define DEBUG_DUMP1 0x0001 10 | #define DEBUG_DUMP2 0x0002 11 | #define DEBUG_DUMP_WATCHER 0x0004 12 | #define DEBUG_OPEN_CLOSE 0x0008 13 | #define DEBUG_OPEN_IOCTL 0x0010 14 | #define DEBUG_REGISTER 0x0100 15 | #define DEBUG_DISPATCH_READ 0x0200 16 | #define DEBUG_DISPATCH_WRITE 0x0400 17 | 18 | #if 0 19 | // queue.c queuec.c queuei.c queued.c 20 | struct tomqueue 21 | { 22 | uint datalen; 23 | uint wrp; /* write pointer */ 24 | uint rdp; /* read pointer */ 25 | uint count; /* number of free chars */ 26 | 27 | // uint stop:1; /* nicht verwendet */ 28 | // uint xoffsend:1; /* XON / XOFF gesendet */ 29 | // uint reserved:14; 30 | 31 | unsigned char data[1]; /* raw data */ 32 | } ; 33 | typedef struct tomqueue * QUEUE; 34 | #define sizeofQUEUE (sizeof(struct tomqueue)) 35 | #define qempty(QUEUE) (QUEUE->wrp == QUEUE->rdp) 36 | #define qcontent(QUEUE) (QUEUE->datalen - QUEUE->count) 37 | #define QSIZE(QUEUE) (QUEUE->datalen) 38 | #define qfree(QUEUE) (QUEUE->count) 39 | 40 | void qflush (QUEUE qptr); 41 | int qwrite (QUEUE qptr,void* buffer,int anzbytes); 42 | int qwritec(QUEUE qptr,char writeval); 43 | int qwritei(QUEUE qptr,int writeval); 44 | int qwrited(QUEUE qptr,void *ptr); 45 | int qread (QUEUE qptr,void* buffer,int anzbytes); 46 | int qreadc (QUEUE qptr); 47 | int qreadi (QUEUE qptr); 48 | void *qreadd (QUEUE qptr); 49 | 50 | // queueopn.c queueshm.c 51 | QUEUE qopen (int queue_length_in_bytes); 52 | QUEUE qopen_shm (int queue_length_in_bytes); 53 | void qclose (QUEUE qptr); 54 | 55 | // queuestr.c 56 | int qwritestr(QUEUE q, char *buff); 57 | int qreadstr(QUEUE q, char *buff); 58 | 59 | 60 | 61 | int DbgInit(void); 62 | void DbgExit(void); 63 | void DbgFlush(void); 64 | 65 | asmlinkage int DbgPrint(const char *fmt, ...); 66 | #endif 67 | 68 | /* Use our own dbg macro */ 69 | #undef dbg 70 | #define dbg(format, arg...) do { if (debug) { \ 71 | struct timeval tv; do_gettimeofday(&tv); \ 72 | printk(KERN_DEBUG /*__FILE__*/ DRIVER_MOD_NAME "%2u.%06u: " format "\n", (int)(tv.tv_sec % 10), (int)tv.tv_usec, ## arg); } } while (0) 73 | 74 | #if 01 75 | #define dbg1(format, arg...) do { if (debug & 0x10) dbg(format, ## arg); } while (0) 76 | #define dbg2(format, arg...) do { if (debug & 0x20) dbg(format, ## arg); } while (0) 77 | #define dbg4(format, arg...) do { if (debug & 0x40) dbg(format, ## arg); } while (0) 78 | #define dbg8(format, arg...) do { if (debug & 0x80) dbg(format, ## arg); } while (0) 79 | #else 80 | #define dbg1(format, arg...) do { if (debug & 0x01) printk(KERN_DEBUG __FILE__ ": " format "\n" , ## arg); } while (0) 81 | #define dbg2(format, arg...) do { if (debug & 0x02) printk(KERN_DEBUG __FILE__ ": " format "\n" , ## arg); } while (0) 82 | #define dbg4(format, arg...) do { if (debug & 0x04) printk(KERN_DEBUG __FILE__ ": " format "\n" , ## arg); } while (0) 83 | #define dbg8(format, arg...) do { if (debug & 0x08) printk(KERN_DEBUG __FILE__ ": " format "\n" , ## arg); } while (0) 84 | #endif 85 | 86 | 87 | inline void DumpBuffer(PCHAR Prefix, PVOID pvBuffer, ULONG length) 88 | //static inline void lonusb_debug_data (const char *function, int size, const unsigned char *data) 89 | { 90 | int i; 91 | unsigned char *data = pvBuffer; 92 | 93 | // if (!debug) return; 94 | 95 | printk (KERN_DEBUG "%s ", Prefix); 96 | for (i = 0; i < length; ++i) 97 | { 98 | printk ("%.2X ", data[i]); 99 | } 100 | printk ("\n"); 101 | } 102 | 103 | 104 | #ifdef __cplusplus 105 | } 106 | #endif 107 | 108 | 109 | #endif // _KDEBUG_ 110 | -------------------------------------------------------------------------------- /kernel_modules_drivers/gesytec-2.08/kdebug.h: -------------------------------------------------------------------------------- 1 | #ifndef _KDEBUG_ 2 | #define _KDEBUG_ 3 | 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | #define DEBUG_DUMP1 0x0001 10 | #define DEBUG_DUMP2 0x0002 11 | #define DEBUG_DUMP_WATCHER 0x0004 12 | #define DEBUG_OPEN_CLOSE 0x0008 13 | #define DEBUG_OPEN_IOCTL 0x0010 14 | #define DEBUG_REGISTER 0x0100 15 | #define DEBUG_DISPATCH_READ 0x0200 16 | #define DEBUG_DISPATCH_WRITE 0x0400 17 | 18 | #if 0 19 | // queue.c queuec.c queuei.c queued.c 20 | struct tomqueue 21 | { 22 | uint datalen; 23 | uint wrp; /* write pointer */ 24 | uint rdp; /* read pointer */ 25 | uint count; /* number of free chars */ 26 | 27 | // uint stop:1; /* nicht verwendet */ 28 | // uint xoffsend:1; /* XON / XOFF gesendet */ 29 | // uint reserved:14; 30 | 31 | unsigned char data[1]; /* raw data */ 32 | } ; 33 | typedef struct tomqueue * QUEUE; 34 | #define sizeofQUEUE (sizeof(struct tomqueue)) 35 | #define qempty(QUEUE) (QUEUE->wrp == QUEUE->rdp) 36 | #define qcontent(QUEUE) (QUEUE->datalen - QUEUE->count) 37 | #define QSIZE(QUEUE) (QUEUE->datalen) 38 | #define qfree(QUEUE) (QUEUE->count) 39 | 40 | void qflush (QUEUE qptr); 41 | int qwrite (QUEUE qptr,void* buffer,int anzbytes); 42 | int qwritec(QUEUE qptr,char writeval); 43 | int qwritei(QUEUE qptr,int writeval); 44 | int qwrited(QUEUE qptr,void *ptr); 45 | int qread (QUEUE qptr,void* buffer,int anzbytes); 46 | int qreadc (QUEUE qptr); 47 | int qreadi (QUEUE qptr); 48 | void *qreadd (QUEUE qptr); 49 | 50 | // queueopn.c queueshm.c 51 | QUEUE qopen (int queue_length_in_bytes); 52 | QUEUE qopen_shm (int queue_length_in_bytes); 53 | void qclose (QUEUE qptr); 54 | 55 | // queuestr.c 56 | int qwritestr(QUEUE q, char *buff); 57 | int qreadstr(QUEUE q, char *buff); 58 | 59 | 60 | 61 | int DbgInit(void); 62 | void DbgExit(void); 63 | void DbgFlush(void); 64 | 65 | asmlinkage int DbgPrint(const char *fmt, ...); 66 | #endif 67 | 68 | /* Use our own dbg macro */ 69 | #undef dbg 70 | #define dbg(format, arg...) do { if (debug) { \ 71 | struct timeval tv; do_gettimeofday(&tv); \ 72 | printk(KERN_DEBUG /*__FILE__*/ DRIVER_MOD_NAME "%2u.%06u: " format "\n", (int)(tv.tv_sec % 10), (int)tv.tv_usec, ## arg); } } while (0) 73 | 74 | #if 01 75 | #define dbg1(format, arg...) do { if (debug & 0x10) dbg(format, ## arg); } while (0) 76 | #define dbg2(format, arg...) do { if (debug & 0x20) dbg(format, ## arg); } while (0) 77 | #define dbg4(format, arg...) do { if (debug & 0x40) dbg(format, ## arg); } while (0) 78 | #define dbg8(format, arg...) do { if (debug & 0x80) dbg(format, ## arg); } while (0) 79 | #else 80 | #define dbg1(format, arg...) do { if (debug & 0x01) printk(KERN_DEBUG __FILE__ ": " format "\n" , ## arg); } while (0) 81 | #define dbg2(format, arg...) do { if (debug & 0x02) printk(KERN_DEBUG __FILE__ ": " format "\n" , ## arg); } while (0) 82 | #define dbg4(format, arg...) do { if (debug & 0x04) printk(KERN_DEBUG __FILE__ ": " format "\n" , ## arg); } while (0) 83 | #define dbg8(format, arg...) do { if (debug & 0x08) printk(KERN_DEBUG __FILE__ ": " format "\n" , ## arg); } while (0) 84 | #endif 85 | 86 | 87 | inline void DumpBuffer(PCHAR Prefix, PVOID pvBuffer, ULONG length) 88 | //static inline void lonusb_debug_data (const char *function, int size, const unsigned char *data) 89 | { 90 | int i; 91 | unsigned char *data = pvBuffer; 92 | 93 | // if (!debug) return; 94 | 95 | printk (KERN_DEBUG "%s ", Prefix); 96 | for (i = 0; i < length; ++i) 97 | { 98 | printk ("%.2X ", data[i]); 99 | } 100 | printk ("\n"); 101 | } 102 | 103 | 104 | #ifdef __cplusplus 105 | } 106 | #endif 107 | 108 | 109 | #endif // _KDEBUG_ 110 | -------------------------------------------------------------------------------- /kernel_modules_drivers/gesytec-2.09/kdebug.h: -------------------------------------------------------------------------------- 1 | #ifndef _KDEBUG_ 2 | #define _KDEBUG_ 3 | 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | #define DEBUG_DUMP1 0x0001 10 | #define DEBUG_DUMP2 0x0002 11 | #define DEBUG_DUMP_WATCHER 0x0004 12 | #define DEBUG_OPEN_CLOSE 0x0008 13 | #define DEBUG_OPEN_IOCTL 0x0010 14 | #define DEBUG_REGISTER 0x0100 15 | #define DEBUG_DISPATCH_READ 0x0200 16 | #define DEBUG_DISPATCH_WRITE 0x0400 17 | 18 | #if 0 19 | // queue.c queuec.c queuei.c queued.c 20 | struct tomqueue 21 | { 22 | uint datalen; 23 | uint wrp; /* write pointer */ 24 | uint rdp; /* read pointer */ 25 | uint count; /* number of free chars */ 26 | 27 | // uint stop:1; /* nicht verwendet */ 28 | // uint xoffsend:1; /* XON / XOFF gesendet */ 29 | // uint reserved:14; 30 | 31 | unsigned char data[1]; /* raw data */ 32 | } ; 33 | typedef struct tomqueue * QUEUE; 34 | #define sizeofQUEUE (sizeof(struct tomqueue)) 35 | #define qempty(QUEUE) (QUEUE->wrp == QUEUE->rdp) 36 | #define qcontent(QUEUE) (QUEUE->datalen - QUEUE->count) 37 | #define QSIZE(QUEUE) (QUEUE->datalen) 38 | #define qfree(QUEUE) (QUEUE->count) 39 | 40 | void qflush (QUEUE qptr); 41 | int qwrite (QUEUE qptr,void* buffer,int anzbytes); 42 | int qwritec(QUEUE qptr,char writeval); 43 | int qwritei(QUEUE qptr,int writeval); 44 | int qwrited(QUEUE qptr,void *ptr); 45 | int qread (QUEUE qptr,void* buffer,int anzbytes); 46 | int qreadc (QUEUE qptr); 47 | int qreadi (QUEUE qptr); 48 | void *qreadd (QUEUE qptr); 49 | 50 | // queueopn.c queueshm.c 51 | QUEUE qopen (int queue_length_in_bytes); 52 | QUEUE qopen_shm (int queue_length_in_bytes); 53 | void qclose (QUEUE qptr); 54 | 55 | // queuestr.c 56 | int qwritestr(QUEUE q, char *buff); 57 | int qreadstr(QUEUE q, char *buff); 58 | 59 | 60 | 61 | int DbgInit(void); 62 | void DbgExit(void); 63 | void DbgFlush(void); 64 | 65 | asmlinkage int DbgPrint(const char *fmt, ...); 66 | #endif 67 | 68 | /* Use our own dbg macro */ 69 | #undef dbg 70 | #define dbg(format, arg...) do { if (debug) { \ 71 | struct timeval tv; do_gettimeofday(&tv); \ 72 | printk(KERN_DEBUG /*__FILE__*/ DRIVER_MOD_NAME "%2u.%06u: " format "\n", (int)(tv.tv_sec % 10), (int)tv.tv_usec, ## arg); } } while (0) 73 | 74 | #if 01 75 | #define dbg1(format, arg...) do { if (debug & 0x10) dbg(format, ## arg); } while (0) 76 | #define dbg2(format, arg...) do { if (debug & 0x20) dbg(format, ## arg); } while (0) 77 | #define dbg4(format, arg...) do { if (debug & 0x40) dbg(format, ## arg); } while (0) 78 | #define dbg8(format, arg...) do { if (debug & 0x80) dbg(format, ## arg); } while (0) 79 | #else 80 | #define dbg1(format, arg...) do { if (debug & 0x01) printk(KERN_DEBUG __FILE__ ": " format "\n" , ## arg); } while (0) 81 | #define dbg2(format, arg...) do { if (debug & 0x02) printk(KERN_DEBUG __FILE__ ": " format "\n" , ## arg); } while (0) 82 | #define dbg4(format, arg...) do { if (debug & 0x04) printk(KERN_DEBUG __FILE__ ": " format "\n" , ## arg); } while (0) 83 | #define dbg8(format, arg...) do { if (debug & 0x08) printk(KERN_DEBUG __FILE__ ": " format "\n" , ## arg); } while (0) 84 | #endif 85 | 86 | 87 | inline void DumpBuffer(PCHAR Prefix, PVOID pvBuffer, ULONG length) 88 | //static inline void lonusb_debug_data (const char *function, int size, const unsigned char *data) 89 | { 90 | int i; 91 | unsigned char *data = pvBuffer; 92 | 93 | // if (!debug) return; 94 | 95 | printk (KERN_DEBUG "%s ", Prefix); 96 | for (i = 0; i < length; ++i) 97 | { 98 | printk ("%.2X ", data[i]); 99 | } 100 | printk ("\n"); 101 | } 102 | 103 | 104 | #ifdef __cplusplus 105 | } 106 | #endif 107 | 108 | 109 | #endif // _KDEBUG_ 110 | -------------------------------------------------------------------------------- /kernel_modules_drivers/gesytec-2.12/driverdata.c: -------------------------------------------------------------------------------- 1 | /*****************************************************************************/ 2 | /* 3 | * Linux driver for Easylon USB Interfaces 4 | * 5 | * Copyright (c)2003 Gesytec GmbH, Volker Schober (info@gesytec.de) 6 | * Licensend for use with Easylon USB Interfaces by Gesytec 7 | * 8 | * Please compile lpclinux.c 9 | * 10 | */ 11 | /*****************************************************************************/ 12 | 13 | #ifdef CONFIG_LPC_DEBUG 14 | static int debug = 0xFF; 15 | #else 16 | static int debug; 17 | #endif 18 | 19 | 20 | #ifdef LPC_MAJOR 21 | static int major = LPC_MAJOR; 22 | #else 23 | static int major = 0; 24 | #endif 25 | 26 | 27 | static char *isa; 28 | 29 | 30 | /* Module paramaters */ 31 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) 32 | module_param(debug, int, S_IRUGO | S_IWUSR); //0644); 33 | module_param(major, int, S_IRUGO | S_IWUSR); //0644); 34 | #ifdef MODULE 35 | module_param(isa, charp, S_IRUGO | S_IWUSR); //0644); 36 | #endif 37 | #else 38 | MODULE_PARM(debug, "i"); 39 | MODULE_PARM(major, "i"); 40 | #ifdef MODULE 41 | MODULE_PARM(isa, "s"); 42 | #endif 43 | #endif 44 | MODULE_PARM_DESC(debug, "Debug enabled or not"); 45 | 46 | 47 | #ifndef NO_PCI 48 | /* table of devices that work with this driver */ 49 | static struct pci_device_id lpp_pci_tbl[] = { 50 | { GESYTEC_VENDOR_ID, LPP_PRODUCT_ID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, }, 51 | { } /* Terminating entry */ 52 | }; 53 | MODULE_DEVICE_TABLE(pci, lpp_pci_tbl); 54 | #endif 55 | 56 | 57 | 58 | 59 | /* array of pointers to our devices that are currently connected */ 60 | static struct _DEVICE_EXTENSION *minor_table[MAX_DEVICES]; 61 | 62 | /* lock to protect the minor_table structure */ 63 | static DECLARE_MUTEX (minor_table_mutex); 64 | 65 | /* 66 | * File operations needed when we register this driver. 67 | * This assumes that this driver NEEDS file operations, 68 | * of course, which means that the driver is expected 69 | * to have a node in the /dev directory. If the USB 70 | * device were for a network interface then the driver 71 | * would use "struct net_driver" instead, and a serial 72 | * device would use "struct tty_driver". 73 | */ 74 | static struct file_operations lpc_fops = 75 | { 76 | /* 77 | * The owner field is part of the module-locking 78 | * mechanism. The idea is that the kernel knows 79 | * which module to increment the use-counter of 80 | * BEFORE it calls the device's open() function. 81 | * This also means that the kernel can decrement 82 | * the use-counter again before calling release() 83 | * or should the open() function fail. 84 | * 85 | * Not all device structures have an "owner" field 86 | * yet. "struct file_operations" and "struct net_device" 87 | * do, while "struct tty_driver" does not. If the struct 88 | * has an "owner" field, then initialize it to the value 89 | * THIS_MODULE and the kernel will handle all module 90 | * locking for you automatically. Otherwise, you must 91 | * increment the use-counter in the open() function 92 | * and decrement it again in the release() function 93 | * yourself. 94 | */ 95 | 96 | owner: THIS_MODULE, 97 | 98 | read: lpc_read, 99 | write: lpc_write, 100 | poll: lpc_poll, 101 | ioctl: lpc_ioctl, 102 | open: lpc_open, 103 | release: lpc_release, 104 | }; 105 | 106 | 107 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) 108 | static class_t *lpcclass; 109 | #endif 110 | 111 | //static const char driver_version[] = DRIVER_VERSION; 112 | 113 | static const u8 irq_table[16] = { 114 | // 0 1 2 *3* 4 *5* 6 *7* 115 | 0x00,0x00,0x00,0x80,0x00,0x90,0x00,0xA0, 116 | // 8 *9* *10* *11* *12* 13 14 *15* 117 | 0x00,0xB0,0xC0,0xD0,0xE0,0x00,0x00,0xF0 118 | }; 119 | 120 | //static DEV *devs[MAX_LPCS+MAX_LPPS]; 121 | 122 | static u16 lpcs[MAX_LPCS];// = { 0x5340, 0x7344 }; 123 | 124 | 125 | #ifndef NO_PCI 126 | static struct pci_driver lpp_driver = { 127 | .name = DRIVER_MOD_NAME, 128 | .id_table = lpp_pci_tbl, 129 | .probe = lpp_init_one, 130 | .remove = lpp_remove_one, 131 | #ifdef CONFIG_PM 132 | .resume = lpp_resume, 133 | .suspend = lpp_suspend, 134 | #endif 135 | }; 136 | #endif 137 | -------------------------------------------------------------------------------- /kernel_modules_drivers/gesytec-2.06/Makefile: -------------------------------------------------------------------------------- 1 | #***************************************************************************** 2 | # 3 | # Linux driver for Easylon ISA/PC-104/PCI Interfaces 4 | # 5 | # Copyright (c)2004 Gesytec GmbH, Volker Schober (info@gesytec.de) 6 | # Licensend for use with Easylon ISA/PC-104/PCI Interfaces by Gesytec 7 | # 8 | #***************************************************************************** 9 | 10 | KERNEL_VERSION = $(shell uname -r) 11 | KERNEL_SOURCE ?= /lib/modules/$(KERNEL_VERSION)/build 12 | KERNEL_HEADERS = $(KERNEL_SOURCE)/include 13 | 14 | # define a unique major number for the character device (see /proc/devices) 15 | EXTRA_CFLAGS += -DLPC_MAJOR=84 16 | 17 | # remove "#" from line below if you want to enable debug messages 18 | # EXTRA_CFLAGS += -DCONFIG_LPC_DEBUG 19 | 20 | 21 | # if Rules.make exists in the kernel tree, we assume 2.4 style modules 22 | # if it doesn't assume 2.5 / 2.6 style 23 | OLDMAKE = $(wildcard $(KERNEL_SOURCE)/Rules.make) 24 | 25 | ifeq (,$(OLDMAKE)) 26 | #***************************************************************************** 27 | # 2.5 / 2.6 style modules, get the kernel makefiles to do the work 28 | #***************************************************************************** 29 | 30 | all: modules 31 | 32 | obj-m := lpclinux.o 33 | 34 | # Set to something different to install somewhere else: 35 | # MOD_DIR := extra 36 | 37 | 38 | 39 | .PHONY: modules install clean modules_add modules_install 40 | 41 | #install : modules_add 42 | install: 43 | @if [ ! -c "/dev/lon1" ]; then mknod /dev/lon1 c 84 0; fi; # (lon1 is the 1st ISA card) 44 | @if [ ! -c "/dev/lon2" ]; then mknod /dev/lon2 c 84 1; fi; # (lon2 is the 2nd ISA card) 45 | @if [ ! -c "/dev/lon3" ]; then mknod /dev/lon3 c 84 32; fi; # (lon3 is the 1st PCI card) 46 | @if [ ! -c "/dev/lon4" ]; then mknod /dev/lon4 c 84 33; fi; # (lon4 is the 2nd PCI card) 47 | @chmod 666 /dev/lon* 48 | @ls -lF /dev/lon* 49 | @echo 50 | $(MAKE) -C $(KERNEL_SOURCE) SUBDIRS=$(CURDIR) modules_install 51 | 52 | 53 | modules modules_add modules_install clean: 54 | $(MAKE) -C $(KERNEL_SOURCE) $@ SUBDIRS=$(CURDIR) 55 | 56 | 57 | else # $(OLDMAKE) 58 | #***************************************************************************** 59 | # 2.4 style modules 60 | #***************************************************************************** 61 | 62 | #INCLUDEDIR = /usr/src/linux-$(KERNEL_VERSION)/include 63 | #INCLUDEDIR = /usr/src/linux/include 64 | #INCLUDEDIR = /usr/src/linux-2.4/include 65 | ifneq (,$(wildcard /usr/src/linux/include)) 66 | INCLUDEDIR = /usr/src/linux/include 67 | else 68 | INCLUDEDIR = /usr/src/linux-2.4/include 69 | endif 70 | INCLUDEDIR = /lib/modules/$(KERNEL_VERSION)/build/include 71 | 72 | CC = gcc 73 | LD = ld 74 | SHELL = sh 75 | TARGET = lpclinux.o 76 | CFILES = driverdata.c driverentry.c lpclinux.c #dynbuf.c 77 | HFILES = Makefile kdebug.h lpclinux.h #dynbuf.h 78 | 79 | CFLAGS = -D__KERNEL__ -DMODULE -DLINUX -DEXPORT_SYMTAB 80 | CFLAGS += $(EXTRA_CFLAGS) 81 | 82 | # remove "#" from line below if kernel compiled with SMP support 83 | # CFLAGS += -D__SMP__ 84 | 85 | 86 | CFLAGS += -I$(INCLUDEDIR) -I. 87 | 88 | # check for module versioning configured in the kernel sources 89 | CFLAGS += $(shell [ -f $(INCLUDEDIR)/linux/modversions.h ] && \ 90 | echo -DMODVERSIONS -include $(INCLUDEDIR)/linux/modversions.h) 91 | CFLAGS += -O2 -pipe 92 | 93 | ifneq (,$(wildcard /lib/modules/$(KERNEL_VERSION)/kernel)) 94 | INSTALLDIR = /lib/modules/$(KERNEL_VERSION)/kernel/drivers/pci 95 | else 96 | INSTALLDIR = /lib/modules/$(KERNEL_VERSION)/pci 97 | endif 98 | 99 | all: modules 100 | 101 | modules: lpclinux.o 102 | 103 | lpclinux.o: $(CFILES) $(HFILES) 104 | # $(CC) $(CFLAGS) -c lpclinux.c -o lpclinux_.o 2>&1 | grep -v "warning: concatenation of string literals with __FUNCTION__ is deprecated" 105 | # $(CC) $(CFLAGS) -c lpclinux.c -o lpclinux.o 106 | $(CC) $(CFLAGS) -c lpclinux.c -o lpclinux_.o 107 | $(LD) -r -o lpclinux.o lpclinux_.o 108 | rm lpclinux_.o 109 | 110 | install: lpclinux.o 111 | @if [ ! -c "/dev/lon1" ]; then mknod /dev/lon1 c 84 0; fi; # (lon1 is the 1st ISA card) 112 | @if [ ! -c "/dev/lon2" ]; then mknod /dev/lon2 c 84 1; fi; # (lon2 is the 2nd ISA card) 113 | @if [ ! -c "/dev/lon3" ]; then mknod /dev/lon3 c 84 32; fi; # (lon3 is the 1st PCI card) 114 | @if [ ! -c "/dev/lon4" ]; then mknod /dev/lon4 c 84 33; fi; # (lon4 is the 2nd PCI card) 115 | @chmod 666 /dev/lon* 116 | @ls -lF /dev/lon* 117 | @echo 118 | @echo INSTALLDIR=$(INSTALLDIR) 119 | mkdir -p $(INSTALLDIR) 120 | install -m 644 lpclinux.o $(INSTALLDIR) 121 | depmod -a -e 122 | 123 | uninstall: 124 | $(SHELL) -c 'if [ -f $(INSTALLDIR)/lpclinux.o ]; then \ 125 | rm $(INSTALLDIR)/lpclinux.o; \ 126 | fi' 127 | 128 | clean: 129 | rm -f *.o core 130 | 131 | endif # $(OLDMAKE) 132 | -------------------------------------------------------------------------------- /kernel_modules_drivers/gesytec-2.08/Makefile: -------------------------------------------------------------------------------- 1 | #***************************************************************************** 2 | # 3 | # Linux driver for Easylon ISA/PC-104/PCI Interfaces 4 | # 5 | # Copyright (c)2004 Gesytec GmbH, Volker Schober (info@gesytec.de) 6 | # Licensend for use with Easylon ISA/PC-104/PCI Interfaces by Gesytec 7 | # 8 | #***************************************************************************** 9 | 10 | KERNEL_VERSION = $(shell uname -r) 11 | KERNEL_SOURCE ?= /lib/modules/$(KERNEL_VERSION)/build 12 | KERNEL_HEADERS = $(KERNEL_SOURCE)/include 13 | 14 | # define a unique major number for the character device (see /proc/devices) 15 | EXTRA_CFLAGS += -DLPC_MAJOR=84 16 | 17 | # remove "#" from line below if you want to enable debug messages 18 | # EXTRA_CFLAGS += -DCONFIG_LPC_DEBUG 19 | 20 | 21 | # if Rules.make exists in the kernel tree, we assume 2.4 style modules 22 | # if it doesn't assume 2.5 / 2.6 style 23 | OLDMAKE = $(wildcard $(KERNEL_SOURCE)/Rules.make) 24 | 25 | ifeq (,$(OLDMAKE)) 26 | #***************************************************************************** 27 | # 2.5 / 2.6 style modules, get the kernel makefiles to do the work 28 | #***************************************************************************** 29 | 30 | all: modules 31 | 32 | obj-m := lpclinux.o 33 | 34 | # Set to something different to install somewhere else: 35 | # MOD_DIR := extra 36 | 37 | 38 | 39 | .PHONY: modules install clean modules_add modules_install 40 | 41 | #install : modules_add 42 | install: 43 | @if [ ! -c "/dev/lon1" ]; then mknod /dev/lon1 c 84 0; fi; # (lon1 is the 1st ISA card) 44 | @if [ ! -c "/dev/lon2" ]; then mknod /dev/lon2 c 84 1; fi; # (lon2 is the 2nd ISA card) 45 | @if [ ! -c "/dev/lon3" ]; then mknod /dev/lon3 c 84 32; fi; # (lon3 is the 1st PCI card) 46 | @if [ ! -c "/dev/lon4" ]; then mknod /dev/lon4 c 84 33; fi; # (lon4 is the 2nd PCI card) 47 | @chmod 666 /dev/lon* 48 | @ls -lF /dev/lon* 49 | @echo 50 | $(MAKE) -C $(KERNEL_SOURCE) SUBDIRS=$(CURDIR) modules_install 51 | 52 | 53 | modules modules_add modules_install clean: 54 | $(MAKE) -C $(KERNEL_SOURCE) $@ SUBDIRS=$(CURDIR) 55 | 56 | 57 | else # $(OLDMAKE) 58 | #***************************************************************************** 59 | # 2.4 style modules 60 | #***************************************************************************** 61 | 62 | #INCLUDEDIR = /usr/src/linux-$(KERNEL_VERSION)/include 63 | #INCLUDEDIR = /usr/src/linux/include 64 | #INCLUDEDIR = /usr/src/linux-2.4/include 65 | ifneq (,$(wildcard /usr/src/linux/include)) 66 | INCLUDEDIR = /usr/src/linux/include 67 | else 68 | INCLUDEDIR = /usr/src/linux-2.4/include 69 | endif 70 | INCLUDEDIR = /lib/modules/$(KERNEL_VERSION)/build/include 71 | 72 | CC = gcc 73 | LD = ld 74 | SHELL = sh 75 | TARGET = lpclinux.o 76 | CFILES = driverdata.c driverentry.c lpclinux.c #dynbuf.c 77 | HFILES = Makefile kdebug.h lpclinux.h #dynbuf.h 78 | 79 | CFLAGS = -D__KERNEL__ -DMODULE -DLINUX -DEXPORT_SYMTAB 80 | CFLAGS += $(EXTRA_CFLAGS) 81 | 82 | # remove "#" from line below if kernel compiled with SMP support 83 | # CFLAGS += -D__SMP__ 84 | 85 | 86 | CFLAGS += -I$(INCLUDEDIR) -I. 87 | 88 | # check for module versioning configured in the kernel sources 89 | CFLAGS += $(shell [ -f $(INCLUDEDIR)/linux/modversions.h ] && \ 90 | echo -DMODVERSIONS -include $(INCLUDEDIR)/linux/modversions.h) 91 | CFLAGS += -O2 -pipe 92 | 93 | ifneq (,$(wildcard /lib/modules/$(KERNEL_VERSION)/kernel)) 94 | INSTALLDIR = /lib/modules/$(KERNEL_VERSION)/kernel/drivers/pci 95 | else 96 | INSTALLDIR = /lib/modules/$(KERNEL_VERSION)/pci 97 | endif 98 | 99 | all: modules 100 | 101 | modules: lpclinux.o 102 | 103 | lpclinux.o: $(CFILES) $(HFILES) 104 | # $(CC) $(CFLAGS) -c lpclinux.c -o lpclinux_.o 2>&1 | grep -v "warning: concatenation of string literals with __FUNCTION__ is deprecated" 105 | # $(CC) $(CFLAGS) -c lpclinux.c -o lpclinux.o 106 | $(CC) $(CFLAGS) -c lpclinux.c -o lpclinux_.o 107 | $(LD) -r -o lpclinux.o lpclinux_.o 108 | rm lpclinux_.o 109 | 110 | install: lpclinux.o 111 | @if [ ! -c "/dev/lon1" ]; then mknod /dev/lon1 c 84 0; fi; # (lon1 is the 1st ISA card) 112 | @if [ ! -c "/dev/lon2" ]; then mknod /dev/lon2 c 84 1; fi; # (lon2 is the 2nd ISA card) 113 | @if [ ! -c "/dev/lon3" ]; then mknod /dev/lon3 c 84 32; fi; # (lon3 is the 1st PCI card) 114 | @if [ ! -c "/dev/lon4" ]; then mknod /dev/lon4 c 84 33; fi; # (lon4 is the 2nd PCI card) 115 | @chmod 666 /dev/lon* 116 | @ls -lF /dev/lon* 117 | @echo 118 | @echo INSTALLDIR=$(INSTALLDIR) 119 | mkdir -p $(INSTALLDIR) 120 | install -m 644 lpclinux.o $(INSTALLDIR) 121 | depmod -a -e 122 | 123 | uninstall: 124 | $(SHELL) -c 'if [ -f $(INSTALLDIR)/lpclinux.o ]; then \ 125 | rm $(INSTALLDIR)/lpclinux.o; \ 126 | fi' 127 | 128 | clean: 129 | rm -f *.o core 130 | 131 | endif # $(OLDMAKE) 132 | -------------------------------------------------------------------------------- /kernel_modules_drivers/gesytec-2.09/Makefile: -------------------------------------------------------------------------------- 1 | #***************************************************************************** 2 | # 3 | # Linux driver for Easylon ISA/PC-104/PCI Interfaces 4 | # 5 | # Copyright (c)2004 Gesytec GmbH, Volker Schober (info@gesytec.de) 6 | # Licensend for use with Easylon ISA/PC-104/PCI Interfaces by Gesytec 7 | # 8 | #***************************************************************************** 9 | 10 | KERNEL_VERSION = $(shell uname -r) 11 | KERNEL_SOURCE ?= /lib/modules/$(KERNEL_VERSION)/build 12 | KERNEL_HEADERS = $(KERNEL_SOURCE)/include 13 | 14 | # define a unique major number for the character device (see /proc/devices) 15 | EXTRA_CFLAGS += -DLPC_MAJOR=84 16 | 17 | # remove "#" from line below if you want to enable debug messages 18 | # EXTRA_CFLAGS += -DCONFIG_LPC_DEBUG 19 | 20 | # remove "#" from line below if you want only a ISA/PC-104 driver 21 | # EXTRA_CFLAGS += -DNO_PCI 22 | 23 | 24 | # if Rules.make exists in the kernel tree, we assume 2.4 style modules 25 | # if it doesn't assume 2.5 / 2.6 style 26 | OLDMAKE = $(wildcard $(KERNEL_SOURCE)/Rules.make) 27 | 28 | ifeq (,$(OLDMAKE)) 29 | #***************************************************************************** 30 | # 2.5 / 2.6 style modules, get the kernel makefiles to do the work 31 | #***************************************************************************** 32 | 33 | all: modules 34 | 35 | obj-m := lpclinux.o 36 | 37 | # Set to something different to install somewhere else: 38 | # MOD_DIR := extra 39 | 40 | 41 | 42 | .PHONY: modules install clean modules_add modules_install 43 | 44 | #install : modules_add 45 | install: 46 | @if [ ! -c "/dev/lon1" ]; then mknod /dev/lon1 c 84 0; fi; # (lon1 is the 1st ISA card) 47 | @if [ ! -c "/dev/lon2" ]; then mknod /dev/lon2 c 84 1; fi; # (lon2 is the 2nd ISA card) 48 | @if [ ! -c "/dev/lon3" ]; then mknod /dev/lon3 c 84 32; fi; # (lon3 is the 1st PCI card) 49 | @if [ ! -c "/dev/lon4" ]; then mknod /dev/lon4 c 84 33; fi; # (lon4 is the 2nd PCI card) 50 | @chmod 666 /dev/lon* 51 | @ls -lF /dev/lon* 52 | @echo 53 | $(MAKE) -C $(KERNEL_SOURCE) SUBDIRS=$(CURDIR) modules_install 54 | 55 | 56 | modules modules_add modules_install clean: 57 | $(MAKE) -C $(KERNEL_SOURCE) $@ SUBDIRS=$(CURDIR) 58 | 59 | 60 | else # $(OLDMAKE) 61 | #***************************************************************************** 62 | # 2.4 style modules 63 | #***************************************************************************** 64 | 65 | #INCLUDEDIR = /usr/src/linux-$(KERNEL_VERSION)/include 66 | #INCLUDEDIR = /usr/src/linux/include 67 | #INCLUDEDIR = /usr/src/linux-2.4/include 68 | ifneq (,$(wildcard /usr/src/linux/include)) 69 | INCLUDEDIR = /usr/src/linux/include 70 | else 71 | INCLUDEDIR = /usr/src/linux-2.4/include 72 | endif 73 | INCLUDEDIR = /lib/modules/$(KERNEL_VERSION)/build/include 74 | 75 | CC = gcc 76 | LD = ld 77 | SHELL = sh 78 | TARGET = lpclinux.o 79 | CFILES = driverdata.c driverentry.c lpclinux.c #dynbuf.c 80 | HFILES = Makefile kdebug.h lpclinux.h #dynbuf.h 81 | 82 | CFLAGS = -D__KERNEL__ -DMODULE -DLINUX -DEXPORT_SYMTAB 83 | CFLAGS += $(EXTRA_CFLAGS) 84 | 85 | # remove "#" from line below if kernel compiled with SMP support 86 | # CFLAGS += -D__SMP__ 87 | 88 | 89 | CFLAGS += -I$(INCLUDEDIR) -I. 90 | 91 | # check for module versioning configured in the kernel sources 92 | CFLAGS += $(shell [ -f $(INCLUDEDIR)/linux/modversions.h ] && \ 93 | echo -DMODVERSIONS -include $(INCLUDEDIR)/linux/modversions.h) 94 | CFLAGS += -O2 -pipe 95 | 96 | ifneq (,$(wildcard /lib/modules/$(KERNEL_VERSION)/kernel)) 97 | INSTALLDIR = /lib/modules/$(KERNEL_VERSION)/kernel/drivers/pci 98 | else 99 | INSTALLDIR = /lib/modules/$(KERNEL_VERSION)/pci 100 | endif 101 | 102 | all: modules 103 | 104 | modules: lpclinux.o 105 | 106 | lpclinux.o: $(CFILES) $(HFILES) 107 | # $(CC) $(CFLAGS) -c lpclinux.c -o lpclinux_.o 2>&1 | grep -v "warning: concatenation of string literals with __FUNCTION__ is deprecated" 108 | # $(CC) $(CFLAGS) -c lpclinux.c -o lpclinux.o 109 | $(CC) $(CFLAGS) -c lpclinux.c -o lpclinux_.o 110 | $(LD) -r -o lpclinux.o lpclinux_.o 111 | rm lpclinux_.o 112 | 113 | install: lpclinux.o 114 | @if [ ! -c "/dev/lon1" ]; then mknod /dev/lon1 c 84 0; fi; # (lon1 is the 1st ISA card) 115 | @if [ ! -c "/dev/lon2" ]; then mknod /dev/lon2 c 84 1; fi; # (lon2 is the 2nd ISA card) 116 | @if [ ! -c "/dev/lon3" ]; then mknod /dev/lon3 c 84 32; fi; # (lon3 is the 1st PCI card) 117 | @if [ ! -c "/dev/lon4" ]; then mknod /dev/lon4 c 84 33; fi; # (lon4 is the 2nd PCI card) 118 | @chmod 666 /dev/lon* 119 | @ls -lF /dev/lon* 120 | @echo 121 | @echo INSTALLDIR=$(INSTALLDIR) 122 | mkdir -p $(INSTALLDIR) 123 | install -m 644 lpclinux.o $(INSTALLDIR) 124 | depmod -a -e 125 | 126 | uninstall: 127 | $(SHELL) -c 'if [ -f $(INSTALLDIR)/lpclinux.o ]; then \ 128 | rm $(INSTALLDIR)/lpclinux.o; \ 129 | fi' 130 | 131 | clean: 132 | rm -f *.o core 133 | 134 | endif # $(OLDMAKE) 135 | -------------------------------------------------------------------------------- /kernel_modules_drivers/gesytec-2.06/lpclinux.h: -------------------------------------------------------------------------------- 1 | /*****************************************************************************/ 2 | /* 3 | * Linux driver for Easylon ISA/PC-104/PCI Interfaces 4 | * 5 | * Copyright (c)2004 Gesytec GmbH, Volker Schober (info@gesytec.de) 6 | * Licensend for use with Easylon USB Interfaces by Gesytec 7 | * 8 | * Please compile lpclinux.c 9 | * 10 | */ 11 | /*****************************************************************************/ 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | #include 21 | #include 22 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) 23 | #include 24 | #else 25 | #include 26 | #endif 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) 35 | #include 36 | #include 37 | #include 38 | #else 39 | #include 40 | #endif 41 | #include 42 | 43 | #include "sysdep.h" 44 | #include "kdebug.h" 45 | #include "Plx9050.h" 46 | //#include "dynbuf.h" 47 | 48 | 49 | 50 | #define CHECK_ISA_AT_LOAD_TIME 51 | 52 | 53 | /* Version Information */ 54 | #define DRIVER_VERSION "V2.06" 55 | #define DRIVER_AUTHOR "Volker Schober, vschober@gesytec.de" 56 | #define DRIVER_DESC "Easylon LPC/LPP PnP Driver" 57 | #define DRIVER_MOD_NAME "lpclinux" /* module name */ 58 | #define DRIVER_DEV_NAME "lpc" /* /dev/lonusb */ 59 | 60 | 61 | /* Define these values to match your device */ 62 | #define GESYTEC_VENDOR_ID 0x1555 63 | #define LPP_PRODUCT_ID 0x0002 64 | 65 | #define IOCTL_VERSION 0x43504C00 66 | #define IOCTL_WATCHER 0x43504C01 67 | 68 | 69 | #define PFX DRIVER_MOD_NAME ": " 70 | 71 | #define NUM_INBUF 64 72 | #define NUM_OUTBUF 16 73 | #define MAX_LPCS 32 74 | #define MAX_LPPS 32 75 | 76 | #define MAX_DEVICES (MAX_LPCS + MAX_LPPS) 77 | 78 | 79 | typedef struct _DEVICE_EXTENSION { 80 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0) 81 | struct wait_queue *rd_wait; 82 | // struct wait_queue *wr_wait; 83 | #else 84 | wait_queue_head_t rd_wait; 85 | // wait_queue_head_t wr_wait; 86 | #endif 87 | uint minor; 88 | int open_count; /* number of times this port has been opened */ 89 | /* 90 | int PciIntCount; 91 | int PciIntCountPlus; 92 | int PciIntCountMinus; 93 | 94 | int TimerCountPlus; 95 | int TimerCountMinus; 96 | */ 97 | struct tasklet_struct Dpc; 98 | struct timer_list drvtimer; 99 | 100 | u32 PlxIntCsrPort; //pciport; 101 | u32 cport; 102 | u32 rport; 103 | u32 wport; 104 | u32 wtcport; 105 | int irq; 106 | 107 | volatile int inhead; 108 | volatile int intail; 109 | volatile int outhead; 110 | volatile int outtail; 111 | volatile u8 ctl; 112 | volatile u8 state; 113 | volatile u8 active; 114 | u8 wtc_exist; 115 | u8 inbuf[NUM_INBUF][256]; 116 | u8 outbuf[NUM_OUTBUF][256]; 117 | } DEV, DEVICE_EXTENSION, *PDEVICE_EXTENSION; 118 | 119 | 120 | 121 | #define CMD_NULL 0x00 122 | #define CMD_XFER 0x01 123 | #define CMD_RESYNC 0x5A 124 | #define CMD_ACKSYNC 0x07 125 | #define EOM 0x00 126 | 127 | #define NOUT(x) outb(x, wport) 128 | #define NIN inb(rport) 129 | #define LPCSTAT inb(cport) 130 | #define SETCTL outb(dev->ctl, cport) 131 | #define HS while((st = LPCSTAT) & 1) if(!(st & 4)) return -1 132 | 133 | #define WOUT(x) outb(x, wtcport) 134 | #define WIN inb(wtcport) 135 | #define WTCHS while(LPCSTAT & 2) if(jiffies>t) return -ENODEV 136 | 137 | enum { 138 | ST_RESYNC = 0, 139 | ST_RESET, 140 | ST_FLCAN, 141 | ST_UPLINK, 142 | ST_IDLE, 143 | ST_NIACK, 144 | }; 145 | 146 | 147 | //#define CLI save_flags(flags); cli() 148 | //#define STI restore_flags(flags) 149 | 150 | /* local function prototypes */ 151 | static ssize_t lpc_read (struct file *file, char *buffer, size_t count, loff_t *ppos); 152 | static ssize_t lpc_write (struct file *file, const char *buffer, size_t count, loff_t *ppos); 153 | static unsigned lpc_poll (struct file *file, struct poll_table_struct *wait); 154 | static int lpc_ioctl (struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg); 155 | static int lpc_open (struct inode *inode, struct file *file); 156 | static int lpc_release (struct inode *inode, struct file *file); 157 | 158 | static int lpp_init_one (struct pci_dev *pdev, const struct pci_device_id *ent); 159 | static void lpp_remove_one (struct pci_dev *pdev); 160 | static int lpp_suspend (struct pci_dev *pdev, u32 state); 161 | static int lpp_resume (struct pci_dev *pdev); 162 | -------------------------------------------------------------------------------- /kernel_modules_drivers/gesytec-2.08/lpclinux.h: -------------------------------------------------------------------------------- 1 | /*****************************************************************************/ 2 | /* 3 | * Linux driver for Easylon ISA/PC-104/PCI Interfaces 4 | * 5 | * Copyright (c)2004 Gesytec GmbH, Volker Schober (info@gesytec.de) 6 | * Licensend for use with Easylon USB Interfaces by Gesytec 7 | * 8 | * Please compile lpclinux.c 9 | * 10 | */ 11 | /*****************************************************************************/ 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | #include 21 | #include 22 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) 23 | #include 24 | #else 25 | #include 26 | #endif 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) 35 | #include 36 | #include 37 | #include 38 | #else 39 | #include 40 | #endif 41 | #include 42 | 43 | #include "sysdep.h" 44 | #include "kdebug.h" 45 | #include "Plx9050.h" 46 | //#include "dynbuf.h" 47 | 48 | 49 | 50 | #define CHECK_ISA_AT_LOAD_TIME 51 | 52 | 53 | /* Version Information */ 54 | #define DRIVER_VERSION "V2.08a" 55 | #define DRIVER_AUTHOR "Volker Schober, vschober@gesytec.de" 56 | #define DRIVER_DESC "Easylon LPC/LPP PnP Driver" 57 | #define DRIVER_MOD_NAME "lpclinux" /* module name */ 58 | #define DRIVER_DEV_NAME "lpc" /* /dev/lonusb */ 59 | 60 | 61 | /* Define these values to match your device */ 62 | #define GESYTEC_VENDOR_ID 0x1555 63 | #define LPP_PRODUCT_ID 0x0002 64 | 65 | #define IOCTL_VERSION 0x43504C00 66 | #define IOCTL_WATCHER 0x43504C01 67 | 68 | 69 | #define PFX DRIVER_MOD_NAME ": " 70 | 71 | #define NUM_INBUF 64 72 | #define NUM_OUTBUF 16 73 | #define MAX_LPCS 32 74 | #define MAX_LPPS 32 75 | 76 | #define MAX_DEVICES (MAX_LPCS + MAX_LPPS) 77 | 78 | 79 | typedef struct _DEVICE_EXTENSION { 80 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0) 81 | struct wait_queue *rd_wait; 82 | // struct wait_queue *wr_wait; 83 | #else 84 | wait_queue_head_t rd_wait; 85 | // wait_queue_head_t wr_wait; 86 | #endif 87 | uint minor; 88 | int open_count; /* number of times this port has been opened */ 89 | /* 90 | int PciIntCount; 91 | int PciIntCountPlus; 92 | int PciIntCountMinus; 93 | 94 | int TimerCountPlus; 95 | int TimerCountMinus; 96 | */ 97 | struct tasklet_struct Dpc; 98 | struct timer_list drvtimer; 99 | 100 | u32 PlxIntCsrPort; //pciport; 101 | u32 cport; 102 | u32 rport; 103 | u32 wport; 104 | u32 wtcport; 105 | int irq; 106 | 107 | volatile int inhead; 108 | volatile int intail; 109 | volatile int outhead; 110 | volatile int outtail; 111 | volatile u8 ctl; 112 | volatile u8 state; 113 | volatile u8 active; 114 | u8 wtc_exist; 115 | u8 inbuf[NUM_INBUF][256]; 116 | u8 outbuf[NUM_OUTBUF][256]; 117 | } DEV, DEVICE_EXTENSION, *PDEVICE_EXTENSION; 118 | 119 | 120 | 121 | #define CMD_NULL 0x00 122 | #define CMD_XFER 0x01 123 | #define CMD_RESYNC 0x5A 124 | #define CMD_ACKSYNC 0x07 125 | #define EOM 0x00 126 | 127 | #define NOUT(x) outb(x, wport) 128 | #define NIN inb(rport) 129 | #define LPCSTAT inb(cport) 130 | #define SETCTL outb(dev->ctl, cport) 131 | #define HS while((st = LPCSTAT) & 1) if(!(st & 4)) return -1 132 | 133 | #define WOUT(x) outb(x, wtcport) 134 | #define WIN inb(wtcport) 135 | #define WTCHS while(LPCSTAT & 2) if(jiffies>t) return -ENODEV 136 | 137 | enum { 138 | ST_RESYNC = 0, 139 | ST_RESET, 140 | ST_FLCAN, 141 | ST_UPLINK, 142 | ST_IDLE, 143 | ST_NIACK, 144 | }; 145 | 146 | 147 | //#define CLI save_flags(flags); cli() 148 | //#define STI restore_flags(flags) 149 | 150 | /* local function prototypes */ 151 | static ssize_t lpc_read (struct file *file, char *buffer, size_t count, loff_t *ppos); 152 | static ssize_t lpc_write (struct file *file, const char *buffer, size_t count, loff_t *ppos); 153 | static unsigned lpc_poll (struct file *file, struct poll_table_struct *wait); 154 | static int lpc_ioctl (struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg); 155 | static int lpc_open (struct inode *inode, struct file *file); 156 | static int lpc_release (struct inode *inode, struct file *file); 157 | 158 | static int lpp_init_one (struct pci_dev *pdev, const struct pci_device_id *ent); 159 | static void lpp_remove_one (struct pci_dev *pdev); 160 | static int lpp_suspend (struct pci_dev *pdev, u32 state); 161 | static int lpp_resume (struct pci_dev *pdev); 162 | -------------------------------------------------------------------------------- /kernel_modules_drivers/gesytec-2.09/lpclinux.h: -------------------------------------------------------------------------------- 1 | /*****************************************************************************/ 2 | /* 3 | * Linux driver for Easylon ISA/PC-104/PCI Interfaces 4 | * 5 | * Copyright (c)2004 Gesytec GmbH, Volker Schober (info@gesytec.de) 6 | * Licensend for use with Easylon USB Interfaces by Gesytec 7 | * 8 | * Please compile lpclinux.c 9 | * 10 | */ 11 | /*****************************************************************************/ 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | #include 21 | #include 22 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) 23 | #include 24 | #else 25 | #include 26 | #endif 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) 35 | #include 36 | #include 37 | #include 38 | #else 39 | #include 40 | #endif 41 | #include 42 | 43 | #include "sysdep.h" 44 | #include "kdebug.h" 45 | #include "Plx9050.h" 46 | //#include "dynbuf.h" 47 | 48 | 49 | 50 | #define CHECK_ISA_AT_LOAD_TIME 51 | 52 | 53 | /* Version Information */ 54 | #define DRIVER_VERSION "V2.09" 55 | #define DRIVER_AUTHOR "Volker Schober, vschober@gesytec.de" 56 | #define DRIVER_DESC "Easylon LPC/LPP PnP Driver" 57 | #define DRIVER_MOD_NAME "lpclinux" /* module name */ 58 | #define DRIVER_DEV_NAME "lpc" /* /dev/lonusb */ 59 | 60 | 61 | /* Define these values to match your device */ 62 | #define GESYTEC_VENDOR_ID 0x1555 63 | #define LPP_PRODUCT_ID 0x0002 64 | 65 | #define IOCTL_VERSION 0x43504C00 66 | #define IOCTL_WATCHER 0x43504C01 67 | 68 | 69 | #define PFX DRIVER_MOD_NAME ": " 70 | 71 | #define NUM_INBUF 64 72 | #define NUM_OUTBUF 16 73 | #define MAX_LPCS 32 74 | #define MAX_LPPS 32 75 | 76 | #define MAX_DEVICES (MAX_LPCS + MAX_LPPS) 77 | 78 | 79 | typedef struct _DEVICE_EXTENSION { 80 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0) 81 | struct wait_queue *rd_wait; 82 | // struct wait_queue *wr_wait; 83 | #else 84 | wait_queue_head_t rd_wait; 85 | // wait_queue_head_t wr_wait; 86 | #endif 87 | uint minor; 88 | int open_count; /* number of times this port has been opened */ 89 | /* 90 | int PciIntCount; 91 | int PciIntCountPlus; 92 | int PciIntCountMinus; 93 | 94 | int TimerCountPlus; 95 | int TimerCountMinus; 96 | */ 97 | struct tasklet_struct Dpc; 98 | struct timer_list drvtimer; 99 | 100 | u32 PlxIntCsrPort; //pciport; 101 | u32 cport; 102 | u32 rport; 103 | u32 wport; 104 | u32 wtcport; 105 | int irq; 106 | 107 | volatile int inhead; 108 | volatile int intail; 109 | volatile int outhead; 110 | volatile int outtail; 111 | volatile u8 ctl; 112 | volatile u8 state; 113 | volatile u8 active; 114 | u8 wtc_exist; 115 | u8 inbuf[NUM_INBUF][256]; 116 | u8 outbuf[NUM_OUTBUF][256]; 117 | } DEV, DEVICE_EXTENSION, *PDEVICE_EXTENSION; 118 | 119 | 120 | 121 | #define CMD_NULL 0x00 122 | #define CMD_XFER 0x01 123 | #define CMD_RESYNC 0x5A 124 | #define CMD_ACKSYNC 0x07 125 | #define EOM 0x00 126 | 127 | #define NOUT(x) outb(x, wport) 128 | #define NIN inb(rport) 129 | #define LPCSTAT inb(cport) 130 | #define SETCTL outb(dev->ctl, cport) 131 | #define HS while((st = LPCSTAT) & 1) if(!(st & 4)) return -1 132 | 133 | #define WOUT(x) outb(x, wtcport) 134 | #define WIN inb(wtcport) 135 | #define WTCHS while(LPCSTAT & 2) if(jiffies>t) return -ENODEV 136 | 137 | enum { 138 | ST_RESYNC = 0, 139 | ST_RESET, 140 | ST_FLCAN, 141 | ST_UPLINK, 142 | ST_IDLE, 143 | ST_NIACK, 144 | }; 145 | 146 | 147 | //#define CLI save_flags(flags); cli() 148 | //#define STI restore_flags(flags) 149 | 150 | /* local function prototypes */ 151 | static ssize_t lpc_read (struct file *file, char *buffer, size_t count, loff_t *ppos); 152 | static ssize_t lpc_write (struct file *file, const char *buffer, size_t count, loff_t *ppos); 153 | static unsigned lpc_poll (struct file *file, struct poll_table_struct *wait); 154 | static int lpc_ioctl (struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg); 155 | static int lpc_open (struct inode *inode, struct file *file); 156 | static int lpc_release (struct inode *inode, struct file *file); 157 | 158 | #ifndef NO_PCI 159 | static int lpp_init_one (struct pci_dev *pdev, const struct pci_device_id *ent); 160 | static void lpp_remove_one (struct pci_dev *pdev); 161 | static int lpp_suspend (struct pci_dev *pdev, u32 state); 162 | static int lpp_resume (struct pci_dev *pdev); 163 | #endif 164 | -------------------------------------------------------------------------------- /kernel_modules_drivers/gesytec-2.12/lpclinux.h: -------------------------------------------------------------------------------- 1 | /*****************************************************************************/ 2 | /* 3 | * Linux driver for Easylon ISA/PC-104/PCI Interfaces 4 | * 5 | * Copyright (c)2004 Gesytec GmbH, Volker Schober (info@gesytec.de) 6 | * Licensend for use with Easylon USB Interfaces by Gesytec 7 | * 8 | * Please compile lpclinux.c 9 | * 10 | */ 11 | /*****************************************************************************/ 12 | 13 | #include 14 | //#include 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | #include 21 | #include 22 | 23 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) 24 | #include 25 | #else 26 | #include 27 | #endif 28 | 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | 37 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) 38 | #include 39 | #include 40 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,13) 41 | #include 42 | #endif 43 | #else 44 | #include 45 | #endif 46 | 47 | #include 48 | 49 | 50 | #include "sysdep.h" 51 | #include "kdebug.h" 52 | #include "Plx9050.h" 53 | //#include "dynbuf.h" 54 | 55 | 56 | 57 | #define CHECK_ISA_AT_LOAD_TIME 58 | 59 | 60 | /* Version Information */ 61 | #define DRIVER_VERSION "V2.12" 62 | #define DRIVER_AUTHOR "Volker Schober, vschober@gesytec.de" 63 | #define DRIVER_DESC "Easylon LPC/LPP PnP Driver" 64 | #define DRIVER_MOD_NAME "lpclinux" /* module name */ 65 | #define DRIVER_DEV_NAME "lpc" /* /dev/lonusb */ 66 | #define CLASS_NAME "easylon" 67 | 68 | 69 | /* Define these values to match your device */ 70 | #define GESYTEC_VENDOR_ID 0x1555 71 | #define LPP_PRODUCT_ID 0x0002 72 | 73 | #define IOCTL_VERSION 0x43504C00 74 | #define IOCTL_WATCHER 0x43504C01 75 | 76 | 77 | #define PFX DRIVER_MOD_NAME ": " 78 | 79 | #define NUM_INBUF 64 80 | #define NUM_OUTBUF 16 81 | #define MAX_LPCS 32 82 | #define MAX_LPPS 32 83 | 84 | #define MAX_DEVICES (MAX_LPCS + MAX_LPPS) 85 | 86 | 87 | typedef struct _DEVICE_EXTENSION { 88 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0) 89 | struct wait_queue *rd_wait; 90 | // struct wait_queue *wr_wait; 91 | #else 92 | wait_queue_head_t rd_wait; 93 | // wait_queue_head_t wr_wait; 94 | #endif 95 | uint minor; 96 | int open_count; /* number of times this port has been opened */ 97 | /* 98 | int PciIntCount; 99 | int PciIntCountPlus; 100 | int PciIntCountMinus; 101 | 102 | int TimerCountPlus; 103 | int TimerCountMinus; 104 | */ 105 | struct tasklet_struct Dpc; 106 | struct timer_list drvtimer; 107 | 108 | u32 PlxIntCsrPort; //pciport; 109 | u32 cport; 110 | u32 rport; 111 | u32 wport; 112 | u32 wtcport; 113 | int irq; 114 | 115 | volatile int inhead; 116 | volatile int intail; 117 | volatile int outhead; 118 | volatile int outtail; 119 | volatile u8 ctl; 120 | volatile u8 state; 121 | volatile u8 active; 122 | struct device *device; 123 | u8 wtc_exist; 124 | u8 inbuf[NUM_INBUF][256]; 125 | u8 outbuf[NUM_OUTBUF][256]; 126 | } DEV, DEVICE_EXTENSION, *PDEVICE_EXTENSION; 127 | 128 | 129 | 130 | #define CMD_NULL 0x00 131 | #define CMD_XFER 0x01 132 | #define CMD_RESYNC 0x5A 133 | #define CMD_ACKSYNC 0x07 134 | #define EOM 0x00 135 | 136 | #define NOUT(x) outb(x, wport) 137 | #define NIN inb(rport) 138 | #define LPCSTAT inb(cport) 139 | #define SETCTL outb(dev->ctl, cport) 140 | #define HS while((st = LPCSTAT) & 1) if(!(st & 4)) return -1 141 | 142 | #define WOUT(x) outb(x, wtcport) 143 | #define WIN inb(wtcport) 144 | #define WTCHS while(LPCSTAT & 2) if(jiffies>t) return -ENODEV 145 | 146 | enum { 147 | ST_RESYNC = 0, 148 | ST_RESET, 149 | ST_FLCAN, 150 | ST_UPLINK, 151 | ST_IDLE, 152 | ST_NIACK, 153 | }; 154 | 155 | 156 | /* local function prototypes */ 157 | static ssize_t lpc_read (struct file *file, char *buffer, size_t count, loff_t *ppos); 158 | static ssize_t lpc_write (struct file *file, const char *buffer, size_t count, loff_t *ppos); 159 | static unsigned lpc_poll (struct file *file, struct poll_table_struct *wait); 160 | static int lpc_ioctl (struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg); 161 | static int lpc_open (struct inode *inode, struct file *file); 162 | static int lpc_release (struct inode *inode, struct file *file); 163 | 164 | #ifndef NO_PCI 165 | static int lpp_init_one (struct pci_dev *pdev, const struct pci_device_id *ent); 166 | static void lpp_remove_one (struct pci_dev *pdev); 167 | static int lpp_suspend (struct pci_dev *pdev, pm_message_t state); 168 | static int lpp_resume (struct pci_dev *pdev); 169 | #endif 170 | 171 | static BOOLEAN sm_stub(DEV *dev); 172 | -------------------------------------------------------------------------------- /kernel_modules_drivers/gesytec-2.06/driverdata.c: -------------------------------------------------------------------------------- 1 | /*****************************************************************************/ 2 | /* 3 | * Linux driver for Easylon USB Interfaces 4 | * 5 | * Copyright (c)2003 Gesytec GmbH, Volker Schober (info@gesytec.de) 6 | * Licensend for use with Easylon USB Interfaces by Gesytec 7 | * 8 | * Please compile lpclinux.c 9 | * 10 | */ 11 | /*****************************************************************************/ 12 | 13 | #ifdef CONFIG_LPC_DEBUG 14 | static int debug = 0xFF; 15 | #else 16 | static int debug; 17 | #endif 18 | 19 | 20 | #ifdef LPC_MAJOR 21 | static int major = LPC_MAJOR; 22 | #else 23 | static int major = 0; 24 | #endif 25 | 26 | 27 | 28 | /* Module paramaters */ 29 | MODULE_PARM(debug, "i"); 30 | MODULE_PARM_DESC(debug, "Debug enabled or not"); 31 | 32 | 33 | /* table of devices that work with this driver */ 34 | static struct pci_device_id lpp_pci_tbl[] = { 35 | { GESYTEC_VENDOR_ID, LPP_PRODUCT_ID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, }, 36 | { }, 37 | }; 38 | MODULE_DEVICE_TABLE(pci, lpp_pci_tbl); 39 | 40 | #ifdef MODULE 41 | 42 | static char *isa; 43 | MODULE_PARM(major, "i"); 44 | MODULE_PARM(isa, "s"); 45 | 46 | #endif 47 | 48 | 49 | 50 | /* array of pointers to our devices that are currently connected */ 51 | static struct _DEVICE_EXTENSION *minor_table[MAX_DEVICES]; 52 | 53 | /* lock to protect the minor_table structure */ 54 | static DECLARE_MUTEX (minor_table_mutex); 55 | 56 | #if 0 57 | /* 58 | * File operations needed when we register this driver. 59 | * This assumes that this driver NEEDS file operations, 60 | * of course, which means that the driver is expected 61 | * to have a node in the /dev directory. If the USB 62 | * device were for a network interface then the driver 63 | * would use "struct net_driver" instead, and a serial 64 | * device would use "struct tty_driver". 65 | */ 66 | static struct file_operations lonusb_fops = { 67 | /* 68 | * The owner field is part of the module-locking 69 | * mechanism. The idea is that the kernel knows 70 | * which module to increment the use-counter of 71 | * BEFORE it calls the device's open() function. 72 | * This also means that the kernel can decrement 73 | * the use-counter again before calling release() 74 | * or should the open() function fail. 75 | * 76 | * Not all device structures have an "owner" field 77 | * yet. "struct file_operations" and "struct net_device" 78 | * do, while "struct tty_driver" does not. If the struct 79 | * has an "owner" field, then initialize it to the value 80 | * THIS_MODULE and the kernel will handle all module 81 | * locking for you automatically. Otherwise, you must 82 | * increment the use-counter in the open() function 83 | * and decrement it again in the release() function 84 | * yourself. 85 | */ 86 | owner: THIS_MODULE, 87 | 88 | read: lonusb_read, 89 | write: lonusb_write, 90 | poll: lonusb_poll, 91 | ioctl: lonusb_ioctl, 92 | open: lonusb_open, 93 | release: lonusb_release, 94 | }; 95 | #endif 96 | 97 | #if LINUX_VERSION_CODE < 0x020400 98 | 99 | static struct file_operations lpc_fops = 100 | { 101 | NULL, // llseek 102 | lpc_read, 103 | lpc_write, 104 | NULL, // readdir 105 | lpc_poll, 106 | lpc_ioctl, 107 | NULL, // mmap 108 | lpc_open, 109 | NULL, // flush 110 | lpc_release, 111 | NULL, // fsync 112 | NULL, // fasync 113 | NULL, // check_media_change 114 | NULL, // revalidate 115 | NULL, // lock 116 | }; 117 | 118 | #else 119 | 120 | static struct file_operations lpc_fops = 121 | { 122 | owner: THIS_MODULE, 123 | 124 | read: lpc_read, 125 | write: lpc_write, 126 | poll: lpc_poll, 127 | ioctl: lpc_ioctl, 128 | open: lpc_open, 129 | release: lpc_release, 130 | /* 131 | THIS_MODULE, // owner 132 | NULL, // llseek 133 | lpc_read, 134 | lpc_write, 135 | NULL, // readdir 136 | lpc_poll, 137 | lpc_ioctl, 138 | NULL, // mmap 139 | lpc_open, 140 | NULL, // flush 141 | lpc_release, 142 | NULL, // fsync 143 | NULL, // fasync 144 | NULL, // lock 145 | NULL, // readv 146 | NULL, // writev 147 | NULL, // sendpage 148 | NULL, // get_unmapped_area 149 | */ 150 | }; 151 | 152 | #endif 153 | 154 | 155 | //static const char driver_version[] = DRIVER_VERSION; 156 | 157 | static const u8 irq_table[16] = { 158 | // 0 1 2 *3* 4 *5* 6 *7* 159 | 0x00,0x00,0x00,0x80,0x00,0x90,0x00,0xA0, 160 | // 8 *9* *10* *11* *12* 13 14 *15* 161 | 0x00,0xB0,0xC0,0xD0,0xE0,0x00,0x00,0xF0 162 | }; 163 | 164 | //static DEV *devs[MAX_LPCS+MAX_LPPS]; 165 | 166 | static u16 lpcs[MAX_LPCS];// = { 0x5340, 0x7344 }; 167 | 168 | 169 | static struct pci_driver lpp_driver = { 170 | .name = DRIVER_MOD_NAME, 171 | .id_table = lpp_pci_tbl, 172 | .probe = lpp_init_one, 173 | .remove = lpp_remove_one, 174 | #ifdef CONFIG_PM 175 | .resume = lpp_resume, 176 | .suspend = lpp_suspend, 177 | #endif 178 | }; 179 | -------------------------------------------------------------------------------- /kernel_modules_drivers/gesytec-2.08/driverdata.c: -------------------------------------------------------------------------------- 1 | /*****************************************************************************/ 2 | /* 3 | * Linux driver for Easylon USB Interfaces 4 | * 5 | * Copyright (c)2003 Gesytec GmbH, Volker Schober (info@gesytec.de) 6 | * Licensend for use with Easylon USB Interfaces by Gesytec 7 | * 8 | * Please compile lpclinux.c 9 | * 10 | */ 11 | /*****************************************************************************/ 12 | 13 | #ifdef CONFIG_LPC_DEBUG 14 | static int debug = 0xFF; 15 | #else 16 | static int debug; 17 | #endif 18 | 19 | 20 | #ifdef LPC_MAJOR 21 | static int major = LPC_MAJOR; 22 | #else 23 | static int major = 0; 24 | #endif 25 | 26 | 27 | 28 | /* Module paramaters */ 29 | MODULE_PARM(debug, "i"); 30 | MODULE_PARM_DESC(debug, "Debug enabled or not"); 31 | 32 | 33 | /* table of devices that work with this driver */ 34 | static struct pci_device_id lpp_pci_tbl[] = { 35 | { GESYTEC_VENDOR_ID, LPP_PRODUCT_ID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, }, 36 | { }, 37 | }; 38 | MODULE_DEVICE_TABLE(pci, lpp_pci_tbl); 39 | 40 | #ifdef MODULE 41 | 42 | static char *isa; 43 | MODULE_PARM(major, "i"); 44 | MODULE_PARM(isa, "s"); 45 | 46 | #endif 47 | 48 | 49 | 50 | /* array of pointers to our devices that are currently connected */ 51 | static struct _DEVICE_EXTENSION *minor_table[MAX_DEVICES]; 52 | 53 | /* lock to protect the minor_table structure */ 54 | static DECLARE_MUTEX (minor_table_mutex); 55 | 56 | #if 0 57 | /* 58 | * File operations needed when we register this driver. 59 | * This assumes that this driver NEEDS file operations, 60 | * of course, which means that the driver is expected 61 | * to have a node in the /dev directory. If the USB 62 | * device were for a network interface then the driver 63 | * would use "struct net_driver" instead, and a serial 64 | * device would use "struct tty_driver". 65 | */ 66 | static struct file_operations lonusb_fops = { 67 | /* 68 | * The owner field is part of the module-locking 69 | * mechanism. The idea is that the kernel knows 70 | * which module to increment the use-counter of 71 | * BEFORE it calls the device's open() function. 72 | * This also means that the kernel can decrement 73 | * the use-counter again before calling release() 74 | * or should the open() function fail. 75 | * 76 | * Not all device structures have an "owner" field 77 | * yet. "struct file_operations" and "struct net_device" 78 | * do, while "struct tty_driver" does not. If the struct 79 | * has an "owner" field, then initialize it to the value 80 | * THIS_MODULE and the kernel will handle all module 81 | * locking for you automatically. Otherwise, you must 82 | * increment the use-counter in the open() function 83 | * and decrement it again in the release() function 84 | * yourself. 85 | */ 86 | owner: THIS_MODULE, 87 | 88 | read: lonusb_read, 89 | write: lonusb_write, 90 | poll: lonusb_poll, 91 | ioctl: lonusb_ioctl, 92 | open: lonusb_open, 93 | release: lonusb_release, 94 | }; 95 | #endif 96 | 97 | #if LINUX_VERSION_CODE < 0x020400 98 | 99 | static struct file_operations lpc_fops = 100 | { 101 | NULL, // llseek 102 | lpc_read, 103 | lpc_write, 104 | NULL, // readdir 105 | lpc_poll, 106 | lpc_ioctl, 107 | NULL, // mmap 108 | lpc_open, 109 | NULL, // flush 110 | lpc_release, 111 | NULL, // fsync 112 | NULL, // fasync 113 | NULL, // check_media_change 114 | NULL, // revalidate 115 | NULL, // lock 116 | }; 117 | 118 | #else 119 | 120 | static struct file_operations lpc_fops = 121 | { 122 | owner: THIS_MODULE, 123 | 124 | read: lpc_read, 125 | write: lpc_write, 126 | poll: lpc_poll, 127 | ioctl: lpc_ioctl, 128 | open: lpc_open, 129 | release: lpc_release, 130 | /* 131 | THIS_MODULE, // owner 132 | NULL, // llseek 133 | lpc_read, 134 | lpc_write, 135 | NULL, // readdir 136 | lpc_poll, 137 | lpc_ioctl, 138 | NULL, // mmap 139 | lpc_open, 140 | NULL, // flush 141 | lpc_release, 142 | NULL, // fsync 143 | NULL, // fasync 144 | NULL, // lock 145 | NULL, // readv 146 | NULL, // writev 147 | NULL, // sendpage 148 | NULL, // get_unmapped_area 149 | */ 150 | }; 151 | 152 | #endif 153 | 154 | 155 | //static const char driver_version[] = DRIVER_VERSION; 156 | 157 | static const u8 irq_table[16] = { 158 | // 0 1 2 *3* 4 *5* 6 *7* 159 | 0x00,0x00,0x00,0x80,0x00,0x90,0x00,0xA0, 160 | // 8 *9* *10* *11* *12* 13 14 *15* 161 | 0x00,0xB0,0xC0,0xD0,0xE0,0x00,0x00,0xF0 162 | }; 163 | 164 | //static DEV *devs[MAX_LPCS+MAX_LPPS]; 165 | 166 | static u16 lpcs[MAX_LPCS];// = { 0x5340, 0x7344 }; 167 | 168 | 169 | static struct pci_driver lpp_driver = { 170 | .name = DRIVER_MOD_NAME, 171 | .id_table = lpp_pci_tbl, 172 | .probe = lpp_init_one, 173 | .remove = lpp_remove_one, 174 | #ifdef CONFIG_PM 175 | .resume = lpp_resume, 176 | .suspend = lpp_suspend, 177 | #endif 178 | }; 179 | -------------------------------------------------------------------------------- /kernel_modules_drivers/gesytec-2.09/driverdata.c: -------------------------------------------------------------------------------- 1 | /*****************************************************************************/ 2 | /* 3 | * Linux driver for Easylon USB Interfaces 4 | * 5 | * Copyright (c)2003 Gesytec GmbH, Volker Schober (info@gesytec.de) 6 | * Licensend for use with Easylon USB Interfaces by Gesytec 7 | * 8 | * Please compile lpclinux.c 9 | * 10 | */ 11 | /*****************************************************************************/ 12 | 13 | #ifdef CONFIG_LPC_DEBUG 14 | static int debug = 0xFF; 15 | #else 16 | static int debug; 17 | #endif 18 | 19 | 20 | #ifdef LPC_MAJOR 21 | static int major = LPC_MAJOR; 22 | #else 23 | static int major = 0; 24 | #endif 25 | 26 | 27 | 28 | /* Module paramaters */ 29 | MODULE_PARM(debug, "i"); 30 | MODULE_PARM_DESC(debug, "Debug enabled or not"); 31 | 32 | 33 | #ifndef NO_PCI 34 | /* table of devices that work with this driver */ 35 | static struct pci_device_id lpp_pci_tbl[] = { 36 | { GESYTEC_VENDOR_ID, LPP_PRODUCT_ID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, }, 37 | { }, 38 | }; 39 | MODULE_DEVICE_TABLE(pci, lpp_pci_tbl); 40 | #endif 41 | 42 | #ifdef MODULE 43 | 44 | static char *isa; 45 | MODULE_PARM(major, "i"); 46 | MODULE_PARM(isa, "s"); 47 | 48 | #endif 49 | 50 | 51 | 52 | /* array of pointers to our devices that are currently connected */ 53 | static struct _DEVICE_EXTENSION *minor_table[MAX_DEVICES]; 54 | 55 | /* lock to protect the minor_table structure */ 56 | static DECLARE_MUTEX (minor_table_mutex); 57 | 58 | #if 0 59 | /* 60 | * File operations needed when we register this driver. 61 | * This assumes that this driver NEEDS file operations, 62 | * of course, which means that the driver is expected 63 | * to have a node in the /dev directory. If the USB 64 | * device were for a network interface then the driver 65 | * would use "struct net_driver" instead, and a serial 66 | * device would use "struct tty_driver". 67 | */ 68 | static struct file_operations lonusb_fops = { 69 | /* 70 | * The owner field is part of the module-locking 71 | * mechanism. The idea is that the kernel knows 72 | * which module to increment the use-counter of 73 | * BEFORE it calls the device's open() function. 74 | * This also means that the kernel can decrement 75 | * the use-counter again before calling release() 76 | * or should the open() function fail. 77 | * 78 | * Not all device structures have an "owner" field 79 | * yet. "struct file_operations" and "struct net_device" 80 | * do, while "struct tty_driver" does not. If the struct 81 | * has an "owner" field, then initialize it to the value 82 | * THIS_MODULE and the kernel will handle all module 83 | * locking for you automatically. Otherwise, you must 84 | * increment the use-counter in the open() function 85 | * and decrement it again in the release() function 86 | * yourself. 87 | */ 88 | owner: THIS_MODULE, 89 | 90 | read: lonusb_read, 91 | write: lonusb_write, 92 | poll: lonusb_poll, 93 | ioctl: lonusb_ioctl, 94 | open: lonusb_open, 95 | release: lonusb_release, 96 | }; 97 | #endif 98 | 99 | #if LINUX_VERSION_CODE < 0x020400 100 | 101 | static struct file_operations lpc_fops = 102 | { 103 | NULL, // llseek 104 | lpc_read, 105 | lpc_write, 106 | NULL, // readdir 107 | lpc_poll, 108 | lpc_ioctl, 109 | NULL, // mmap 110 | lpc_open, 111 | NULL, // flush 112 | lpc_release, 113 | NULL, // fsync 114 | NULL, // fasync 115 | NULL, // check_media_change 116 | NULL, // revalidate 117 | NULL, // lock 118 | }; 119 | 120 | #else 121 | 122 | static struct file_operations lpc_fops = 123 | { 124 | owner: THIS_MODULE, 125 | 126 | read: lpc_read, 127 | write: lpc_write, 128 | poll: lpc_poll, 129 | ioctl: lpc_ioctl, 130 | open: lpc_open, 131 | release: lpc_release, 132 | /* 133 | THIS_MODULE, // owner 134 | NULL, // llseek 135 | lpc_read, 136 | lpc_write, 137 | NULL, // readdir 138 | lpc_poll, 139 | lpc_ioctl, 140 | NULL, // mmap 141 | lpc_open, 142 | NULL, // flush 143 | lpc_release, 144 | NULL, // fsync 145 | NULL, // fasync 146 | NULL, // lock 147 | NULL, // readv 148 | NULL, // writev 149 | NULL, // sendpage 150 | NULL, // get_unmapped_area 151 | */ 152 | }; 153 | 154 | #endif 155 | 156 | 157 | //static const char driver_version[] = DRIVER_VERSION; 158 | 159 | static const u8 irq_table[16] = { 160 | // 0 1 2 *3* 4 *5* 6 *7* 161 | 0x00,0x00,0x00,0x80,0x00,0x90,0x00,0xA0, 162 | // 8 *9* *10* *11* *12* 13 14 *15* 163 | 0x00,0xB0,0xC0,0xD0,0xE0,0x00,0x00,0xF0 164 | }; 165 | 166 | //static DEV *devs[MAX_LPCS+MAX_LPPS]; 167 | 168 | static u16 lpcs[MAX_LPCS];// = { 0x5340, 0x7344 }; 169 | 170 | 171 | #ifndef NO_PCI 172 | static struct pci_driver lpp_driver = { 173 | .name = DRIVER_MOD_NAME, 174 | .id_table = lpp_pci_tbl, 175 | .probe = lpp_init_one, 176 | .remove = lpp_remove_one, 177 | #ifdef CONFIG_PM 178 | .resume = lpp_resume, 179 | .suspend = lpp_suspend, 180 | #endif 181 | }; 182 | #endif 183 | -------------------------------------------------------------------------------- /kernel_modules_drivers/gesytec-2.12/Makefile: -------------------------------------------------------------------------------- 1 | #***************************************************************************** 2 | # 3 | # Linux driver for Easylon ISA/PC-104/PCI Interfaces 4 | # 5 | # Copyright (c)2004 Gesytec GmbH, Volker Schober (info@gesytec.de) 6 | # Licensend for use with Easylon ISA/PC-104/PCI Interfaces by Gesytec 7 | # 8 | #***************************************************************************** 9 | 10 | MODULE=lpclinux 11 | KERNEL_VERSION = $(shell uname -r) 12 | KERNEL_SOURCE ?= /lib/modules/$(KERNEL_VERSION)/build 13 | KERNEL_HEADERS = $(KERNEL_SOURCE)/include 14 | UDEV_RULES_PATH = /etc/udev/rules.d 15 | UDEV_RULES = 25-easylon.rules 16 | 17 | # define a unique major number for the character device (see /proc/devices) 18 | EXTRA_CFLAGS += -DLPC_MAJOR=84 19 | 20 | # remove "#" from line below if you want to enable debug messages 21 | # EXTRA_CFLAGS += -DCONFIG_LPC_DEBUG 22 | 23 | # remove "#" from line below if you want only a ISA/PC-104 driver 24 | # EXTRA_CFLAGS += -DNO_PCI 25 | 26 | # use deferred interrupt handling 27 | EXTRA_CFLAGS += -DUSE_TASKLET 28 | 29 | # if Rules.make exists in the kernel tree, we assume 2.4 style modules 30 | # if it doesn't assume 2.5 / 2.6 style 31 | OLDMAKE = $(findstring 2.4,$(KERNEL_VERSION)) 32 | 33 | ifeq (,$(OLDMAKE)) 34 | #***************************************************************************** 35 | # 2.5 / 2.6 style modules, get the kernel makefiles to do the work 36 | #***************************************************************************** 37 | 38 | all: modules 39 | 40 | obj-m := $(MODULE).o 41 | 42 | # Set to something different to install somewhere else: 43 | # MOD_DIR := extra 44 | 45 | 46 | 47 | .PHONY: help debug modules install clean modules_add modules_install 48 | 49 | debug: modules 50 | -modprobe -r $(MODULE) 51 | insmod $(MODULE).ko debug=0xFF 52 | 53 | #install : modules_add 54 | install: 55 | # @if [ ! -c "/dev/lon1" ]; then mknod /dev/lon1 c 84 0; fi; # (lon1 is the 1st ISA card) 56 | # @if [ ! -c "/dev/lon2" ]; then mknod /dev/lon2 c 84 1; fi; # (lon2 is the 2nd ISA card) 57 | # @if [ ! -c "/dev/lon3" ]; then mknod /dev/lon3 c 84 32; fi; # (lon3 is the 1st PCI card) 58 | # @if [ ! -c "/dev/lon4" ]; then mknod /dev/lon4 c 84 33; fi; # (lon4 is the 2nd PCI card) 59 | # @chmod 666 /dev/lon* 60 | @-ls -lF /dev/lon* 61 | @echo 62 | $(MAKE) -C $(KERNEL_SOURCE) SUBDIRS=$(CURDIR) modules_install 63 | @if ! `cmp -s ./$(UDEV_RULES) $(UDEV_RULES_PATH)/$(UDEV_RULES)` ; then cp -vi $(UDEV_RULES) $(UDEV_RULES_PATH)/; fi 64 | -modprobe -r $(MODULE) 65 | depmod -a -e 66 | modprobe $(MODULE) debug=0xFF 67 | 68 | 69 | modules modules_add modules_install help: 70 | $(MAKE) -C $(KERNEL_SOURCE) $@ SUBDIRS=$(CURDIR) 71 | 72 | clean: 73 | $(MAKE) -C $(KERNEL_SOURCE) $@ SUBDIRS=$(CURDIR) 74 | -rm -f lpctest 75 | 76 | modules_uninstall: 77 | -modprobe -r $(MODULE) 78 | 79 | else # $(OLDMAKE) 80 | #***************************************************************************** 81 | # 2.4 style modules 82 | #***************************************************************************** 83 | 84 | #INCLUDEDIR = /usr/src/linux-$(KERNEL_VERSION)/include 85 | #INCLUDEDIR = /usr/src/linux/include 86 | #INCLUDEDIR = /usr/src/linux-2.4/include 87 | ifneq (,$(wildcard /usr/src/linux/include)) 88 | INCLUDEDIR = /usr/src/linux/include 89 | else 90 | INCLUDEDIR = /usr/src/linux-2.4/include 91 | endif 92 | INCLUDEDIR = /lib/modules/$(KERNEL_VERSION)/build/include 93 | 94 | SHELL = sh 95 | TARGET = $(MODULE).o 96 | CFILES = driverdata.c driverentry.c $(MODULE).c #dynbuf.c 97 | HFILES = Makefile $(MODULE).h sysdep.h kdebug.h #dynbuf.h 98 | 99 | CFLAGS = -D__KERNEL__ -DMODULE -DLINUX -DEXPORT_SYMTAB 100 | CFLAGS += $(EXTRA_CFLAGS) 101 | 102 | # remove "#" from line below if kernel compiled with SMP support 103 | # CFLAGS += -D__SMP__ 104 | 105 | 106 | CFLAGS += -I$(INCLUDEDIR) -I. 107 | 108 | # check for module versioning configured in the kernel sources 109 | CFLAGS += $(shell [ -f $(INCLUDEDIR)/linux/modversions.h ] && \ 110 | echo -DMODVERSIONS -include $(INCLUDEDIR)/linux/modversions.h) 111 | CFLAGS += -O2 -pipe 112 | 113 | ifneq (,$(wildcard /lib/modules/$(KERNEL_VERSION)/kernel)) 114 | INSTALLDIR = /lib/modules/$(KERNEL_VERSION)/kernel/drivers/pci 115 | else 116 | INSTALLDIR = /lib/modules/$(KERNEL_VERSION)/pci 117 | endif 118 | 119 | all: modules 120 | 121 | debug: modules 122 | -modprobe -r $(MODULE) 123 | insmod $(MODULE).o debug=0xFF 124 | 125 | modules: $(MODULE).o 126 | 127 | $(MODULE).o: $(CFILES) $(HFILES) 128 | # $(CC) $(CFLAGS) -c $(MODULE).c -o $(MODULE)_.o 2>&1 | grep -v "warning: concatenation of string literals with __FUNCTION__ is deprecated" 129 | # $(CC) $(CFLAGS) -c $(MODULE).c -o $(MODULE).o 130 | $(CC) $(CFLAGS) -c $(MODULE).c -o $(MODULE)_.o 131 | $(LD) -r -o $(MODULE).o $(MODULE)_.o 132 | rm $(MODULE)_.o 133 | 134 | install: $(MODULE).o 135 | @if [ ! -c "/dev/lon1" ]; then mknod /dev/lon1 c 84 0; fi; # (lon1 is the 1st ISA card) 136 | @if [ ! -c "/dev/lon2" ]; then mknod /dev/lon2 c 84 1; fi; # (lon2 is the 2nd ISA card) 137 | @if [ ! -c "/dev/lon3" ]; then mknod /dev/lon3 c 84 32; fi; # (lon3 is the 1st PCI card) 138 | @if [ ! -c "/dev/lon4" ]; then mknod /dev/lon4 c 84 33; fi; # (lon4 is the 2nd PCI card) 139 | @chmod 666 /dev/lon* 140 | @ls -lF /dev/lon* 141 | @echo 142 | @echo INSTALLDIR=$(INSTALLDIR) 143 | mkdir -p $(INSTALLDIR) 144 | install -m 644 $(MODULE).o $(INSTALLDIR) 145 | -modprobe -r $(MODULE) 146 | depmod -a -e 147 | modprobe $(MODULE) debug=0xFF 148 | 149 | uninstall: 150 | -modprobe -r $(MODULE) 151 | $(SHELL) -c 'if [ -f $(INSTALLDIR)/$(MODULE).o ]; then \ 152 | rm $(INSTALLDIR)/$(MODULE).o; \ 153 | fi' 154 | 155 | clean: 156 | -rm -f *.o core 157 | -rm -f lpctest 158 | 159 | endif # $(OLDMAKE) 160 | 161 | 162 | ################################################################## 163 | # 164 | # Userland tools 165 | # 166 | ################################################################## 167 | 168 | #CFLAGS += -Wall -O2 -pipe 169 | 170 | lpctest: lpctest.c 171 | gcc -o lpctest $^ 172 | 173 | tools: lpctest 174 | 175 | 176 | 177 | test: 178 | @echo INSTALLDIR=$(INSTALLDIR) 179 | @echo OLDMAKE=$(OLDMAKE) 180 | @echo KERNEL_SOURCE=$(KERNEL_SOURCE) 181 | @echo KERNEL_VERSION=$(KERNEL_VERSION) 182 | -------------------------------------------------------------------------------- /kernel_modules_drivers/gesytec-2.06/driverentry.c: -------------------------------------------------------------------------------- 1 | 2 | static int lpp_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) 3 | { 4 | DEV *dev; 5 | int rc; 6 | uint minor; 7 | unsigned long plx_base; 8 | 9 | dbg("%s(): pci_dev->vendor=%04X device=%04X\n pci_device_id->vendor=%04X device=%04X", 10 | __FUNCTION__, 11 | pdev->vendor, pdev->device, 12 | ent->vendor, ent->device); 13 | //return -ENODEV; 14 | 15 | dev = kmalloc (sizeof(DEV), GFP_KERNEL); 16 | if (!dev) return -ENOMEM; 17 | memset (dev, 0x00, sizeof (*dev)); 18 | 19 | 20 | /* Enable tasklet for the device */ 21 | tasklet_init(&dev->Dpc, DpcForIsr, (unsigned long) dev); 22 | 23 | /* enable device (incl. PCI PM wakeup), and bus-mastering */ 24 | rc = pci_enable_device(pdev); 25 | dbg1("pci_enable_device()=%d dev=%p", rc, dev); 26 | if (rc) goto err_out_free; 27 | 28 | rc = pci_set_mwi(pdev); 29 | dbg1("pci_set_mwi()=%d", rc); 30 | if (rc) goto err_out_disable; 31 | 32 | rc = pci_request_regions(pdev, DRIVER_MOD_NAME); 33 | dbg1("pci_request_regions()=%d", rc); 34 | if (rc) goto err_out_mwi; 35 | 36 | if (pdev->irq < 2) 37 | { 38 | rc = -EIO; 39 | printk(KERN_ERR PFX "invalid irq (%d) for pci dev %s\n", 40 | pdev->irq, pdev->slot_name); 41 | goto err_out_res; 42 | } 43 | 44 | plx_base = pci_resource_start (pdev, 1); 45 | dev->PlxIntCsrPort = plx_base + P9050_INTCSR; 46 | dev->cport = pci_resource_start (pdev, 2); 47 | dev->rport = pci_resource_start (pdev, 3); 48 | dev->wport = dev->rport; 49 | dev->wtcport = pci_resource_start (pdev, 5); 50 | dev->irq = pdev->irq; 51 | 52 | /* 53 | pio_end = pci_resource_end (pdev, 0); 54 | pio_flags = pci_resource_flags (pdev, 0); 55 | pio_len = pci_resource_len (pdev, 0); 56 | */ 57 | 58 | // rc = register_netdev(dev); 59 | // if (rc) goto err_out_iomap; 60 | 61 | 62 | /* select a "subminor" number (part of a minor number) */ 63 | down (&minor_table_mutex); 64 | for (minor = MAX_LPCS; minor < MAX_DEVICES; ++minor) 65 | { 66 | if (minor_table[minor] == NULL) 67 | break; 68 | } 69 | if (minor >= MAX_DEVICES) 70 | { 71 | info ("Too many devices plugged in, can not handle this device."); 72 | rc = -EINVAL; 73 | goto err_minor_table; 74 | } 75 | 76 | dev->minor = minor; 77 | minor_table[minor] = dev; 78 | 79 | pci_set_drvdata(pdev, dev); 80 | #ifdef CONFIG_DEVFS_FS 81 | devfs_mk_cdev(MKDEV(major, minor), 82 | S_IFCHR | S_IRUGO | S_IWUGO, 83 | "lpc/%d", minor); 84 | #endif 85 | up (&minor_table_mutex); 86 | 87 | dbg1("%s(): minor=%d return 0", 88 | __FUNCTION__, 89 | minor); 90 | return 0; 91 | 92 | 93 | err_minor_table: 94 | up (&minor_table_mutex); 95 | //err_out_iomap: 96 | // iounmap(regs); 97 | err_out_res: 98 | pci_release_regions(pdev); 99 | err_out_mwi: 100 | pci_clear_mwi(pdev); 101 | err_out_disable: 102 | pci_disable_device(pdev); 103 | err_out_free: 104 | tasklet_kill(&dev->Dpc); 105 | kfree(dev); 106 | dbg1("%s(): return %d", 107 | __FUNCTION__, 108 | rc); 109 | return rc; 110 | } 111 | 112 | static void lpp_remove_one (struct pci_dev *pdev) 113 | { 114 | DEV *dev = pci_get_drvdata(pdev); 115 | dbg("%s(): dev=%08X pci_dev->vendor=%04X device=%04X", 116 | __FUNCTION__, (uint)dev, 117 | pdev->vendor, pdev->device); 118 | if (!dev) BUG(); 119 | 120 | down (&minor_table_mutex); 121 | #ifdef CONFIG_DEVFS_FS 122 | devfs_remove("lpc/%d", dev->minor); 123 | #endif 124 | minor_table[dev->minor] = NULL; 125 | // unregister_netdev(dev); 126 | // iounmap(cp->regs); 127 | pci_release_regions(pdev); 128 | pci_clear_mwi(pdev); 129 | pci_disable_device(pdev); 130 | pci_set_drvdata(pdev, NULL); 131 | tasklet_kill(&dev->Dpc); 132 | kfree(dev); 133 | 134 | info(DRIVER_DESC " " DRIVER_DEV_NAME "%d now disconnected", dev->minor); 135 | up (&minor_table_mutex); 136 | } 137 | 138 | 139 | #ifdef CONFIG_PM 140 | static int lpp_suspend (struct pci_dev *pdev, u32 state) 141 | { 142 | return 0; 143 | } 144 | 145 | static int lpp_resume (struct pci_dev *pdev) 146 | { 147 | return 0; 148 | } 149 | #endif /* CONFIG_PM */ 150 | 151 | 152 | #ifdef MODULE 153 | 154 | static int __init module_lpc_init(void) 155 | { 156 | int i, val; 157 | char c; 158 | 159 | // if (!DbgInit()) return -ENOMEM; 160 | info(DRIVER_DESC " " DRIVER_VERSION); 161 | 162 | int ret = register_chrdev(major, DRIVER_DEV_NAME, &lpc_fops); 163 | if (ret < 0) 164 | { 165 | err("register_chrdev(major=%d, \"" DRIVER_DEV_NAME "\")=%d -> failed", major, ret); 166 | // DbgExit(); 167 | return ret; 168 | } 169 | if (major == 0) major = ret; // dynamic major 170 | 171 | #ifdef CONFIG_DEVFS_FS 172 | #warning CONFIG_DEVFS_FS not tested 173 | ret = devfs_mk_dir("lpc"); 174 | dbg1("major=%d devfs_mk_dir()=%08X", major, ret); 175 | #else 176 | #warning Info: CONFIG_DEVFS_FS not used 177 | #endif 178 | 179 | ret = pci_module_init(&lpp_driver); 180 | 181 | if( isa ) 182 | { 183 | i = 0; 184 | while( *isa && (i < MAX_LPCS*4) ) 185 | { 186 | c = *isa++; 187 | val = -1; 188 | if((c >= '0') && (c <= '9')) val = c - '0'; 189 | if((c >= 'A') && (c <= 'F')) val = c + 10 - 'A'; 190 | if((c >= 'a') && (c <= 'f')) val = c + 10 - 'a'; 191 | if(val >= 0) 192 | { 193 | lpcs[i >> 2] = (lpcs[i >> 2] << 4) | val; 194 | i++; 195 | } 196 | } 197 | } 198 | 199 | dbg("Loading module " DRIVER_MOD_NAME " " DRIVER_VERSION " pci_module_init()=%d", ret); 200 | if (!lpc_init()) return 0; 201 | if (ret) 202 | { 203 | unregister_chrdev( major, DRIVER_DEV_NAME ); 204 | #ifdef CONFIG_DEVFS_FS 205 | devfs_remove("lpc"); 206 | #endif 207 | // DbgExit(); 208 | } 209 | return ret; 210 | } 211 | 212 | static void __exit module_lpc_exit(void) 213 | { 214 | pci_unregister_driver(&lpp_driver); 215 | 216 | #ifdef CHECK_ISA_AT_LOAD_TIME 217 | int i; 218 | 219 | for( i=0; i= KERNEL_VERSION(2,4,0) 233 | 234 | module_init(module_lpc_init); 235 | module_exit(module_lpc_exit); 236 | 237 | MODULE_AUTHOR(DRIVER_AUTHOR); 238 | MODULE_DESCRIPTION(DRIVER_DESC); 239 | MODULE_LICENSE("GPL"); 240 | 241 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) 242 | MODULE_INFO(supported, "external"); 243 | #endif 244 | 245 | #endif 246 | 247 | #endif // #ifdef MODULE 248 | -------------------------------------------------------------------------------- /kernel_modules_drivers/gesytec-2.08/driverentry.c: -------------------------------------------------------------------------------- 1 | 2 | static int lpp_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) 3 | { 4 | DEV *dev; 5 | int rc; 6 | uint minor; 7 | unsigned long plx_base; 8 | 9 | dbg("%s(): pci_dev->vendor=%04X device=%04X\n pci_device_id->vendor=%04X device=%04X", 10 | __FUNCTION__, 11 | pdev->vendor, pdev->device, 12 | ent->vendor, ent->device); 13 | //return -ENODEV; 14 | 15 | dev = kmalloc (sizeof(DEV), GFP_KERNEL); 16 | if (!dev) return -ENOMEM; 17 | memset (dev, 0x00, sizeof (*dev)); 18 | 19 | 20 | /* Enable tasklet for the device */ 21 | tasklet_init(&dev->Dpc, DpcForIsr, (unsigned long) dev); 22 | 23 | /* enable device (incl. PCI PM wakeup), and bus-mastering */ 24 | rc = pci_enable_device(pdev); 25 | dbg1("pci_enable_device()=%d dev=%p", rc, dev); 26 | if (rc) goto err_out_free; 27 | 28 | rc = pci_set_mwi(pdev); 29 | dbg1("pci_set_mwi()=%d", rc); 30 | if (rc) goto err_out_disable; 31 | 32 | rc = pci_request_regions(pdev, DRIVER_MOD_NAME); 33 | dbg1("pci_request_regions()=%d", rc); 34 | if (rc) goto err_out_mwi; 35 | 36 | if (pdev->irq < 2) 37 | { 38 | rc = -EIO; 39 | printk(KERN_ERR PFX "invalid irq (%d) for pci dev %s\n", 40 | pdev->irq, pci_name(pdev)); // pdev->slot_name); 41 | goto err_out_res; 42 | } 43 | 44 | plx_base = pci_resource_start (pdev, 1); 45 | dev->PlxIntCsrPort = plx_base + P9050_INTCSR; 46 | dev->cport = pci_resource_start (pdev, 2); 47 | dev->rport = pci_resource_start (pdev, 3); 48 | dev->wport = dev->rport; 49 | dev->wtcport = pci_resource_start (pdev, 5); 50 | dev->irq = pdev->irq; 51 | 52 | /* 53 | pio_end = pci_resource_end (pdev, 0); 54 | pio_flags = pci_resource_flags (pdev, 0); 55 | pio_len = pci_resource_len (pdev, 0); 56 | */ 57 | 58 | // rc = register_netdev(dev); 59 | // if (rc) goto err_out_iomap; 60 | 61 | 62 | /* select a "subminor" number (part of a minor number) */ 63 | down (&minor_table_mutex); 64 | for (minor = MAX_LPCS; minor < MAX_DEVICES; ++minor) 65 | { 66 | if (minor_table[minor] == NULL) 67 | break; 68 | } 69 | if (minor >= MAX_DEVICES) 70 | { 71 | info ("Too many devices plugged in, can not handle this device."); 72 | rc = -EINVAL; 73 | goto err_minor_table; 74 | } 75 | 76 | dev->minor = minor; 77 | minor_table[minor] = dev; 78 | 79 | pci_set_drvdata(pdev, dev); 80 | #ifdef CONFIG_DEVFS_FS 81 | devfs_mk_cdev(MKDEV(major, minor), 82 | S_IFCHR | S_IRUGO | S_IWUGO, 83 | "lpc/%d", minor); 84 | #endif 85 | up (&minor_table_mutex); 86 | 87 | dbg1("%s(): minor=%d return 0", 88 | __FUNCTION__, 89 | minor); 90 | return 0; 91 | 92 | 93 | err_minor_table: 94 | up (&minor_table_mutex); 95 | //err_out_iomap: 96 | // iounmap(regs); 97 | err_out_res: 98 | pci_release_regions(pdev); 99 | err_out_mwi: 100 | pci_clear_mwi(pdev); 101 | err_out_disable: 102 | pci_disable_device(pdev); 103 | err_out_free: 104 | tasklet_kill(&dev->Dpc); 105 | kfree(dev); 106 | dbg1("%s(): return %d", 107 | __FUNCTION__, 108 | rc); 109 | return rc; 110 | } 111 | 112 | static void lpp_remove_one (struct pci_dev *pdev) 113 | { 114 | DEV *dev = pci_get_drvdata(pdev); 115 | dbg("%s(): dev=%08X pci_dev->vendor=%04X device=%04X", 116 | __FUNCTION__, (uint)dev, 117 | pdev->vendor, pdev->device); 118 | if (!dev) BUG(); 119 | 120 | down (&minor_table_mutex); 121 | #ifdef CONFIG_DEVFS_FS 122 | devfs_remove("lpc/%d", dev->minor); 123 | #endif 124 | minor_table[dev->minor] = NULL; 125 | // unregister_netdev(dev); 126 | // iounmap(cp->regs); 127 | pci_release_regions(pdev); 128 | pci_clear_mwi(pdev); 129 | pci_disable_device(pdev); 130 | pci_set_drvdata(pdev, NULL); 131 | tasklet_kill(&dev->Dpc); 132 | kfree(dev); 133 | 134 | info(DRIVER_DESC " " DRIVER_DEV_NAME "%d now disconnected", dev->minor); 135 | up (&minor_table_mutex); 136 | } 137 | 138 | 139 | #ifdef CONFIG_PM 140 | static int lpp_suspend (struct pci_dev *pdev, u32 state) 141 | { 142 | return 0; 143 | } 144 | 145 | static int lpp_resume (struct pci_dev *pdev) 146 | { 147 | return 0; 148 | } 149 | #endif /* CONFIG_PM */ 150 | 151 | 152 | #ifdef MODULE 153 | 154 | static int __init module_lpc_init(void) 155 | { 156 | int i, val, ret; 157 | char c; 158 | 159 | // if (!DbgInit()) return -ENOMEM; 160 | info(DRIVER_DESC " " DRIVER_VERSION); 161 | 162 | ret = register_chrdev(major, DRIVER_DEV_NAME, &lpc_fops); 163 | if (ret < 0) 164 | { 165 | err("register_chrdev(major=%d, \"" DRIVER_DEV_NAME "\")=%d -> failed", major, ret); 166 | // DbgExit(); 167 | return ret; 168 | } 169 | if (major == 0) major = ret; // dynamic major 170 | 171 | #ifdef CONFIG_DEVFS_FS 172 | #warning CONFIG_DEVFS_FS not tested 173 | ret = devfs_mk_dir("lpc"); 174 | dbg1("major=%d devfs_mk_dir()=%08X", major, ret); 175 | #else 176 | #warning Info: CONFIG_DEVFS_FS not used 177 | #endif 178 | 179 | ret = pci_module_init(&lpp_driver); 180 | 181 | if( isa ) 182 | { 183 | i = 0; 184 | while( *isa && (i < MAX_LPCS*4) ) 185 | { 186 | c = *isa++; 187 | val = -1; 188 | if((c >= '0') && (c <= '9')) val = c - '0'; 189 | if((c >= 'A') && (c <= 'F')) val = c + 10 - 'A'; 190 | if((c >= 'a') && (c <= 'f')) val = c + 10 - 'a'; 191 | if(val >= 0) 192 | { 193 | lpcs[i >> 2] = (lpcs[i >> 2] << 4) | val; 194 | i++; 195 | } 196 | } 197 | } 198 | 199 | dbg("Loading module " DRIVER_MOD_NAME " " DRIVER_VERSION " pci_module_init()=%d", ret); 200 | if (!lpc_init()) return 0; 201 | if (ret) 202 | { 203 | unregister_chrdev( major, DRIVER_DEV_NAME ); 204 | #ifdef CONFIG_DEVFS_FS 205 | devfs_remove("lpc"); 206 | #endif 207 | // DbgExit(); 208 | } 209 | return ret; 210 | } 211 | 212 | static void __exit module_lpc_exit(void) 213 | { 214 | pci_unregister_driver(&lpp_driver); 215 | 216 | #ifdef CHECK_ISA_AT_LOAD_TIME 217 | { 218 | int i; 219 | for (i=0; i= KERNEL_VERSION(2,4,0) 234 | 235 | module_init(module_lpc_init); 236 | module_exit(module_lpc_exit); 237 | 238 | MODULE_AUTHOR(DRIVER_AUTHOR); 239 | MODULE_DESCRIPTION(DRIVER_DESC); 240 | MODULE_LICENSE("GPL"); 241 | 242 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) 243 | MODULE_INFO(supported, "external"); 244 | #endif 245 | 246 | #endif 247 | 248 | #endif // #ifdef MODULE 249 | -------------------------------------------------------------------------------- /ldv/ldv.cpp: -------------------------------------------------------------------------------- 1 | /*********** 2 | 3 | Copyright (c) 2000-2005 Karl Hiramoto 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 6 | documentation files (the "Software"), to deal in the Software without restriction, including without limitation the 7 | rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the 11 | Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 14 | WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS 15 | OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 16 | OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 17 | **********/ 18 | 19 | #include "ldv.h" 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | 35 | 36 | LDVCode 37 | ldv_open( const char *device_name, LNI *pHandle ) 38 | { 39 | int handle; 40 | 41 | int len; 42 | struct sockaddr_in address; 43 | int result; 44 | int flag = 1; 45 | 46 | if (network_flag==true) 47 | { 48 | handle = socket(AF_INET, SOCK_STREAM, 0); 49 | 50 | address.sin_family = AF_INET; 51 | address.sin_addr.s_addr = inet_addr(device_name); 52 | address.sin_port=6666; 53 | 54 | len = sizeof(address); 55 | 56 | result = connect(handle, (struct sockaddr *) &address, len); 57 | 58 | if (result ==-1) 59 | { 60 | perror("opps: Client Error on Connect. "); 61 | exit(1); 62 | } 63 | 64 | result = setsockopt(handle, // socket affected 65 | IPPROTO_TCP, // set option at TCP level 66 | TCP_NODELAY, // name of option 67 | (char *) &flag, // the cast is historical cruft 68 | sizeof(int)); // length of option value 69 | 70 | if (result ==-1) 71 | { 72 | perror("opps: setsockopt "); 73 | exit(1); 74 | } 75 | 76 | if (fcntl(handle,F_SETFL, O_NONBLOCK) == -1 ) 77 | { 78 | perror("opps: Client Error on fcntl in ldvpclta.c "); 79 | exit(1); 80 | } 81 | 82 | } 83 | else // network flag false 84 | { 85 | handle = open( device_name, O_RDWR | O_NONBLOCK ); 86 | } 87 | 88 | if( handle < 0 ) 89 | { 90 | // perror("TEST ldv_open() error is: "); 91 | //printf("TEST ldv_open handle=%d \n",handle); 92 | //printf("TEST ldv_open device name=%s \n",device_name); 93 | 94 | switch( errno ) 95 | { 96 | 97 | case EBUSY: 98 | case EACCES: 99 | return LDV_ALREADY_OPEN; 100 | case ENOENT: 101 | case ENAMETOOLONG: 102 | case ENOTDIR: 103 | return LDV_NOT_FOUND; 104 | case ENODEV: 105 | return LDV_NO_RESOURCES; 106 | default: 107 | return LDV_DEVICE_ERR; 108 | } 109 | } 110 | *pHandle = handle; 111 | // printf("SUCCESS ldv_open handle=%d \n",handle); 112 | // printf("SUCCESS ldv_open device name=%s \n",device_name); 113 | 114 | // printf("Connected"); 115 | 116 | return LDV_OK; 117 | } 118 | 119 | LDVCode ldv_close( LNI handle ) 120 | { 121 | if( 0 > close( handle ) ) 122 | return LDV_INVALID_DEVICE_ID; 123 | return LDV_OK; 124 | } 125 | 126 | LDVCode ldv_read( LNI handle, void *pMsg, unsigned length ) 127 | { 128 | 129 | int ret_code=-999; 130 | unsigned char msg_length=0; 131 | // printf("\n ldv_read() START \n"); 132 | 133 | 134 | if (network_flag==true) 135 | ret_code=read( handle, pMsg, 2 ); // get the ni command and length 136 | else 137 | ret_code=read( handle, pMsg, length ); 138 | 139 | // printf("\n ldv_read() read call done. \n"); 140 | 141 | if( 0 > ret_code ) 142 | { 143 | // printf("\n ldv_read() ERROR error=%d ret_code=%d\n",errno,ret_code); 144 | 145 | switch( errno ) 146 | { 147 | case EISDIR: 148 | case EBADF: 149 | case EINVAL: 150 | { 151 | // printf("ldv_read() LDV_INVALID_DEVICE_ID\n"); 152 | // perror("Error is:"); 153 | 154 | return LDV_INVALID_DEVICE_ID; 155 | } 156 | case EINTR: 157 | case EAGAIN: 158 | case ENODATA: /// Karl's hack. 159 | { 160 | // printf("ldv_read() LDV_NO_MSG_AVAIL\n"); 161 | // perror("Error is:"); 162 | 163 | return LDV_NO_MSG_AVAIL; 164 | } 165 | case EFAULT: 166 | return LDV_INVALID_BUF_LEN; 167 | case EBUSY: 168 | return LDV_DEVICE_BUSY; 169 | default: 170 | { 171 | // printf("ldv_read() LDV_DEVICE_ERR \n"); 172 | 173 | // perror("Error is:"); 174 | return LDV_DEVICE_ERR; 175 | } 176 | } 177 | } 178 | 179 | if (network_flag==false) 180 | return LDV_OK; 181 | 182 | //there is more stuff to read. 183 | // msg_length=((unsigned char)pMsg+1); 184 | memcpy(&msg_length,(char *)pMsg+1,1); 185 | 186 | if (msg_length==0) 187 | return LDV_OK; 188 | 189 | // printf("\n Reading %d more bytes\n",msg_length); 190 | 191 | // maybe we should block on this read 192 | ret_code=read( handle, (unsigned char *) pMsg+2,msg_length); // get the ni command and length 193 | 194 | // printf("\n ldv_read() SUCCESS. Length=%d \n",ret_code); 195 | 196 | return LDV_OK; 197 | } 198 | 199 | LDVCode ldv_write( LNI handle, void *pMsg, unsigned length ) 200 | { 201 | int ret_code=-999; 202 | 203 | // printf("TEST ldv_write() Length = %d ; Handle = %d\n",length,handle); 204 | 205 | ret_code= write( handle, pMsg, length ); 206 | 207 | // printf("TEST ldv_write() RET_CODE = %d\n",ret_code); 208 | 209 | 210 | if( 0 > ret_code ) 211 | { 212 | // printf("TEST ldv_read() handle = %d\n",handle); 213 | // perror("TEST ldv_write() error is "); 214 | // printf("TEST ldv_write() errno = %d\n",errno); 215 | 216 | switch( errno ) 217 | { 218 | case EISDIR: 219 | case EBADF: 220 | case EINVAL: 221 | return LDV_INVALID_DEVICE_ID; 222 | case EINTR: 223 | case EAGAIN: 224 | return LDV_NO_MSG_AVAIL; 225 | case EFAULT: 226 | return LDV_INVALID_BUF_LEN; 227 | case EBUSY: 228 | return LDV_DEVICE_BUSY; 229 | default: 230 | return LDV_DEVICE_ERR; 231 | } 232 | } 233 | return LDV_OK; 234 | } 235 | -------------------------------------------------------------------------------- /kernel_modules_drivers/gesytec-2.09/driverentry.c: -------------------------------------------------------------------------------- 1 | 2 | #ifndef NO_PCI 3 | static int lpp_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) 4 | { 5 | DEV *dev; 6 | int rc; 7 | uint minor; 8 | unsigned long plx_base; 9 | 10 | dbg("%s(): pci_dev->vendor=%04X device=%04X\n pci_device_id->vendor=%04X device=%04X", 11 | __FUNCTION__, 12 | pdev->vendor, pdev->device, 13 | ent->vendor, ent->device); 14 | //return -ENODEV; 15 | 16 | dev = kmalloc (sizeof(DEV), GFP_KERNEL); 17 | if (!dev) return -ENOMEM; 18 | memset (dev, 0x00, sizeof (*dev)); 19 | 20 | 21 | /* Enable tasklet for the device */ 22 | tasklet_init(&dev->Dpc, DpcForIsr, (unsigned long) dev); 23 | 24 | /* enable device (incl. PCI PM wakeup), and bus-mastering */ 25 | rc = pci_enable_device(pdev); 26 | dbg1("pci_enable_device()=%d dev=%p", rc, dev); 27 | if (rc) goto err_out_free; 28 | 29 | rc = pci_set_mwi(pdev); 30 | dbg1("pci_set_mwi()=%d", rc); 31 | if (rc) goto err_out_disable; 32 | 33 | rc = pci_request_regions(pdev, DRIVER_MOD_NAME); 34 | dbg1("pci_request_regions()=%d", rc); 35 | if (rc) goto err_out_mwi; 36 | 37 | if (pdev->irq < 2) 38 | { 39 | rc = -EIO; 40 | printk(KERN_ERR PFX "invalid irq (%d) for pci dev %s\n", 41 | pdev->irq, pci_name(pdev)); // pdev->slot_name); 42 | goto err_out_res; 43 | } 44 | 45 | plx_base = pci_resource_start (pdev, 1); 46 | dev->PlxIntCsrPort = plx_base + P9050_INTCSR; 47 | dev->cport = pci_resource_start (pdev, 2); 48 | dev->rport = pci_resource_start (pdev, 3); 49 | dev->wport = dev->rport; 50 | dev->wtcport = pci_resource_start (pdev, 5); 51 | dev->irq = pdev->irq; 52 | 53 | /* 54 | pio_end = pci_resource_end (pdev, 0); 55 | pio_flags = pci_resource_flags (pdev, 0); 56 | pio_len = pci_resource_len (pdev, 0); 57 | */ 58 | 59 | // rc = register_netdev(dev); 60 | // if (rc) goto err_out_iomap; 61 | 62 | 63 | /* select a "subminor" number (part of a minor number) */ 64 | down (&minor_table_mutex); 65 | for (minor = MAX_LPCS; minor < MAX_DEVICES; ++minor) 66 | { 67 | if (minor_table[minor] == NULL) 68 | break; 69 | } 70 | if (minor >= MAX_DEVICES) 71 | { 72 | info ("Too many devices plugged in, can not handle this device."); 73 | rc = -EINVAL; 74 | goto err_minor_table; 75 | } 76 | 77 | dev->minor = minor; 78 | minor_table[minor] = dev; 79 | 80 | pci_set_drvdata(pdev, dev); 81 | #ifdef CONFIG_DEVFS_FS 82 | devfs_mk_cdev(MKDEV(major, minor), 83 | S_IFCHR | S_IRUGO | S_IWUGO, 84 | "lpc/%d", minor); 85 | #endif 86 | up (&minor_table_mutex); 87 | 88 | dbg1("%s(): minor=%d return 0", 89 | __FUNCTION__, 90 | minor); 91 | return 0; 92 | 93 | 94 | err_minor_table: 95 | up (&minor_table_mutex); 96 | //err_out_iomap: 97 | // iounmap(regs); 98 | err_out_res: 99 | pci_release_regions(pdev); 100 | err_out_mwi: 101 | pci_clear_mwi(pdev); 102 | err_out_disable: 103 | pci_disable_device(pdev); 104 | err_out_free: 105 | tasklet_kill(&dev->Dpc); 106 | kfree(dev); 107 | dbg1("%s(): return %d", 108 | __FUNCTION__, 109 | rc); 110 | return rc; 111 | } 112 | 113 | static void lpp_remove_one (struct pci_dev *pdev) 114 | { 115 | DEV *dev = pci_get_drvdata(pdev); 116 | dbg("%s(): dev=%08X pci_dev->vendor=%04X device=%04X", 117 | __FUNCTION__, (uint)dev, 118 | pdev->vendor, pdev->device); 119 | if (!dev) BUG(); 120 | 121 | down (&minor_table_mutex); 122 | #ifdef CONFIG_DEVFS_FS 123 | devfs_remove("lpc/%d", dev->minor); 124 | #endif 125 | minor_table[dev->minor] = NULL; 126 | // unregister_netdev(dev); 127 | // iounmap(cp->regs); 128 | pci_release_regions(pdev); 129 | pci_clear_mwi(pdev); 130 | pci_disable_device(pdev); 131 | pci_set_drvdata(pdev, NULL); 132 | tasklet_kill(&dev->Dpc); 133 | kfree(dev); 134 | 135 | info(DRIVER_DESC " " DRIVER_DEV_NAME "%d now disconnected", dev->minor); 136 | up (&minor_table_mutex); 137 | } 138 | 139 | 140 | #ifdef CONFIG_PM 141 | static int lpp_suspend (struct pci_dev *pdev, u32 state) 142 | { 143 | return 0; 144 | } 145 | 146 | static int lpp_resume (struct pci_dev *pdev) 147 | { 148 | return 0; 149 | } 150 | #endif /* CONFIG_PM */ 151 | #endif // NO_PCI 152 | 153 | 154 | #ifdef MODULE 155 | 156 | static int __init module_lpc_init(void) 157 | { 158 | int i, val, ret; 159 | char c; 160 | 161 | // if (!DbgInit()) return -ENOMEM; 162 | info(DRIVER_DESC " " DRIVER_VERSION); 163 | 164 | ret = register_chrdev(major, DRIVER_DEV_NAME, &lpc_fops); 165 | if (ret < 0) 166 | { 167 | err("register_chrdev(major=%d, \"" DRIVER_DEV_NAME "\")=%d -> failed", major, ret); 168 | // DbgExit(); 169 | return ret; 170 | } 171 | if (major == 0) major = ret; // dynamic major 172 | 173 | #ifdef CONFIG_DEVFS_FS 174 | #warning CONFIG_DEVFS_FS not tested 175 | ret = devfs_mk_dir("lpc"); 176 | dbg1("major=%d devfs_mk_dir()=%08X", major, ret); 177 | #else 178 | #warning Info: CONFIG_DEVFS_FS not used 179 | #endif 180 | 181 | #ifndef NO_PCI 182 | ret = pci_module_init(&lpp_driver); 183 | #else 184 | ret = 0; 185 | #endif 186 | if( isa ) 187 | { 188 | i = 0; 189 | while( *isa && (i < MAX_LPCS*4) ) 190 | { 191 | c = *isa++; 192 | val = -1; 193 | if((c >= '0') && (c <= '9')) val = c - '0'; 194 | if((c >= 'A') && (c <= 'F')) val = c + 10 - 'A'; 195 | if((c >= 'a') && (c <= 'f')) val = c + 10 - 'a'; 196 | if(val >= 0) 197 | { 198 | lpcs[i >> 2] = (lpcs[i >> 2] << 4) | val; 199 | i++; 200 | } 201 | } 202 | } 203 | 204 | dbg("Loading module " DRIVER_MOD_NAME " " DRIVER_VERSION " pci_module_init()=%d", ret); 205 | if (!lpc_init()) return 0; 206 | if (ret) 207 | { 208 | unregister_chrdev( major, DRIVER_DEV_NAME ); 209 | #ifdef CONFIG_DEVFS_FS 210 | devfs_remove("lpc"); 211 | #endif 212 | // DbgExit(); 213 | } 214 | return ret; 215 | } 216 | 217 | static void __exit module_lpc_exit(void) 218 | { 219 | #ifndef NO_PCI 220 | pci_unregister_driver(&lpp_driver); 221 | #endif 222 | 223 | #ifdef CHECK_ISA_AT_LOAD_TIME 224 | { 225 | int i; 226 | for (i=0; i= KERNEL_VERSION(2,4,0) 241 | 242 | module_init(module_lpc_init); 243 | module_exit(module_lpc_exit); 244 | 245 | MODULE_AUTHOR(DRIVER_AUTHOR); 246 | MODULE_DESCRIPTION(DRIVER_DESC); 247 | MODULE_LICENSE("GPL"); 248 | 249 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) 250 | MODULE_INFO(supported, "external"); 251 | #endif 252 | 253 | #endif 254 | 255 | #endif // #ifdef MODULE 256 | -------------------------------------------------------------------------------- /kernel_modules_drivers/gesytec-2.12/Plx9050.h: -------------------------------------------------------------------------------- 1 | #ifndef _PLXLIB_H_ 2 | #define _PLXLIB_H_ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | /* 9 | #ifndef _NTDEF_ 10 | typedef BOOL BOOLEAN; 11 | #endif 12 | */ 13 | 14 | /* 15 | // PCI register definitions 16 | enum { 17 | PCI_IDR = 0x00, 18 | PCI_CR = 0x04, 19 | PCI_SR = 0x06, 20 | PCI_REV = 0x08, 21 | PCI_CCR = 0x09, 22 | PCI_LSR = 0x0c, 23 | PCI_LTR = 0x0d, 24 | PCI_HTR = 0x0e, 25 | PCI_BISTR= 0x0f, 26 | PCI_BAR0 = 0x10, 27 | PCI_BAR1 = 0x14, 28 | PCI_BAR2 = 0x18, 29 | PCI_BAR3 = 0x1c, 30 | PCI_BAR4 = 0x20, 31 | PCI_BAR5 = 0x24, 32 | PCI_CIS = 0x28, 33 | PCI_SVID = 0x2c, 34 | PCI_SID = 0x2e, 35 | PCI_ERBAR= 0x30, 36 | PCI_ILR = 0x3c, 37 | PCI_IPR = 0x3d, 38 | PCI_MGR = 0x3e, 39 | PCI_MLR = 0x3f 40 | }; 41 | */ 42 | 43 | // PLX register definitions 44 | enum { 45 | P9050_LAS0RR = 0x00, 46 | P9050_LAS1RR = 0x04, 47 | P9050_LAS2RR = 0x08, 48 | P9050_LAS3RR = 0x0c, 49 | P9050_EROMRR = 0x10, 50 | P9050_LAS0BA = 0x14, 51 | P9050_LAS1BA = 0x18, 52 | P9050_LAS2BA = 0x1c, 53 | P9050_LAS3BA = 0x20, 54 | P9050_EROMBA = 0x24, 55 | P9050_LAS0BRD = 0x28, 56 | P9050_LAS1BRD = 0x2c, 57 | P9050_LAS2BRD = 0x30, 58 | P9050_LAS3BRD = 0x34, 59 | P9050_EROMBRD = 0x38, 60 | P9050_CS0BASE = 0x3c, 61 | P9050_CS1BASE = 0x40, 62 | P9050_CS2BASE = 0x44, 63 | P9050_CS3BASE = 0x48, 64 | P9050_INTCSR = 0x4c, 65 | P9050_CNTRL = 0x50 66 | }; 67 | 68 | /****** Data Structures *****************************************************/ 69 | /* 70 | * RUNTIME_9050 - PLX PCI9050-1 local configuration and shared runtime 71 | * registers. This structure can be used to access the 9050 registers 72 | * (memory mapped). 73 | */ 74 | /* 75 | typedef struct _PLX_9050 76 | { 77 | ULONG loc_addr_range[4]; // 00-0Ch : Local Address Ranges 78 | ULONG loc_rom_range; // 10h : Local ROM Range 79 | ULONG loc_addr_base[4]; // 14-20h : Local Address Base Addrs 80 | ULONG loc_rom_base; // 24h : Local ROM Base 81 | ULONG loc_bus_descr[4]; // 28-34h : Local Bus Descriptors 82 | ULONG rom_bus_descr; // 38h : ROM Bus Descriptor 83 | ULONG cs_base[4]; // 3C-48h : Chip Select Base Addrs 84 | ULONG intr_ctrl_stat; // 4Ch : Interrupt Control/Status 85 | ULONG init_ctrl; // 50h : EEPROM ctrl, Init Ctrl, etc 86 | } PLX_9050, *PPLX_9050; 87 | */ 88 | /* 89 | 4.3.20 (INTCSR; 4Ch) Interrupt Control/Status Register 90 | Talbe 43: Interrupt Control/Status Register Description 91 | Field Description Read Write Value after Reset 92 | 0 Local interrupt 1 enable. 1 = Enabled. 0 = Disabled. Yes Yes 0 93 | 1 Local interrupt 1 polarity. 1 = Active high. 0 = Active low. Yes Yes 0 94 | 2 Local interrupt 1 status. 1 = Interrupt active. 0 = Interrupt not active Yes No 0 95 | 3 Local interrupt 2 enable. 1 = Enabled. 0 = Disabled. Yes Yes 0 96 | 4 Local interrupt 2 polarity. 1 = Active high. 0 = Active low. Yes Yes 0 97 | 5 Local interrupt 2 status. 1 = Interrupt active. 0 = Interrupt not active Yes No 0 98 | 6 PCI interrupt enable. A value of 1 will enable PCI interrupt. Yes Yes 0 99 | 7 Software Interrupt. 1 = Generate interrupt. Yes Yes 0 100 | 31:8 Not used. Yes No 0 101 | */ 102 | 103 | #define PLX_9050_LINT1_ENABLE 0x01 104 | #define PLX_9050_LINT1_POL 0x02 105 | #define PLX_9050_LINT1_STATUS 0x04 106 | #define PLX_9050_LINT2_ENABLE 0x08 107 | #define PLX_9050_LINT2_POL 0x10 108 | #define PLX_9050_LINT2_STATUS 0x20 109 | #define PLX_9050_INTR_ENABLE 0x40 110 | #define PLX_9050_SW_INTR 0x80 111 | 112 | 113 | 114 | typedef enum 115 | { 116 | P9050_MODE_BYTE = 0, 117 | P9050_MODE_WORD = 1, 118 | P9050_MODE_ULONG = 2 119 | } P9050_MODE; 120 | 121 | typedef enum 122 | { 123 | P9050_ADDR_REG = 0, 124 | P9050_ADDR_SPACE0 = 1, 125 | P9050_ADDR_SPACE1 = 2, 126 | P9050_ADDR_SPACE2 = 3, 127 | P9050_ADDR_SPACE3 = 4, 128 | P9050_ADDR_EPROM = 5 129 | } P9050_ADDR; 130 | 131 | 132 | enum { P9050_RANGE_REG = 0x00000080 }; 133 | /* 134 | typedef struct _P9050_ADDR_DESC 135 | { 136 | ULONG dwLocalBase; 137 | ULONG dwMask; 138 | ULONG dwBytes; 139 | ULONG dwAddr; 140 | ULONG dwAddrDirect; 141 | BOOLEAN fIsMemory; 142 | ULONG modeDesc[3]; 143 | } P9050_ADDR_DESC; 144 | */ 145 | /* 146 | typedef struct 147 | { 148 | HANDLE hWD; 149 | WD_CARD cardLock; 150 | WD_INTERRUPT Int; 151 | WD_PCI_SLOT pciSlot; 152 | WD_CARD_REGISTER cardReg; 153 | HANDLE hIntThread; 154 | P9050_ADDR_DESC addrDesc[6]; 155 | BOOL fUseInt; 156 | WD_TRANSFER IntTrans[2]; 157 | } P9050_STRUCT, *P9050HANDLE; 158 | */ 159 | /* 160 | typedef struct 161 | { 162 | ULONG dwCounter; // number of interrupts received 163 | ULONG dwLost; // number of interrupts not yet dealt with 164 | BOOLEAN fStopped; // was interrupt disabled during wait 165 | ULONG dwIntStatusReg; // value of status register when interrupt occured 166 | } P9050_INTERRUPT; 167 | */ 168 | 169 | /* 170 | // options for PLX_Open 171 | enum { P9050_OPEN_USE_INT = 0x1 }; 172 | 173 | ULONG P9050_CountCards (ULONG dwVendorID, ULONG dwDeviceID); 174 | BOOL P9050_Open (P9050HANDLE *phPlx, ULONG dwVendorID, ULONG dwDeviceID, ULONG nCardNum, ULONG options); 175 | void P9050_Close (P9050HANDLE hPlx); 176 | 177 | BOOL P9050_IsAddrSpaceActive(P9050HANDLE hPlx, P9050_ADDR addrSpace); 178 | void P9050_ReadBlock (P9050HANDLE hPlx, ULONG dwLocalAddr, PVOID buf, 179 | ULONG dwBytes, P9050_ADDR addrSpace, P9050_MODE mode); 180 | void P9050_WriteBlock (P9050HANDLE hPlx, ULONG dwLocalAddr, PVOID buf, 181 | ULONG dwBytes, P9050_ADDR addrSpace, P9050_MODE mode); 182 | BYTE P9050_ReadByte (P9050HANDLE hPlx, P9050_ADDR addrSpace, ULONG dwLocalAddr); 183 | void P9050_WriteByte (P9050HANDLE hPlx, P9050_ADDR addrSpace, ULONG dwLocalAddr, BYTE data); 184 | WORD P9050_ReaULONG (P9050HANDLE hPlx, P9050_ADDR addrSpace, ULONG dwLocalAddr); 185 | void P9050_WriteWord (P9050HANDLE hPlx, P9050_ADDR addrSpace, ULONG dwLocalAddr, WORD data); 186 | ULONG P9050_ReadULONG (P9050HANDLE hPlx, P9050_ADDR addrSpace, ULONG dwLocalAddr); 187 | void P9050_WriteULONG (P9050HANDLE hPlx, P9050_ADDR addrSpace, ULONG dwLocalAddr, ULONG data); 188 | 189 | BOOL P9050_IntEnable(P9050HANDLE hPlx); 190 | void P9050_IntDisable(P9050HANDLE hPlx); 191 | void P9050_IntWait(P9050HANDLE hPlx, P9050_INTERRUPT *intResult); 192 | 193 | void P9050_WriteReg (P9050HANDLE hPlx, ULONG dwReg, ULONG dwData); 194 | ULONG P9050_ReadReg (P9050HANDLE hPlx, ULONG dwReg); 195 | */ 196 | 197 | 198 | enum 199 | { 200 | BIT0 = 0x00000001, 201 | BIT1 = 0x00000002, 202 | BIT2 = 0x00000004, 203 | BIT3 = 0x00000008, 204 | BIT4 = 0x00000010, 205 | BIT5 = 0x00000020, 206 | BIT6 = 0x00000040, 207 | BIT7 = 0x00000080, 208 | BIT8 = 0x00000100, 209 | BIT9 = 0x00000200, 210 | BIT10 = 0x00000400, 211 | BIT11 = 0x00000800, 212 | BIT12 = 0x00001000, 213 | BIT13 = 0x00002000, 214 | BIT14 = 0x00004000, 215 | BIT15 = 0x00008000, 216 | BIT16 = 0x00010000, 217 | BIT17 = 0x00020000, 218 | BIT18 = 0x00040000, 219 | BIT19 = 0x00080000, 220 | BIT20 = 0x00100000, 221 | BIT21 = 0x00200000, 222 | BIT22 = 0x00400000, 223 | BIT23 = 0x00800000, 224 | BIT24 = 0x01000000, 225 | BIT25 = 0x02000000, 226 | BIT26 = 0x04000000, 227 | BIT27 = 0x08000000, 228 | BIT28 = 0x10000000, 229 | BIT29 = 0x20000000, 230 | BIT30 = 0x40000000, 231 | BIT31 = 0x80000000 232 | }; 233 | 234 | #ifdef __cplusplus 235 | } 236 | #endif 237 | 238 | #endif 239 | -------------------------------------------------------------------------------- /kernel_modules_drivers/gesytec-2.12/analyzer.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | // Transceiver Id Watcher 11 | // Bit 2: Baud/16 Bit 1: Baud/2 Bit 0: 1=Single-ended 0=Differential 12 | #define TP1250 0 13 | #define TP78 4 14 | #define FTT10 5 15 | #define RS485_625 3 // Neuron site is Single-ended 16 | #define RS485_39 7 // Neuron site is Single-ended 17 | 18 | #define XCVR FTT10 19 | 20 | #define IOCTL_VERSION 0x43504C00 21 | #define IOCTL_WATCHER 0x43504C01 22 | 23 | #define CMD_LOAD 0 24 | #define CMD_PACKET 1 25 | #define CMD_CLEAR 2 26 | #define CMD_TIME 3 27 | #define CMD_START 4 28 | #define CMD_STOP 5 29 | #define CMD_GETTIME 6 30 | 31 | typedef unsigned char u8; 32 | typedef unsigned short u16; 33 | typedef unsigned long u32; 34 | 35 | u8 gbuf[4096]; 36 | int ni_handle; 37 | 38 | static const char svctype[3][8][12] = { 39 | { "ACKD ","UNACKD_REP","ack ","??? ", 40 | "REMINDER ","REM/MSG ","??? ","??? " }, 41 | { "REQUEST ","??? ","response ","??? ", 42 | "REMINDER ","REM/MSG ","??? ","??? " }, 43 | { "CHALLENGE ","??? ","reply ","??? ", 44 | "??? ","??? ","??? ","??? " } 45 | }; 46 | 47 | 48 | // Show an error message and exit 49 | 50 | void myerror(char *s) 51 | { 52 | perror( s ); 53 | close( ni_handle ); 54 | exit( -1 ); 55 | } 56 | 57 | 58 | // Load a file into a buffer and return its size 59 | 60 | int loadfile( u8 *d, char *s ) 61 | { 62 | int fd; 63 | int size; 64 | 65 | fd = open( s, O_RDONLY ); 66 | if( fd < 0 ) return -1; 67 | size = read( fd, d, 4096 ); 68 | close( fd ); 69 | return( size ); 70 | } 71 | 72 | 73 | // Store the actual time in 102.4 us intervals since 01.01.1970 74 | // in a 6 byte buffer ( Motorola order ) 75 | 76 | void get_time( u8 *d ) 77 | { 78 | struct timezone tz; 79 | struct timeval tv; 80 | long long t; 81 | u8 *p; 82 | 83 | tz.tz_minuteswest = 0; 84 | tz.tz_dsttime = 0; 85 | gettimeofday( &tv, &tz ); 86 | t = tv.tv_sec; 87 | t = (t * 1000) + tv.tv_usec/1000; // Milliseconds since 01.01.1970 88 | 89 | t *= 2500; 90 | t /= 256; // 102.4 us intervals 91 | p = (u8 *)&t; 92 | *d++ = p[5]; *d++ = p[4]; *d++ = p[3]; // Store in Motorola order 93 | *d++ = p[2]; *d++ = p[1]; *d++ = p[0]; 94 | } 95 | 96 | 97 | // Convert a 6 byte ( Motorola order ) timestamp 98 | // in 102.4 us intervals at the END of a packet 99 | // into millisecond intervals at packet START and display it 100 | 101 | void show_time( u8 *s, int len, u8 xcvr ) 102 | { 103 | struct tm *lt; 104 | int ms; 105 | time_t gmt; 106 | long long t; 107 | u8 *p; 108 | 109 | if( xcvr & 2 ) len *= 2; // Packet duration depends 110 | if( !(xcvr & 1) ) len /= 16; // on transceiver baud rate 111 | 112 | t = 0; 113 | p = (u8 *)&t; 114 | p[5] = *s++; p[4] = *s++; p[3] = *s++; // Motorola -> Intel 115 | p[2] = *s++; p[1] = *s++; p[0] = *s++; 116 | t -= len; 117 | t *= 256; 118 | t /= 2500; // Milliseconds 119 | 120 | ms = t % 1000; gmt = (time_t)(t / 1000); 121 | lt = localtime( &gmt ); 122 | printf( "\n%02d.%02d.%04d %02d:%02d:%02d.%03d ", 123 | lt->tm_mday, lt->tm_mon+1, lt->tm_year+1900, 124 | lt->tm_hour, lt->tm_min, lt->tm_sec, ms ); 125 | } 126 | 127 | 128 | // Decode a packet from LonTalk format and display it 129 | // For further datails see the LonTalk protocol specification 130 | 131 | void show_packet( u8* buf, int count ) 132 | { 133 | u8 *p; 134 | int i; 135 | u8 pdufmt, pdutype, adrfmt, domlen; 136 | u8 snet, snode, dnet, dnode; 137 | 138 | p = buf; 139 | 140 | // Media access control 141 | 142 | printf( "Backlog =%2d", *p & 0x3F ); 143 | if( *p & 0x80 ) printf( " Prio" ); 144 | if( *p & 0x40 ) printf( " AltPath" ); 145 | printf( "\n" ); 146 | p++; 147 | 148 | // Address field 149 | 150 | pdufmt = (*p >> 4) & 3; 151 | adrfmt = (*p >> 2) & 3; 152 | domlen = *p++ & 3; 153 | domlen = (domlen * (domlen + 1)) / 2; 154 | snet = *p++; 155 | snode = *p++; 156 | dnet = *p++; 157 | printf( "%3d/%-3d -> ", snet, snode & 0x7F ); 158 | switch( adrfmt ) 159 | { 160 | case 0: 161 | if( dnet ) printf( "Subnet %-3d ", dnet ); 162 | else printf( "Broadcast " ); 163 | break; 164 | case 1: 165 | printf( "Group %-3d ", dnet ); 166 | break; 167 | case 2: 168 | dnode = *p++ & 0x7F; 169 | if( snode & 0x80 ) printf( "%3d/%-3d ", dnet, dnode ); 170 | else { 171 | printf( "%3d/%-3d G%-3d M%-2d", dnet, dnode, p[0], p[1] ); 172 | p += 2; 173 | } 174 | break; 175 | case 3: 176 | printf( "NID " ); 177 | for( i = 0; i < 6; i++ ) printf( "%02X", *p++ ); 178 | break; 179 | } 180 | 181 | // Domain field 182 | 183 | printf( " Domain: " ); 184 | if( !domlen ) printf( "default " ); 185 | else { 186 | for( i = 0; i < domlen; i++ ) printf( "%02X", *p++ ); 187 | for( i = domlen; i < 6; i++ ) printf( " " ); 188 | } 189 | 190 | // Transaction 191 | 192 | if( pdufmt == 3 ) printf( " - UNACKD " ); 193 | else { 194 | printf( " %2d ", *p & 0x0F ); 195 | pdutype = (*p++ >> 4) & 7; 196 | printf( svctype[ pdufmt ][ pdutype ] ); 197 | if((pdutype == 4) || (pdutype == 5)) 198 | { 199 | i = *p++; 200 | printf( "\nMList: " ); 201 | while( i-- ) printf( "%02X", *p++ ); 202 | } 203 | } 204 | 205 | // Data field 206 | 207 | printf( "\n" ); 208 | count -= (p - buf); 209 | if( count > 0 ) 210 | { 211 | if((*p & 0x80) && (count >= 2)) 212 | { 213 | printf( "NV %02X%02X:", p[0] & 0x3F, p[1] ); // NV selector 214 | if(*p & 0x40) printf( " Poll"); 215 | p += 2; 216 | count -= 2; 217 | } 218 | else { 219 | printf( "%02X:", *p++ ); // Message code 220 | count--; 221 | } 222 | while( count-- ) printf( " %02X", *p++ ); // data 223 | printf( "\n" ); 224 | } 225 | } 226 | 227 | 228 | int main(int argc, char **argv) 229 | { 230 | char *devname; 231 | char version[80]; 232 | int result; 233 | int count; 234 | u8 *p; 235 | 236 | // Argument must be '1'...'9' for lon1...lon9 237 | 238 | if(argc < 2) { 239 | printf("Syntax: ./analyzer \n"); 240 | return 1; 241 | } 242 | devname = argv[1]; 243 | 244 | // Open the LON device 245 | 246 | ni_handle = open( devname, O_RDWR ); 247 | if( ni_handle < 0 ) myerror( "LON device not found" ); 248 | 249 | ioctl( ni_handle, IOCTL_VERSION, (unsigned long)&version ); 250 | printf("%s\n", version); 251 | 252 | 253 | // Buffer format of watcher ioctl is: 254 | // Length (hi & lo byte) of following data 255 | // Watcher command 256 | // Optional data 257 | 258 | // Load the firmware file 259 | 260 | result = loadfile( &gbuf[4], "lwafw.lwa" ); 261 | if( result <= 0 ) myerror( "LWA firmware not found" ); 262 | 263 | count = result + 2; 264 | gbuf[0] = count >> 8; 265 | gbuf[1] = count & 0xFF; 266 | gbuf[2] = CMD_LOAD; 267 | gbuf[3] = XCVR; 268 | result = ioctl( ni_handle, IOCTL_WATCHER, (u32)&gbuf ); 269 | if( result != 2 ) myerror( "LWA hardware not found" ); 270 | 271 | printf("Record...\n"); 272 | 273 | // Set time 274 | 275 | gbuf[0] = 0; 276 | gbuf[1] = 7; 277 | gbuf[2] = CMD_TIME; 278 | get_time( &gbuf[3] ); 279 | result = ioctl( ni_handle, IOCTL_WATCHER, (u32)&gbuf ); 280 | 281 | // Start recording 282 | 283 | gbuf[0] = 0; 284 | gbuf[1] = 1; 285 | gbuf[2] = CMD_START; 286 | result = ioctl( ni_handle, IOCTL_WATCHER, (u32)&gbuf ); 287 | 288 | while( 1 ) 289 | { 290 | gbuf[0] = 0; 291 | gbuf[1] = 1; 292 | gbuf[2] = CMD_PACKET; 293 | result = ioctl( ni_handle, IOCTL_WATCHER, (u32)&gbuf ); 294 | if( result < 2 ) myerror( "Device error" ); 295 | 296 | p = gbuf; 297 | count = *p++; 298 | count = (count << 8) | *p++; 299 | if( count > 7 ) 300 | { 301 | show_time( p, count - 5, XCVR ); 302 | if( count < 12 ) printf( "too short\n" ); 303 | else if( p[6] & 2 ) printf( "CRC-ERROR\n" ); 304 | else show_packet( &p[7], count - 7 ); 305 | } 306 | else poll( NULL, 0, 100 ); 307 | } 308 | 309 | return 0; 310 | } 311 | -------------------------------------------------------------------------------- /kernel_modules_drivers/gesytec-2.06/Plx9050.h: -------------------------------------------------------------------------------- 1 | #ifndef _PLXLIB_H_ 2 | #define _PLXLIB_H_ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | /* 9 | #ifndef _NTDEF_ 10 | typedef BOOL BOOLEAN; 11 | #endif 12 | */ 13 | 14 | /* 15 | // PCI register definitions 16 | enum { 17 | PCI_IDR = 0x00, 18 | PCI_CR = 0x04, 19 | PCI_SR = 0x06, 20 | PCI_REV = 0x08, 21 | PCI_CCR = 0x09, 22 | PCI_LSR = 0x0c, 23 | PCI_LTR = 0x0d, 24 | PCI_HTR = 0x0e, 25 | PCI_BISTR= 0x0f, 26 | PCI_BAR0 = 0x10, 27 | PCI_BAR1 = 0x14, 28 | PCI_BAR2 = 0x18, 29 | PCI_BAR3 = 0x1c, 30 | PCI_BAR4 = 0x20, 31 | PCI_BAR5 = 0x24, 32 | PCI_CIS = 0x28, 33 | PCI_SVID = 0x2c, 34 | PCI_SID = 0x2e, 35 | PCI_ERBAR= 0x30, 36 | PCI_ILR = 0x3c, 37 | PCI_IPR = 0x3d, 38 | PCI_MGR = 0x3e, 39 | PCI_MLR = 0x3f 40 | }; 41 | */ 42 | 43 | // PLX register definitions 44 | enum { 45 | P9050_LAS0RR = 0x00, 46 | P9050_LAS1RR = 0x04, 47 | P9050_LAS2RR = 0x08, 48 | P9050_LAS3RR = 0x0c, 49 | P9050_EROMRR = 0x10, 50 | P9050_LAS0BA = 0x14, 51 | P9050_LAS1BA = 0x18, 52 | P9050_LAS2BA = 0x1c, 53 | P9050_LAS3BA = 0x20, 54 | P9050_EROMBA = 0x24, 55 | P9050_LAS0BRD = 0x28, 56 | P9050_LAS1BRD = 0x2c, 57 | P9050_LAS2BRD = 0x30, 58 | P9050_LAS3BRD = 0x34, 59 | P9050_EROMBRD = 0x38, 60 | P9050_CS0BASE = 0x3c, 61 | P9050_CS1BASE = 0x40, 62 | P9050_CS2BASE = 0x44, 63 | P9050_CS3BASE = 0x48, 64 | P9050_INTCSR = 0x4c, 65 | P9050_CNTRL = 0x50 66 | }; 67 | 68 | /****** Data Structures *****************************************************/ 69 | /* 70 | * RUNTIME_9050 - PLX PCI9050-1 local configuration and shared runtime 71 | * registers. This structure can be used to access the 9050 registers 72 | * (memory mapped). 73 | */ 74 | /* 75 | typedef struct _PLX_9050 76 | { 77 | ULONG loc_addr_range[4]; // 00-0Ch : Local Address Ranges 78 | ULONG loc_rom_range; // 10h : Local ROM Range 79 | ULONG loc_addr_base[4]; // 14-20h : Local Address Base Addrs 80 | ULONG loc_rom_base; // 24h : Local ROM Base 81 | ULONG loc_bus_descr[4]; // 28-34h : Local Bus Descriptors 82 | ULONG rom_bus_descr; // 38h : ROM Bus Descriptor 83 | ULONG cs_base[4]; // 3C-48h : Chip Select Base Addrs 84 | ULONG intr_ctrl_stat; // 4Ch : Interrupt Control/Status 85 | ULONG init_ctrl; // 50h : EEPROM ctrl, Init Ctrl, etc 86 | } PLX_9050, *PPLX_9050; 87 | */ 88 | /* 89 | 4.3.20 (INTCSR; 4Ch) Interrupt Control/Status Register 90 | Talbe 43: Interrupt Control/Status Register Description 91 | Field Description Read Write Value after Reset 92 | 0 Local interrupt 1 enable. 1 = Enabled. 0 = Disabled. Yes Yes 0 93 | 1 Local interrupt 1 polarity. 1 = Active high. 0 = Active low. Yes Yes 0 94 | 2 Local interrupt 1 status. 1 = Interrupt active. 0 = Interrupt not active Yes No 0 95 | 3 Local interrupt 2 enable. 1 = Enabled. 0 = Disabled. Yes Yes 0 96 | 4 Local interrupt 2 polarity. 1 = Active high. 0 = Active low. Yes Yes 0 97 | 5 Local interrupt 2 status. 1 = Interrupt active. 0 = Interrupt not active Yes No 0 98 | 6 PCI interrupt enable. A value of 1 will enable PCI interrupt. Yes Yes 0 99 | 7 Software Interrupt. 1 = Generate interrupt. Yes Yes 0 100 | 31:8 Not used. Yes No 0 101 | */ 102 | 103 | #define PLX_9050_LINT1_ENABLE 0x01 104 | #define PLX_9050_LINT1_POL 0x02 105 | #define PLX_9050_LINT1_STATUS 0x04 106 | #define PLX_9050_LINT2_ENABLE 0x08 107 | #define PLX_9050_LINT2_POL 0x10 108 | #define PLX_9050_LINT2_STATUS 0x20 109 | #define PLX_9050_INTR_ENABLE 0x40 110 | #define PLX_9050_SW_INTR 0x80 111 | 112 | 113 | 114 | typedef enum 115 | { 116 | P9050_MODE_BYTE = 0, 117 | P9050_MODE_WORD = 1, 118 | P9050_MODE_ULONG = 2 119 | } P9050_MODE; 120 | 121 | typedef enum 122 | { 123 | P9050_ADDR_REG = 0, 124 | P9050_ADDR_SPACE0 = 1, 125 | P9050_ADDR_SPACE1 = 2, 126 | P9050_ADDR_SPACE2 = 3, 127 | P9050_ADDR_SPACE3 = 4, 128 | P9050_ADDR_EPROM = 5 129 | } P9050_ADDR; 130 | 131 | 132 | enum { P9050_RANGE_REG = 0x00000080 }; 133 | /* 134 | typedef struct _P9050_ADDR_DESC 135 | { 136 | ULONG dwLocalBase; 137 | ULONG dwMask; 138 | ULONG dwBytes; 139 | ULONG dwAddr; 140 | ULONG dwAddrDirect; 141 | BOOLEAN fIsMemory; 142 | ULONG modeDesc[3]; 143 | } P9050_ADDR_DESC; 144 | */ 145 | /* 146 | typedef struct 147 | { 148 | HANDLE hWD; 149 | WD_CARD cardLock; 150 | WD_INTERRUPT Int; 151 | WD_PCI_SLOT pciSlot; 152 | WD_CARD_REGISTER cardReg; 153 | HANDLE hIntThread; 154 | P9050_ADDR_DESC addrDesc[6]; 155 | BOOL fUseInt; 156 | WD_TRANSFER IntTrans[2]; 157 | } P9050_STRUCT, *P9050HANDLE; 158 | */ 159 | /* 160 | typedef struct 161 | { 162 | ULONG dwCounter; // number of interrupts received 163 | ULONG dwLost; // number of interrupts not yet dealt with 164 | BOOLEAN fStopped; // was interrupt disabled during wait 165 | ULONG dwIntStatusReg; // value of status register when interrupt occured 166 | } P9050_INTERRUPT; 167 | */ 168 | 169 | /* 170 | // options for PLX_Open 171 | enum { P9050_OPEN_USE_INT = 0x1 }; 172 | 173 | ULONG P9050_CountCards (ULONG dwVendorID, ULONG dwDeviceID); 174 | BOOL P9050_Open (P9050HANDLE *phPlx, ULONG dwVendorID, ULONG dwDeviceID, ULONG nCardNum, ULONG options); 175 | void P9050_Close (P9050HANDLE hPlx); 176 | 177 | BOOL P9050_IsAddrSpaceActive(P9050HANDLE hPlx, P9050_ADDR addrSpace); 178 | void P9050_ReadBlock (P9050HANDLE hPlx, ULONG dwLocalAddr, PVOID buf, 179 | ULONG dwBytes, P9050_ADDR addrSpace, P9050_MODE mode); 180 | void P9050_WriteBlock (P9050HANDLE hPlx, ULONG dwLocalAddr, PVOID buf, 181 | ULONG dwBytes, P9050_ADDR addrSpace, P9050_MODE mode); 182 | BYTE P9050_ReadByte (P9050HANDLE hPlx, P9050_ADDR addrSpace, ULONG dwLocalAddr); 183 | void P9050_WriteByte (P9050HANDLE hPlx, P9050_ADDR addrSpace, ULONG dwLocalAddr, BYTE data); 184 | WORD P9050_ReaULONG (P9050HANDLE hPlx, P9050_ADDR addrSpace, ULONG dwLocalAddr); 185 | void P9050_WriteWord (P9050HANDLE hPlx, P9050_ADDR addrSpace, ULONG dwLocalAddr, WORD data); 186 | ULONG P9050_ReadULONG (P9050HANDLE hPlx, P9050_ADDR addrSpace, ULONG dwLocalAddr); 187 | void P9050_WriteULONG (P9050HANDLE hPlx, P9050_ADDR addrSpace, ULONG dwLocalAddr, ULONG data); 188 | 189 | BOOL P9050_IntEnable(P9050HANDLE hPlx); 190 | void P9050_IntDisable(P9050HANDLE hPlx); 191 | void P9050_IntWait(P9050HANDLE hPlx, P9050_INTERRUPT *intResult); 192 | 193 | void P9050_WriteReg (P9050HANDLE hPlx, ULONG dwReg, ULONG dwData); 194 | ULONG P9050_ReadReg (P9050HANDLE hPlx, ULONG dwReg); 195 | */ 196 | 197 | 198 | enum 199 | { 200 | BIT0 = 0x00000001, 201 | BIT1 = 0x00000002, 202 | BIT2 = 0x00000004, 203 | BIT3 = 0x00000008, 204 | BIT4 = 0x00000010, 205 | BIT5 = 0x00000020, 206 | BIT6 = 0x00000040, 207 | BIT7 = 0x00000080, 208 | BIT8 = 0x00000100, 209 | BIT9 = 0x00000200, 210 | BIT10 = 0x00000400, 211 | BIT11 = 0x00000800, 212 | BIT12 = 0x00001000, 213 | BIT13 = 0x00002000, 214 | BIT14 = 0x00004000, 215 | BIT15 = 0x00008000, 216 | BIT16 = 0x00010000, 217 | BIT17 = 0x00020000, 218 | BIT18 = 0x00040000, 219 | BIT19 = 0x00080000, 220 | BIT20 = 0x00100000, 221 | BIT21 = 0x00200000, 222 | BIT22 = 0x00400000, 223 | BIT23 = 0x00800000, 224 | BIT24 = 0x01000000, 225 | BIT25 = 0x02000000, 226 | BIT26 = 0x04000000, 227 | BIT27 = 0x08000000, 228 | BIT28 = 0x10000000, 229 | BIT29 = 0x20000000, 230 | BIT30 = 0x40000000, 231 | BIT31 = 0x80000000 232 | }; 233 | 234 | #ifdef __cplusplus 235 | } 236 | #endif 237 | 238 | #endif 239 | -------------------------------------------------------------------------------- /kernel_modules_drivers/gesytec-2.08/Plx9050.h: -------------------------------------------------------------------------------- 1 | #ifndef _PLXLIB_H_ 2 | #define _PLXLIB_H_ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | /* 9 | #ifndef _NTDEF_ 10 | typedef BOOL BOOLEAN; 11 | #endif 12 | */ 13 | 14 | /* 15 | // PCI register definitions 16 | enum { 17 | PCI_IDR = 0x00, 18 | PCI_CR = 0x04, 19 | PCI_SR = 0x06, 20 | PCI_REV = 0x08, 21 | PCI_CCR = 0x09, 22 | PCI_LSR = 0x0c, 23 | PCI_LTR = 0x0d, 24 | PCI_HTR = 0x0e, 25 | PCI_BISTR= 0x0f, 26 | PCI_BAR0 = 0x10, 27 | PCI_BAR1 = 0x14, 28 | PCI_BAR2 = 0x18, 29 | PCI_BAR3 = 0x1c, 30 | PCI_BAR4 = 0x20, 31 | PCI_BAR5 = 0x24, 32 | PCI_CIS = 0x28, 33 | PCI_SVID = 0x2c, 34 | PCI_SID = 0x2e, 35 | PCI_ERBAR= 0x30, 36 | PCI_ILR = 0x3c, 37 | PCI_IPR = 0x3d, 38 | PCI_MGR = 0x3e, 39 | PCI_MLR = 0x3f 40 | }; 41 | */ 42 | 43 | // PLX register definitions 44 | enum { 45 | P9050_LAS0RR = 0x00, 46 | P9050_LAS1RR = 0x04, 47 | P9050_LAS2RR = 0x08, 48 | P9050_LAS3RR = 0x0c, 49 | P9050_EROMRR = 0x10, 50 | P9050_LAS0BA = 0x14, 51 | P9050_LAS1BA = 0x18, 52 | P9050_LAS2BA = 0x1c, 53 | P9050_LAS3BA = 0x20, 54 | P9050_EROMBA = 0x24, 55 | P9050_LAS0BRD = 0x28, 56 | P9050_LAS1BRD = 0x2c, 57 | P9050_LAS2BRD = 0x30, 58 | P9050_LAS3BRD = 0x34, 59 | P9050_EROMBRD = 0x38, 60 | P9050_CS0BASE = 0x3c, 61 | P9050_CS1BASE = 0x40, 62 | P9050_CS2BASE = 0x44, 63 | P9050_CS3BASE = 0x48, 64 | P9050_INTCSR = 0x4c, 65 | P9050_CNTRL = 0x50 66 | }; 67 | 68 | /****** Data Structures *****************************************************/ 69 | /* 70 | * RUNTIME_9050 - PLX PCI9050-1 local configuration and shared runtime 71 | * registers. This structure can be used to access the 9050 registers 72 | * (memory mapped). 73 | */ 74 | /* 75 | typedef struct _PLX_9050 76 | { 77 | ULONG loc_addr_range[4]; // 00-0Ch : Local Address Ranges 78 | ULONG loc_rom_range; // 10h : Local ROM Range 79 | ULONG loc_addr_base[4]; // 14-20h : Local Address Base Addrs 80 | ULONG loc_rom_base; // 24h : Local ROM Base 81 | ULONG loc_bus_descr[4]; // 28-34h : Local Bus Descriptors 82 | ULONG rom_bus_descr; // 38h : ROM Bus Descriptor 83 | ULONG cs_base[4]; // 3C-48h : Chip Select Base Addrs 84 | ULONG intr_ctrl_stat; // 4Ch : Interrupt Control/Status 85 | ULONG init_ctrl; // 50h : EEPROM ctrl, Init Ctrl, etc 86 | } PLX_9050, *PPLX_9050; 87 | */ 88 | /* 89 | 4.3.20 (INTCSR; 4Ch) Interrupt Control/Status Register 90 | Talbe 43: Interrupt Control/Status Register Description 91 | Field Description Read Write Value after Reset 92 | 0 Local interrupt 1 enable. 1 = Enabled. 0 = Disabled. Yes Yes 0 93 | 1 Local interrupt 1 polarity. 1 = Active high. 0 = Active low. Yes Yes 0 94 | 2 Local interrupt 1 status. 1 = Interrupt active. 0 = Interrupt not active Yes No 0 95 | 3 Local interrupt 2 enable. 1 = Enabled. 0 = Disabled. Yes Yes 0 96 | 4 Local interrupt 2 polarity. 1 = Active high. 0 = Active low. Yes Yes 0 97 | 5 Local interrupt 2 status. 1 = Interrupt active. 0 = Interrupt not active Yes No 0 98 | 6 PCI interrupt enable. A value of 1 will enable PCI interrupt. Yes Yes 0 99 | 7 Software Interrupt. 1 = Generate interrupt. Yes Yes 0 100 | 31:8 Not used. Yes No 0 101 | */ 102 | 103 | #define PLX_9050_LINT1_ENABLE 0x01 104 | #define PLX_9050_LINT1_POL 0x02 105 | #define PLX_9050_LINT1_STATUS 0x04 106 | #define PLX_9050_LINT2_ENABLE 0x08 107 | #define PLX_9050_LINT2_POL 0x10 108 | #define PLX_9050_LINT2_STATUS 0x20 109 | #define PLX_9050_INTR_ENABLE 0x40 110 | #define PLX_9050_SW_INTR 0x80 111 | 112 | 113 | 114 | typedef enum 115 | { 116 | P9050_MODE_BYTE = 0, 117 | P9050_MODE_WORD = 1, 118 | P9050_MODE_ULONG = 2 119 | } P9050_MODE; 120 | 121 | typedef enum 122 | { 123 | P9050_ADDR_REG = 0, 124 | P9050_ADDR_SPACE0 = 1, 125 | P9050_ADDR_SPACE1 = 2, 126 | P9050_ADDR_SPACE2 = 3, 127 | P9050_ADDR_SPACE3 = 4, 128 | P9050_ADDR_EPROM = 5 129 | } P9050_ADDR; 130 | 131 | 132 | enum { P9050_RANGE_REG = 0x00000080 }; 133 | /* 134 | typedef struct _P9050_ADDR_DESC 135 | { 136 | ULONG dwLocalBase; 137 | ULONG dwMask; 138 | ULONG dwBytes; 139 | ULONG dwAddr; 140 | ULONG dwAddrDirect; 141 | BOOLEAN fIsMemory; 142 | ULONG modeDesc[3]; 143 | } P9050_ADDR_DESC; 144 | */ 145 | /* 146 | typedef struct 147 | { 148 | HANDLE hWD; 149 | WD_CARD cardLock; 150 | WD_INTERRUPT Int; 151 | WD_PCI_SLOT pciSlot; 152 | WD_CARD_REGISTER cardReg; 153 | HANDLE hIntThread; 154 | P9050_ADDR_DESC addrDesc[6]; 155 | BOOL fUseInt; 156 | WD_TRANSFER IntTrans[2]; 157 | } P9050_STRUCT, *P9050HANDLE; 158 | */ 159 | /* 160 | typedef struct 161 | { 162 | ULONG dwCounter; // number of interrupts received 163 | ULONG dwLost; // number of interrupts not yet dealt with 164 | BOOLEAN fStopped; // was interrupt disabled during wait 165 | ULONG dwIntStatusReg; // value of status register when interrupt occured 166 | } P9050_INTERRUPT; 167 | */ 168 | 169 | /* 170 | // options for PLX_Open 171 | enum { P9050_OPEN_USE_INT = 0x1 }; 172 | 173 | ULONG P9050_CountCards (ULONG dwVendorID, ULONG dwDeviceID); 174 | BOOL P9050_Open (P9050HANDLE *phPlx, ULONG dwVendorID, ULONG dwDeviceID, ULONG nCardNum, ULONG options); 175 | void P9050_Close (P9050HANDLE hPlx); 176 | 177 | BOOL P9050_IsAddrSpaceActive(P9050HANDLE hPlx, P9050_ADDR addrSpace); 178 | void P9050_ReadBlock (P9050HANDLE hPlx, ULONG dwLocalAddr, PVOID buf, 179 | ULONG dwBytes, P9050_ADDR addrSpace, P9050_MODE mode); 180 | void P9050_WriteBlock (P9050HANDLE hPlx, ULONG dwLocalAddr, PVOID buf, 181 | ULONG dwBytes, P9050_ADDR addrSpace, P9050_MODE mode); 182 | BYTE P9050_ReadByte (P9050HANDLE hPlx, P9050_ADDR addrSpace, ULONG dwLocalAddr); 183 | void P9050_WriteByte (P9050HANDLE hPlx, P9050_ADDR addrSpace, ULONG dwLocalAddr, BYTE data); 184 | WORD P9050_ReaULONG (P9050HANDLE hPlx, P9050_ADDR addrSpace, ULONG dwLocalAddr); 185 | void P9050_WriteWord (P9050HANDLE hPlx, P9050_ADDR addrSpace, ULONG dwLocalAddr, WORD data); 186 | ULONG P9050_ReadULONG (P9050HANDLE hPlx, P9050_ADDR addrSpace, ULONG dwLocalAddr); 187 | void P9050_WriteULONG (P9050HANDLE hPlx, P9050_ADDR addrSpace, ULONG dwLocalAddr, ULONG data); 188 | 189 | BOOL P9050_IntEnable(P9050HANDLE hPlx); 190 | void P9050_IntDisable(P9050HANDLE hPlx); 191 | void P9050_IntWait(P9050HANDLE hPlx, P9050_INTERRUPT *intResult); 192 | 193 | void P9050_WriteReg (P9050HANDLE hPlx, ULONG dwReg, ULONG dwData); 194 | ULONG P9050_ReadReg (P9050HANDLE hPlx, ULONG dwReg); 195 | */ 196 | 197 | 198 | enum 199 | { 200 | BIT0 = 0x00000001, 201 | BIT1 = 0x00000002, 202 | BIT2 = 0x00000004, 203 | BIT3 = 0x00000008, 204 | BIT4 = 0x00000010, 205 | BIT5 = 0x00000020, 206 | BIT6 = 0x00000040, 207 | BIT7 = 0x00000080, 208 | BIT8 = 0x00000100, 209 | BIT9 = 0x00000200, 210 | BIT10 = 0x00000400, 211 | BIT11 = 0x00000800, 212 | BIT12 = 0x00001000, 213 | BIT13 = 0x00002000, 214 | BIT14 = 0x00004000, 215 | BIT15 = 0x00008000, 216 | BIT16 = 0x00010000, 217 | BIT17 = 0x00020000, 218 | BIT18 = 0x00040000, 219 | BIT19 = 0x00080000, 220 | BIT20 = 0x00100000, 221 | BIT21 = 0x00200000, 222 | BIT22 = 0x00400000, 223 | BIT23 = 0x00800000, 224 | BIT24 = 0x01000000, 225 | BIT25 = 0x02000000, 226 | BIT26 = 0x04000000, 227 | BIT27 = 0x08000000, 228 | BIT28 = 0x10000000, 229 | BIT29 = 0x20000000, 230 | BIT30 = 0x40000000, 231 | BIT31 = 0x80000000 232 | }; 233 | 234 | #ifdef __cplusplus 235 | } 236 | #endif 237 | 238 | #endif 239 | -------------------------------------------------------------------------------- /kernel_modules_drivers/gesytec-2.09/Plx9050.h: -------------------------------------------------------------------------------- 1 | #ifndef _PLXLIB_H_ 2 | #define _PLXLIB_H_ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | /* 9 | #ifndef _NTDEF_ 10 | typedef BOOL BOOLEAN; 11 | #endif 12 | */ 13 | 14 | /* 15 | // PCI register definitions 16 | enum { 17 | PCI_IDR = 0x00, 18 | PCI_CR = 0x04, 19 | PCI_SR = 0x06, 20 | PCI_REV = 0x08, 21 | PCI_CCR = 0x09, 22 | PCI_LSR = 0x0c, 23 | PCI_LTR = 0x0d, 24 | PCI_HTR = 0x0e, 25 | PCI_BISTR= 0x0f, 26 | PCI_BAR0 = 0x10, 27 | PCI_BAR1 = 0x14, 28 | PCI_BAR2 = 0x18, 29 | PCI_BAR3 = 0x1c, 30 | PCI_BAR4 = 0x20, 31 | PCI_BAR5 = 0x24, 32 | PCI_CIS = 0x28, 33 | PCI_SVID = 0x2c, 34 | PCI_SID = 0x2e, 35 | PCI_ERBAR= 0x30, 36 | PCI_ILR = 0x3c, 37 | PCI_IPR = 0x3d, 38 | PCI_MGR = 0x3e, 39 | PCI_MLR = 0x3f 40 | }; 41 | */ 42 | 43 | // PLX register definitions 44 | enum { 45 | P9050_LAS0RR = 0x00, 46 | P9050_LAS1RR = 0x04, 47 | P9050_LAS2RR = 0x08, 48 | P9050_LAS3RR = 0x0c, 49 | P9050_EROMRR = 0x10, 50 | P9050_LAS0BA = 0x14, 51 | P9050_LAS1BA = 0x18, 52 | P9050_LAS2BA = 0x1c, 53 | P9050_LAS3BA = 0x20, 54 | P9050_EROMBA = 0x24, 55 | P9050_LAS0BRD = 0x28, 56 | P9050_LAS1BRD = 0x2c, 57 | P9050_LAS2BRD = 0x30, 58 | P9050_LAS3BRD = 0x34, 59 | P9050_EROMBRD = 0x38, 60 | P9050_CS0BASE = 0x3c, 61 | P9050_CS1BASE = 0x40, 62 | P9050_CS2BASE = 0x44, 63 | P9050_CS3BASE = 0x48, 64 | P9050_INTCSR = 0x4c, 65 | P9050_CNTRL = 0x50 66 | }; 67 | 68 | /****** Data Structures *****************************************************/ 69 | /* 70 | * RUNTIME_9050 - PLX PCI9050-1 local configuration and shared runtime 71 | * registers. This structure can be used to access the 9050 registers 72 | * (memory mapped). 73 | */ 74 | /* 75 | typedef struct _PLX_9050 76 | { 77 | ULONG loc_addr_range[4]; // 00-0Ch : Local Address Ranges 78 | ULONG loc_rom_range; // 10h : Local ROM Range 79 | ULONG loc_addr_base[4]; // 14-20h : Local Address Base Addrs 80 | ULONG loc_rom_base; // 24h : Local ROM Base 81 | ULONG loc_bus_descr[4]; // 28-34h : Local Bus Descriptors 82 | ULONG rom_bus_descr; // 38h : ROM Bus Descriptor 83 | ULONG cs_base[4]; // 3C-48h : Chip Select Base Addrs 84 | ULONG intr_ctrl_stat; // 4Ch : Interrupt Control/Status 85 | ULONG init_ctrl; // 50h : EEPROM ctrl, Init Ctrl, etc 86 | } PLX_9050, *PPLX_9050; 87 | */ 88 | /* 89 | 4.3.20 (INTCSR; 4Ch) Interrupt Control/Status Register 90 | Talbe 43: Interrupt Control/Status Register Description 91 | Field Description Read Write Value after Reset 92 | 0 Local interrupt 1 enable. 1 = Enabled. 0 = Disabled. Yes Yes 0 93 | 1 Local interrupt 1 polarity. 1 = Active high. 0 = Active low. Yes Yes 0 94 | 2 Local interrupt 1 status. 1 = Interrupt active. 0 = Interrupt not active Yes No 0 95 | 3 Local interrupt 2 enable. 1 = Enabled. 0 = Disabled. Yes Yes 0 96 | 4 Local interrupt 2 polarity. 1 = Active high. 0 = Active low. Yes Yes 0 97 | 5 Local interrupt 2 status. 1 = Interrupt active. 0 = Interrupt not active Yes No 0 98 | 6 PCI interrupt enable. A value of 1 will enable PCI interrupt. Yes Yes 0 99 | 7 Software Interrupt. 1 = Generate interrupt. Yes Yes 0 100 | 31:8 Not used. Yes No 0 101 | */ 102 | 103 | #define PLX_9050_LINT1_ENABLE 0x01 104 | #define PLX_9050_LINT1_POL 0x02 105 | #define PLX_9050_LINT1_STATUS 0x04 106 | #define PLX_9050_LINT2_ENABLE 0x08 107 | #define PLX_9050_LINT2_POL 0x10 108 | #define PLX_9050_LINT2_STATUS 0x20 109 | #define PLX_9050_INTR_ENABLE 0x40 110 | #define PLX_9050_SW_INTR 0x80 111 | 112 | 113 | 114 | typedef enum 115 | { 116 | P9050_MODE_BYTE = 0, 117 | P9050_MODE_WORD = 1, 118 | P9050_MODE_ULONG = 2 119 | } P9050_MODE; 120 | 121 | typedef enum 122 | { 123 | P9050_ADDR_REG = 0, 124 | P9050_ADDR_SPACE0 = 1, 125 | P9050_ADDR_SPACE1 = 2, 126 | P9050_ADDR_SPACE2 = 3, 127 | P9050_ADDR_SPACE3 = 4, 128 | P9050_ADDR_EPROM = 5 129 | } P9050_ADDR; 130 | 131 | 132 | enum { P9050_RANGE_REG = 0x00000080 }; 133 | /* 134 | typedef struct _P9050_ADDR_DESC 135 | { 136 | ULONG dwLocalBase; 137 | ULONG dwMask; 138 | ULONG dwBytes; 139 | ULONG dwAddr; 140 | ULONG dwAddrDirect; 141 | BOOLEAN fIsMemory; 142 | ULONG modeDesc[3]; 143 | } P9050_ADDR_DESC; 144 | */ 145 | /* 146 | typedef struct 147 | { 148 | HANDLE hWD; 149 | WD_CARD cardLock; 150 | WD_INTERRUPT Int; 151 | WD_PCI_SLOT pciSlot; 152 | WD_CARD_REGISTER cardReg; 153 | HANDLE hIntThread; 154 | P9050_ADDR_DESC addrDesc[6]; 155 | BOOL fUseInt; 156 | WD_TRANSFER IntTrans[2]; 157 | } P9050_STRUCT, *P9050HANDLE; 158 | */ 159 | /* 160 | typedef struct 161 | { 162 | ULONG dwCounter; // number of interrupts received 163 | ULONG dwLost; // number of interrupts not yet dealt with 164 | BOOLEAN fStopped; // was interrupt disabled during wait 165 | ULONG dwIntStatusReg; // value of status register when interrupt occured 166 | } P9050_INTERRUPT; 167 | */ 168 | 169 | /* 170 | // options for PLX_Open 171 | enum { P9050_OPEN_USE_INT = 0x1 }; 172 | 173 | ULONG P9050_CountCards (ULONG dwVendorID, ULONG dwDeviceID); 174 | BOOL P9050_Open (P9050HANDLE *phPlx, ULONG dwVendorID, ULONG dwDeviceID, ULONG nCardNum, ULONG options); 175 | void P9050_Close (P9050HANDLE hPlx); 176 | 177 | BOOL P9050_IsAddrSpaceActive(P9050HANDLE hPlx, P9050_ADDR addrSpace); 178 | void P9050_ReadBlock (P9050HANDLE hPlx, ULONG dwLocalAddr, PVOID buf, 179 | ULONG dwBytes, P9050_ADDR addrSpace, P9050_MODE mode); 180 | void P9050_WriteBlock (P9050HANDLE hPlx, ULONG dwLocalAddr, PVOID buf, 181 | ULONG dwBytes, P9050_ADDR addrSpace, P9050_MODE mode); 182 | BYTE P9050_ReadByte (P9050HANDLE hPlx, P9050_ADDR addrSpace, ULONG dwLocalAddr); 183 | void P9050_WriteByte (P9050HANDLE hPlx, P9050_ADDR addrSpace, ULONG dwLocalAddr, BYTE data); 184 | WORD P9050_ReaULONG (P9050HANDLE hPlx, P9050_ADDR addrSpace, ULONG dwLocalAddr); 185 | void P9050_WriteWord (P9050HANDLE hPlx, P9050_ADDR addrSpace, ULONG dwLocalAddr, WORD data); 186 | ULONG P9050_ReadULONG (P9050HANDLE hPlx, P9050_ADDR addrSpace, ULONG dwLocalAddr); 187 | void P9050_WriteULONG (P9050HANDLE hPlx, P9050_ADDR addrSpace, ULONG dwLocalAddr, ULONG data); 188 | 189 | BOOL P9050_IntEnable(P9050HANDLE hPlx); 190 | void P9050_IntDisable(P9050HANDLE hPlx); 191 | void P9050_IntWait(P9050HANDLE hPlx, P9050_INTERRUPT *intResult); 192 | 193 | void P9050_WriteReg (P9050HANDLE hPlx, ULONG dwReg, ULONG dwData); 194 | ULONG P9050_ReadReg (P9050HANDLE hPlx, ULONG dwReg); 195 | */ 196 | 197 | 198 | enum 199 | { 200 | BIT0 = 0x00000001, 201 | BIT1 = 0x00000002, 202 | BIT2 = 0x00000004, 203 | BIT3 = 0x00000008, 204 | BIT4 = 0x00000010, 205 | BIT5 = 0x00000020, 206 | BIT6 = 0x00000040, 207 | BIT7 = 0x00000080, 208 | BIT8 = 0x00000100, 209 | BIT9 = 0x00000200, 210 | BIT10 = 0x00000400, 211 | BIT11 = 0x00000800, 212 | BIT12 = 0x00001000, 213 | BIT13 = 0x00002000, 214 | BIT14 = 0x00004000, 215 | BIT15 = 0x00008000, 216 | BIT16 = 0x00010000, 217 | BIT17 = 0x00020000, 218 | BIT18 = 0x00040000, 219 | BIT19 = 0x00080000, 220 | BIT20 = 0x00100000, 221 | BIT21 = 0x00200000, 222 | BIT22 = 0x00400000, 223 | BIT23 = 0x00800000, 224 | BIT24 = 0x01000000, 225 | BIT25 = 0x02000000, 226 | BIT26 = 0x04000000, 227 | BIT27 = 0x08000000, 228 | BIT28 = 0x10000000, 229 | BIT29 = 0x20000000, 230 | BIT30 = 0x40000000, 231 | BIT31 = 0x80000000 232 | }; 233 | 234 | #ifdef __cplusplus 235 | } 236 | #endif 237 | 238 | #endif 239 | -------------------------------------------------------------------------------- /kernel_modules_drivers/gesytec-2.06/analyzer.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | // Transceiver Id Watcher 11 | // Bit 2: Baud/16 Bit 1: Baud/2 Bit 0: 1=Single-ended 0=Differential 12 | #define TP1250 0 13 | #define TP78 4 14 | #define FTT10 5 15 | #define RS485_625 3 // Neuron site is Single-ended 16 | #define RS485_39 7 // Neuron site is Single-ended 17 | 18 | #define XCVR FTT10 19 | 20 | #define IOCTL_VERSION 0x43504C00 21 | #define IOCTL_WATCHER 0x43504C01 22 | 23 | #define CMD_LOAD 0 24 | #define CMD_PACKET 1 25 | #define CMD_CLEAR 2 26 | #define CMD_TIME 3 27 | #define CMD_START 4 28 | #define CMD_STOP 5 29 | #define CMD_GETTIME 6 30 | 31 | typedef unsigned char u8; 32 | typedef unsigned short u16; 33 | typedef unsigned long u32; 34 | 35 | u8 gbuf[4096]; 36 | int ni_handle; 37 | 38 | static const char svctype[3][8][12] = { 39 | { "ACKD ","UNACKD_REP","ack ","??? ", 40 | "REMINDER ","REM/MSG ","??? ","??? " }, 41 | { "REQUEST ","??? ","response ","??? ", 42 | "REMINDER ","REM/MSG ","??? ","??? " }, 43 | { "CHALLENGE ","??? ","reply ","??? ", 44 | "??? ","??? ","??? ","??? " } 45 | }; 46 | 47 | 48 | // Show an error message and exit 49 | 50 | void myerror(char *s) 51 | { 52 | perror( s ); 53 | close( ni_handle ); 54 | exit( -1 ); 55 | } 56 | 57 | 58 | // Load a file into a buffer and return its size 59 | 60 | int loadfile( u8 *d, char *s ) 61 | { 62 | int fd; 63 | int size; 64 | 65 | fd = open( s, O_RDONLY ); 66 | if( fd < 0 ) return -1; 67 | size = read( fd, d, 4096 ); 68 | close( fd ); 69 | return( size ); 70 | } 71 | 72 | 73 | // Store the actual time in 102.4 us intervals since 01.01.1970 74 | // in a 6 byte buffer ( Motorola order ) 75 | 76 | void get_time( u8 *d ) 77 | { 78 | struct timezone tz; 79 | struct timeval tv; 80 | long long t; 81 | u8 *p; 82 | 83 | tz.tz_minuteswest = 0; 84 | tz.tz_dsttime = 0; 85 | gettimeofday( &tv, &tz ); 86 | t = tv.tv_sec; 87 | t = (t * 1000) + tv.tv_usec/1000; // Milliseconds since 01.01.1970 88 | 89 | t *= 2500; 90 | t /= 256; // 102.4 us intervals 91 | p = (u8 *)&t; 92 | *d++ = p[5]; *d++ = p[4]; *d++ = p[3]; // Store in Motorola order 93 | *d++ = p[2]; *d++ = p[1]; *d++ = p[0]; 94 | } 95 | 96 | 97 | // Convert a 6 byte ( Motorola order ) timestamp 98 | // in 102.4 us intervals at the END of a packet 99 | // into millisecond intervals at packet START and display it 100 | 101 | void show_time( u8 *s, int len, u8 xcvr ) 102 | { 103 | struct tm *lt; 104 | int ms; 105 | time_t gmt; 106 | long long t; 107 | u8 *p; 108 | 109 | if( xcvr & 2 ) len *= 2; // Packet duration depends 110 | if( !(xcvr & 1) ) len /= 16; // on transceiver baud rate 111 | 112 | t = 0; 113 | p = (u8 *)&t; 114 | p[5] = *s++; p[4] = *s++; p[3] = *s++; // Motorola -> Intel 115 | p[2] = *s++; p[1] = *s++; p[0] = *s++; 116 | t -= len; 117 | t *= 256; 118 | t /= 2500; // Milliseconds 119 | 120 | ms = t % 1000; gmt = (time_t)(t / 1000); 121 | lt = localtime( &gmt ); 122 | printf( "\n%02d.%02d.%04d %02d:%02d:%02d.%03d ", 123 | lt->tm_mday, lt->tm_mon+1, lt->tm_year+1900, 124 | lt->tm_hour, lt->tm_min, lt->tm_sec, ms ); 125 | } 126 | 127 | 128 | // Decode a packet from LonTalk format and display it 129 | // For further datails see the LonTalk protocol specification 130 | 131 | void show_packet( u8* buf, int count ) 132 | { 133 | u8 *p; 134 | int i; 135 | u8 pdufmt, pdutype, adrfmt, domlen; 136 | u8 snet, snode, dnet, dnode; 137 | 138 | p = buf; 139 | 140 | // Media access control 141 | 142 | printf( "Backlog =%2d", *p & 0x3F ); 143 | if( *p & 0x80 ) printf( " Prio" ); 144 | if( *p & 0x40 ) printf( " AltPath" ); 145 | printf( "\n" ); 146 | p++; 147 | 148 | // Address field 149 | 150 | pdufmt = (*p >> 4) & 3; 151 | adrfmt = (*p >> 2) & 3; 152 | domlen = *p++ & 3; 153 | domlen = (domlen * (domlen + 1)) / 2; 154 | snet = *p++; 155 | snode = *p++; 156 | dnet = *p++; 157 | printf( "%3d/%-3d -> ", snet, snode & 0x7F ); 158 | switch( adrfmt ) 159 | { 160 | case 0: 161 | if( dnet ) printf( "Subnet %-3d ", dnet ); 162 | else printf( "Broadcast " ); 163 | break; 164 | case 1: 165 | printf( "Group %-3d ", dnet ); 166 | break; 167 | case 2: 168 | dnode = *p++ & 0x7F; 169 | if( snode & 0x80 ) printf( "%3d/%-3d ", dnet, dnode ); 170 | else { 171 | printf( "%3d/%-3d G%-3d M%-2d", dnet, dnode, p[0], p[1] ); 172 | p += 2; 173 | } 174 | break; 175 | case 3: 176 | printf( "NID " ); 177 | for( i = 0; i < 6; i++ ) printf( "%02X", *p++ ); 178 | break; 179 | } 180 | 181 | // Domain field 182 | 183 | printf( " Domain: " ); 184 | if( !domlen ) printf( "default " ); 185 | else { 186 | for( i = 0; i < domlen; i++ ) printf( "%02X", *p++ ); 187 | for( i = domlen; i < 6; i++ ) printf( " " ); 188 | } 189 | 190 | // Transaction 191 | 192 | if( pdufmt == 3 ) printf( " - UNACKD " ); 193 | else { 194 | printf( " %2d ", *p & 0x0F ); 195 | pdutype = (*p++ >> 4) & 7; 196 | printf( svctype[ pdufmt ][ pdutype ] ); 197 | if((pdutype == 4) || (pdutype == 5)) 198 | { 199 | i = *p++; 200 | printf( "\nMList: " ); 201 | while( i-- ) printf( "%02X", *p++ ); 202 | } 203 | } 204 | 205 | // Data field 206 | 207 | printf( "\n" ); 208 | count -= (p - buf); 209 | if( count > 0 ) 210 | { 211 | if((*p & 0x80) && (count >= 2)) 212 | { 213 | printf( "NV %02X%02X:", p[0] & 0x3F, p[1] ); // NV selector 214 | if(*p & 0x40) printf( " Poll"); 215 | p += 2; 216 | count -= 2; 217 | } 218 | else { 219 | printf( "%02X:", *p++ ); // Message code 220 | count--; 221 | } 222 | while( count-- ) printf( " %02X", *p++ ); // data 223 | printf( "\n" ); 224 | } 225 | } 226 | 227 | 228 | int main(int argc, char **argv) 229 | { 230 | char devname[] = "/dev/lonx"; 231 | char version[80]; 232 | int result; 233 | int count; 234 | u8 *p; 235 | 236 | // Argument must be '1'...'9' for lon1...lon9 237 | 238 | if(argc < 2) { 239 | printf("Syntax: ./analyzer n (n=1...9)\n"); 240 | return 1; 241 | } 242 | if((argv[1][0] < '1') || (argv[1][0] > '9')) { 243 | printf( "Argument must be between 1 and 9\n" ); 244 | return 1; 245 | } 246 | devname[8] = argv[1][0]; 247 | 248 | // Open the LON device 249 | 250 | ni_handle = open( devname, O_RDWR ); 251 | if( ni_handle < 0 ) myerror( "LON device not found" ); 252 | 253 | ioctl( ni_handle, IOCTL_VERSION, (unsigned long)&version ); 254 | printf("%s\n", version); 255 | 256 | 257 | // Buffer format of watcher ioctl is: 258 | // Length (hi & lo byte) of following data 259 | // Watcher command 260 | // Optional data 261 | 262 | // Load the firmware file 263 | 264 | result = loadfile( &gbuf[4], "lwafw.lwa" ); 265 | if( result <= 0 ) myerror( "LWA firmware not found" ); 266 | 267 | count = result + 2; 268 | gbuf[0] = count >> 8; 269 | gbuf[1] = count & 0xFF; 270 | gbuf[2] = CMD_LOAD; 271 | gbuf[3] = XCVR; 272 | result = ioctl( ni_handle, IOCTL_WATCHER, (u32)&gbuf ); 273 | if( result != 2 ) myerror( "LWA hardware not found" ); 274 | 275 | printf("Record...\n"); 276 | 277 | // Set time 278 | 279 | gbuf[0] = 0; 280 | gbuf[1] = 7; 281 | gbuf[2] = CMD_TIME; 282 | get_time( &gbuf[3] ); 283 | result = ioctl( ni_handle, IOCTL_WATCHER, (u32)&gbuf ); 284 | 285 | // Start recording 286 | 287 | gbuf[0] = 0; 288 | gbuf[1] = 1; 289 | gbuf[2] = CMD_START; 290 | result = ioctl( ni_handle, IOCTL_WATCHER, (u32)&gbuf ); 291 | 292 | while( 1 ) 293 | { 294 | gbuf[0] = 0; 295 | gbuf[1] = 1; 296 | gbuf[2] = CMD_PACKET; 297 | result = ioctl( ni_handle, IOCTL_WATCHER, (u32)&gbuf ); 298 | if( result < 2 ) myerror( "Device error" ); 299 | 300 | p = gbuf; 301 | count = *p++; 302 | count = (count << 8) | *p++; 303 | if( count > 7 ) 304 | { 305 | show_time( p, count - 5, XCVR ); 306 | if( count < 12 ) printf( "too short\n" ); 307 | else if( p[6] & 2 ) printf( "CRC-ERROR\n" ); 308 | else show_packet( &p[7], count - 7 ); 309 | } 310 | else poll( NULL, 0, 100 ); 311 | } 312 | 313 | return 0; 314 | } 315 | -------------------------------------------------------------------------------- /kernel_modules_drivers/gesytec-2.08/analyzer.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | // Transceiver Id Watcher 11 | // Bit 2: Baud/16 Bit 1: Baud/2 Bit 0: 1=Single-ended 0=Differential 12 | #define TP1250 0 13 | #define TP78 4 14 | #define FTT10 5 15 | #define RS485_625 3 // Neuron site is Single-ended 16 | #define RS485_39 7 // Neuron site is Single-ended 17 | 18 | #define XCVR FTT10 19 | 20 | #define IOCTL_VERSION 0x43504C00 21 | #define IOCTL_WATCHER 0x43504C01 22 | 23 | #define CMD_LOAD 0 24 | #define CMD_PACKET 1 25 | #define CMD_CLEAR 2 26 | #define CMD_TIME 3 27 | #define CMD_START 4 28 | #define CMD_STOP 5 29 | #define CMD_GETTIME 6 30 | 31 | typedef unsigned char u8; 32 | typedef unsigned short u16; 33 | typedef unsigned long u32; 34 | 35 | u8 gbuf[4096]; 36 | int ni_handle; 37 | 38 | static const char svctype[3][8][12] = { 39 | { "ACKD ","UNACKD_REP","ack ","??? ", 40 | "REMINDER ","REM/MSG ","??? ","??? " }, 41 | { "REQUEST ","??? ","response ","??? ", 42 | "REMINDER ","REM/MSG ","??? ","??? " }, 43 | { "CHALLENGE ","??? ","reply ","??? ", 44 | "??? ","??? ","??? ","??? " } 45 | }; 46 | 47 | 48 | // Show an error message and exit 49 | 50 | void myerror(char *s) 51 | { 52 | perror( s ); 53 | close( ni_handle ); 54 | exit( -1 ); 55 | } 56 | 57 | 58 | // Load a file into a buffer and return its size 59 | 60 | int loadfile( u8 *d, char *s ) 61 | { 62 | int fd; 63 | int size; 64 | 65 | fd = open( s, O_RDONLY ); 66 | if( fd < 0 ) return -1; 67 | size = read( fd, d, 4096 ); 68 | close( fd ); 69 | return( size ); 70 | } 71 | 72 | 73 | // Store the actual time in 102.4 us intervals since 01.01.1970 74 | // in a 6 byte buffer ( Motorola order ) 75 | 76 | void get_time( u8 *d ) 77 | { 78 | struct timezone tz; 79 | struct timeval tv; 80 | long long t; 81 | u8 *p; 82 | 83 | tz.tz_minuteswest = 0; 84 | tz.tz_dsttime = 0; 85 | gettimeofday( &tv, &tz ); 86 | t = tv.tv_sec; 87 | t = (t * 1000) + tv.tv_usec/1000; // Milliseconds since 01.01.1970 88 | 89 | t *= 2500; 90 | t /= 256; // 102.4 us intervals 91 | p = (u8 *)&t; 92 | *d++ = p[5]; *d++ = p[4]; *d++ = p[3]; // Store in Motorola order 93 | *d++ = p[2]; *d++ = p[1]; *d++ = p[0]; 94 | } 95 | 96 | 97 | // Convert a 6 byte ( Motorola order ) timestamp 98 | // in 102.4 us intervals at the END of a packet 99 | // into millisecond intervals at packet START and display it 100 | 101 | void show_time( u8 *s, int len, u8 xcvr ) 102 | { 103 | struct tm *lt; 104 | int ms; 105 | time_t gmt; 106 | long long t; 107 | u8 *p; 108 | 109 | if( xcvr & 2 ) len *= 2; // Packet duration depends 110 | if( !(xcvr & 1) ) len /= 16; // on transceiver baud rate 111 | 112 | t = 0; 113 | p = (u8 *)&t; 114 | p[5] = *s++; p[4] = *s++; p[3] = *s++; // Motorola -> Intel 115 | p[2] = *s++; p[1] = *s++; p[0] = *s++; 116 | t -= len; 117 | t *= 256; 118 | t /= 2500; // Milliseconds 119 | 120 | ms = t % 1000; gmt = (time_t)(t / 1000); 121 | lt = localtime( &gmt ); 122 | printf( "\n%02d.%02d.%04d %02d:%02d:%02d.%03d ", 123 | lt->tm_mday, lt->tm_mon+1, lt->tm_year+1900, 124 | lt->tm_hour, lt->tm_min, lt->tm_sec, ms ); 125 | } 126 | 127 | 128 | // Decode a packet from LonTalk format and display it 129 | // For further datails see the LonTalk protocol specification 130 | 131 | void show_packet( u8* buf, int count ) 132 | { 133 | u8 *p; 134 | int i; 135 | u8 pdufmt, pdutype, adrfmt, domlen; 136 | u8 snet, snode, dnet, dnode; 137 | 138 | p = buf; 139 | 140 | // Media access control 141 | 142 | printf( "Backlog =%2d", *p & 0x3F ); 143 | if( *p & 0x80 ) printf( " Prio" ); 144 | if( *p & 0x40 ) printf( " AltPath" ); 145 | printf( "\n" ); 146 | p++; 147 | 148 | // Address field 149 | 150 | pdufmt = (*p >> 4) & 3; 151 | adrfmt = (*p >> 2) & 3; 152 | domlen = *p++ & 3; 153 | domlen = (domlen * (domlen + 1)) / 2; 154 | snet = *p++; 155 | snode = *p++; 156 | dnet = *p++; 157 | printf( "%3d/%-3d -> ", snet, snode & 0x7F ); 158 | switch( adrfmt ) 159 | { 160 | case 0: 161 | if( dnet ) printf( "Subnet %-3d ", dnet ); 162 | else printf( "Broadcast " ); 163 | break; 164 | case 1: 165 | printf( "Group %-3d ", dnet ); 166 | break; 167 | case 2: 168 | dnode = *p++ & 0x7F; 169 | if( snode & 0x80 ) printf( "%3d/%-3d ", dnet, dnode ); 170 | else { 171 | printf( "%3d/%-3d G%-3d M%-2d", dnet, dnode, p[0], p[1] ); 172 | p += 2; 173 | } 174 | break; 175 | case 3: 176 | printf( "NID " ); 177 | for( i = 0; i < 6; i++ ) printf( "%02X", *p++ ); 178 | break; 179 | } 180 | 181 | // Domain field 182 | 183 | printf( " Domain: " ); 184 | if( !domlen ) printf( "default " ); 185 | else { 186 | for( i = 0; i < domlen; i++ ) printf( "%02X", *p++ ); 187 | for( i = domlen; i < 6; i++ ) printf( " " ); 188 | } 189 | 190 | // Transaction 191 | 192 | if( pdufmt == 3 ) printf( " - UNACKD " ); 193 | else { 194 | printf( " %2d ", *p & 0x0F ); 195 | pdutype = (*p++ >> 4) & 7; 196 | printf( svctype[ pdufmt ][ pdutype ] ); 197 | if((pdutype == 4) || (pdutype == 5)) 198 | { 199 | i = *p++; 200 | printf( "\nMList: " ); 201 | while( i-- ) printf( "%02X", *p++ ); 202 | } 203 | } 204 | 205 | // Data field 206 | 207 | printf( "\n" ); 208 | count -= (p - buf); 209 | if( count > 0 ) 210 | { 211 | if((*p & 0x80) && (count >= 2)) 212 | { 213 | printf( "NV %02X%02X:", p[0] & 0x3F, p[1] ); // NV selector 214 | if(*p & 0x40) printf( " Poll"); 215 | p += 2; 216 | count -= 2; 217 | } 218 | else { 219 | printf( "%02X:", *p++ ); // Message code 220 | count--; 221 | } 222 | while( count-- ) printf( " %02X", *p++ ); // data 223 | printf( "\n" ); 224 | } 225 | } 226 | 227 | 228 | int main(int argc, char **argv) 229 | { 230 | char devname[] = "/dev/lonx"; 231 | char version[80]; 232 | int result; 233 | int count; 234 | u8 *p; 235 | 236 | // Argument must be '1'...'9' for lon1...lon9 237 | 238 | if(argc < 2) { 239 | printf("Syntax: ./analyzer n (n=1...9)\n"); 240 | return 1; 241 | } 242 | if((argv[1][0] < '1') || (argv[1][0] > '9')) { 243 | printf( "Argument must be between 1 and 9\n" ); 244 | return 1; 245 | } 246 | devname[8] = argv[1][0]; 247 | 248 | // Open the LON device 249 | 250 | ni_handle = open( devname, O_RDWR ); 251 | if( ni_handle < 0 ) myerror( "LON device not found" ); 252 | 253 | ioctl( ni_handle, IOCTL_VERSION, (unsigned long)&version ); 254 | printf("%s\n", version); 255 | 256 | 257 | // Buffer format of watcher ioctl is: 258 | // Length (hi & lo byte) of following data 259 | // Watcher command 260 | // Optional data 261 | 262 | // Load the firmware file 263 | 264 | result = loadfile( &gbuf[4], "lwafw.lwa" ); 265 | if( result <= 0 ) myerror( "LWA firmware not found" ); 266 | 267 | count = result + 2; 268 | gbuf[0] = count >> 8; 269 | gbuf[1] = count & 0xFF; 270 | gbuf[2] = CMD_LOAD; 271 | gbuf[3] = XCVR; 272 | result = ioctl( ni_handle, IOCTL_WATCHER, (u32)&gbuf ); 273 | if( result != 2 ) myerror( "LWA hardware not found" ); 274 | 275 | printf("Record...\n"); 276 | 277 | // Set time 278 | 279 | gbuf[0] = 0; 280 | gbuf[1] = 7; 281 | gbuf[2] = CMD_TIME; 282 | get_time( &gbuf[3] ); 283 | result = ioctl( ni_handle, IOCTL_WATCHER, (u32)&gbuf ); 284 | 285 | // Start recording 286 | 287 | gbuf[0] = 0; 288 | gbuf[1] = 1; 289 | gbuf[2] = CMD_START; 290 | result = ioctl( ni_handle, IOCTL_WATCHER, (u32)&gbuf ); 291 | 292 | while( 1 ) 293 | { 294 | gbuf[0] = 0; 295 | gbuf[1] = 1; 296 | gbuf[2] = CMD_PACKET; 297 | result = ioctl( ni_handle, IOCTL_WATCHER, (u32)&gbuf ); 298 | if( result < 2 ) myerror( "Device error" ); 299 | 300 | p = gbuf; 301 | count = *p++; 302 | count = (count << 8) | *p++; 303 | if( count > 7 ) 304 | { 305 | show_time( p, count - 5, XCVR ); 306 | if( count < 12 ) printf( "too short\n" ); 307 | else if( p[6] & 2 ) printf( "CRC-ERROR\n" ); 308 | else show_packet( &p[7], count - 7 ); 309 | } 310 | else poll( NULL, 0, 100 ); 311 | } 312 | 313 | return 0; 314 | } 315 | -------------------------------------------------------------------------------- /kernel_modules_drivers/gesytec-2.09/analyzer.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | // Transceiver Id Watcher 11 | // Bit 2: Baud/16 Bit 1: Baud/2 Bit 0: 1=Single-ended 0=Differential 12 | #define TP1250 0 13 | #define TP78 4 14 | #define FTT10 5 15 | #define RS485_625 3 // Neuron site is Single-ended 16 | #define RS485_39 7 // Neuron site is Single-ended 17 | 18 | #define XCVR FTT10 19 | 20 | #define IOCTL_VERSION 0x43504C00 21 | #define IOCTL_WATCHER 0x43504C01 22 | 23 | #define CMD_LOAD 0 24 | #define CMD_PACKET 1 25 | #define CMD_CLEAR 2 26 | #define CMD_TIME 3 27 | #define CMD_START 4 28 | #define CMD_STOP 5 29 | #define CMD_GETTIME 6 30 | 31 | typedef unsigned char u8; 32 | typedef unsigned short u16; 33 | typedef unsigned long u32; 34 | 35 | u8 gbuf[4096]; 36 | int ni_handle; 37 | 38 | static const char svctype[3][8][12] = { 39 | { "ACKD ","UNACKD_REP","ack ","??? ", 40 | "REMINDER ","REM/MSG ","??? ","??? " }, 41 | { "REQUEST ","??? ","response ","??? ", 42 | "REMINDER ","REM/MSG ","??? ","??? " }, 43 | { "CHALLENGE ","??? ","reply ","??? ", 44 | "??? ","??? ","??? ","??? " } 45 | }; 46 | 47 | 48 | // Show an error message and exit 49 | 50 | void myerror(char *s) 51 | { 52 | perror( s ); 53 | close( ni_handle ); 54 | exit( -1 ); 55 | } 56 | 57 | 58 | // Load a file into a buffer and return its size 59 | 60 | int loadfile( u8 *d, char *s ) 61 | { 62 | int fd; 63 | int size; 64 | 65 | fd = open( s, O_RDONLY ); 66 | if( fd < 0 ) return -1; 67 | size = read( fd, d, 4096 ); 68 | close( fd ); 69 | return( size ); 70 | } 71 | 72 | 73 | // Store the actual time in 102.4 us intervals since 01.01.1970 74 | // in a 6 byte buffer ( Motorola order ) 75 | 76 | void get_time( u8 *d ) 77 | { 78 | struct timezone tz; 79 | struct timeval tv; 80 | long long t; 81 | u8 *p; 82 | 83 | tz.tz_minuteswest = 0; 84 | tz.tz_dsttime = 0; 85 | gettimeofday( &tv, &tz ); 86 | t = tv.tv_sec; 87 | t = (t * 1000) + tv.tv_usec/1000; // Milliseconds since 01.01.1970 88 | 89 | t *= 2500; 90 | t /= 256; // 102.4 us intervals 91 | p = (u8 *)&t; 92 | *d++ = p[5]; *d++ = p[4]; *d++ = p[3]; // Store in Motorola order 93 | *d++ = p[2]; *d++ = p[1]; *d++ = p[0]; 94 | } 95 | 96 | 97 | // Convert a 6 byte ( Motorola order ) timestamp 98 | // in 102.4 us intervals at the END of a packet 99 | // into millisecond intervals at packet START and display it 100 | 101 | void show_time( u8 *s, int len, u8 xcvr ) 102 | { 103 | struct tm *lt; 104 | int ms; 105 | time_t gmt; 106 | long long t; 107 | u8 *p; 108 | 109 | if( xcvr & 2 ) len *= 2; // Packet duration depends 110 | if( !(xcvr & 1) ) len /= 16; // on transceiver baud rate 111 | 112 | t = 0; 113 | p = (u8 *)&t; 114 | p[5] = *s++; p[4] = *s++; p[3] = *s++; // Motorola -> Intel 115 | p[2] = *s++; p[1] = *s++; p[0] = *s++; 116 | t -= len; 117 | t *= 256; 118 | t /= 2500; // Milliseconds 119 | 120 | ms = t % 1000; gmt = (time_t)(t / 1000); 121 | lt = localtime( &gmt ); 122 | printf( "\n%02d.%02d.%04d %02d:%02d:%02d.%03d ", 123 | lt->tm_mday, lt->tm_mon+1, lt->tm_year+1900, 124 | lt->tm_hour, lt->tm_min, lt->tm_sec, ms ); 125 | } 126 | 127 | 128 | // Decode a packet from LonTalk format and display it 129 | // For further datails see the LonTalk protocol specification 130 | 131 | void show_packet( u8* buf, int count ) 132 | { 133 | u8 *p; 134 | int i; 135 | u8 pdufmt, pdutype, adrfmt, domlen; 136 | u8 snet, snode, dnet, dnode; 137 | 138 | p = buf; 139 | 140 | // Media access control 141 | 142 | printf( "Backlog =%2d", *p & 0x3F ); 143 | if( *p & 0x80 ) printf( " Prio" ); 144 | if( *p & 0x40 ) printf( " AltPath" ); 145 | printf( "\n" ); 146 | p++; 147 | 148 | // Address field 149 | 150 | pdufmt = (*p >> 4) & 3; 151 | adrfmt = (*p >> 2) & 3; 152 | domlen = *p++ & 3; 153 | domlen = (domlen * (domlen + 1)) / 2; 154 | snet = *p++; 155 | snode = *p++; 156 | dnet = *p++; 157 | printf( "%3d/%-3d -> ", snet, snode & 0x7F ); 158 | switch( adrfmt ) 159 | { 160 | case 0: 161 | if( dnet ) printf( "Subnet %-3d ", dnet ); 162 | else printf( "Broadcast " ); 163 | break; 164 | case 1: 165 | printf( "Group %-3d ", dnet ); 166 | break; 167 | case 2: 168 | dnode = *p++ & 0x7F; 169 | if( snode & 0x80 ) printf( "%3d/%-3d ", dnet, dnode ); 170 | else { 171 | printf( "%3d/%-3d G%-3d M%-2d", dnet, dnode, p[0], p[1] ); 172 | p += 2; 173 | } 174 | break; 175 | case 3: 176 | printf( "NID " ); 177 | for( i = 0; i < 6; i++ ) printf( "%02X", *p++ ); 178 | break; 179 | } 180 | 181 | // Domain field 182 | 183 | printf( " Domain: " ); 184 | if( !domlen ) printf( "default " ); 185 | else { 186 | for( i = 0; i < domlen; i++ ) printf( "%02X", *p++ ); 187 | for( i = domlen; i < 6; i++ ) printf( " " ); 188 | } 189 | 190 | // Transaction 191 | 192 | if( pdufmt == 3 ) printf( " - UNACKD " ); 193 | else { 194 | printf( " %2d ", *p & 0x0F ); 195 | pdutype = (*p++ >> 4) & 7; 196 | printf( svctype[ pdufmt ][ pdutype ] ); 197 | if((pdutype == 4) || (pdutype == 5)) 198 | { 199 | i = *p++; 200 | printf( "\nMList: " ); 201 | while( i-- ) printf( "%02X", *p++ ); 202 | } 203 | } 204 | 205 | // Data field 206 | 207 | printf( "\n" ); 208 | count -= (p - buf); 209 | if( count > 0 ) 210 | { 211 | if((*p & 0x80) && (count >= 2)) 212 | { 213 | printf( "NV %02X%02X:", p[0] & 0x3F, p[1] ); // NV selector 214 | if(*p & 0x40) printf( " Poll"); 215 | p += 2; 216 | count -= 2; 217 | } 218 | else { 219 | printf( "%02X:", *p++ ); // Message code 220 | count--; 221 | } 222 | while( count-- ) printf( " %02X", *p++ ); // data 223 | printf( "\n" ); 224 | } 225 | } 226 | 227 | 228 | int main(int argc, char **argv) 229 | { 230 | char devname[] = "/dev/lonx"; 231 | char version[80]; 232 | int result; 233 | int count; 234 | u8 *p; 235 | 236 | // Argument must be '1'...'9' for lon1...lon9 237 | 238 | if(argc < 2) { 239 | printf("Syntax: ./analyzer n (n=1...9)\n"); 240 | return 1; 241 | } 242 | if((argv[1][0] < '1') || (argv[1][0] > '9')) { 243 | printf( "Argument must be between 1 and 9\n" ); 244 | return 1; 245 | } 246 | devname[8] = argv[1][0]; 247 | 248 | // Open the LON device 249 | 250 | ni_handle = open( devname, O_RDWR ); 251 | if( ni_handle < 0 ) myerror( "LON device not found" ); 252 | 253 | ioctl( ni_handle, IOCTL_VERSION, (unsigned long)&version ); 254 | printf("%s\n", version); 255 | 256 | 257 | // Buffer format of watcher ioctl is: 258 | // Length (hi & lo byte) of following data 259 | // Watcher command 260 | // Optional data 261 | 262 | // Load the firmware file 263 | 264 | result = loadfile( &gbuf[4], "lwafw.lwa" ); 265 | if( result <= 0 ) myerror( "LWA firmware not found" ); 266 | 267 | count = result + 2; 268 | gbuf[0] = count >> 8; 269 | gbuf[1] = count & 0xFF; 270 | gbuf[2] = CMD_LOAD; 271 | gbuf[3] = XCVR; 272 | result = ioctl( ni_handle, IOCTL_WATCHER, (u32)&gbuf ); 273 | if( result != 2 ) myerror( "LWA hardware not found" ); 274 | 275 | printf("Record...\n"); 276 | 277 | // Set time 278 | 279 | gbuf[0] = 0; 280 | gbuf[1] = 7; 281 | gbuf[2] = CMD_TIME; 282 | get_time( &gbuf[3] ); 283 | result = ioctl( ni_handle, IOCTL_WATCHER, (u32)&gbuf ); 284 | 285 | // Start recording 286 | 287 | gbuf[0] = 0; 288 | gbuf[1] = 1; 289 | gbuf[2] = CMD_START; 290 | result = ioctl( ni_handle, IOCTL_WATCHER, (u32)&gbuf ); 291 | 292 | while( 1 ) 293 | { 294 | gbuf[0] = 0; 295 | gbuf[1] = 1; 296 | gbuf[2] = CMD_PACKET; 297 | result = ioctl( ni_handle, IOCTL_WATCHER, (u32)&gbuf ); 298 | if( result < 2 ) myerror( "Device error" ); 299 | 300 | p = gbuf; 301 | count = *p++; 302 | count = (count << 8) | *p++; 303 | if( count > 7 ) 304 | { 305 | show_time( p, count - 5, XCVR ); 306 | if( count < 12 ) printf( "too short\n" ); 307 | else if( p[6] & 2 ) printf( "CRC-ERROR\n" ); 308 | else show_packet( &p[7], count - 7 ); 309 | } 310 | else poll( NULL, 0, 100 ); 311 | } 312 | 313 | return 0; 314 | } 315 | -------------------------------------------------------------------------------- /kernel_modules_drivers/gesytec-2.12/driverentry.c: -------------------------------------------------------------------------------- 1 | 2 | #ifndef NO_PCI 3 | static int lpp_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) 4 | { 5 | DEV *dev; 6 | int rc; 7 | uint minor; 8 | unsigned long plx_base; 9 | // #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) 10 | // struct class_device *class_dev; 11 | // #endif 12 | 13 | dbg("%s(): pci_dev->vendor=%04X device=%04X\n pci_device_id->vendor=%04X device=%04X", 14 | __FUNCTION__, 15 | pdev->vendor, pdev->device, 16 | ent->vendor, ent->device); 17 | //return -ENODEV; 18 | 19 | dev = kmalloc (sizeof(DEV), GFP_KERNEL); 20 | if (!dev) return -ENOMEM; 21 | memset (dev, 0x00, sizeof (*dev)); 22 | 23 | 24 | /* Enable tasklet for the device */ 25 | tasklet_init(&dev->Dpc, DpcForIsr, (unsigned long) dev); 26 | 27 | /* enable device (incl. PCI PM wakeup), and bus-mastering */ 28 | rc = pci_enable_device(pdev); 29 | dbg1("pci_enable_device()=%d dev=%p", rc, dev); 30 | if (rc) goto err_out_free; 31 | 32 | rc = pci_set_mwi(pdev); 33 | dbg1("pci_set_mwi()=%d", rc); 34 | if (rc) goto err_out_disable; 35 | 36 | rc = pci_request_regions(pdev, DRIVER_MOD_NAME); 37 | dbg1("pci_request_regions()=%d", rc); 38 | if (rc) goto err_out_mwi; 39 | 40 | if (pdev->irq < 2) 41 | { 42 | rc = -EIO; 43 | printk(KERN_ERR PFX "invalid irq (%d) for pci dev %s\n", 44 | pdev->irq, pci_name(pdev)); // pdev->slot_name); 45 | goto err_out_res; 46 | } 47 | 48 | plx_base = pci_resource_start (pdev, 1); 49 | dev->PlxIntCsrPort = plx_base + P9050_INTCSR; 50 | dev->cport = pci_resource_start (pdev, 2); 51 | dev->rport = pci_resource_start (pdev, 3); 52 | dev->wport = dev->rport; 53 | dev->wtcport = pci_resource_start (pdev, 5); 54 | dev->irq = pdev->irq; 55 | 56 | /* 57 | pio_end = pci_resource_end (pdev, 0); 58 | pio_flags = pci_resource_flags (pdev, 0); 59 | pio_len = pci_resource_len (pdev, 0); 60 | */ 61 | 62 | // rc = register_netdev(dev); 63 | // if (rc) goto err_out_iomap; 64 | 65 | 66 | /* select a "subminor" number (part of a minor number) */ 67 | down (&minor_table_mutex); 68 | for (minor = MAX_LPCS; minor < MAX_DEVICES; ++minor) 69 | { 70 | if (minor_table[minor] == NULL) 71 | break; 72 | } 73 | if (minor >= MAX_DEVICES) 74 | { 75 | pr_info ("Too many devices plugged in, can not handle this device."); 76 | rc = -EINVAL; 77 | goto err_minor_table; 78 | } 79 | 80 | dev->minor = minor; 81 | minor_table[minor] = dev; 82 | 83 | pci_set_drvdata(pdev, dev); 84 | up (&minor_table_mutex); 85 | 86 | #ifdef CONFIG_DEVFS_FS 87 | devfs_mk_cdev(MKDEV(major, minor), 88 | S_IFCHR | S_IRUGO | S_IWUGO, 89 | "lpc/%d", minor); 90 | #endif 91 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) 92 | device_create(lpcclass, NULL, MKDEV(major, minor), NULL, "lppdrv%u", minor-MAX_LPCS); 93 | 94 | /* class_dev = CLASS_DEVICE_CREATE(lpcclass, MKDEV(major, minor), 95 | NULL, "lppdrv%u", minor-MAX_LPCS); 96 | if (IS_ERR(class_dev)) 97 | { 98 | err("class_device_create() -> failed"); 99 | }*/ 100 | #endif 101 | dbg1("%s(): minor=%d return 0", 102 | __FUNCTION__, 103 | minor); 104 | return 0; 105 | 106 | 107 | err_minor_table: 108 | up (&minor_table_mutex); 109 | //err_out_iomap: 110 | // iounmap(regs); 111 | err_out_res: 112 | pci_release_regions(pdev); 113 | err_out_mwi: 114 | pci_clear_mwi(pdev); 115 | err_out_disable: 116 | pci_disable_device(pdev); 117 | err_out_free: 118 | tasklet_kill(&dev->Dpc); 119 | kfree(dev); 120 | dbg1("%s(): return %d", 121 | __FUNCTION__, 122 | rc); 123 | return rc; 124 | } 125 | 126 | static void lpp_remove_one (struct pci_dev *pdev) 127 | { 128 | DEV *dev = pci_get_drvdata(pdev); 129 | dbg("%s(): dev=%p pci_dev->vendor=%04X device=%04X", 130 | __FUNCTION__, dev, 131 | pdev->vendor, pdev->device); 132 | if (!dev) BUG(); 133 | 134 | down (&minor_table_mutex); 135 | #ifdef CONFIG_DEVFS_FS 136 | devfs_remove("lpc/%d", dev->minor); 137 | #endif 138 | minor_table[dev->minor] = NULL; 139 | // unregister_netdev(dev); 140 | // iounmap(cp->regs); 141 | pci_release_regions(pdev); 142 | pci_clear_mwi(pdev); 143 | pci_disable_device(pdev); 144 | pci_set_drvdata(pdev, NULL); 145 | tasklet_kill(&dev->Dpc); 146 | kfree(dev); 147 | up (&minor_table_mutex); 148 | 149 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) 150 | device_destroy(lpcclass, MKDEV(major, dev->minor)); 151 | #endif 152 | pr_info(DRIVER_DESC " " DRIVER_DEV_NAME "%d now disconnected", dev->minor); 153 | } 154 | 155 | 156 | #ifdef CONFIG_PM 157 | static int lpp_suspend (struct pci_dev *pdev, pm_message_t state) 158 | { 159 | return 0; 160 | } 161 | 162 | static int lpp_resume (struct pci_dev *pdev) 163 | { 164 | return 0; 165 | } 166 | #endif /* CONFIG_PM */ 167 | #endif // NO_PCI 168 | 169 | 170 | #ifdef MODULE 171 | 172 | static int __init module_lpc_init(void) 173 | { 174 | int i, val, ret; 175 | char c; 176 | 177 | // if (!DbgInit()) return -ENOMEM; 178 | pr_info(DRIVER_DESC " " DRIVER_VERSION " debug=%02X", debug); 179 | 180 | ret = register_chrdev(major, DRIVER_DEV_NAME, &lpc_fops); 181 | if (ret < 0) 182 | { 183 | pr_err("register_chrdev(major=%d, \"" DRIVER_DEV_NAME "\")=%d -> failed", major, ret); 184 | // DbgExit(); 185 | return ret; 186 | } 187 | if (major == 0) major = ret; // dynamic major 188 | 189 | #ifdef CONFIG_DEVFS_FS 190 | #warning CONFIG_DEVFS_FS not tested 191 | ret = devfs_mk_dir(DRIVER_DEV_NAME); 192 | dbg1("major=%d devfs_mk_dir()=%08X", major, ret); 193 | #else 194 | //#warning Info: CONFIG_DEVFS_FS not used 195 | #endif 196 | 197 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) 198 | lpcclass = class_create(THIS_MODULE, CLASS_NAME); 199 | dbg("class_create(%s)=%p\n", CLASS_NAME, lpcclass); 200 | if(IS_ERR(lpcclass)) 201 | { 202 | pr_err("class_create(%s) failed\n", CLASS_NAME); 203 | ret = -1; 204 | goto out_unregister; 205 | } 206 | #endif 207 | #ifndef NO_PCI 208 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) 209 | ret = pci_register_driver(&lpp_driver); 210 | #else 211 | ret = pci_module_init(&lpp_driver); 212 | #endif 213 | #else 214 | ret = 0; 215 | #endif 216 | if( isa ) 217 | { 218 | i = 0; 219 | while( *isa && (i < MAX_LPCS*4) ) 220 | { 221 | c = *isa++; 222 | val = -1; 223 | if((c >= '0') && (c <= '9')) val = c - '0'; 224 | if((c >= 'A') && (c <= 'F')) val = c + 10 - 'A'; 225 | if((c >= 'a') && (c <= 'f')) val = c + 10 - 'a'; 226 | if(val >= 0) 227 | { 228 | lpcs[i >> 2] = (lpcs[i >> 2] << 4) | val; 229 | i++; 230 | } 231 | } 232 | } 233 | 234 | dbg("Loading module " DRIVER_MOD_NAME " " DRIVER_VERSION " pci_register_driver()=%d", ret); 235 | if (!lpc_init()) return 0; 236 | if (ret) 237 | { 238 | out_unregister: 239 | unregister_chrdev( major, DRIVER_DEV_NAME ); 240 | #ifdef CONFIG_DEVFS_FS 241 | devfs_remove(DRIVER_DEV_NAME); 242 | #endif 243 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) 244 | class_destroy(lpcclass); 245 | #endif 246 | // DbgExit(); 247 | } 248 | return ret; 249 | } 250 | 251 | 252 | static void __exit module_lpc_exit(void) 253 | { 254 | #ifndef NO_PCI 255 | pci_unregister_driver(&lpp_driver); 256 | #endif 257 | 258 | #ifdef CHECK_ISA_AT_LOAD_TIME 259 | { 260 | int i; 261 | for (i=0; i= KERNEL_VERSION(2,5,0) 268 | { 269 | uint minor; 270 | 271 | /* select a "subminor" number (part of a minor number) */ 272 | down (&minor_table_mutex); 273 | for (minor = 0; minor < MAX_LPCS; ++minor) 274 | { 275 | if (minor_table[minor]) 276 | device_destroy(lpcclass, MKDEV(major, minor)); 277 | } 278 | up (&minor_table_mutex); 279 | } 280 | #endif 281 | unregister_chrdev( major, DRIVER_DEV_NAME ); 282 | #ifdef CONFIG_DEVFS_FS 283 | devfs_remove(DRIVER_DEV_NAME); 284 | #endif 285 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) 286 | class_destroy(lpcclass); 287 | #endif 288 | pr_info("Unloading module " DRIVER_MOD_NAME " "DRIVER_VERSION); 289 | // DbgExit(); 290 | } 291 | 292 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0) 293 | 294 | module_init(module_lpc_init); 295 | module_exit(module_lpc_exit); 296 | 297 | MODULE_AUTHOR(DRIVER_AUTHOR); 298 | MODULE_DESCRIPTION(DRIVER_DESC); 299 | MODULE_LICENSE("GPL"); 300 | 301 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) 302 | MODULE_INFO(supported, "external"); 303 | #endif 304 | 305 | #endif 306 | 307 | #endif // #ifdef MODULE 308 | -------------------------------------------------------------------------------- /application_messaging/ni_typedef_msg.h: -------------------------------------------------------------------------------- 1 | /* network interface typdefs and managment codes for application messaging. */ 2 | 3 | 4 | #ifndef _NI_MGMT_H 5 | #define _NI_MGMT_H 1 6 | 7 | #define ID_STR_LEN 8 /* program ID length */ 8 | 9 | #define NULL_IDX 15 /* unused address table index */ 10 | 11 | // network variable direction bit. 12 | #define NV_INPUT 0 13 | #define NV_OUTPUT 1 14 | 15 | typedef struct { 16 | bits selector_hi : 6; 17 | bits direction : 1; 18 | bits priority : 1; 19 | bits selector_lo : 8; 20 | bits addr_index : 4; 21 | bits auth : 1; 22 | bits service : 2; 23 | bits turnaround : 1; 24 | } nv_struct; 25 | 26 | // Note - Microsoft C will make nv_struct 4 bytes long because it does 27 | // not allow odd-length bit-fields. It is really 3 bytes long. 28 | // Be careful when using sizeof() any structure that includes an nv_struct. 29 | 30 | #define NM_update_nv_cnfg 0x6B 31 | #define NM_update_nv_cnfg_fail 0x0B 32 | #define NM_update_nv_cnfg_succ 0x2B 33 | 34 | typedef struct { 35 | byte code; 36 | nv_struct nv_cnfg; 37 | } NM_query_nv_cnfg_response; 38 | 39 | #define NM_query_nv_cnfg 0x68 40 | #define NM_query_nv_cnfg_fail 0x08 41 | #define NM_query_nv_cnfg_succ 0x28 42 | 43 | typedef enum { 44 | APPL_OFFLINE = 0, /* Soft offline state */ 45 | APPL_ONLINE =1, 46 | APPL_RESET =2, 47 | CHANGE_STATE =3 48 | } nm_node_mode; 49 | 50 | typedef enum { 51 | APPL_UNCNFG = 2, 52 | NO_APPL_UNCNFG = 3, 53 | CNFG_ONLINE = 4, 54 | CNFG_OFFLINE = 6, /* Hard offline state */ 55 | SOFT_OFFLINE = 0xC 56 | } nm_node_state; 57 | 58 | 59 | // karl's test 60 | typedef struct { 61 | byte code; 62 | byte mode; /* Interpret with 'nm_node_mode' */ 63 | byte node_state; /* Optional field if mode==CHANGE_STATE */ 64 | /* Interpret with 'nm_node_state' */ 65 | } NM_set_node_mode_request; 66 | 67 | 68 | 69 | 70 | #define NM_set_node_mode 0x6C 71 | 72 | typedef enum { 73 | ABSOLUTE = 0, 74 | READ_ONLY_RELATIVE = 1, 75 | CONFIG_RELATIVE = 2, 76 | } nm_mem_mode; 77 | 78 | typedef enum { 79 | NO_ACTION = 0, 80 | BOTH_CS_RECALC = 1, 81 | CNFG_CS_RECALC = 4, 82 | ONLY_RESET = 8, 83 | BOTH_CS_RECALC_RESET = 9, 84 | CNFG_CS_RECALC_RESET = 12, 85 | } nm_mem_form; 86 | 87 | typedef struct { 88 | byte code; 89 | byte mode; 90 | byte offset_hi; 91 | byte offset_lo; 92 | byte count; 93 | byte form; // followed by the data 94 | } NM_write_memory_request; 95 | 96 | #define NM_write_memory 0x6E 97 | 98 | 99 | typedef struct { 100 | byte code; 101 | byte mode; 102 | byte offset_hi; 103 | byte offset_lo; 104 | byte count; 105 | } NM_read_memory_request; 106 | 107 | #define NM_read_memory 0x6D 108 | 109 | 110 | typedef struct { 111 | byte length_hi; 112 | byte length_lo; 113 | byte num_netvars; 114 | byte version; // version 0 format 115 | byte mtag_count; 116 | } snvt_struct_v0; 117 | 118 | typedef struct { 119 | byte length_hi; 120 | byte length_lo; 121 | byte num_netvars_lo; 122 | byte version; // version 1 format 123 | byte num_netvars_hi; 124 | byte mtag_count; 125 | } snvt_struct_v1; 126 | 127 | // Partial list of SNVT type index values 128 | 129 | typedef enum { 130 | SNVT_str_asc = 36, 131 | SNVT_lev_cont = 21, 132 | SNVT_lev_disc = 22, 133 | SNVT_count_f = 51, 134 | } SNVT_t; 135 | 136 | typedef struct { 137 | bits nv_config_class :1; 138 | bits nv_auth_config :1; 139 | bits nv_priority_config :1; 140 | bits nv_service_type_config :1; 141 | bits nv_offline :1; 142 | bits nv_polled :1; 143 | bits nv_sync :1; 144 | bits ext_rec :1; 145 | bits snvt_type_index :8; // use enum SNVT_t 146 | } snvt_desc_struct; 147 | 148 | typedef struct { 149 | #ifdef _MSC_VER 150 | byte mask; // Microsoft C does not allow odd-length 151 | #else // bit fields 152 | bits unused :3; 153 | bits nc :1; // array count 154 | bits sd :1; // self-documentation 155 | bits nm :1; // network variable name 156 | bits re :1; // rate estimate 157 | bits mre :1; // max rate estimate 158 | #endif 159 | } snvt_ext_rec_mask; 160 | 161 | // Network management message codes 162 | 163 | #define NM_query_SNVT 0x72 164 | #define NM_query_SNVT_fail 0x12 165 | #define NM_query_SNVT_succ 0x32 166 | #define NM_service_pin_message_code 0x7f 167 | 168 | typedef struct // karladded 07/28/00 169 | { 170 | byte neuron_id[NEURON_ID_LEN]; 171 | byte program_id[ID_STR_LEN]; 172 | 173 | } NM_service_pin_msg; 174 | 175 | typedef struct { 176 | byte code; 177 | byte offset_hi; // big-endian 16-bits 178 | byte offset_lo; 179 | byte count; 180 | } NM_query_SNVT_request; 181 | 182 | #define NM_wink 0x70 183 | 184 | #define NM_NV_fetch 0x73 185 | #define NM_NV_fetch_fail 0x13 186 | #define NM_NV_fetch_succ 0x33 187 | 188 | // Explicit application message codes 189 | 190 | #define NA_appl_msg 0x00 191 | #define NA_appl_offline 0x3F 192 | #define NA_foreign_msg 0x40 193 | #define NA_foreign_offline 0x4F 194 | 195 | // Structure used by host application to store network variables 196 | 197 | typedef enum { NV_IN = 0, NV_OUT = 1 } nv_direction; 198 | 199 | typedef struct { // structure to define NVs 200 | int size; // number of bytes 201 | nv_direction direction; // input or output 202 | const char * name; // name of variable 203 | void ( * print_func )( byte * ); // routine to print value 204 | void ( * read_func )( byte * ); // routine to read value 205 | byte data[ MAX_NETVAR_DATA ]; // actual storage for value 206 | } network_variable; 207 | 208 | 209 | typedef struct 210 | { 211 | byte code; 212 | byte index; 213 | } short_index_struct; 214 | 215 | typedef struct 216 | { 217 | short_index_struct short_index; 218 | nv_struct nv_cnfg_data; 219 | } short_config_data_struct; 220 | 221 | 222 | typedef struct 223 | { 224 | byte code; 225 | byte index_escape; /* Must be 255 */ 226 | word index; 227 | } long_index_struct; 228 | 229 | 230 | typedef struct 231 | { 232 | long_index_struct index; 233 | nv_struct nv_cnfg_data; 234 | } long_config_data_struct; 235 | 236 | 237 | /* Update Network Variable Configuration Request 238 | */ 239 | typedef union NM_update_nv_cnfg_request 240 | { 241 | short_config_data_struct short_config_index; 242 | long_config_data_struct long_config_index; 243 | } NM_update_nv_cnfg_request; 244 | 245 | /* Query Network Variable Configuration Request 246 | */ 247 | typedef union NM_query_nv_cnfg_request 248 | { 249 | short_index_struct short_index; 250 | long_index_struct long_index; 251 | } NM_query_nv_cnfg_request; 252 | 253 | /* Network Variable Fetch Request 254 | */ 255 | typedef NM_query_nv_cnfg_request NM_nv_fetch_request; 256 | 257 | /* Network Variable Fetch Response 258 | */ 259 | typedef union NM_nv_fetch_response 260 | { 261 | short_index_struct short_index; 262 | long_index_struct long_index; /* followed by data */ 263 | } NM_nv_fetch_response; 264 | 265 | 266 | 267 | #define NM_clear_status 0x53 268 | 269 | #define NM_query_status 0x51 270 | 271 | typedef struct status_struct 272 | { 273 | word xmit_errors; 274 | word transaction_timeouts; 275 | word rcv_transaction_full; 276 | word lost_msgs; 277 | word missed_msgs; 278 | byte reset_cause; 279 | byte node_state; 280 | byte version_number; 281 | byte error_log; 282 | byte model_number; 283 | } status_struct; 284 | 285 | 286 | #define NM_checksum_recalculate 0x6f 287 | typedef enum 288 | { 289 | BOTH_CS = 1, 290 | CNFG_CS = 4, 291 | } NM_checksum_recalc_request_type; 292 | 293 | #define NM_update_addr_request_code 0x66 294 | 295 | typedef struct NM_update_addr_request 296 | { 297 | byte code; 298 | byte addr_index; 299 | byte type; 300 | bits member_or_node:7; 301 | bits domain: 1; 302 | bits retry :4; 303 | bits rpt_timer :4; 304 | bits tx_timer :4; 305 | bits rcv_timer :4; 306 | byte group_or_subnet; 307 | 308 | } NM_update_addr_request_struct; 309 | 310 | 311 | #define NM_update_domain_request_code 0x63 312 | #define DOMAIN_ID_LEN 6 313 | #define AUTH_KEY_LEN 6 314 | 315 | typedef struct NM_update_domain_request 316 | { 317 | byte code; 318 | byte domain_index; 319 | byte id[DOMAIN_ID_LEN]; 320 | byte subnet; 321 | bits node : 7; 322 | bits must_be_one :1; // reversed for endian ness 323 | byte len; 324 | byte key[AUTH_KEY_LEN]; 325 | 326 | } NM_update_domain_request_struct; 327 | 328 | #endif 329 | 330 | -------------------------------------------------------------------------------- /kernel_modules_drivers/gesytec-2.06/lpctest.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #define IOCTL_VERSION 0x43504C00 11 | 12 | // Explicite message codes for network management 13 | 14 | #define NM_query_status 0x51 15 | #define NM_query_status_succ 0x31 16 | #define NM_query_status_fail 0x11 17 | 18 | #define NM_update_address 0x66 19 | #define NM_update_address_succ 0x26 20 | #define NM_update_address_fail 0x06 21 | 22 | #define NM_query_address 0x67 23 | #define NM_query_address_succ 0x27 24 | #define NM_query_address_fail 0x07 25 | 26 | #define NM_update_nv_config 0x6B 27 | #define NM_update_nv_config_succ 0x2B 28 | #define NM_update_nv_config_fail 0x0B 29 | 30 | #define NM_query_nv_config 0x68 31 | #define NM_query_nv_config_succ 0x28 32 | #define NM_query_nv_config_fail 0x08 33 | 34 | #define NM_update_domain 0x63 35 | #define NM_update_domain_succ 0x23 36 | #define NM_update_domain_fail 0x03 37 | 38 | #define NM_leave_domain 0x64 39 | #define NM_leave_domain_succ 0x24 40 | #define NM_leave_domain_fail 0x04 41 | 42 | #define NM_query_domain 0x6A 43 | #define NM_query_domain_succ 0x2A 44 | #define NM_query_domain_fail 0x0A 45 | 46 | #define NM_read_memory 0x6D 47 | #define NM_read_memory_succ 0x2D 48 | #define NM_read_memory_fail 0x0D 49 | 50 | #define NM_write_memory 0x6E 51 | #define NM_write_memory_succ 0x2E 52 | #define NM_write_memory_fail 0x0E 53 | 54 | #define NM_set_node_mode 0x6C 55 | #define NM_set_node_mode_succ 0x2C 56 | #define NM_set_node_mode_fail 0x0C 57 | 58 | #define NM_query_snvt 0x72 59 | #define NM_query_snvt_succ 0x32 60 | #define NM_query_snvt_fail 0x12 61 | 62 | #define NM_nv_fetch 0x73 63 | #define NM_nv_fetch_succ 0x33 64 | #define NM_nv_fetch_fail 0x13 65 | 66 | #define NM_wink 0x70 67 | #define NM_wink_succ 0x30 68 | #define NM_wink_fail 0x10 69 | 70 | #define NM_file_xfer 0x3E 71 | 72 | // Service types */ 73 | 74 | #define SVC_ackd 0x00 75 | #define SVC_unackd_rpt 0x20 76 | #define SVC_unackd 0x40 77 | #define SVC_request 0x60 78 | #define SVC_MASK 0x60 79 | 80 | // Default transaction timer values 81 | 82 | #define DEFAULT_RPTRETRY 0x43 83 | #define DEFAULT_TXTIMER 0x05 84 | 85 | // Network interface commands 86 | 87 | #define niTQ 0x12 88 | #define niTQ_P 0x13 89 | #define niNTQ 0x14 90 | #define niNTQ_P 0x15 91 | #define niRESPONSE 0x16 92 | #define niINCOMING 0x18 93 | #define niLOCAL 0x22 94 | #define niRESET 0x50 95 | #define niFLUSH_CANCEL 0x60 96 | #define niONLINE 0x70 97 | #define niOFFLINE 0x80 98 | #define niFLUSH_IGN 0xA0 99 | 100 | // Mixed 101 | 102 | #define LENMASK 0x1F 103 | #define CFG 0x80 104 | #define DIR 0x40 105 | #define XDIR 0x4000 106 | #define AUTH 0x10 107 | #define PRIO 0x80 108 | #define EXPLICIT 8 109 | 110 | typedef unsigned char u8; 111 | 112 | typedef struct { 113 | u8 cmq; // cmd[7..4] queue[3..0] 114 | u8 len; 115 | u8 svc_tag; // 0[7] Service[6..5] auth[4] tag[3..0] 116 | u8 flags; // prio path cplcode[5..4] expl altp pool resp 117 | u8 data_len; 118 | u8 format; // rcv: domain[7] flex[6] 119 | union { 120 | struct { 121 | u8 dom_node; // domain[7] node/memb[6..0] 122 | u8 rpt_retry; // rpt_timer[7..4] retry[3..0] 123 | u8 tx_timer; // tx_timer[3..0] 124 | u8 dnet_grp; // destination subnet or group 125 | u8 nid[6]; // NEURON ID 126 | } send; 127 | struct { 128 | u8 snet; // source subnet 129 | u8 snode; // source node 130 | u8 dnet_grp; // destination subnet or group 131 | u8 dnode_nid[7]; // destination node or NEURON ID 132 | } rcv; 133 | struct { 134 | u8 snet; // source subnet 135 | u8 snode; // source node 136 | u8 dnet; // destination subnet 137 | u8 dnode; // destination node 138 | u8 group; 139 | u8 member; 140 | u8 reserved[4]; 141 | } resp; 142 | } adr; 143 | u8 code; // message code or selector MSB 144 | u8 data[239]; 145 | } ExpAppBuf; // Total size must be 256, else alignment mismatch 146 | 147 | 148 | ExpAppBuf msg_out; /* Explicit message buffer for outgoing messages */ 149 | ExpAppBuf msg_in; /* Explicit message buffer for incoming messages */ 150 | ExpAppBuf msg_rsp; /* Explicit message buffer for response messages */ 151 | int ni_handle; 152 | 153 | u8 ha_online, min_rspcode; 154 | 155 | void dumpmsg( u8 *buf, u8 len ) 156 | { 157 | while( len-- ) printf( " %02X", *buf++ ); 158 | printf( "\n" ); 159 | } 160 | 161 | /************************************************************************* 162 | * Function : do_response( code, len ); 163 | * Parameters : code = response code. 164 | * len = number of data bytes in the reponse message. 165 | * Description: 166 | * Sends a response message for an incoming request. To create a response 167 | * message only msg_in.data[] has to be modified because the message 168 | * header is modified by the function itself. 169 | * 170 | *************************************************************************/ 171 | 172 | void do_response( u8 code, int len ) 173 | { 174 | if( (msg_in.svc_tag & SVC_MASK) == SVC_request ) 175 | { 176 | msg_in.cmq = (msg_in.flags & PRIO) ? niNTQ_P : niNTQ; 177 | msg_in.code = code; 178 | msg_in.len = len + 16; 179 | msg_in.data_len = len + 1; 180 | msg_in.svc_tag &= 0x6F; 181 | msg_in.flags = (msg_in.flags & PRIO) + 0x01; 182 | write( ni_handle, &msg_in, len + 18 ); 183 | } 184 | } 185 | 186 | 187 | /************************************************************************* 188 | * Function : handle_incoming(); 189 | * Description: 190 | * Handles any incoming message (NV, network management or application 191 | * message). 192 | * 193 | *************************************************************************/ 194 | 195 | static void handle_incoming() 196 | { 197 | if(msg_in.code & 0x80) 198 | { 199 | return; 200 | } 201 | switch( msg_in.code ) 202 | { 203 | } 204 | } 205 | 206 | 207 | /************************************************************************* 208 | * Function : send_msg( len ); 209 | * Parameters : Length of data field (message code not included). 210 | * Ret.Value : Completion code. 211 | * Description: 212 | * Sends any message over the network. If the NEURON has made a reset, the 213 | * host application is set online and the transaction breaks. 214 | * Message header and address field must be initialized while msg_out.cmq 215 | * and all length are initialized by this function. 216 | * 217 | *************************************************************************/ 218 | 219 | int send_msg( int len ) 220 | { 221 | int ldv_err, timeout; 222 | u8 cpl; 223 | 224 | msg_out.cmq = (msg_out.flags & PRIO) ? niTQ_P : niTQ; 225 | if( (msg_out.svc_tag & SVC_MASK) == SVC_unackd) msg_out.cmq += 2; 226 | msg_out.len = len + 15; 227 | msg_out.data_len = len + 1; 228 | if( write( ni_handle, &msg_out, len + 17 ) < 0 ) return 0; 229 | min_rspcode = 128; 230 | timeout = 1000; 231 | while( timeout ) 232 | { 233 | ldv_err = read( ni_handle, &msg_in, 256 ); 234 | if( ldv_err >= 0 ) 235 | { 236 | if(msg_in.cmq == niRESET) { // local reset 237 | ha_online = 1; 238 | return 0; 239 | } 240 | if(msg_in.cmq == niINCOMING) handle_incoming(); 241 | if(msg_in.cmq == niRESPONSE) 242 | { 243 | cpl = msg_in.flags & 0x30; 244 | if( cpl ) return (cpl >> 4); // Completion event 245 | else 246 | { 247 | if( (msg_in.svc_tag & SVC_MASK) == SVC_request) 248 | { 249 | memcpy(&msg_rsp, &msg_in, msg_in.len + 2); 250 | if(min_rspcode > msg_rsp.code) 251 | min_rspcode = msg_rsp.code; /* for FTP */ 252 | } 253 | } 254 | } 255 | } 256 | else { 257 | // Wait a little bit... 258 | // timeout--; 259 | } 260 | } 261 | return 0; 262 | } 263 | 264 | 265 | /************************************************************************* 266 | * Function : send_local( len ); 267 | * Parameters : Length of data field (message code not included). 268 | * Ret.Value : Completion code. 269 | * Description: 270 | * Same functionality as send_msg() but it is used to address the local 271 | * NEURON chip. Message header and address field must not be set and 272 | * Request/Response service is always used. 273 | * 274 | *************************************************************************/ 275 | 276 | int send_local( int len ) { 277 | int ldv_err, timeout; 278 | 279 | msg_out.cmq = niLOCAL; 280 | msg_out.svc_tag = SVC_request; 281 | msg_out.flags = 8; 282 | msg_out.len = len + 15; 283 | msg_out.data_len = len + 1; 284 | 285 | // dumpmsg( (u8*)&msg_out ); 286 | 287 | if( write( ni_handle, &msg_out, len + 17 ) < 0 ) return 0; 288 | timeout = 40; 289 | while( timeout ) 290 | { 291 | ldv_err = read( ni_handle, &msg_in, 256 ); 292 | if( ldv_err >= 0 ) 293 | { 294 | 295 | // dumpmsg( (u8*)&msg_in ); 296 | 297 | if(msg_in.cmq == niRESET) { // Local reset 298 | ha_online = 1; 299 | return 0; 300 | } 301 | if(msg_in.cmq == niINCOMING) handle_incoming(); 302 | if(msg_in.cmq == niRESPONSE) 303 | { 304 | memcpy(&msg_rsp, &msg_in, msg_in.len + 2); 305 | return 1; // Ok 306 | } 307 | } 308 | else { 309 | //poll( NULL, 0, 50 ); 310 | timeout--; 311 | } 312 | } 313 | return 0; 314 | } 315 | 316 | 317 | void init_local_node( u8 node ) 318 | { 319 | msg_out.code = NM_update_domain; 320 | msg_out.data[0] = 0; // Domain index 0 321 | memset( &msg_out.data[1], 0, 6 ); // Domain ID 322 | msg_out.data[7] = 1; // Subnet 323 | msg_out.data[8] = node | 0x80; // Node 324 | msg_out.data[9] = 0; // Domain length 325 | memset( &msg_out.data[10], 0xFF, 6 ); // Authentication key 326 | send_local(16); 327 | 328 | msg_out.code = NM_set_node_mode; 329 | msg_out.data[0] = 3; // Set state 330 | msg_out.data[1] = 4; // Configured online 331 | send_local(2); 332 | } 333 | 334 | void receive_packets() 335 | { 336 | int i = 0; 337 | struct pollfd fds; 338 | 339 | fds.fd = ni_handle; 340 | fds.events = POLLIN; 341 | while( 1 ) 342 | { 343 | msg_in.code = 0; 344 | fds.revents = 0; 345 | if( !poll( &fds, 1, 1000 ) ) { 346 | printf( "%d\n", i); 347 | continue; 348 | } 349 | read( ni_handle, &msg_in, 256 ); 350 | i++; 351 | if( !(i % 10) ) printf("%d\n", i); 352 | } 353 | } 354 | 355 | int main(int argc, char **argv) 356 | { 357 | char version[80]; 358 | int i; 359 | struct timezone tz; 360 | struct timeval t0, t1; 361 | int msec; 362 | char devname[] = "/dev/lonx"; 363 | u8 node; 364 | 365 | if(argc < 2) { 366 | printf("Syntax: ./lpctest n (n=1..9) to send unackd packets\n"); 367 | printf(" or: ./lpctest n anything (n=1..9) to count received packets\n"); 368 | return 1; 369 | } 370 | node = argv[1][0] - '0'; 371 | if( (node<1) || (node>9) ) { 372 | printf( "Argument must be between 1 and 9\n" ); 373 | return 1; 374 | } 375 | devname[8] = node + '0'; 376 | printf("Open device %s\n", devname); 377 | ni_handle = open( devname, O_RDWR ); 378 | if( ni_handle < 0 ) { 379 | printf( "Cannot open the device\n" ); 380 | return 1; 381 | } 382 | ioctl( ni_handle, IOCTL_VERSION, (unsigned long)&version ); 383 | printf("%s\n", version); 384 | #if 01 385 | ha_online = 1; 386 | 387 | init_local_node( node ); 388 | 389 | if(argc > 2) receive_packets(); 390 | 391 | //msg_out.code = NM_query_status; 392 | 393 | msg_out.svc_tag = SVC_unackd; 394 | msg_out.flags = EXPLICIT; 395 | msg_out.format = 1; // Broadcast 396 | msg_out.adr.send.dom_node = 1; // Backlog 397 | msg_out.adr.send.rpt_retry = DEFAULT_RPTRETRY; 398 | msg_out.adr.send.tx_timer = DEFAULT_TXTIMER; 399 | msg_out.adr.send.dnet_grp = 1; 400 | 401 | msg_out.code = 1; 402 | 403 | tz.tz_minuteswest = 0; 404 | tz.tz_dsttime = 0; 405 | gettimeofday( &t0, &tz ); 406 | 407 | for( i=1; i<=100; i++ ) 408 | { 409 | //if( !send_local( 0 ) ) 410 | if( !send_msg( 0 ) ) 411 | { 412 | printf( "send_local() failed\n" ); 413 | } 414 | if( !(i % 10) ) printf( "%d\n", i ); 415 | } 416 | 417 | gettimeofday( &t1, &tz ); 418 | 419 | msec = (t1.tv_sec - t0.tv_sec) * 1000; 420 | msec += (t1.tv_usec / 1000); 421 | msec -= (t0.tv_usec / 1000); 422 | 423 | printf( "Zeit: %d ms. %d Transactions/s\n", msec, 100000 / msec ); 424 | //dumpmsg( &msg_rsp.code, msg_rsp.data_len ); 425 | #endif 426 | printf( "\nClosing device\n" ); 427 | close( ni_handle ); 428 | 429 | return 0; 430 | } 431 | 432 | --------------------------------------------------------------------------------