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

📄 windrvr.h

📁 一个用vc编写的基于串口的边界扫描测试源程序代码
💻 H
📖 第 1 页 / 共 5 页
字号:
/*
 * W i n D r i v e r
 * =================
 *
 * FOR DETAILS ON THE WinDriver FUNCTIONS, PLEASE SEE THE WinDriver MANUAL
 * OR INCLUDED HELP FILES.
 *
 * This file may not be distributed -- it may only be used for development
 * or evaluation purposes (See \WinDriver\docs\license.txt for details).
 *
 * Web site: http://www.jungo.com
 * Email:    support@jungo.com
 *
 * Copyright (C) Jungo 1997 - 2004
 */
#ifndef _WINDRVR_H_
#define _WINDRVR_H_
#if defined(__cplusplus)
    extern "C" {
#endif

#include "wd_ver.h"

// these lines break standard VxWorks builds. remove the -asni flag from the
// compiler flags (from the makefile or the Tornado IDE) to compile WinDriver
// related source code.
#if defined(WIN32)
    #define DLLCALLCONV __stdcall
#else
    #define DLLCALLCONV
#endif
        
#if defined(VXWORKS)
    #define WD_PROD_NAME "DriverBuilder"
#else
    #define WD_PROD_NAME "WinDriver"
#endif

#if !defined(SPARC) && (defined(__sparc__) || defined (__sparc) || \
        defined(sparc))
    #define SPARC
#endif

#if !defined(POWERPC) && !defined(x86) && ( defined(LINUX) || \
    (defined(WIN32) && !defined(WINCE) && !defined(_ALPHA_)) || \
    (defined(SOLARIS) && defined(i386)) )
    #define x86
#endif

#if defined(VXWORKS)
    #if defined(MBX860)
        #define WD_CPU_SPEC " PPC860"
    #elif defined(MCP750)
        #define WD_CPU_SPEC " PPC750"
    #elif defined(x86)
        #define WD_CPU_SPEC " X86"
    #else
        #define WD_CPU_SPEC ""
    #endif
#elif defined(WINCE)
    #if defined(ARM)
        #define WD_CPU_SPEC " ARM"
    #elif defined(MIPS)
        #define WD_CPU_SPEC " MIPS"
    #elif defined(x86)
        #define WD_CPU_SPEC " x86"
    #else
        #define WD_CPU_SPEC ""
    #endif
#else
    #if defined(SPARC)
        #define WD_CPU_SPEC " Sparc"
    #elif defined(POWERPC)
        #define WD_CPU_SPEC " PowerPC"
    #else
        #define WD_CPU_SPEC " X86"
    #endif
#endif

#if defined(WINNT)
    #define WD_FILE_FORMAT " SYS"
#elif defined(WIN95)
    #define WD_FILE_FORMAT " VXD"
#elif defined(WINCE)
    #define WD_FILE_FORMAT " DLL"
#else
    #define WD_FILE_FORMAT ""
#endif

#define WD_VER_STR  WD_PROD_NAME " v" WD_VERSION_STR " Jungo (c) 1997 - 2004 Build Date: " __DATE__ WD_CPU_SPEC WD_FILE_FORMAT

#if !defined(UNIX) && (defined(LINUX) || defined(SOLARIS) || defined(VXWORKS))
    #define UNIX
#endif

#if !defined(WIN32) && (defined(WINCE) || defined(WIN95) || defined(WINNT))
    #define WIN32
#endif

#if defined(_WIN32_WCE) && !defined(WINCE)
    #define WINCE
#endif

#if defined(_KERNEL) && !defined(__KERNEL__)
    #define __KERNEL__
#endif

#if defined( __KERNEL__) && !defined(_KERNEL)
    #define _KERNEL
#endif

#if !defined(WIN32) && !defined(WINCE) && !defined(UNIX)
    #define WIN32
#endif

#if  !defined(POWERPC) && defined(VXWORKS) && !defined(x86)
    #define POWERPC
#endif
#if !defined(_BIGENDIAN) && (defined (SPARC) || defined(POWERPC))
    #define _BIGENDIAN
#endif

