/** return 0 if OK, 1 if !OK*/
//int apci3600_read_digital_input (struct pci_dev *pdev, uint8 * val )
//{
//
//	if (!pdev) return 1;
//
//	*val = inl(GET_BAR2(pdev)+PCI3600_DIGITAL_INPUT_OFFSET) && 0xFF;
//
//}
//
//int do_CMD_APCI3600_Read8DigitalInputs(struct pci_dev *pdev, unsigned int cmd, unsigned long arg)
//{
//	uint32 val = 0;
//	apci3600_read_digital_input(pdev,&val);
//
//	/* Puts the modified input value to the user */
//	//if ( EXPORT_DATA(cmd, (uint8_t*) arg , (uint32_t*) &ul_InputValue, sizeof(uint8_t) ) )
//if ( EXPORT_DATA(cmd, (uint8_t*) arg , (uint32_t*) &ul_InputValue, sizeof(uint8_t) ) )
//		return -EFAULT;
//
//	return 0;
//}
//
//EXPORT_SYMBOL(apci3600_read_digital_input);



/** @file init.c
 
   Contains initialization function that is called on "load module".
 
   @par CREATION  
   @author Guinot Catherine
   @date   17.06.05
   
   @par VERSION
   @verbatim
   $LastChangedRevision: 77 $
   $LastChangedDate: 2005-06-15 16:47:53 +0200 (Wed, 15 Jun 2005) $
   @endverbatim   
   
   @par COMPILER
   @verbatim
   Compiler	: gcc
   Version	: gcc (GCC) 3.3.6 (Debian 1:3.3.6-5)   
   kernel	: 2.4.26
   @endverbatim  
   
   
   @par LICENCE
   @verbatim
   Copyright (C) 2004,2005  ADDI-DATA GmbH for the source code of this module.
        
        ADDI-DATA GmbH 
        Dieselstrasse 3 
        D-77833 Ottersweier 
        Tel: +19(0)7223/9493-0 
        Fax: +49(0)7223/9493-92 
        http://www.addi-data-com 
        info@addi-data.com 
        
   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 of the License, 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; if not, write to the Free Software Foundation, 
   Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 
   You shoud also find the complete GPL in the COPYING file 
   accompanying this source code.
   @endverbatim   
 */




#ifdef _INIT_DEBUG
#define INIT_DPRINTK(fmt, args...)	printk("%s: " fmt, __FUNCTION__ , ## args)
#else
#define INIT_DPRINTK(fmt, args...)
#endif





#include "apci3600-kapi.h"

#include "apci3600-private.h"


EXPORT_SYMBOL(i_PCI3600_InitBoard);

EXPORT_SYMBOL(i_PCI3600_GetBoardInitialisation);

EXPORT_SYMBOL(i_PCI3600_GetBoardInformation);




