/*++
 * Copyright (c) 1990-96 Digi International Inc., All Rights Reserved
 * 
 * This software contains proprietary and confidential information of Digi
 * International Inc.  By accepting transfer of this copy, Recipient agrees
 * to retain this software in confidence, to prevent disclosure to others,
 * and to make no use of this software other than that for which it was
 * delivered.  This is an unpublished copyrighted work of Digi International
 * Inc.  Except as permitted by federal law, 17 USC 117, copying is strictly
 * prohibited.
 * 
 * Restricted Rights Legend
 *
 * Use, duplication, or disclosure by the Government is subject to
 * restrictions set forth in sub-paragraph (c)(1)(ii) of The Rights in
 * Technical Data and Computer Software clause at DFARS 252.227-7031 or
 * subparagraphs (c)(1) and (2) of the Commercial Computer Software -
 * Restricted Rights at 48 CFR 52.227-19, as applicable.
 *
 * Digi International Inc. 11001 Bren Road East, Minnetonka, MN 55343
 *
 *
 * Last Update: $Date: 10/22/97 11:56a $
 *
 * $Header: /Components/Windows/NT/Sync/Build/Mp570/hwutils.h 5     10/22/97 11:56a Darinh $
 *
 * Revision History:
 * $Log: /Components/Windows/NT/Sync/Build/Mp570/hwutils.h $
 * 
 * 5     10/22/97 11:56a Darinh
 * Changes to make multiple board installations work better.
 * 
 * 4     7/15/97 1:05p Darinh
 * Added DigiLogError statements and message file, altered code to function
 * in DStreams environment and SNA environment with a conditional
 * compilation.
 * 
 * 3     6/06/97 1:48p Darinh
 * Everything seems functional, but more testing is required.
 * 
 * 2     4/08/97 4:55p Darinh
 * Changes made to correspond to the new DigiUtil library.  It
 * successfully transmits data!  I don't know about receiving data yet.
 * 
 * 1     4/02/97 10:08a Darinh
 * Initial checkin; ISA cards initialize, but do not pass data.
 * 
--*/

#ifndef _HWUTILS_H
#define _HWUTILS_H


#define	IF_232	    0	// 570i -- 232 interface
#define	IF_V35_232  1	// 570i -- V.35/232 interface
#define	IF_530	    2	// 570i -- 530/X.21 with 530 cable
#define	IF_X21	    3	// 570i -- 530/X.21 with X21 cable
#define IF_SW56     4	// 570i -- Switched 56Kb
#define	IF_530_X21  6	// 570i -- 530/X.21 with mixed cable
#define	IF_UNKNOWN  7	// unknown interface type
#define	IF_NONE	    8	// no interface card present
#define	IF_TTL	    9	// i for pci -- TTL loopback
#define	IF_UIB	   10	// i for pci -- Universal interface board
#define IF_4P232   11	// i for pci -- 232 interface (w/ RING)
#define IF_4PV35   12	// i for pci -- V.35 interface
#define IF_2PDUAL  13	// i for pci -- V.35/232 interface

//
//  Port Types
//

#define	RING		(0x0100)
#define	TESTMODE	(0x0200)

#define PT_NONE		(0x0000)
#define PT_232		(0x0001)
#define	PT_232_RI	(0x0001 | RING)
#define	PT_V35		(0x0002)
#define PT_530		(0x0004)
#define PT_X21		(0x0008)
#define	PT_SW56		(0x0010)
#define	PT_TTL		(0x0020 | RING)
#define	PT_LOOP		(0x0040 | RING | TESTMODE)
#define PT_NO_DC 	(0x1000)
#define PT_NO_CABLE	(0x2000)
#define	PT_UNKNOWN	(0x4000)

#define	PT_V35_232		(PT_V35 | PT_232)
#define	PT_V35_232_RI	(PT_V35_232 | RING)


VOID
fnInitCommonScaRegs (
	IN PDEVICE_EXT	pDeviceExt);

VOID
fnSetupPortRelatedRegisters (
	IN PDEVICE_EXT	pDeviceExt);

VOID
fnSetupAdapter (
	IN PCONTROLLER_EXT	pControllerExt);

VOID
fnSetupTimerValues (
	IN PDEVICE_EXT	pControllerExt);

NTSTATUS
fnZeroCardMemory (
	IN PCONTROLLER_EXT	pControllerExt);

VOID
fnAllocateDmaResources (
	IN PDEVICE_EXT		pDeviceExt);

VOID
fnSetupDmaChain (
	IN PDEVICE_EXT		pDeviceExt);

VOID
fnConvertRealAddrToWindowAddr (
	IN ULONG_PTR	RealAddress,
	IN PULONG		pWindowAddress,
	IN PUCHAR		pMemoryWindowNumber,
	IN ULONG		WindowSize);

VOID
fnSetupDmaDspChains (
	IN PDEVICE_EXT	pControllerExt,
	IN int			ChainType);

VOID
fnInitializeRxDmaChains (
	IN PDEVICE_EXT	pDeviceExt);

VOID
fnInitializeTxDmaChains (
	IN PDEVICE_EXT	pDeviceExt);

VOID
fnCopyToCardMemory (
	IN PUCHAR		pSrc,
	IN ULONG_PTR	RealAddress,
	IN USHORT		Length,
	IN PDEVICE_EXT	pDeviceExt);

VOID
fnReadFromCardMemory (
	IN ULONG_PTR	RealAddress,
	IN OUT PUCHAR	pDest,
	IN USHORT		Length,
	IN PDEVICE_EXT	pDeviceExt);

VOID 
GetInterfaceId (
	IN PCONTROLLER_EXT	pControllerExt);

VOID 
ReadInterfaceType (
	IN PCONTROLLER_EXT	pControllerExt);

typedef struct
{
	LONG	LowLimit;
	LONG	HighLimit;
	LONG	Interface;
} AdcToInterface_t;

ULONG
AdcToInterface (
	IN LONG		ADC);

VOID
ReadUcType (
	IN PDEVICE_EXT		pDeviceExt);

VOID
GetPortType (
	IN PDEVICE_EXT		pDeviceExt);

#endif // _HWUTILS_H
