⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 comemdrv.h

📁 The Lite Evaluation/Demonstration Kit is intended to illustrate use of the AN3042. The AN3042 is c
💻 H
字号:
//////////////////////////////////////////////////////////////////////
//
// File:      comemdrv.h
// $Archive: /ComemL/Util/PCfg/comemdrv.h $
//
// Purpose:
//   this header file contains the IOCTL definitions, structures,
//   and status codes used to communicate with the COMEM device
//   driver.
//
// Environment:
//    kernel & User mode
//
// $Author: Tpm $
//
// $History: comemdrv.h $
//  
//  *****************  Version 1  *****************
//  User: Tpm          Date: 7/13/98    Time: 8:37a
//  Created in $/ComemL/Util/PCfg
//  
//  *****************  Version 9  *****************
//  User: Stevek       Date: 10/31/97   Time: 4:42p
//  Updated in $/Comem/Win 95 driver
//  Added reference count.
//  
//  *****************  Version 8  *****************
//  User: Markm        Date: 10/28/97   Time: 3:39p
//  Updated in $/Comem/Win NT driver
//  added conditionals to the defines of PAGE_SIZE and NO_ERROR
//  
//  *****************  Version 7  *****************
//  User: Stevek       Date: 10/22/97   Time: 12:34p
//  Updated in $/Comem/Win 95 driver
//  Added file header block
//  
// Copyright (c) 1997 Anchor Chips, Inc.  May not be reproduced without
// permission.  See the license agreement for more details.
//
//////////////////////////////////////////////////////////////////////

#ifndef __comemdrv_h__
#define __comemdrv_h__

//////////////////////////////////////////////////////////////////////
//
// miscellaneous defines
//
//////////////////////////////////////////////////////////////////////

#define COMEM_Major		1
#define COMEM_Minor		0
#define COMEM_DeviceID		UNDEFINED_DEVICE_ID    /* this is only needed if we publish API entries for Win16 apps */
#define COMEM_Init_Order	UNDEFINED_INIT_ORDER

#define PCI_ENUM_FUNC_GET_DEVICE_INFO   0
#define PCI_ENUM_FUNC_SET_DEVICE_INFO   1


//////////////////////////////////////////////////////////////////////
// Define generic types -- the user may not include win.h
//////////////////////////////////////////////////////////////////////
#ifndef NULL
#define NULL ((void *) 0)
#endif 

#ifndef _UCHAR_DEFINED
#define _UCHAR_DEFINED
typedef unsigned char UCHAR;
#endif // !_UCHAR_DEFINED

#ifndef _USHORT_DEFINED
#define _USHORT_DEFINED
typedef unsigned short USHORT;
#endif // !_USHORT_DEFINED

#ifndef _WORD_DEFINED
#define _WORD_DEFINED
typedef unsigned short WORD;
#endif // !_WORD_DEFINED

#ifndef _DWORD_DEFINED
#define _DWORD_DEFINED
typedef unsigned long DWORD;
#endif // !_DWORD_DEFINED

#ifndef _ULONG_DEFINED
#define _ULONG_DEFINED
typedef unsigned long ULONG;
#endif // !_ULONG_DEFINED

#define MAX_FRAGMENTS 16               // Maximum number of fragments permitted in the memory map
#define COMEM_MAX_DEVICES 16           // Max number of co-memory devices in a system
#define COMEM_MAX_REGIONS 4            // Maximum number of memory regions in the co-mem
#define COMEM_MAX_BARS   4             // Number of Base Address Registers in the PCI config space of co-mem
#ifndef PAGE_SIZE
#define PAGE_SIZE 4096                 // Page size in a Windows system
#endif
#define NUM_PAGES 4096                 // Total number of pages used by co-mem 
#define PAGE_TABLE_NUM_PAGES 0x4		   // Number of pages in the page table 
#define PAGE_TABLE_ALIGN		0x3		// Alignment of page table -- 3 is 16K boundary 

#ifndef NO_ERROR
#define NO_ERROR           				(0)
#endif

#define ERROR_INVALID_REGION 				(-1)
#define ERROR_INVALID_ADDIN_ADDR 		(-2)
#define ERROR_OVERLAID_REGION 			(-3)
#define ERROR_BAD_PAGE_TABLE				(-4)
#define ERROR_MEMORY_ALLOC  				(-5)
#define ERROR_ALLOC_EXISTS					(-6)
#define ERROR_NO_DRIVER    				(-7)
#define ERROR_INVALID_COMEM_ID			(-8)
#define ERROR_DEVICE_NOT_FOUND			(-9)
#define ERROR_UNKNOWN 						(-10)