/*Function's Name   : i_PCI3600_InitBoard*/
/*+----------------------------------------------------------------------------+*/
/*| Function Name : i_PCI3600_InitBoard ()                                     |*/
/*+----------------------------------------------------------------------------+*/
/*| Task :                                                                     |*/
/*  Initialise the board : do the initialisation of the two master clock        */
/*  used by the analog input and the analog output and the divisor to use       */
/*  for the clock of the chronometer.                                           */
/*  And define if the board work as Master or as Slave.                         */
/*+----------------------------------------------------------------------------+*/
/*| Input Parameters :                                                         |*/
/*  uint32_t dw_BoardHandle Handle of the board                                    */
/*  uint8_t b_MasterSlaveMode Selection of the mode of the board :                 */
/*                         0 : Master Mode                                      */
/*                         1 : Slave Mode                                       */
/*                         In slave mode, the Clock1&2 selection and divisor    */
/*                         must be the same that the master board.              */
/*  uint8_t b_ClockGen1_Divisor                                                    */
/*                         Selection of the divisor for the clock generator 1   */
/*  uint8_t b_ClockGen2_Divisor                                                    */
/*                         Selection of the divisor for the clock generator 2   */
/*  uint8_t b_SamplingClock1_Selection                                             */
/*                         Selection of the clock for the sampling clock 1      */
/*  uint8_t b_SamplingClock2_Selection                                             */
/*                         Selection of the clock for the sampling clock 2      */
/*  uint8_t b_SlaveSamplingClock1_Selection                                        */
/*                         Selection of the clock for the sampling clock 1      */
/*                         for the slave board                                  */
/*                         0 : PCI3600_EXT_CLOCK_1                              */
/*                         1 : PCI3600_EXT_CLOCK_2                              */
/*  uint8_t b_SlaveSamplingClock2_Selection                                        */
/*                         Selection of the clock for the sampling clock 2      */
/*                         for the slave board                                  */
/*                         0 : PCI3600_EXT_CLOCK_1                              */
/*                         1 : PCI3600_EXT_CLOCK_2                              */
/*  uint8_t b_Chronometer_MasterClockDivisor                                       */
/*                         Selection of the divisor for the master clock        */
/*                         for the Chronometer:                                 */
/*                         PCI3600_CHRONOMETER_DIVISOR_1                        */
/*                         PCI3600_CHRONOMETER_DIVISOR_10                       */
/*                         PCI3600_CHRONOMETER_DIVISOR_100                      */
/*+----------------------------------------------------------------------------+*/
/*| Output Parameters :                                                        |*/
/*                                                                              */
/*+----------------------------------------------------------------------------+*/
/*| Return Value :                                                             |*/
/*         > 0 : Warning                                                        */
/*         0 : No Error                                                         */
/*         -1 : The handle parameter of the board is wrong                      */
/*         -2 : Master,Slave mode parameter is wrong                            */
/*         -3 : one or both of the selected bus clock divisor parameter is wrong*/
/*         -4 : one or both of the clock selection is wrong                     */
/*         -5 : Slave sampling clock selection is wrong                         */
/*         -6 : Chronometer master clock divisor parameter is wrong             */
/*         -7 : The board is already initialised by another process             */
/*         -8 : The board is in use : Release all channels to reinitialise it   */
/*+----------------------------------------------------------------------------+*/
int __needlock i_PCI3600_InitBoard (struct pci_dev *pdev,
						   uint8_t b_MasterSlaveMode,
						   uint8_t b_ClockGen1_Divisor,
						   uint8_t b_ClockGen2_Divisor,
						   uint8_t b_SamplingClock1_Selection,
						   uint8_t b_SamplingClock2_Selection,
						   uint8_t b_SlaveSamplingClock1_Selection,
						   uint8_t b_SlaveSamplingClock2_Selection,
						   uint8_t b_Chronometer_MasterClock_Divisor)
{
	int   i_ReturnValue     = 0;
	uint8_t  b_BoardInUse      = 0;
	uint8_t  b_Cpt             = 0;
	uint32_t dw_Value          = 0;
	if (!pdev)
		return -1;

	/******************************/
	/* Test the master,slave mode */
	/******************************/
	if ((b_MasterSlaveMode == PCI3600_MASTER_MODE) ||
			(b_MasterSlaveMode == PCI3600_SLAVE_MODE))
	{
		/******************************/
		/* Test the bus clock divisor */
		/******************************/
		if (((b_ClockGen1_Divisor == PCI3600_DIVISOR_4) ||
				(b_ClockGen1_Divisor == PCI3600_DIVISOR_5) ||
				(b_ClockGen1_Divisor == PCI3600_DIVISOR_6) ||
				(b_ClockGen1_Divisor == PCI3600_DIVISOR_8) ||
				(b_ClockGen1_Divisor == PCI3600_DIVISOR_10) ||
				(b_ClockGen1_Divisor == PCI3600_DIVISOR_12) ||
				(b_ClockGen1_Divisor == PCI3600_DIVISOR_16) ||
				(b_ClockGen1_Divisor == PCI3600_DIVISOR_20) ||
				(b_ClockGen1_Divisor == PCI3600_DIVISOR_25) ||
				(b_ClockGen1_Divisor == PCI3600_DIVISOR_40) ||
				(b_ClockGen1_Divisor == PCI3600_DIVISOR_50) ||
				(b_ClockGen1_Divisor == PCI3600_DIVISOR_60) ||
				(b_ClockGen1_Divisor == PCI3600_DIVISOR_80) ||
				(b_ClockGen1_Divisor == PCI3600_DIVISOR_100)) &&
				((b_ClockGen2_Divisor == PCI3600_DIVISOR_4) ||
				 (b_ClockGen2_Divisor == PCI3600_DIVISOR_5) ||
				 (b_ClockGen2_Divisor == PCI3600_DIVISOR_6) ||
				 (b_ClockGen2_Divisor == PCI3600_DIVISOR_8) ||
				 (b_ClockGen2_Divisor == PCI3600_DIVISOR_10) ||
				 (b_ClockGen2_Divisor == PCI3600_DIVISOR_12) ||
				 (b_ClockGen2_Divisor == PCI3600_DIVISOR_16) ||
				 (b_ClockGen2_Divisor == PCI3600_DIVISOR_20) ||
				 (b_ClockGen2_Divisor == PCI3600_DIVISOR_25) ||
				 (b_ClockGen2_Divisor == PCI3600_DIVISOR_40) ||
				 (b_ClockGen2_Divisor == PCI3600_DIVISOR_50) ||
				 (b_ClockGen2_Divisor == PCI3600_DIVISOR_60) ||
				 (b_ClockGen2_Divisor == PCI3600_DIVISOR_80) ||
				 (b_ClockGen2_Divisor == PCI3600_DIVISOR_100))) {
			/*************************************/
			/* Test the sampling clock selection */
			/*************************************/
			if (((b_SamplingClock1_Selection == PCI3600_CLK_GENERATOR_1) ||
					(b_SamplingClock1_Selection == PCI3600_CLK_GENERATOR_2) ||
					(b_SamplingClock1_Selection == PCI3600_CHRONOMETER_0_LATCH_INPUT) ||
					(b_SamplingClock1_Selection == PCI3600_CHRONOMETER_1_LATCH_INPUT)) &&
					((b_SamplingClock2_Selection == PCI3600_CLK_GENERATOR_1) ||
					 (b_SamplingClock2_Selection == PCI3600_CLK_GENERATOR_2) ||
					 (b_SamplingClock2_Selection == PCI3600_CHRONOMETER_0_LATCH_INPUT) ||
					 (b_SamplingClock2_Selection == PCI3600_CHRONOMETER_1_LATCH_INPUT))) {
				/**********************************************************/
				/* In Slave Mode, test the slave sampling clock selection */
				/**********************************************************/
				if (((b_MasterSlaveMode == PCI3600_SLAVE_MODE) &&
						((b_SlaveSamplingClock1_Selection == PCI3600_EXT_CLOCK_1) ||
						 (b_SlaveSamplingClock1_Selection == PCI3600_EXT_CLOCK_2)) &&
						((b_SlaveSamplingClock2_Selection == PCI3600_EXT_CLOCK_1) ||
						 (b_SlaveSamplingClock2_Selection == PCI3600_EXT_CLOCK_2))
					) ||
						(b_MasterSlaveMode == PCI3600_MASTER_MODE)) {
					/*********************************************/
					/* Test the Chronometer master clock divisor */
					/*********************************************/
					if ((b_Chronometer_MasterClock_Divisor != PCI3600_CHRONOMETER_DIVISOR_1) &&
							(b_Chronometer_MasterClock_Divisor != PCI3600_CHRONOMETER_DIVISOR_10) &&
							(b_Chronometer_MasterClock_Divisor != PCI3600_CHRONOMETER_DIVISOR_100)) {
						/*******************************************************/
						/* Chronometer master clock divisor parameter is wrong */
						/*******************************************************/
						i_ReturnValue = -6;

					}
				} else {
					/*******************************************/
					/* Slave sampling clock selection is wrong */
					/*******************************************/
					i_ReturnValue = -5;

				}
			} else {
				/***********************************************/
				/* one or both of the clock selection is wrong */
				/***********************************************/
				i_ReturnValue = -4;

			}
		} else {
			/********************************************************************/
			/* one or both of the selected bus clock divisor parameter is wrong */
			/********************************************************************/
			i_ReturnValue = -3;

		}
	} else
	{
		/****************************************/
		/* Master,Slave mode parameter is wrong */
		/****************************************/
		i_ReturnValue = -2;

	}
	/********************************************/
	/* Test if an error occur by the parameters */
	/********************************************/
	if (i_ReturnValue == 0)
	{
		INIT_DPRINTK ("b_BoardInitialised:%hu\n",APCI3600_PRIVDATA(pdev)->
				s_PCI3600_BoardInformation.
				s_BoardInfos.
				b_BoardInitialised);
		INIT_DPRINTK ("ProcessIndex:%hu\n",APCI3600_PRIVDATA(pdev)->
				s_PCI3600_BoardInformation.
				s_BoardInfos.
				b_BoardInitialisedProcessIndex);
		/****************************************/
		/* Test if the board is not initialised */
		/****************************************/
		if ((APCI3600_PRIVDATA(pdev)->
				s_PCI3600_BoardInformation.
				s_BoardInfos.
				b_BoardInitialised == 0) ||
				((APCI3600_PRIVDATA(pdev)->
				  s_PCI3600_BoardInformation.
				  s_BoardInfos.
				  b_BoardInitialised == 1) && (APCI3600_PRIVDATA(pdev)->
											   s_PCI3600_BoardInformation.
											   s_BoardInfos.
											   b_BoardInitialisedProcessIndex == 0))) {
			/*********************************/
			/* Define if the board is in use */
			/*********************************/
			for (b_Cpt = 0; b_Cpt < APCI3600_PRIVDATA(pdev)->
					s_PCI3600_BoardInformation.
					b_AnalogInModuleNumber; b_Cpt ++) {
				if (APCI3600_PRIVDATA(pdev)->
						s_PCI3600_BoardInformation.
						s_AnalogInModuleInfos[b_Cpt].
						b_ModuleInitStatus == 1) {
					b_BoardInUse = 1;

					b_Cpt = APCI3600_PRIVDATA(pdev)->
							s_PCI3600_BoardInformation.
							b_AnalogInModuleNumber;

				}
			}
			for (b_Cpt = 0; b_Cpt < APCI3600_PRIVDATA(pdev)->
					s_PCI3600_BoardInformation.
					b_ChronometerNumber; b_Cpt ++) {
				if (APCI3600_PRIVDATA(pdev)->
						s_PCI3600_BoardInformation.
						s_ChronometerInfos[b_Cpt].
						b_ChronometerInitStatus == 1) {
					b_BoardInUse = 1;

					b_Cpt = APCI3600_PRIVDATA(pdev)->
							s_PCI3600_BoardInformation.
							b_ChronometerNumber;

				}
			}
			for (b_Cpt = 0; b_Cpt < APCI3600_PRIVDATA(pdev)->
					s_PCI3600_BoardInformation.
					b_AnalogOutChannelNumber; b_Cpt ++) {
				if (APCI3600_PRIVDATA(pdev)->
						s_PCI3600_BoardInformation.
						s_AnalogOutInfos[b_Cpt].
						b_ChannelInitStatus == 1) {
					b_BoardInUse = 1;

					b_Cpt = APCI3600_PRIVDATA(pdev)->
							s_PCI3600_BoardInformation.
							b_AnalogOutChannelNumber;

				}
			}
			/*******************************/
			/* Test if the board is in use */
			/*******************************/
			if ((b_BoardInUse == 0) || (APCI3600_PRIVDATA(pdev)->
										s_PCI3600_BoardInformation.
										s_BoardInfos.
										b_BoardInitialised == 0)) {
				/****************************************/
				/* Write the configuration on the board */
				/****************************************/
				dw_Value = ((uint32_t)(b_Chronometer_MasterClock_Divisor << 19)) |
						   ((uint32_t)(b_MasterSlaveMode << 18)) |
						   ((uint32_t)(b_SamplingClock2_Selection << 16)) |
						   ((uint32_t)(b_SamplingClock1_Selection << 14)) |
						   ((uint32_t)(b_ClockGen2_Divisor << 7)) |
						   ((uint32_t) b_ClockGen1_Divisor);


				OUTPDW_MEM(GET_MEM_BAR3(pdev),PCI3600_CLOCK_BUS_GENERAL_OFFSET,dw_Value);

				/***************************************/
				/* Save the configuration of the board */
				/***************************************/
				APCI3600_PRIVDATA(pdev)->
				s_PCI3600_BoardInformation.
				s_BoardInfos.
				b_MasterSlaveMode = b_MasterSlaveMode;

				APCI3600_PRIVDATA(pdev)->
				s_PCI3600_BoardInformation.
				s_BoardInfos.
				b_ClockGen1_Divisor = b_ClockGen1_Divisor;

				APCI3600_PRIVDATA(pdev)->
				s_PCI3600_BoardInformation.
				s_BoardInfos.
				b_ClockGen2_Divisor = b_ClockGen2_Divisor;

				APCI3600_PRIVDATA(pdev)->
				s_PCI3600_BoardInformation.
				s_BoardInfos.
				b_SamplingClock1_Selection = b_SamplingClock1_Selection;

				APCI3600_PRIVDATA(pdev)->
				s_PCI3600_BoardInformation.
				s_BoardInfos.
				b_SamplingClock2_Selection = b_SamplingClock2_Selection;

				APCI3600_PRIVDATA(pdev)->
				s_PCI3600_BoardInformation.
				s_BoardInfos.
				b_SlaveSamplingClock1_Selection = b_SlaveSamplingClock1_Selection;

				APCI3600_PRIVDATA(pdev)->
				s_PCI3600_BoardInformation.
				s_BoardInfos.
				b_SlaveSamplingClock2_Selection = b_SlaveSamplingClock2_Selection;

				APCI3600_PRIVDATA(pdev)->
				s_PCI3600_BoardInformation.
				s_BoardInfos.
				b_Chronometer_MasterClock_Divisor = b_Chronometer_MasterClock_Divisor;

				/********************************/
				/* Set the board as initialised */
				/********************************/
				APCI3600_PRIVDATA(pdev)->
				s_PCI3600_BoardInformation.
				s_BoardInfos.
				b_BoardInitialised = 1;

				/***************************************************************/
				/* Save the index of the process who has initialised the board */
				/***************************************************************/
				APCI3600_PRIVDATA(pdev)->
				s_PCI3600_BoardInformation.
				s_BoardInfos.
				b_BoardInitialisedProcessIndex = 0;

			} else {
				/*****************************************************************/
				/* The board is in use : Release all channels to reinitialise it */
				/*****************************************************************/
				i_ReturnValue = -8;

			}
		} else {
			/*******************************************************/
			/* The board is already initialised by another process */
			/*******************************************************/
			i_ReturnValue = -7;

		}
	}
	return (i_ReturnValue);

}
/*Function's Name   : i_PCI3600_GetBoardInitialisation*/
/*+----------------------------------------------------------------------------+*/
/*| Function Name : i_PCI3600_GetBoardInitialisation ()                        |*/
/*+----------------------------------------------------------------------------+*/
/*| Task :                                                                     |*/
/*        Return the board initialisation information of the board              */
/*+----------------------------------------------------------------------------+*/
/*| Input Parameters :                                                         |*/
/*         uint32_t dw_BoardHandle     : Handle of the board                      */
/*                                                                              */
/*+----------------------------------------------------------------------------+*/
/*| Output Parameters :                                                        |*/
/*  uint8_t* pb_MasterSlaveMode Selection of the mode of the board :               */
/*                         0 : Master Mode                                      */
/*                         1 : Slave Mode                                       */
/*                         In slave mode, the Clock1&2 selection and divisor    */
/*                         must be the same that the master board.              */
/*  uint8_t* pb_ClockGen1_Divisor                                                  */
/*                         Selection of the divisor for the clock generator 1   */
/*  uint8_t* pb_ClockGen2_Divisor                                                  */
/*                         Selection of the divisor for the clock generator 2   */
/*  uint8_t* pb_SamplingClock1_Selection                                           */
/*                         Selection of the clock for the sampling clock 1      */
/*  uint8_t* pb_SamplingClock2_Selection                                           */
/*                         Selection of the clock for the sampling clock 2      */
/*  uint8_t* pb_SlaveSamplingClock1_Selection                                      */
/*                         Selection of the clock for the sampling clock 1      */
/*                         for the slave board                                  */
/*                         0 : PCI3600_EXT_CLOCK_1                              */
/*                         1 : PCI3600_EXT_CLOCK_2                              */
/*  uint8_t* pb_SlaveSamplingClock2_Selection                                      */
/*                         Selection of the clock for the sampling clock 2      */
/*                         for the slave board                                  */
/*                         0 : PCI3600_EXT_CLOCK_1                              */
/*                         1 : PCI3600_EXT_CLOCK_2                              */
/*  uint8_t* pb_Chronometer_MasterClockDivisor                                     */
/*                         Selection of the divisor for the master clock        */
/*                         for the Chronometer:                                 */
/*                         PCI3600_CHRONOMETER_DIVISOR_1                        */
/*                         PCI3600_CHRONOMETER_DIVISOR_10                       */
/*                         PCI3600_CHRONOMETER_DIVISOR_100                      */
/*+----------------------------------------------------------------------------+*/
/*| Return Value :                                                             |*/
/*         > 0 : Warning                                                        */
/*         0 : No Error                                                         */
/*         -1 : The handle parameter of the board is wrong                      */
/*         -2 : The board is not initialised                                    */
/*+----------------------------------------------------------------------------+*/
int __needlock i_PCI3600_GetBoardInitialisation (struct pci_dev *pdev,
										uint8_t* pb_MasterSlaveMode,
										uint8_t* pb_ClockGen1_Divisor,
										uint8_t* pb_ClockGen2_Divisor,
										uint8_t* pb_SamplingClock1_Selection,
										uint8_t* pb_SamplingClock2_Selection,
										uint8_t* pb_SlaveSamplingClock1_Selection,
										uint8_t* pb_SlaveSamplingClock2_Selection,
										uint8_t* pb_Chronometer_MasterClock_Divisor)
{
	int   i_ReturnValue     = 0;


	if (!pdev)
		return -1;

	/************************************/
	/* Test if the board is initialised */
	/************************************/
	if (APCI3600_PRIVDATA(pdev)->
			s_PCI3600_BoardInformation.
			s_BoardInfos.
			b_BoardInitialised == 1)
	{
		/*****************************************/
		/* Return the configuration of the board */
		/*****************************************/
		*pb_MasterSlaveMode = APCI3600_PRIVDATA(pdev)->
							  s_PCI3600_BoardInformation.
							  s_BoardInfos.
							  b_MasterSlaveMode;

		*pb_ClockGen1_Divisor = APCI3600_PRIVDATA(pdev)->
								s_PCI3600_BoardInformation.
								s_BoardInfos.
								b_ClockGen1_Divisor;

		*pb_ClockGen2_Divisor = APCI3600_PRIVDATA(pdev)->
								s_PCI3600_BoardInformation.
								s_BoardInfos.
								b_ClockGen2_Divisor;

		*pb_SamplingClock1_Selection = APCI3600_PRIVDATA(pdev)->
									   s_PCI3600_BoardInformation.
									   s_BoardInfos.
									   b_SamplingClock1_Selection;

		*pb_SamplingClock2_Selection = APCI3600_PRIVDATA(pdev)->
									   s_PCI3600_BoardInformation.
									   s_BoardInfos.
									   b_SamplingClock2_Selection;

		*pb_SlaveSamplingClock1_Selection = APCI3600_PRIVDATA(pdev)->
											s_PCI3600_BoardInformation.
											s_BoardInfos.
											b_SlaveSamplingClock1_Selection;

		*pb_SlaveSamplingClock2_Selection = APCI3600_PRIVDATA(pdev)->
											s_PCI3600_BoardInformation.
											s_BoardInfos.
											b_SlaveSamplingClock2_Selection;

		*pb_Chronometer_MasterClock_Divisor = APCI3600_PRIVDATA(pdev)->
											  s_PCI3600_BoardInformation.
											  s_BoardInfos.
											  b_Chronometer_MasterClock_Divisor;

	} else
	{
		/********************************/
		/* The board is not initialised */
		/********************************/
		i_ReturnValue = -2;

	}
	return (i_ReturnValue);

}
/*Function's Name   : i_PCI3600_GetBoardInformation*/
/*+----------------------------------------------------------------------------+*/
/*| Function Name : i_PCI3600_GetBoardInformation ()                           |*/
/*+----------------------------------------------------------------------------+*/
/*| Task :                                                                     |*/
/*        Return the memory information of the board and the allocated memory   */
/*        from the computer for this board.                                     */
/*+----------------------------------------------------------------------------+*/
/*| Input Parameters :                                                         |*/
/*         uint32_t dw_BoardHandle     : Handle of the board                      */
/*                                                                              */
/*+----------------------------------------------------------------------------+*/
/*| Output Parameters :                                                        |*/
/*  uint32_t* pdw_OnBoardRAMTotalSize  : Return the size of the RAM of the board  */
/*                                     (Size in MBytes).                        */
/*  uint8_t* pb_NbrOfComputerBufferAllocated :                                    */
/*                   Return the number of buffer allocated in the computer RAM  */
/*  uint32_t* pdw_ComputerBufferSizeArray    :                                    */
/*                   Return the size of the buffer allocated in the computer    */
/*                   RAM.(Size in Byte).                                        */
/*+----------------------------------------------------------------------------+*/
/*| Return Value :                                                             |*/
/*         > 0 : Warning                                                        */
/*         0 : No Error                                                         */
/*         -1 : The handle parameter of the board is wrong                      */
/*+----------------------------------------------------------------------------+*/
int __needlock i_PCI3600_GetBoardInformation (struct pci_dev *pdev,
									 uint32_t* pdw_OnBoardRAMTotalSize,
									 uint8_t* pb_NbrOfComputerBufferAllocated,
									 uint32_t* pdw_ComputerBufferSizeArray)
{
	int   i_ReturnValue     = 0;
	uint32_t dw_BufferCpt       = 0;

	if (!pdev)
		return -1;


	*pb_NbrOfComputerBufferAllocated = 0;

	/********************************/
	/* Return the on board RAM Size */
	/********************************/
	*pdw_OnBoardRAMTotalSize = ((APCI3600_PRIVDATA(pdev)->
								 s_PCI3600_BoardInformation.
								 s_HardwareInformations.
								 dw_OnBoardRAMSize / 1024) / 1024);


	/******************************************/
	/* Return the Computer Buffer information */
	/******************************************/
	/***************************************/
	/* Test if the memory allocation is OK */
	/***************************************/
	if (APCI3600_PRIVDATA(pdev)->
			s_PCI3600_BoardInformation.
			s_BoardInfos.
			s_PCAllocatedMemoryBuffer.
			ul_Status == 1)
	{
		/******************************************/
		/* Return the Computer Buffer information */
		/******************************************/
		for (dw_BufferCpt = 0; dw_BufferCpt < APCI3600_PRIVDATA(pdev)->
				s_PCI3600_BoardInformation.
				s_BoardInfos.
				s_PCAllocatedMemoryBuffer.
				ul_BufferNbr; dw_BufferCpt++) {
			pdw_ComputerBufferSizeArray[*pb_NbrOfComputerBufferAllocated] = APCI3600_PRIVDATA(pdev)->
					s_PCI3600_BoardInformation.
					s_BoardInfos.
					s_PCAllocatedMemoryBuffer.
					ul_BufferSize;

			*pb_NbrOfComputerBufferAllocated = *pb_NbrOfComputerBufferAllocated + 1;

		}
	}
	return (i_ReturnValue);

}



//------------------------------------------------------------------------------




