📄 ul_drv.c
字号:
/******************************************************************* uLan Communication - uL_DRV - multiplatform uLan driver ul_drv.c - uLan driver main source file (C) Copyright 1996-2004 by Pavel Pisa - project originator http://cmp.felk.cvut.cz/~pisa (C) Copyright 1996-2004 PiKRON Ltd. http://www.pikron.com (C) Copyright 2002-2004 Petr Smolik The uLan driver project can be used and distributed in compliance with any of next licenses - GPL - GNU Public License See file COPYING for details. - LGPL - Lesser GNU Public License - MPL - Mozilla Public License - and other licenses added by project originator Code can be modified and re-distributed under any combination of the above listed licenses. If contributor does not agree with some of the licenses, he/she can delete appropriate line. WARNING: if you delete all lines, you are not allowed to distribute code or sources in any form. *******************************************************************/#ifdef CONFIG_OC_UL_DRV_SYSLESS #include "ul_drv_config.h"#endif /* CONFIG_OC_UL_DRV_SYSLESS */#define UL_WITH_UART_450#define UL_WITH_UART_510#ifdef CONFIG_OC_UL_DRV_USLIB #define UL_DRV_IN_LIB #include <stdio.h> #include <unistd.h> #include <time.h> #include <errno.h> #include <asm/io.h> #include <asm/bitops.h> #include <asm/atomic.h> #include <sys/perm.h> /*#include <sys/io.h>*/ #include <string.h> #include "emu_irq.h"#elif defined(_WIN32) #ifdef FOR_WIN_KMD #ifndef FOR_WIN_KMD #define FOR_WIN_KMD #endif #define UL_WITH_PCI #include "ntddk.h" #else #ifndef FOR_WIN_WDM #define FOR_WIN_WDM #endif #pragma warning(disable:4242) #define DBG 1 #define DBG_USB 0 #define ULD_DEBUG_DEFAULT (0x01|0x08|0x10|0x40|0x80) #define UL_WITH_PCI #define UL_WITH_USB #include "wdm.h" //#include "ntddk.h" /*KeReadStateEvent is missing in WDM*/ //NTKERNELAPI LONG KeReadStateEvent (IN PRKEVENT Event); #include "ul_wdinc.h" #ifdef UL_WITH_USB #include "usbdi.h" #include "usbdlib.h" #include "ul_wdusb.h" #endif #define UL_WITH_WIN_PWR #endif#elif defined(__DJGPP__) int uld_djgpp_data_beg; void uld_djgpp_code_beg(void) {;}; #include <unistd.h> #include <errno.h> #include <stdio.h> #include <time.h> #include <string.h>#elif defined(CONFIG_OC_UL_DRV_SYSLESS) #include <unistd.h> #include <errno.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/time.h> #include <time.h> #include <cpu_def.h> #undef UL_WITH_UART_510 #define UL_WITH_IAC#else #include <linux/version.h> #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,17)) #include <linux/config.h> #endif #include <linux/module.h> #include <linux/errno.h> #include <linux/kernel.h> #include <linux/sched.h> #include <linux/ioport.h> #include <linux/sys.h> #include <linux/fs.h> #include <linux/interrupt.h> #include <linux/poll.h> #include <linux/delay.h> #include <asm/bitops.h> #include <asm/segment.h> #include <asm/system.h> #include <asm/io.h> #include <asm/irq.h> #ifdef __KERNEL__ #ifndef KERNEL #define KERNEL #endif #endif #include "k_compat.h" #if (LINUX_VERSION_CODE < VERSION(2,5,50)) #include <linux/modversions.h> #endif /* 2.5.50 */ #if (LINUX_VERSION_CODE < VERSION(2,4,10)) #include <linux/malloc.h> #else #include <linux/slab.h> #endif /* 2.4.10 */ #if (LINUX_VERSION_CODE < VERSION(2,3,20)) #include <asm/spinlock.h> #else #include <linux/spinlock.h> #endif #if (LINUX_VERSION_CODE >= VERSION(2,4,0)) #if (LINUX_VERSION_CODE <= VERSION(2,6,17)) #define UL_WITH_DEVFS #endif /*2.6.17*/ #define UL_WITH_PCI #define UL_WITH_USB #include <linux/miscdevice.h> #include <linux/init.h> #endif #if (LINUX_VERSION_CODE < VERSION(2,5,40)) #include <linux/tqueue.h> #else /* 2.5.40 */ #ifdef UL_WITH_DEVFS #include <linux/devfs_fs_kernel.h> #endif /*UL_WITH_DEVFS*/ #endif /* 2.5.40 */ #ifdef UL_WITH_PCI #include <linux/pci.h> #endif #ifdef UL_WITH_USB #include <linux/usb.h> #include <linux/smp_lock.h> #endif#endif#if defined(UL_WITH_UART_450) || defined(UL_WITH_UART_510) #define UL_WITH_UARTS#endif#if defined(UL_WITH_UARTS) || defined(UL_WITH_PCI) #define UL_WITH_FRAME_FSM #define ENABLE_UL_IRQ_STALE_WDG#endif /*defined(UL_WITH_UARTS) || defined(UL_WITH_PCI)*/#define ULD_DEFAULT_BUFFER_SIZE 0x8000#include "ul_drv.h"#include "ul_hdep.h"#ifdef CONFIG_OC_UL_DRV_SYSLESS /* for check prototypes */ #include "ul_drv_init.h" #endif /* CONFIG_OC_UL_DRV_SYSLESS */#ifndef UL_DRV_IN_LIBunsigned uld_debug_flg=ULD_DEBUG_DEFAULT;#elseunsigned uld_debug_flg; /* Left application set defaults */#endifint ulbuffer=ULD_DEFAULT_BUFFER_SIZE; /* default communication buffer size */#ifdef UL_IRQ_LOCK_GINI UL_IRQ_LOCK_GINI /* Inicialize global uLan spinlock */#endif#ifdef UL_GLOBAL_IRQ_LOCK_GINI UL_GLOBAL_IRQ_LOCK_GINI /* Initialize global IRQ lock, very bad if needed */#endif#ifdef ENABLE_UL_MEM_CHECKatomic_t ul_mem_check_counter=ATOMIC_INIT(0);#endif /* ENABLE_UL_MEM_CHECK */int uld_null_fnc(ul_drv *udrv, int ret_code){ return 0;}#ifndef UL_WITH_FRAME_FSM /* empty watchdog timer function */ #ifdef _WIN32 VOID ulan_wd_dpc(IN PKDPC Dpc,IN PVOID data, IN PVOID arg1,IN PVOID arg2) {;} #else /* _WIN32 */ void ulan_do_wd_timer(unsigned long data) {;} #endif /* _WIN32 */#endif /*UL_WITH_FRAME_FSM*//* Data iterator */#include "ul_di.c"/* uLan memory management and bidirection linked lists */#include "ul_mem.c"#ifdef UL_WITH_UART_450 /* Chip driver for 16450 */ #include "ul_c450.c"#endif /*UL_WITH_UART_450*/#ifdef UL_WITH_UART_510 /* Chip driver for 82510 */ #include "ul_c510.c"#endif /*UL_WITH_UART_510*/#ifdef UL_WITH_PCI #include "ul_c950pci.c"#endif#ifdef UL_WITH_USB /* Petr Smolik 1 */ #include "ul_cps1.c"#endif /*UL_WITH_USB*/#ifdef UL_WITH_FRAME_FSM /* Frame begin/end */ #include "ul_frame.c"#endif /*UL_WITH_FRAME_FSM*/#ifdef UL_WITH_IAC #include "ul_iac.c"#endif /*UL_WITH_IAC*/#ifdef UL_WITH_FRAME_FSM /* uLan main driver automata loop */ #include "ul_ufsm.c"#endif /*UL_WITH_FRAME_FSM*//* Supported devices table */ #include "ul_devtab.c"/* initialize and free of one driver */ #include "ul_tors.c"#undef UL_INT_TST#ifdef UL_INT_TST /* Some internal test routines */ #include "ul_tst.c"#endif /* UL_INT_TST */#include "ul_debug.c"#include "ul_base.c"/*******************************************************************//* Linux kernel and module specific part */ #ifdef FOR_LINUX_KERNEL #include "ul_linux.c" #ifdef UL_WITH_PCI /* Linux kernel PCI device support */ #include "ul_linpci.c" #endif /*UL_WITH_PCI*/ #ifdef UL_WITH_USB /* Linux kernel PCI device support */ #include "ul_linusb.c" #endif /*UL_WITH_USB*/ #endif /* FOR_LINUX_KERNEL */#ifdef UL_DRV_IN_LIB /* Interface for driver in library */ #include "ul_inlib.c"#endif /* UL_DRV_IN_LIB */#ifdef __DJGPP__ /* Interface for driver in library for DJGPP environment */ #include "ul_djgpp.c"#endif /* __DJGPP__ */#ifdef CONFIG_OC_UL_DRV_SYSLESS /* Interface for driver in library for SYSLESS environment */ #include "ul_sysless.c"#endif /* CONFIG_OC_UL_DRV_SYSLESS *//*******************************************************************//* NT Kernel Mode Driver specific code */ #ifdef _WIN32#include "ul_wdbase.h"#include "ul_wdbase.c"#ifndef FOR_WIN_WDM #include "ul_kdmnt.c"#endif /* !FOR_WIN_WDM */#ifdef FOR_WIN_WDM#ifdef UL_WITH_USB #include "ul_wdusb.c"#endif /*UL_WITH_USB*/#include "ul_wdent.c"#include "ul_wdpnp.c"#ifdef UL_WITH_WIN_PWR #include "ul_wdpwr.c"#endif /* UL_WITH_WIN_PWR */#endif /* FOR_WIN_WDM */#endif /* _WIN32 */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -