initial push

This commit is contained in:
Bernd Mueller
2026-06-17 13:44:30 +02:00
commit adfd70813f
372 changed files with 146450 additions and 0 deletions

View File

@@ -0,0 +1,7 @@
cd /dev
mknod -m666 pd_bdm0 c 53 0
mknod -m666 pd_bdm1 c 53 1
mknod -m666 pd_bdm2 c 53 2
mknod -m666 icd_bdm0 c 53 4
mknod -m666 icd_bdm1 c 53 5
mknod -m666 icd_bdm2 c 53 6

121
m683xx/bdm-driver/Makefile Normal file
View File

@@ -0,0 +1,121 @@
#*******************************************************************
# Motorola 683xx BDM Driver for Linux Kernel and GNU Debugger
#
# Makefile-mod - Makefile for regular compilation
# through Linux kernel rules
#
# This file must be renamed or linked to Makefile
#
# (C) Copyright 1999 by Pavel Pisa
#
# The BDM driver is distributed under the Gnu General Public Licence.
# See file COPYING for details.
#*******************************************************************/
# Use "make MODULE_NAME=foobar" if you want to give the driver module
# a different name. This might be usefull if you want to install both,
# Chris's and Pavel's drivers at the same machine.
MODULE_NAME=m683xx-bdm
# currently running kernel
CURRENT=$(shell uname -r)
KERNEL_NEW=$(shell if [ -d /lib/modules/$(CURRENT)/build ] ; \
then echo yes ; else echo no ; fi )
# Where to look for kernel
#KERNEL_LOCATION=/usr/src/linux
#KERNEL_LOCATION=/usr/src/kernel/$(CURRENT)
#KERNEL_LOCATION=/lib/modules/$(CURRENT)/build
#KERNEL_LOCATION=/usr/src/linux-2.2.19
#KERNEL_LOCATION=/usr/src/linux-2.5.60
ifndef KERNEL_LOCATION
ifeq ($(KERNEL_NEW),yes)
KERNEL_LOCATION=/lib/modules/$(CURRENT)/build
MODULE_CHAR_LOC=/lib/modules/$(CURRENT)/kernel/drivers/char
else
KERNEL_LOCATION=/usr/src/linux
MODULE_CHAR_LOC=/lib/modules/$(CURRENT)/misc
endif
endif
# Test for latest 2.5.xx and future 2.6.xx kernels
KERNEL_VERSION := $(shell awk -F\" '/REL/ {print $$2}' \
$(KERNEL_LOCATION)/include/linux/version.h | awk -F\- '{print $$1}')
ifeq ($(KERNEL_VERSION),)
KERNEL_VERSION=$(shell grep UTS_RELEASE ${KERNEL_LOCATION}/include/linux/utsrelease.h | \
sed 's/[^"]*"\(.*\)\{1\}"/\1/')
endif
KERNEL_MODULE_V26 := $(shell echo $(KERNEL_VERSION) \
| sed -n 's/^.*2\.[5-9]\..*$$/yes/p')
# Target object file if any
O_TARGET :=
# Regular object files
O_OBJS = $(MODULE_NAME).o
# Objects with exported symbols (-DEXPORT_SYMTAB)
OX_OBJS =
# Module objects
M_OBJS = $(O_OBJS)
# Module only objects with exported symbols (-DEXPORT_SYMTAB)
MX_OBJS =
# Kernel only objects
L_OBJS =
# Kernel only objects with exported symbols (-DEXPORT_SYMTAB)
LX_OBJS =
# Additional CFLAGS
EXTRA_CFLAGS =
# Linux 2.4.2 build system needs next
obj-m += $(O_OBJS)
ifndef KERNEL_MODULE_V26
FINAL_MODULE_OBJS=$(obj-m)
else
FINAL_MODULE_OBJS=$(obj-m:%.o=%.ko)
endif
all : make_this_module
install : install_this_module
$(MODULE_NAME).c: bdm.c bdm.h
cp $< $@
make_this_module: $(MODULE_NAME).c
DIR=`pwd`; (cd $(KERNEL_LOCATION); make SUBDIRS=$$DIR modules)
install_this_module: make_this_module
su -c "mkdir -v -p $(MODULE_CHAR_LOC) && cp -v $(FINAL_MODULE_OBJS) $(MODULE_CHAR_LOC)"
clean:
rm -f $(M_OBJS) $(MX_OBJS) *.ko .*.o.flags .*.o.cmd .*.ko.cmd .depend *~
# which interface do you want to use
# now you can select both without problems
INTERFACE+= -D PD_INTERFACE
INTERFACE+= -D ICD_INTERFACE
# if you want to use ispGAL programming
INTERFACE+= -DEFIICDISP
# last possible way to make system work when you have problems
# with single step or stop
# it tries to find 17 bit protocol boundary
# after single step or stop
BDM_DEFS += -D BDM_TRY_RESYNCHRO
# if you want a PARPORT compatible device, then
# uncomment the following line
BDM_DEFS += -DWITH_PARPORT_SUPPORT
EXTRA_CFLAGS= $(INTERFACE) $(BDM_DEFS)
ifndef KERNEL_MODULE_V26
include $(KERNEL_LOCATION)/Rules.make
endif

91
m683xx/bdm-driver/README Normal file
View File

@@ -0,0 +1,91 @@
This version of BDM driver is updated to be compatible with
the most of existing kernel versions. Main focus has been oriented
to 2.2.x and 2.4.x, but most of other unstable and stable kernels
back to 1.3.x stone age should be supported.
Driver needs to find kernel sources to compile.
You may need to edit "Makefile-mod" for some strange kernel
sources locations. There is automatic location selection depending
on current kernel version and "/lib/modules" structure.
It select next kernel souces directory for older kernels
KERNEL_LOCATION=/usr/src/linux
it uses more reliable way of build process for
new modules hierarchy
KERNEL_LOCATION=/lib/modules/$(CURRENT)/build
*** BDM driver autoloading ***
No longer su to root, insmod the module of choice, and then start the
debugger as user-joe, but just start the debugger, and the necessary
modules get loaded automatically.
What do you have to do?
* You need to copy the device driver code to
/lib/modules/<kernel-version>/misc
for 2.4.0 kernels use
/lib/modules/<kernel-version>/kernel/drivers/char
* edit /etc/conf.modules
(see my local /etc/conf.modules as an example)
* do a "depmod -a".
* Start "kerneld" at an early boot stage
or enable "kmod" in kernel configuration in section
"Loadable module support".
For more details on dynamic kernel module support, see the READMEs
in the latest modules utilities. The current release is modutils-2.4.22.
*** IMPORTANT ***
The bdm driver checks if the required resources (here only the io-port
addresses) are in use, e.g. by the lp device driver or a parallel port
ethernet device. When everything is free, it reserves these resources, and
releases them when closing the device. So no double access should be possible.
If BDM driver is compiled without PARPORT support, there could be problem
with "parport", "parport_pc" and "lp" module stack resource reservation,
which could compete with "m683xx-bdm" driver. Compile "lp" and "parport"
as modules in such case and unload them before "m683xx-bdm".
Opposite is true in the case of BDM driver with PARPORT support.
You need "parport_pc" compiled into kernel or as module.
Possibilities reworded
A) You need to rmmod parport, if you have compiled BDM driver WITHOUT parport
support. It can be done by next line added to "/etc/modules.conf"
pre-install bdm /sbin/modprobe -r lp parport_pc
B) If BDM driver is compiled WITH parport support, the "parport_pc" module
have to be loaded before "bdm" one. It is loaded by boot process in the
most cases but next line in "/etc/modules.conf" doe not hurt
below bdm parport_pc
** DEVFS support ***
Driver supports new "devfs" virtual device filesystem found in
2.4.0 kernels. There are compiled-in next device names for those
kenels "/dev/m683xx-bdm/pd0" and "/dev/m683xx-bdm/icd0" etc.
You can add next line to "/etc/devfs.conf"
LOOKUP m683xx-bdm MODLOAD
Next line helps to connect simple "/dev/bdm" name for right configuration
LOOKUP m683xx-bdm EXECUTE /bin/ln -s ${mntpnt}/m683xx-bdm/icd0 ${mntpnt}/m683xx-bdm
There are lines for "/dev/modules.conf" with aliases for different kernels
# m68k BDM
alias /dev/bdm m683xx-bdm
alias /dev/m683xx-bdm m683xx-bdm
alias char-major-53 m683xx-bdm
# the next line is required/usable for BDM driver compiled without
# parport support. You might want to remove this line if you get errors
# about unresolved symbols when the driver is loaded.
pre-install m683xx-bdm /sbin/modprobe -r lp parport_pc

1967
m683xx/bdm-driver/bdm.c Normal file

File diff suppressed because it is too large Load Diff

126
m683xx/bdm-driver/bdm.h Normal file
View File

@@ -0,0 +1,126 @@
#ifndef LINUX_BDM_H
#define LINUX_BDM_H
/*
* $Id: bdm.h,v 1.1 2003/06/04 01:31:31 ppisa Exp $
*
* Linux Device Driver for Public Domain BDM Interface
* based on the PD driver package by Scott Howard, Feb 93
* ported to Linux by M.Schraut
* tested for kernel version 1.2.4
* (C) 1995 Technische Universitaet Muenchen, Lehrstuhl fuer Prozessrechner
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#define BDM_MAJOR_NUMBER 53
/* error codes */
#define BDM_FAULT_NOERROR 0 /* no error, no ret value */
#define BDM_FAULT_UNKNOWN 610
#define BDM_FAULT_POWER 611
#define BDM_FAULT_CABLE 612
#define BDM_FAULT_RESPONSE 613 /*NOT Ready */
#define BDM_FAULT_RESET 614
#define BDM_FAULT_PORT 615
#define BDM_FAULT_BERR 616
#define BDM_FAULT_NVC 617 /*no valid command */
/* Debug Levels */
#define BDM_DEBUG_NONE 0
#define BDM_DEBUG_SOME 1
#define BDM_DEBUG_ALL 2
/* supported ioctls */
#define BDM_INIT 0 /* no argument */
#define BDM_DEINIT 1 /* no argument */
#define BDM_RESET_CHIP 2 /* no argument */
#define BDM_RESTART_CHIP 3 /* no argument */
#define BDM_STOP_CHIP 4 /* no argument */
#define BDM_STEP_CHIP 5 /* no argument */
#define BDM_GET_STATUS 6 /* no argument */
#define BDM_SPEED 7 /* arg = speed */
#define BDM_RELEASE_CHIP 8 /* no argument */
#define BDM_DEBUG_LEVEL 9 /* arg = level */
#define BDM_GET_VERSION 10 /* arg = &int */
#define BDM_SENSECABLE 11 /* arg =on/off */
#define BDM_RESPW 12 /* arg = width */
#define BDM_SETLED 13 /* arg = 0-off 1-on */
#define BDM_ISPSET 50 /* arg = which pin + which level */
#define BDM_ISPGET 51 /* no argument */
/* bits for efiicdbdm isp programming */
#define BDM_ispSDI 1
#define BDM_ispSCLK 2
#define BDM_ispMODE 3
#define BDM_ispISP 4
#define BDM_isp_LEVEL 0x80
/* functional bits of ioctl BDM_GET_STATUS */
#define BDM_TARGETRESET (1<<0) /* Target reset */
#define BDM_TARGETSTOPPED (1<<2) /* Target (was already) stopped */
#define BDM_TARGETPOWER (1<<3) /* Power failed */
#define BDM_TARGETNC (1<<4) /* Target not Connected */
/* command codes for bdm interface */
#define BDM_RREG_CMD 0x2180
#define BDM_WREG_CMD 0x2080
#define BDM_RSREG_CMD 0x2580
#define BDM_WSREG_CMD 0x2480
#define BDM_READ_CMD 0x1900
#define BDM_WRITE_CMD 0x1800
#define BDM_DUMP_CMD 0x1d00
#define BDM_FILL_CMD 0x1c00
#define BDM_GO_CMD 0x0c00
#define BDM_CALL_CMD 0x0800
#define BDM_RST_CMD 0x0400
#define BDM_NOP_CMD 0x0000
/* system register for RSREG/WSREG */
#define BDM_REG_RPC 0x0
#define BDM_REG_PCC 0x1
#define BDM_REG_SR 0xb
#define BDM_REG_USP 0xc
#define BDM_REG_SSP 0xd
#define BDM_REG_SFC 0xe
#define BDM_REG_DFC 0xf
#define BDM_REG_ATEMP 0x8
#define BDM_REG_FAR 0x9
#define BDM_REG_VBR 0xa
/* system register for RREG/WREG */
#define BDM_REG_D0 0x0
#define BDM_REG_D1 0x1
#define BDM_REG_D2 0x2
#define BDM_REG_D3 0x3
#define BDM_REG_D4 0x4
#define BDM_REG_D5 0x5
#define BDM_REG_D6 0x6
#define BDM_REG_D7 0x7
#define BDM_REG_A0 0x8
#define BDM_REG_A1 0x9
#define BDM_REG_A2 0xa
#define BDM_REG_A3 0xb
#define BDM_REG_A4 0xc
#define BDM_REG_A5 0xd
#define BDM_REG_A6 0xe
#define BDM_REG_A7 0xf
/* op size for READ/WRITE */
#define BDM_SIZE_BYTE 0x0000
#define BDM_SIZE_WORD 0x0040
#define BDM_SIZE_LONG 0x0080
#endif

