/*+-----------------------------------------------------------------------+  */

/*| (C) ADDI-DATA GmbH Dieselstra?e 3 D-77833 Ottersweier                 |  */
/*+-----------------------------------------------------------------------+  */
/*| Tel : +49 (0) 7223/9493-0     | email : info@addi-data.com            |  */
/*| Fax : +49 (0) 7223/9493-92    | Internet : http:$/$/www.addi-data.com   |*/
/*+-------------------------------+---------------------------------------+  */
/*| Project : APCI-3600           | Compiler : Microsoft Visual C++       |  */
/*| Module name : Intern_Include.H|  Version : 6.0                        |  */
/*+-------------------------------+---------------------------------------+  */
/*| Author : Guinot Catherine       Date : 16/09/2004                     |  */
/*+-----------------------------------------------------------------------+  */
/*| Description : Header file of the intern function                      |  */
/*+-----------------------------------------------------------------------+  */
/*|                             UPDATES                                   |  */
/*+----------+-----------+------------------------------------------------+  */
/*| Date     | Author    | Description of updates                         |  */
/*+----------+-----------+------------------------------------------------+  */
/*|          |           |                                                |  */
/*+----------+-----------+------------------------------------------------+  */

#ifndef _APCI3600_INTERN_INCLUDE__
#define _APCI3600_INTERN_INCLUDE__

/*****************************************************************************/
/*                               AI_Intern.C                                 */
/*****************************************************************************/
int i_PCI3600_Intern_TestSpeedModeParameter (pstr_PCI3600_SingleBoardInformation
		ps_PCI3600_Board,
		uint8_t b_ClockSelection,
		uint8_t b_SpeedMode);

/*****************************************************************************/
/*                            Global_Intern.C                                */
/*****************************************************************************/
int __needlock i_PCI3600_Intern_ReserveOnBoardRAMBuffer (pstr_PCI3600_SingleBoardInformation
		ps_SingleBoard, uint8_t b_RessourceID,
		uint32_t dw_BufferSize);
		
int __needlock i_PCI3600_Intern_FreeOnBoardRAMBuffer (pstr_PCI3600_SingleBoardInformation
									   ps_SingleBoard, uint8_t b_RessourceID);
									   
int __needlock i_PCI3600_Intern_PCI9054_CompleteScatterGatherDescriptor (uint8_t 
		b_TransferDirection,
		uint8_t  b_InterruptFlag,
		uint8_t  b_ReserveHeaderPlace,
		uint32_t dw_PCBufferPhysicalAddress,
		uint32_t dw_PCBufferSize,
		uint32_t dw_PCBufferReadPointer,
		uint32_t dw_PCBufferWritePointer,
		uint32_t dw_PCBufferNbrOfData,
		uint32_t dw_OnBoardBufferAddress,
		uint32_t dw_OnBoardBufferSize,
		uint32_t dw_OnBoardBufferReadPointer,
		uint32_t dw_OnBoardBufferWritePointer,
		uint32_t dw_OnBoardBufferNbrOfData,
		uint32_t dw_NbrOfDescriptorAllocated,
		uint32_t dw_DescriptorListPhysicalAddress,
		pstr_PCI9054DMADescriptor ps_PCI9054DMADescriptor,
		uint32_t* pdw_NbrOfDescriptorUsed,
		uint32_t* pdw_NbrOfDataTransferedByTheDescriptor);
		
int __needlock i_PCI3600_Intern_PCI9054_ChainingScatterGatherDescriptors (pstr_DMAControllerInfos ps_DMAControllersInfos, 
		uint8_t b_DMAChannel,
 		pstr_DescriptorInfos ps_DescriptorsInfos);
 		
int __needlock i_PCI3600_Intern_UpdatePCBufferWithHeaderAndReturnPointer (uint8_t b_CallLevel, 
		uint8_t b_Module, 
		uint8_t b_Source, 
		uint32_t* pdw_DMABufferAddress, 
		uint32_t dw_PCBufferSize,	// In Byte
		uint32_t dw_PCBufferReadPointer,	// In uint32_t 
		uint32_t dw_PCBufferWritePointer,	// In uint32_t 
		uint32_t dw_PCBufferNbrOfDataWritten,	// In uint32_t 
		uint32_t* pdw_ComputerBufferAddressKernelLevel,
		uint32_t* pdw_ComputerBufferAddressApplicLevel,
		uint32_t* pdw_NbrOfBuffer);

int __needlock i_PCI3600_Intern_CloseHardware (struct pci_dev *pdev);

//Error __stdcall e_PCI3600_Intern_CallBackCloseHardware (Void* pArgs, Void* pContext);
//
//void __cdecl v_PCI3600_Intern_CallCriticalFunction (uint8_t                         b_CriticalSelection,
//                                                    uint8_t                         b_CallLevel,
//                                                    uint8_t                         b_BoardIndex,
//                                                    uint8_t                         b_ProcessIndex,
//                                                    str_PCI3600_GlobalStruct * ps_PCI3600_GlobalStruct,
//                                                    uint8_t                         b_SelectedCriticalFunction,
//                                                    uint32_t                        dw_InputArgNbr,
//                                                    uint32_t                        dw_OutputArgNbr,
//                                                    ...);
//
//Error __stdcall e_PCI3600_Intern_IncrAnaInpChronoBufferReadPointer (pstr_CriticalFunctionArg ps_Args);
//
//Error __stdcall e_PCI3600_Intern_IncrAnaOupBufferWritePointer (pstr_CriticalFunctionArg ps_Args);

/* dw_IncNbr: amount of data read */ 
int __needlock i_PCI3600_Intern_IncrAnaInpChronoBufferReadPointer (struct pci_dev *pdev,
		uint32_t dw_IncNbr);
		
int __needlock i_PCI3600_Intern_IncrAnaOupBufferWritePointer (struct pci_dev *pdev,
		uint8_t b_Channel,
		uint32_t dw_NbrOfWrittenValues);

#endif //_APCI3600_INTERN_INCLUDE__