#if defined(UNIX)
    #if !defined(__P_TYPES__)
        #if !defined(VXWORKS)
            typedef void VOID;
            typedef unsigned char UCHAR;
            typedef unsigned short USHORT;
            typedef unsigned int UINT;
            typedef unsigned long ULONG;
            typedef ULONG BOOL;
        #endif
        typedef void *PVOID;
        typedef unsigned char *PBYTE;
        typedef char CHAR;
        typedef char *PCHAR;
        typedef unsigned short *PWORD;
        typedef unsigned long DWORD, *PDWORD;
        typedef PVOID HANDLE;
    #endif
    #if !defined(__KERNEL__)
        #include <string.h>
        #include <ctype.h>
        #include <stdlib.h>
        #include <stdarg.h>
    #endif
    #define TRUE 1
    #define FALSE 0
    #define __cdecl
    #define WINAPI

    #if defined(__KERNEL__)
        #if defined(SOLARIS)
            #include <sys/conf.h>
            #include <sys/modctl.h>
            #include <sys/ksynch.h>
            #include <sys/cmn_err.h>
            #include <sys/types.h>
            #include <sys/file.h>
            #include <sys/errno.h>
            #include <sys/open.h>
            #include <sys/cred.h>
            #include <sys/kmem.h>
            #include <sys/devops.h>
            #include <sys/spl.h>
            #include <sys/varargs.h>
            #include <sys/time.h>
            #include <sys/proc.h>
            #include <sys/stat.h>
            #include <sys/ddi_impldefs.h>
            #include <sys/ddi_implfuncs.h>
            #include <sys/ddidmareq.h>
            #include <sys/promif.h>
            #include <sys/ddi.h>
            #include <sys/sunddi.h>
            #include <sys/stream.h>

            #ifdef u // solaris defines u in sys/user.h for imbicilic reasons.
                #undef u
            #endif

            #ifdef BYTE //defined in sys/promif.h
                #undef BYTE
            #endif
        #endif
    #else
        #include <unistd.h>
        #if defined(LINUX)
            #include <sys/ioctl.h> /* for BSD ioctl() */
            #include <unistd.h>
        #else
            #include <unistd.h> /* for SVR4 ioctl()*/
        #endif
        #if defined(VXWORKS)
            #include <vxWorks.h>
            #undef SPARC /* defined in vxworks.h */
            #include <string.h>
            #include <memLib.h>
            #include <stdlib.h>
            #include <taskLib.h>
            #include <ioLib.h>
            #include <iosLib.h>
            #include <taskLib.h>
            #include <semLib.h>
            #include <timers.h>
        #endif
        #include <sys/types.h>
        #include <sys/stat.h>
        #include <fcntl.h>
    #endif
    #if defined(SOLARIS)
        typedef uint64_t UINT64;
    #else
        typedef unsigned long long UINT64;
    #endif
#elif defined(WINCE)
    #include <windows.h>
    #include <winioctl.h>
    typedef char CHAR;
    typedef unsigned __int64 UINT64;
    #define perror(str) fprintf(stderr, "%s: error no. %d\n", (str), GetLastError())
#elif defined(WIN32)
    #if defined(__KERNEL__)
        int sprintf(char *buffer, const char *format, ...);
    #else
        #include <windows.h>
        #include <winioctl.h>
    #endif
    #if defined(__KERNEL__) && defined(WIN32)
        int sprintf(char *buffer, const char *format, ...);
    #endif
    typedef unsigned __int64 UINT64;
    #if defined(__KERNEL__) && defined(WIN95) && !defined(__KERPLUG__)
        #include "kdstdlib.h"
    #endif
#endif
#ifndef WINAPI
    #define WINAPI
#endif

#if !defined(_WINDEF_)
    typedef unsigned char BYTE;
    typedef unsigned short int WORD;
#endif

#if !defined(_BASETSD_H_)
    typedef unsigned int UINT32;
#endif

    // formatting for printing a 64bit variable
#if defined(UNIX)
    #define PRI64       "ll"
#elif defined(WIN32)
    #define PRI64       "I64"
#else
#endif

// formatting for printing a kernel pointer
#if defined(KERNEL_64BIT)
    #define KPRI PRI64
#else
    #define KPRI "l"
#endif


#if defined(SOLARIS) && defined(KERNEL_64BIT)
    typedef UINT64 KPTR;
#else
    #define KPTR DWORD
#endif