View File

@@ -0,0 +1,56 @@
/*
* $Id: bdmlib.h,v 1.1 2003/06/04 01:31:31 ppisa Exp $
*/
#include <sys/types.h>
#include <stdarg.h>
#include <stdio.h>
typedef u_short bdmstatus;
extern unsigned int bdmlib_delay, bdmlib_respw;
extern int bdmlib_open(char *device);
extern int bdmlib_close(int);
extern int bdmlib_isopen(void);
extern int bdmlib_ioctl(u_int code);
extern int bdmlib_setioctl(u_int code, u_int val);
extern bdmstatus bdmlib_getstatus(void);
extern int bdmlib_write_var(caddr_t adr, u_short size, u_int val);
extern int bdmlib_read_var(caddr_t adr, u_short size, void *val);
extern int bdmlib_write_block(caddr_t adr, u_int size, u_char *block);
extern int bdmlib_read_block(caddr_t adr, u_int size, u_char *block);
extern int bdmlib_load(char *file, u_long *entry_pt);
extern int bdmlib_do_load_binary(char *file_name, u_long *entry_pt);
extern int bdmlib_do_load_macro(char *file_name, int is_begin_macro);
extern int bdmlib_get_sys_reg(u_int, u_int *);
extern int bdmlib_set_sys_reg(u_int, u_int);
extern int bdmlib_get_reg(u_int, u_int *);
extern int bdmlib_set_reg(u_int, u_int);
extern int bdmlib_get_mbar(u_int, u_int *);
extern int bdmlib_set_mbar(u_int, u_int);
extern int bdmlib_go(void);
extern char *bdmlib_geterror_str(int);
extern char *bdmlib_getstatus_str(bdmstatus);
extern int bdmlib_reset(void);
extern void bdmlib_setdebug(int switch_on);
extern int bdmlib_querydebug(void);
extern void bdmlib_showpc(void);
extern void bdmlib_log(const char *format, ...);
extern void bdmlib_propeller(FILE * fp);
extern int bdmlib_do_load_binary_section(char *file_name, char *sect_name);
/* some additional error codes beyond those of the driver */
#define BDM_ERR_NOT_OPEN -650
#define BDM_ERR_ILL_IOCTL -651
#define BDM_ERR_WRITE_FAIL -652
#define BDM_ERR_READ_FAIL -653
#define BDM_ERR_ILL_SIZE -654
#define BDM_ERR_OPEN -655
#define BDM_ERR_LOAD -656
#define BDM_ERR_MACROFILE -657
#define BDM_ERR_SECTION -658
#define BDM_ERR_VERSION -659
#define BDM_NO_ERROR 0