#define FILE_DEVICE_COMEM  FILE_DEVICE_UNKNOWN
#define COMEM_IOCTL_INDEX  0x801

//////////////////////////////////////////////////////////////////////
//
// IOCTL defines
//
//////////////////////////////////////////////////////////////////////
#define IOCTL_COMEM_GETSTATUS                   CTL_CODE(FILE_DEVICE_COMEM ,   \
                                                         COMEM_IOCTL_INDEX+0,  \
                                                         METHOD_BUFFERED,      \
                                                         FILE_ANY_ACCESS)

#define IOCTL_COMEM_GETVERSION                  CTL_CODE(FILE_DEVICE_COMEM ,   \
                                                         COMEM_IOCTL_INDEX+1,  \
                                                         METHOD_BUFFERED,      \
                                                         FILE_ANY_ACCESS)

#define IOCTL_COMEM_GETPCICFG                   CTL_CODE(FILE_DEVICE_COMEM ,   \
                                                         COMEM_IOCTL_INDEX+2,  \
                                                         METHOD_BUFFERED,      \
                                                         FILE_ANY_ACCESS)

#define IOCTL_COMEM_SETPCICFG                   CTL_CODE(FILE_DEVICE_COMEM ,   \
                                                         COMEM_IOCTL_INDEX+3,  \
                                                         METHOD_BUFFERED,      \
                                                         FILE_ANY_ACCESS)

#define IOCTL_COMEM_ALLOCMEMORY                 CTL_CODE(FILE_DEVICE_COMEM ,   \
                                                         COMEM_IOCTL_INDEX+4,  \
                                                         METHOD_BUFFERED,       \
                                                         FILE_ANY_ACCESS)

#define IOCTL_COMEM_DEALLOCMEMORY               CTL_CODE(FILE_DEVICE_COMEM ,   \
                                                         COMEM_IOCTL_INDEX+5,  \
                                                         METHOD_BUFFERED,      \
                                                         FILE_ANY_ACCESS)


#define IOCTL_COMEM_CREATELINPTR                CTL_CODE(FILE_DEVICE_COMEM ,   \
                                                         COMEM_IOCTL_INDEX+7,  \
                                                         METHOD_BUFFERED,      \
                                                         FILE_ANY_ACCESS)

#define IOCTL_COMEM_DESTROYLINPTR               CTL_CODE(FILE_DEVICE_COMEM,    \
                                                         COMEM_IOCTL_INDEX+8,  \
                                                         METHOD_BUFFERED,      \
                                                         FILE_ANY_ACCESS)

#define IOCTL_COMEM_CREATEBARPTR                CTL_CODE(FILE_DEVICE_COMEM ,   \
                                                         COMEM_IOCTL_INDEX+9,  \
                                                         METHOD_BUFFERED,      \
                                                         FILE_ANY_ACCESS)

#define IOCTL_COMEM_DESTROYBARPTR               CTL_CODE(FILE_DEVICE_COMEM,    \
                                                         COMEM_IOCTL_INDEX+10, \
                                                         METHOD_BUFFERED,      \
                                                         FILE_ANY_ACCESS)


//////////////////////////////////////////////////////////////////////
//
// structures
//
//////////////////////////////////////////////////////////////////////

// Structure passed into IOCTL_COMEM_GETSTATUS
typedef struct  {
		DWORD comemID;		// A structure must have at least one member
		}GetStatusIn;

// Structure passed out of IOCTL_COMEM_GETSTATUS
typedef struct {
		DWORD status;           // Currently not used -- return 0 for no error
      DWORD referenceCount;   // Number of handles currently open for this device
		} GetStatusOut;


// Structure passed into IOCTL_COMEM_GETPCICFG
typedef struct 
{
   DWORD ComemId;
} GetPciCfgIn;