// IN WD_TRANSFER_CMD and WD_Transfer() DWORD stands for 32 bits and QWORD is 64 bit.
typedef enum
{
    CMD_NONE = 0,       // No command
    CMD_END = 1,        // End command

    RP_BYTE = 10,       // Read port byte
    RP_WORD = 11,       // Read port word
    RP_DWORD = 12,      // Read port dword
    WP_BYTE = 13,       // Write port byte
    WP_WORD = 14,       // Write port word
    WP_DWORD = 15,      // Write port dword
    RP_QWORD = 16,      // Read port qword
    WP_QWORD = 17,      // Write port qword
    

    RP_SBYTE = 20,      // Read port string byte
    RP_SWORD = 21,      // Read port string word
    RP_SDWORD = 22,     // Read port string dword
    WP_SBYTE = 23,      // Write port string byte
    WP_SWORD = 24,      // Write port string word
    WP_SDWORD = 25,     // Write port string dword
    RP_SQWORD = 26,      // Read port string qword
    WP_SQWORD = 27,      // Write port string qword

    RM_BYTE = 30,       // Read memory byte
    RM_WORD = 31,       // Read memory word
    RM_DWORD = 32,      // Read memory dword
    WM_BYTE = 33,       // Write memory byte
    WM_WORD = 34,       // Write memory word
    WM_DWORD = 35,      // Write memory dword
    RM_QWORD = 36,      // Read memory qword
    WM_QWORD = 37,      // Write memory qword

    RM_SBYTE = 40,      // Read memory string byte
    RM_SWORD = 41,      // Read memory string word
    RM_SDWORD = 42,     // Read memory string dword
    WM_SBYTE = 43,      // Write memory string byte
    WM_SWORD = 44,      // Write memory string word
    WM_SDWORD = 45,     // Write memory string dword
    RM_SQWORD = 46,     // Read memory string quad word
    WM_SQWORD = 47,     // Write memory string quad word
} WD_TRANSFER_CMD;

enum { WD_DMA_PAGES = 256 };

enum {
    DMA_KERNEL_BUFFER_ALLOC = 0x1, // The system allocates a contiguous buffer.
        // The user does not need to supply linear address.

    DMA_KBUF_BELOW_16M = 0x2, // If DMA_KERNEL_BUFFER_ALLOC is used,
        // this will make sure it is under 16M.

    DMA_LARGE_BUFFER = 0x4, // If DMA_LARGE_BUFFER is used,
        // the maximum number of pages are dwPages, and not
        // WD_DMA_PAGES. If you lock a user buffer (not a kernel
        // allocated buffer) that is larger than 1MB, then use this
        // option and allocate memory for pages.

    DMA_ALLOW_CACHE = 0x8,  // allow caching of the memory for contiguous memory 
        // allocation on Windows NT/2k/XP (not recommended!)

    DMA_KERNEL_ONLY_MAP = 0x10, // Only map to kernel, dont map to user-mode.
        // relevant with DMA_KERNEL_BUFFER_ALLOC flag only

    DMA_READ_FROM_DEVICE = 0x20, // memory pages are locked to be written to (read from device)
    
    DMA_WRITE_TO_DEVICE = 0x40, // memory pages are locked to be read from (write to device)
};

enum {
    WD_MATCH_EXCLUDE = 0x1, // exclude if there is a match
};

enum {
    WD_CPCI_PNP_SUPPORT = 0x1, // set this flag in case we want to use OS PnP support
};

typedef struct
{
    KPTR pPhysicalAddr;   // Physical address of page.
    DWORD dwBytes;          // Size of page.
} WD_DMA_PAGE, WD_DMA_PAGE_V30;

typedef struct
{
    DWORD hDma;             // Handle of dma buffer.
    PVOID pUserAddr;        // Beginning of buffer.
    KPTR  pKernelAddr;      // Kernel mapping of kernel allocated buffer
    DWORD dwBytes;          // Size of buffer.
    DWORD dwOptions;        // Allocation options:
                            // DMA_KERNEL_BUFFER_ALLOC, DMA_KBUF_BELOW_16M, DMA_LARGE_BUFFER
                            // DMA_ALLOW_CACHE, DMA_KERNEL_ONLY_MAP,
                            // DMA_WRITE_TO_DEVICE
    DWORD dwPages;          // Number of pages in buffer.
    DWORD hCard;            // Handle of relevant card as received from WD_CardRegister()
    WD_DMA_PAGE Page[WD_DMA_PAGES];
} WD_DMA, WD_DMA_V30;

typedef struct
{
    KPTR dwPort;       // IO port for transfer or kernel memory address.
    DWORD cmdTrans;    // Transfer command WD_TRANSFER_CMD.

⌨️ 快捷键说明

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