View File

@@ -0,0 +1,9 @@
#
alias char-major-9 st
alias char-major-27 ftape
# alias char-major-30 oldbdm
# now obsolete
alias char-major-53 m683xx-bdm
alias sl0 slhc
alias eth0 wd
options wd irq=5 io=0x300

View File

@@ -0,0 +1,436 @@
/*
* k_compat.h 1.8 1995/12/03 01:26:43 (David Hinds)
* 1998/07/12 modified by Pavel Pisa pisa@CMP.felk.cvut.cz
*/
#ifndef _LINUX_K_COMPAT_H
#define _LINUX_K_COMPAT_H
#define VERSION(v,p,s) (((v)<<16)+(p<<8)+s)
#ifndef LINUX_VERSION_CODE
#error LINUX_VERSION_CODE not defined
#endif
#if (LINUX_VERSION_CODE < VERSION(1,3,38))
#ifdef MODULE
#include <linux/module.h>
#if !defined(CONFIG_MODVERSIONS) && !defined(__NO_VERSION__)
char kernel_version[] = UTS_RELEASE;
#endif
#else
#define MOD_DEC_USE_COUNT
#define MOD_INC_USE_COUNT
#endif
#else /* 1.3.38 */
#if (LINUX_VERSION_CODE <= VERSION(2,5,60))
#ifdef CONFIG_MODVERSIONS
#define MODVERSIONS 1
#if (LINUX_VERSION_CODE >= VERSION(1,3,40))
#include <linux/modversions.h>
#endif /* >=1.3.40 */
#endif /* CONFIG_MODVERSIONS */
#endif /* <=2.5.60 */
#include <linux/module.h>
#endif /* 1.3.38 */
#if (LINUX_VERSION_CODE < VERSION(2,5,50))
#define kc_MOD_DEC_USE_COUNT MOD_DEC_USE_COUNT
#define kc_MOD_INC_USE_COUNT MOD_INC_USE_COUNT
#else /* 2.5.50 */
#define kc_MOD_DEC_USE_COUNT
#define kc_MOD_INC_USE_COUNT
#endif /* 2.5.50 */
#if ((LINUX_VERSION_CODE < VERSION(2,2,0)) || (LINUX_VERSION_CODE >= VERSION(2,6,0)))
#ifndef EXPORT_NO_SYMBOLS
#define EXPORT_NO_SYMBOLS
#endif /*EXPORT_NO_SYMBOLS*/
#endif /* 2.2.0 */
/*** user memory access ***/
/* I do not know exactly all dates of changes */
#if (LINUX_VERSION_CODE < VERSION(2,1,5))
#define kc_copy_from_user(dst,src,len) ({ \
if(!(verify_area(VERIFY_READ, src, len))) \
{memcpy_fromfs(dst,src,len);0;} else len; })
#define kc_copy_to_user(dst,src,len) ({ \
if(!(verify_area(VERIFY_WRITE, dst, len))) \
{memcpy_tofs(dst,src,len);0;} else len; })
#define kc_get_user_long(x,ptr) \
(if(!verify_area(VERIFY_READ, (ptr), sizeof(long))) {(x)=get_fs_long((ptr));0;} else 1; })
#define kc_get_user_word(x,ptr) \
(if(!verify_area(VERIFY_READ, (ptr), sizeof(short))) {(x)=get_fs_word((ptr));0;} else 1; })
#define kc_get_user_byte(x,ptr) \
(if(!verify_area(VERIFY_READ, (ptr), sizeof(char))) {(x)=get_fs_byte((ptr));0;} else 1; })
#define kc_put_user_long(x,ptr) \
(if(!verify_area(VERIFY_WRITE, (ptr), sizeof(long))) {put_fs_long((x),(ptr));0;} else 1; })
#define kc_put_user_word(x,ptr) \
(if(!verify_area(VERIFY_WRITE, (ptr), sizeof(short))){put_fs_word((x),(ptr));0;} else 1; })
#define kc_put_user_byte(x,ptr) \
(if(!verify_area(VERIFY_WRITE, (ptr), sizeof(char))) {put_fs_byte((x),(ptr));0;} else 1; })
#elif (LINUX_VERSION_CODE < VERSION(2,1,100)) /* may need correction */
#include <asm/uaccess.h>
#define kc_copy_from_user copy_from_user
#define kc_copy_to_user copy_to_user
#define kc_get_user(x,ptr) \
(__get_user_check((x),(ptr),sizeof(*(ptr))))
#define kc_put_user(x,ptr) \
(__put_user_check((x),(ptr),sizeof(*(ptr))))
#else /* >= 2.1.100 */
#include <asm/uaccess.h>
#define kc_copy_from_user copy_from_user
#define kc_copy_to_user copy_to_user
#define kc_get_user(x,ptr) \
(get_user((x),(ptr)))
#define kc_put_user(x,ptr) \
(put_user((x),(ptr)))
#endif /* < 2.1.100 */
#if (LINUX_VERSION_CODE >= VERSION(2,1,5))
#define kc_get_user_long(x,ptr) (kc_get_user((x),(long*)(ptr)))
#define kc_get_user_word(x,ptr) (kc_get_user((x),(unsigned short*)(ptr)))
#define kc_get_user_byte(x,ptr) (kc_get_user((x),(unsigned char*)(ptr)))
#define kc_put_user_long(x,ptr) (kc_put_user((x),(long *)(ptr)))
#define kc_put_user_word(x,ptr) (kc_put_user((x),(unsigned short*)(ptr)))
#define kc_put_user_byte(x,ptr) (kc_put_user((x),(unsigned char*)(ptr)))
#endif /* >= 2.1.5 */
/*** resource manipulation changes ***/
#if (LINUX_VERSION_CODE >= VERSION(2,4,0))
#define kc_request_region request_region
#define kc_release_region release_region
#else /* < 2.6.0 */
#define kc_request_region(start,len,name) \
({ unsigned long kc_t_start=(start), kc_t_len=(len); \
int kc_t_res=!check_region(kc_t_start,kc_t_len); \
if(kc_t_res) request_region(kc_t_start,kc_t_len,name); \
kc_t_res; \
})
#define kc_release_region release_region
#endif /* < 2.6.0 */
/*** bitops changes ***/
#if (LINUX_VERSION_CODE < VERSION(2,1,36)) /* may need correction */
#define test_and_set_bit set_bit
#endif
/*** interrupt related stuff ***/
#if (LINUX_VERSION_CODE < VERSION(2,1,36)) /* may need correction */
#define kc_synchronize_irq(irqnum) do{cli();sti();}while(0)
#elif (LINUX_VERSION_CODE < VERSION(2,5,33)) /* may need correction */
#define kc_synchronize_irq(irqnum) synchronize_irq()
#else /* >=2.5.33 */
#define kc_synchronize_irq synchronize_irq
#endif
#if (LINUX_VERSION_CODE <= VERSION(2,5,67)) && !defined(IRQ_RETVAL)
typedef void irqreturn_t;
#define IRQ_NONE
#define IRQ_HANDLED
#define IRQ_RETVAL(x)
#endif /* <=2.5.67 */
#if (LINUX_VERSION_CODE <= VERSION(2,6,18))
#define KC_IRQ_HANDLER_ARGS(intno, dev_id) \
int intno, void *dev_id, struct pt_regs *regs
#else /* <=2.6.18 */
#define KC_IRQ_HANDLER_ARGS(intno, dev_id) \
int intno, void *dev_id
#endif /* <=2.6.18 */
/*** timming related stuff ***/
#if (LINUX_VERSION_CODE < VERSION(2,1,100)) /* needs correction */
#define schedule_timeout(timeout_jif) ({ \
current->timeout = jiffies + (timeout_jif); \
schedule(); \
current->timeout = 0; \
})
#ifndef set_current_state
#define set_current_state(state_value) do { current->state = state_value; } while (0)
#endif
#endif
#if (LINUX_VERSION_CODE < VERSION(2,1,36)) /* needs correction */
#define mod_timer(timer,expires) ({\
del_timer(timer); \
timer->expires=expires; \
add_timer(timer); \
})
#endif
/*** file_operations changes ***/
#if (LINUX_VERSION_CODE < VERSION(2,1,5))
#define CLOSERET void
#define RWRET int
#define RWCOUNT_T int
#define RWINODE_P struct inode *inode,
#define RWPPOS_P
#define RWINODE inode
#define KC_FOPS_FLUSH(ptr)
#define kc_dev2minor MINOR
#elif (LINUX_VERSION_CODE < VERSION(2,1,36))
#define CLOSERET void
#define RWRET long
#define RWCOUNT_T unsigned long
#define RWINODE_P struct inode *inode,
#define RWPPOS_P
#define RWINODE inode
#define KC_FOPS_FLUSH(ptr)
#define kc_dev2minor MINOR
#elif (LINUX_VERSION_CODE < VERSION(2,1,76)) /* may need correction */
#define CLOSERET int
#define RWRET long
#define RWCOUNT_T unsigned long
#define RWINODE_P struct inode *inode,
#define RWPPOS_P
#define RWINODE inode
#define KC_FOPS_FLUSH(ptr)
#define kc_dev2minor MINOR
#elif (LINUX_VERSION_CODE < VERSION(2,1,117)) /* may need correction */
#define CLOSERET int
#define RWRET ssize_t
#define RWCOUNT_T size_t
#define RWINODE_P
#define RWPPOS_P ,loff_t *ppos
#define RWINODE file->f_dentry->d_inode
#define KC_FOPS_FLUSH(ptr)
#define kc_dev2minor MINOR
#elif ((LINUX_VERSION_CODE >= VERSION(2,5,7)) && (LINUX_VERSION_CODE < VERSION(2,6,0)))
#define CLOSERET int
#define RWRET ssize_t
#define RWCOUNT_T size_t
#define RWINODE_P
#define RWPPOS_P ,loff_t *ppos
#define RWINODE file->f_dentry->d_inode
#define KC_FOPS_FLUSH(ptr) flush:(ptr),
#define kc_dev2minor minor
#else /* <2.5.7 >=2.6.0 */ /* may need correction */
#define CLOSERET int
#define RWRET ssize_t
#define RWCOUNT_T size_t
#define RWINODE_P
#define RWPPOS_P ,loff_t *ppos
#define RWINODE file->f_dentry->d_inode
#define KC_FOPS_FLUSH(ptr) flush:(ptr),
#define kc_dev2minor MINOR
#endif /* 2.1.36 */
#if (LINUX_VERSION_CODE < VERSION(2,1,50)) /* may need correction */
#define kc_poll_wait(file,address,wait) poll_wait(address,wait)
#else /* >= 2.1.50 */
#define kc_poll_wait poll_wait
#endif /* 2.1.50 */
/* definition of standard parameters for read/write file functions */
#define READ_PARAMETERS \
RWINODE_P struct file *file, char *buf, RWCOUNT_T count RWPPOS_P
#define WRITE_PARAMETERS \
RWINODE_P struct file *file, const char *buf, RWCOUNT_T count RWPPOS_P
#define LSEEK_PARAMETERS \
RWINODE_P struct file *file, loff_t pos, int whence
#if (LINUX_VERSION_CODE < VERSION(2,2,0)) /* may need correction */
#define KC_CHRDEV_FOPS_BEG(fops_var) \
static struct file_operations fops_var =\
{
#define KC_CHRDEV_FOPS_END \
}
#define KC_FOPS_LSEEK(ptr) lseek:(ptr),
#define KC_FOPS_RELEASE(ptr) close:(ptr),
#elif (LINUX_VERSION_CODE < VERSION(2,4,0)) /* may need correction */
#define KC_CHRDEV_FOPS_BEG(fops_var) \
static struct file_operations fops_var =\
{
#define KC_CHRDEV_FOPS_END \
}
#define KC_FOPS_LSEEK(ptr) llseek:(ptr),
#define KC_FOPS_RELEASE(ptr) release:(ptr),
#else /* >= 2.4.0 */
#define KC_CHRDEV_FOPS_BEG(fops_var) \
static struct file_operations fops_var = {\
owner:THIS_MODULE,
#define KC_CHRDEV_FOPS_END \
}
#define KC_FOPS_LSEEK(ptr) llseek:(ptr),
#define KC_FOPS_RELEASE(ptr) release:(ptr),
#endif /* 2.4.0 */
/*** devices and drivers registration ***/
#if (LINUX_VERSION_CODE >= VERSION(2,5,41)) /* may need correction */
#define devfs_register_chrdev register_chrdev
#define devfs_unregister_chrdev unregister_chrdev
#endif /* 2.5.40 */
#if (LINUX_VERSION_CODE >= VERSION(2,5,60)) /* may need correction */
#define kc_devfs_handle_t char *
#define kc_devfs_delete(handle) ({ devfs_remove(handle); kfree(handle); })
#define kc_devfs_new_cdev(dir_handle, dev_num, dev_mode, dev_ops, dev_info, dev_name) ({ \
char *kc_t_name; \
const char *kc_t_dev=(dev_name); \
const char *kc_t_dir=(dir_handle); \
const int kc_t_d=kc_t_dir?strlen(kc_t_dir)+1:0; \
int kc_t_n=strlen(kc_t_dev)+1+kc_t_d; \
if ((kc_t_name=kmalloc(kc_t_n,GFP_KERNEL))) { \
if(kc_t_d) {memcpy(kc_t_name,kc_t_dir,kc_t_d-1); kc_t_name[kc_t_d-1]='/';} \
strcpy(kc_t_name+kc_t_d,kc_t_dev); \
if(devfs_mk_cdev((dev_num), (dev_mode), kc_t_name)<0) { \
kfree(kc_t_name); \
kc_t_name = NULL ; \
} \
} \
kc_t_name; \
})
#define kc_devfs_mk_dir devfs_mk_dir
#else /* 2.5.60 */
#define kc_devfs_handle_t devfs_handle_t
#define kc_devfs_delete devfs_unregister
#define kc_devfs_new_cdev(dir_handle, dev_num, dev_mode, dev_ops, dev_info, dev_name) ({ \
devfs_register((dir_handle), (dev_name), DEVFS_FL_DEFAULT, \
MAJOR(dev_num), MINOR(dev_num), (dev_mode), (dev_ops), (dev_info)); \
})
#define kc_devfs_mk_dir(dirname...) ({ \
char kc_buf[64]; int kc_n; \
kc_n = snprintf(buf, 64, ##dirname); \
(kc_n >= 64 || !buf[0])? NULL: devfs_mk_dir(NULL, kc_buf, NULL); \
})
#endif /* 2.5.60 */
#if (LINUX_VERSION_CODE <= VERSION(2,6,0))
typedef struct {int dummy;} kc_class;
#define kc_class_create(...) (NULL)
#define kc_class_device_create(...)
#define kc_class_device_destroy(...)
#define kc_class_destroy(...)
#else /* 2.6.0 */
#define KC_WITH
#include <linux/device.h>
#if LINUX_VERSION_CODE >= VERSION(2,6,15)
#define kc_class class
#define kc_class_create class_create
#define kc_class_device_create class_device_create
#define kc_class_device_destroy class_device_destroy
#define kc_class_destroy class_destroy
#elif LINUX_VERSION_CODE >= VERSION(2,6,13)
#define kc_class class
#define kc_class_create class_create
#define kc_class_device_create(cls, parent, devt, device, fmt...) \
class_device_create(cls, devt, device, ##fmt)
#define kc_class_device_destroy class_device_destroy
#define kc_class_destroy class_destroy
#else /* 2.6.0 ... 2.6.12 */
#define kc_class class_simple
#define kc_class_create class_simple_create
#define kc_class_device_create(cls, parent, devt, device, fmt...) \
class_simple_device_add(cls, devt, device, ##fmt)
#define kc_class_device_destroy(a,b) class_simple_device_remove(b)
#define kc_class_destroy class_simple_destroy
#endif
#define kc_pci_dev_to_dev(pdev) (&(pdev)->dev)
#define kc_usb_dev_to_dev(pdev) (&(pdev)->dev)
#endif
/*** tasklet declaration and processing ***/
#if (LINUX_VERSION_CODE < VERSION(2,5,0)) /* may need correction */
#define kc_tasklet_struct tq_struct
#define kc_tasklet_data_type void *
#define KC_DECLARE_TASKLET(_name, _func, _data) \
struct tq_struct _name = { sync: 0, routine: _func, data: (void*)_data }
/* void tasklet_init(struct tasklet_struct *t, void (*func)(unsigned long), unsigned long data); */
#define kc_tasklet_init(_tasklet, _func, _data) \
do{ \
/* (_tasklet)->next=NULL; */ \
/* Above not needed for 2.2.x and buggy for 2.4.x */ \
(_tasklet)->sync=0; \
(_tasklet)->routine=_func; \
(_tasklet)->data=(void*)_data; \
}while(0)
/* void tasklet_schedule(struct tasklet_struct *t) */
#define kc_tasklet_schedule(_tasklet) \
do{ \
queue_task(_tasklet,&tq_immediate); \
mark_bh(IMMEDIATE_BH); \
}while(0)
/* void tasklet_kill(struct tasklet_struct *t); */
#define kc_tasklet_kill(_tasklet) \
synchronize_irq()
#else /* 2.5.40 */
/* struct tasklet_struct */
#define kc_tasklet_struct tasklet_struct
/* DECLARE_TASKLET(name, func, data) */
#define kc_tasklet_data_type unsigned long
#define KC_DECLARE_TASKLET DECLARE_TASKLET
/* void tasklet_init(struct tasklet_struct *t, void (*func)(unsigned long), unsigned long data); */
#define kc_tasklet_init tasklet_init
/* void tasklet_schedule(struct tasklet_struct *t) */
#define kc_tasklet_schedule tasklet_schedule
/* void tasklet_kill(struct tasklet_struct *t); */
#define kc_tasklet_kill tasklet_kill
#endif /* 2.5.40 */
/*** scheduler changes ***/
#if (LINUX_VERSION_CODE < VERSION(2,3,0)) /* may need correction */
#define kc_yield schedule
#else /* 2.3.0 */
#define kc_yield yield
#endif /* 2.3.0 */
/*** PCI changes ***/
#if (LINUX_VERSION_CODE < VERSION(2,6,11)) /* may need correction */
#define kc_pci_name(pdev) (pdev->slot_name)
#else /* 2.6.11 */
#define kc_pci_name pci_name
#endif /* 2.6.11 */
/*** wait queues changes ***/
/* Next is not sctrictly correct, because of 2.3.0, 2.3.1, 2.3.2
probably need next definitions */
#if (LINUX_VERSION_CODE < VERSION(2,2,19)) /* may need correction */
#define wait_queue_head_t struct wait_queue *
#define wait_queue_t struct wait_queue
#define init_waitqueue_head(queue_head) (*queue_head=NULL)
#define init_waitqueue_entry(qentry,qtask) \
(qentry->next=NULL,qentry->task=qtask)
#define DECLARE_WAIT_QUEUE_HEAD(name) \
struct wait_queue * name=NULL
#define DECLARE_WAITQUEUE(wait, current) \
struct wait_queue wait = { current, NULL }
#define init_MUTEX(sem) (*sem=MUTEX)
#define DECLARE_MUTEX(name) struct semaphore name=MUTEX
#endif /* 2.2.19 */
#ifndef MODULE_LICENSE
#define MODULE_LICENSE(dummy)
#endif /* MODULE_LICENSE */
#endif /* _LINUX_K_COMPAT_H */