/*++
*******************************************************************************
* Copyright (c) 1990-98 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				*
*																										*
*******************************************************************************

Module Name:

   digires.h

Abstract:

   Routines to report and un-report resources to NT.

Author:

   Michael Zarns

--*/
#ifndef _DIGIRES_
#define _DIGIRES_

VOID DigiUnlockBuffers( IN PIRP pIrp );

NTSTATUS DigiLockBuffer( IN PIRP   pIrp, 
                         IN PVOID  pBuffer, 
                         IN ULONG  cbBuffer, 
                         OUT PVOID *ppLockedBuffer );

typedef struct DIGI_IO_RESOURCE
{
	PHYSICAL_ADDRESS BaseAddress;
	PHYSICAL_ADDRESS BaseAddressTranslated;	// If translated due to bus
	ULONG            Length;
	ULONG            AddressSpace;	// Use this to determines whether MmMapIoSpace should be called
	ULONG            RawType;			// The physical type we expect (ports are ports, mem is mem)
} DIGI_IO_RESOURCE, *PDIGI_IO_RESOURCE;

typedef struct DIGI_IRQ_RESOURCE
{
	ULONG           Level;
	ULONG           RawLevel;
	ULONG           Vector;
	KAFFINITY       Affinity;
	KINTERRUPT_MODE Mode;	// LevelSensitive or Latched
} DIGI_IRQ_RESOURCE, *PDIGI_IRQ_RESOURCE;

typedef struct DIGI_RESOURCE_LIST
{
	INTERFACE_TYPE    BusType;
	ULONG             BusNumber;
	DIGI_IO_RESOURCE  Io[PCI_TYPE0_ADDRESSES]; // Both Io and Memory addresses
	DIGI_IRQ_RESOURCE Irq;
} DIGI_RESOURCE_LIST, *PDIGI_RESOURCE_LIST;


NTSTATUS DigiReportResources( IN  PDRIVER_OBJECT pDriverObject,
                              IN  INTERFACE_TYPE BusType,
                              IN  ULONG BusNumber,
                              IN  PPHYSICAL_ADDRESS pIoBase,
                              IN  ULONG IoLength,
                              IN  PPHYSICAL_ADDRESS pMemoryBase,
                              IN  ULONG MemoryLength,
                              IN  ULONG IrqLevel,
                              IN  ULONG IrqVector,
                              IN  KAFFINITY IrqAffinity,
                              IN  KINTERRUPT_MODE IrqMode,
                              OUT PBOOLEAN pbConflictDetected,
                              OUT PHANDLE phResources );

NTSTATUS DigiUnreportResources( IN PDRIVER_OBJECT pDriverObject,
                                IN HANDLE         hResources );

#if !NT5_BUILD
NTSTATUS DigiAssignPciSlotResources( IN PDRIVER_OBJECT       pDriverObject,
                                     IN PUNICODE_STRING      pRegistryPath,
                                     IN ULONG                BusNumber,
                                     IN ULONG                SlotNumber,
                                     OUT PHANDLE             phResources,
                                     OUT PDIGI_RESOURCE_LIST pResourceList );
#else
NTSTATUS DigiAssignPnpResources( IN PCM_RESOURCE_LIST    pResources,
                                 IN PCM_RESOURCE_LIST    pResourcesTranslated,
                                 OUT PDIGI_RESOURCE_LIST pResourceList );
#endif

#if DBG

VOID
DigiDumpResourceList( 
	IN PCM_RESOURCE_LIST pResourceList
	);

#endif

#endif