// Structure returned by IOCTL_COMEM_GETPCICFG
typedef struct GetPciCfgOut_t
{
    USHORT  VendorID;
    USHORT  DeviceID;
    USHORT  Command; 
    USHORT  Status;
    UCHAR   RevisionID;
    UCHAR   ProgIf;    
    UCHAR   SubClass;  
    UCHAR   BaseClass; 
    UCHAR   CacheLineSize;
    UCHAR   LatencyTimer; 
    UCHAR   HeaderType;   
    UCHAR   BIST;          
    ULONG   BaseAddresses[6];
	 ULONG	CardBusCISPtr;
    USHORT	SubsystemVendorID;
	 USHORT	SubsystemID;
	 ULONG	ROMBaseAddress;
    ULONG   Reserved2[2];
    UCHAR   InterruptLine; 
    UCHAR   InterruptPin;  
    UCHAR   MinimumGrant;  
    UCHAR   MaximumLatency;
    DWORD   status;
} GetPciCfgOut;

typedef struct _pci_config_header_0_t
{
    USHORT  VendorID;
    USHORT  DeviceID;
    USHORT  Command; 
    USHORT  Status;
    UCHAR   RevisionID;
    UCHAR   ProgIf;    
    UCHAR   SubClass;  
    UCHAR   BaseClass; 
    UCHAR   CacheLineSize;
    UCHAR   LatencyTimer; 
    UCHAR   HeaderType;   
    UCHAR   BIST;          
    ULONG   BaseAddresses[6];
	 ULONG	CardBusCISPtr;
    USHORT	SubsystemVendorID;
	 USHORT	SubsystemID;
	 ULONG	ROMBaseAddress;
    ULONG   Reserved2[2];
    UCHAR   InterruptLine; 
    UCHAR   InterruptPin;  
    UCHAR   MinimumGrant;  
    UCHAR   MaximumLatency;
} PCI_CONFIG_HEADER_0;

// Structure passed into by IOCTL_COMEM_SETPCICFG
typedef struct _SetPciCfgIn
{
    USHORT  VendorID;
    USHORT  DeviceID;
    USHORT  Command; 
    USHORT  Status;
    UCHAR   RevisionID;
    UCHAR   ProgIf;    
    UCHAR   SubClass;  
    UCHAR   BaseClass; 
    UCHAR   CacheLineSize;
    UCHAR   LatencyTimer; 
    UCHAR   HeaderType;   
    UCHAR   BIST;          
    ULONG   BaseAddresses[6];
	 ULONG	CardBusCISPtr;
    USHORT	SubsystemVendorID;
	 USHORT	SubsystemID;
	 ULONG	ROMBaseAddress;
    ULONG   Reserved2[2];
    UCHAR   InterruptLine; 
    UCHAR   InterruptPin;  
    UCHAR   MinimumGrant;  
    UCHAR   MaximumLatency;
    DWORD ComemID;
} SetPciCfgIn;

// Input structure to IOCTL_COMEM_ALLOCMEMORY
typedef struct 
  {
  struct AllocBlockInSubStruct
    {
    DWORD addinAddr;
    DWORD size;
    } data[MAX_FRAGMENTS];
  DWORD comemID;
  } AllocMemoryIn ;

// Output structure to IOCTL_COMEM_ALLOCMEMORY
// Output structure to IOCTL_COMEM_DEALLOCMEMORY
// Output structure to IOCTL_COMEM_REALLOCMEMORY
// Output structure to IOCTL_COMEM_DESTROYLINPTR
typedef struct
{
   DWORD status;
} AllocMemoryOut, DeallocMemoryOut, SetPciCfgOut, 
   DestroyLinPtrOut, DestroyBarPtrOut;

// Input structure for IOCTL_COMEM_CREATELINPTR
typedef struct 
{
   DWORD comemID;
} CreateLinPtrIn, DestroyLinPtrIn, 
   DeallocMemoryIn, 
   CreateBarPtrIn, DestroyBarPtrIn;

// Structure used in internal allocation routines
// Output structure returned by IOCTL_COMEM_CREATELINPTR
typedef struct 
{
  struct AllocMemoryAllSubStruct
     {
     DWORD linearAddr;
     DWORD addinAddr;
     DWORD size;
     } data[MAX_FRAGMENTS];
     DWORD status;
}  CreateLinPtrOut, AllocBlockAll;

typedef struct
{
	DWORD linBAR[COMEM_MAX_BARS];    // Addresses of comem in user space
	DWORD linPage;
	DWORD physPage;
    DWORD status;
} CreateBarPtrOut;



#endif			// __comemdrv_h__

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -