/* This software is covered by the GNU GENERAL PUBLIC LICENSE (GPL). */
/* Any Device - Driver - Linux */
/* $Workfile: kernel_2_4.h $ */
/* $Revision: 3 $ */
/* $Date: 10/27/07 10:36a $ */
/*
*	Provide special handling for things specific to the 2.4 kernel.
*/
/* $Log: /NEW SOURCESAFE DATABASE/SDK/PLX/gsc/common/driver/linux/kernel_2_4.h $
 * 
 * 3     10/27/07 10:36a Dnewbold
 * Additional driver porting updates.
 *
 * 2     3/29/07 2:47p Dnewbold
 *
 * 1     5/10/06 1:01p Dnewbold
*/



#ifndef __KERNEL_2_4_H__
#define __KERNEL_2_4_H__

#if	(LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)) && \
	(LINUX_VERSION_CODE <  KERNEL_VERSION(2,5,0))

#include <linux/iobuf.h>
#include <linux/slab.h>
#include <linux/wrapper.h>



/* #defines	**************************************************************/

#define	__GFP_NOWARN				0
#define	DMA_SGL_SUPPORT_FIELD		struct kiobuf*	iobuf;
#define	EVENT_RESUME_IRQ(q,c)		wake_up_interruptible(q)
#define	EVENT_WAIT_IRQ_TO(q,c,t)	interruptible_sleep_on_timeout(q,t)
#define	GET_PAGE(page)				get_page((page))
#define	KILL_FASYNC(q,s,b)			kill_fasync(&(q),(s),(b))
#define	KMALLOC_LIMIT				(128L * 1024)
#undef	MOD_DEC_USE_COUNT
#define	MOD_DEC_USE_COUNT
#undef	MOD_INC_USE_COUNT
#define	MOD_INC_USE_COUNT
#define	PAGE_RESERVE(vpa)			mem_map_reserve(virt_to_page((vpa)))
#define	PAGE_UNRESERVE(vpa)			mem_map_unreserve(virt_to_page((vpa)))
#define	PCI_DEVICE_LOOP(p)			pci_for_each_dev(p)
#define	PCI_ENABLE_DEVICE(pci)		pci_enable_device(pci)
#define	PROC_GET_INFO(pro,fun)		(pro)->get_info = (fun)
#define	REGION_IO_CHECK(a,s)		check_region(a,s)
#define	REGION_IO_RELEASE(a,s)		release_region(a,s)
#define	REGION_IO_REQUEST(a,s,n)	request_region(a,s,n)
#define	REGION_MEM_CHECK(a,s)		check_mem_region(a,s)
#define	REGION_MEM_RELEASE(a,s)		release_mem_region(a,s)
#define	REGION_MEM_REQUEST(a,s,n)	request_mem_region(a,s,n)
#define	SET_CURRENT_STATE(s)		current->state = (s)
#define	VADDR_T						unsigned long
#define	VIRT_TO_PAGE(p)				virt_to_page((p))
#define	VM_OFFSET_BYTES(vma)		((vma)->vm_pgoff * PAGE_SIZE)
#define	VM_OPS_FAULT(vmo,fun)
#define	VM_OPS_NOPAGE(vmo,fun)		(vmo).nopage = (fun)
#define	VM_OPS_UNMAP(vmo,fun)
#define	WAIT_QUEUE_ENTRY_INIT(w,c)	init_waitqueue_entry((w),(c))
#define	WAIT_QUEUE_ENTRY_T			wait_queue_t
#define	WAIT_QUEUE_HEAD_INIT(q)		init_waitqueue_head((q))
#define	WAIT_QUEUE_HEAD_T			wait_queue_head_t

#define	IRQ_REQUEST(dv,fnc)			request_irq((dv)->pci->irq,				\
												(fnc),						\
												SA_SHIRQ,					\
												DRV_DEV_DEVICE_NAME_LOWER,	\
												(dv))

#if	(LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,20)) && \
	(RED_HAT_LINUX_KERNEL)

	#define	REMAP_PAGE_RANGE(v,f,t,s,p)	remap_page_range(v,f,t,s,p)
#else
	#define	REMAP_PAGE_RANGE(v,f,t,s,p)	remap_page_range(f,t,s,p)
#endif

#if	(LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,19))
	#define	CURRENT_PROCESS_ID			current->tgid
#else
	#define	CURRENT_PROCESS_ID			current->pgrp
#endif


/* prototypes	**************************************************************/

void			irq_isr(int irq, void* dev_id, struct pt_regs* regs);

struct page*	mmap_nopage(struct vm_area_struct*	vma,
							unsigned long			address,
							int						unused);

int				proc_get_info(	char*	page,
								char**	start,
								off_t	offset,
								int		count);



#endif
#endif
