一个开放源码的bt848/878驱动程序的源码

源代码在线查看: cpprt.cpp

软件大小: 604 K
上传用户: ywq9089
关键词: 848 878 bt 开放源码
下载地址: 免注册下载 普通下载 VIP

相关代码

				
				#include "Debug.hpp"
				#include "CppRt.hpp"
				
				/**************************************************************************\
				* Module Name: ourcrt.cpp
				*
				* This file contains magic that prevents the c runtimes from being 
				* linked in.  If they are linked in, the driver will not load.
				* This primarily comes into play when your driver is C++.
				*
				\**************************************************************************/
				
				extern "C" const int _fltused = 0;
				
				/**************************************************************************\
				* int __cdecl _purecall
				*
				* This function serves to avoid linking the CRT library for C++ code.
				*
				* History:
				*  24-Aug-1998 -by- Tom Zakrajsek [tomz]
				*   Documented it.
				*
				\**************************************************************************/
				
				int __cdecl _purecall( void )
				{
					ERROR(("purecall was called!\n"));
					return( FALSE );
				}
				
				VOID InitCppRT(void) {}
				VOID TermCppRT(void) {}
				
				//////////////////////////////////////////////////////////////////
				// memory allocation operators
				
				void * _cdecl operator new( size_t sz )
				{
				   PVOID p = ExAllocatePoolWithTag( NonPagedPool, sz , '848b' );
				   DUMP(("Alloc %x got = %x\n", sz, p ) );
				   return p;
				}
				
				void _cdecl operator delete( void *p )
				{
				   DUMP(("deleting = %x\n", p ) );
				   if ( p ) {
				      ExFreePool( p );
				   }
				}
				
				#ifndef VC_4X_BUILD
				// In VC versions below 5.0, the following two cases are covered by the 
				// new and delete defined above. The following syntax is invalid in pre-
				// 5.0 versions.
				void * _cdecl operator new[]( size_t sz )  
				{
				   PVOID p = ExAllocatePoolWithTag( NonPagedPool, sz , '848b' );
				   DUMP(("Alloc %x got = %x\n", sz, p ) );
				   return p;
				}
				
				void _cdecl operator delete []( void *p )
				{
				   DUMP(( "deleting [] = %x\n", p ) );
				   if ( p ) {
				      ExFreePool( p );
				   }
				}
				#endif
				
				////////////////////////////////////////////////////////////////////
				// Delay routines
				
				// Delay function in us
				void udelay( DWORD time ) // delay in us.
				{
					LARGE_INTEGER tm;
					tm.QuadPart = - int( time * 10); // Relative mode
					KeDelayExecutionThread( KernelMode , FALSE , &tm );
				}
				
				// Delay function in ms
				void mdelay( DWORD time )
				{
					LARGE_INTEGER tm;
					tm.QuadPart = - int( time * 10000 ); // Relative mode
					KeDelayExecutionThread( KernelMode , FALSE , &tm );
				}
				
				// GetTickCount in milliseconds
				ULONG GetTickCountInMs( void )
				{
					LARGE_INTEGER t;
					KeQuerySystemTime(&t);
					return (ULONG)( t.QuadPart / 10000 );
				}
				
				void busywaitus( DWORD time ) 
				{
					// First delay in multiples of 32 us (a			

相关资源