vcache.h
来自「用于查询PC机上的USB端口是否有设备挂接上」· C头文件 代码 · 共 661 行 · 第 1/2 页
H
661 行
// service does not preserve the values of ebx, ecx, & ebp across the call.
//
// Entry (ah) = FSD ID
// (edx) = function to call for each buffer
// (ebx, ecx, ebp) = passed to function unchanged
// Exit none
// Uses all
//** VCache_GetStats - return cache statistics
//
// VCache_GetStats returns some statistics used by the memory manager
// to tune how much memory is available for VCache and how much
// for paging. When the statistics are queried, the counts are cleared.
// Therefore, if anyone other than the memory manager uses this service
// system performance will suffer.
//
// Entry none
// Exit (ebx) = number of cache misses to one of the last 26 discarded
// cache blocks since the last call to VCache_GetStats.
// (ecx) = number of cache hits to one of the last 26 LRU cache
// blocks since the last call to VCache_GetStats.
// (edx) = base address of range reserved for vcache
// (edi) = number of cache blocks discarded since the last call
// to VCache_GetStats
// Uses ebx, ecx, edi
//** VCache_Deregister - deregister an FSD with cache
//
// An FSD must call this function to tell VCACHE that it no
// longer needs any cache resources.
//
// We do not recycle deregisterd Cache IDs because we do
// not want to give out the same ID twice.
//
// ENTRY (AH) = FSD ID
//
// EXIT NONE
//
// USES EAX, EBX, ECX, EDX, EDI, ESI, Flags
//** VCache_AdjustMinimum - adjust minimum buffer quota
//
// This function adjusts the client's minimum buffer quota.
//
// ENTRY (AH) = FSD ID
// (ECX) = new buffer quota
//
// EXIT Carry clear
// Adjustment made
// Carry set
// Adjustment failed
//
// USES EAX, EBX, ECX, EDX, EDI, ESI, Flags
//** VCache_SwapBuffers - swap a pair of cache block's buffer
//
// Given two cache block handles, this procedure
// swaps the buffers associated with the handles.
// The blocks must be owned by the same client and
// they must both be held.
//
// ENTRY (ESI) = fist cache handle
// (EDI) = second cache handle
//
// EXIT Carry clear
// Swap performed
// Carry set
// Swap not performed
//
// USES EAX, Flags
//**** Debug services ***
//** VCache_TestHandle - test buffer handle
//
// Verifies that ESI is a valid cache block handle.
//
// Entry (ah) = FSD ID
// (esi) = cache block handle
// Exit none
// Uses none
//** VCache_GetDebugWorkArea - get debug work area
//
// This routine returns the address and size of the specified
// buffer's debug work area.
//
// ENTRY (esi) = cache block handle
//
// EXIT (EAX) = work area address
// (ECX) = work area size (0 if none)
//
// USES EAX, ECX, Flags
//**** End of debug services ***
//* Offsets of fields in the cache block handle:
/*ASM
B_FSKey1 equ dword ptr 08H
B_FSKey2 equ dword ptr 0CH
B_BufPtr equ dword ptr 10H
B_FSDData equ 014H
SizeFSDData equ (7*4) ; seven dwords for FSD use
B_Dirty equ byte ptr 032H
*/
/*XLATOFF*/
typedef struct _VCACHE_BLOCK {
DWORD Reserved1[ 2 ];
DWORD FSKey1;
DWORD FSKey2;
PVOID BufPtr;
DWORD FSData[ 7 ];
WORD Reserved2;
BYTE Dirty;
} VCACHE_BLOCK, *PVCACHE_BLOCK;
/*XLATON*/
// Size of VCache buffers (one page):
#define VCACHE_BUFSIZE 4096 // 80x86 uses 4K pages
//**** Services to be used by the memory manager only ****
//** VCache_RelinquishPage - return a page to the memory manager
//
// This routine tries to find a page it can return to the
// memory manager. In general it will only fail if all pages
// are currently reserved, held or dirty.
//
// Entry none
// Exit (eax) = linear address of page or 0
// Uses flags
//** VCache_UseThisPage - a page is given to vcache
//
// By virtue of this routine the memory manager makes a new page
// available to vcache.
//
// Entry (eax) = address of page
// Exit none
// Uses flags
//**** End of services reserved for memory manager
/*XLATOFF*/
#pragma warning (disable:4035) // turn off "no return value"
//** The 'Lookup Cache' is a separate caching subsystem that allows
// arbitrary keys to be associated with arbitrary data. This data
// is stored in the registry and persistent. Note that the
// caches themselves live in locked memory, the registry is used
// as a backup store and is updated periodically as a background
// process - so _VCache_Lookup and _VCache_UpdateLookup can be called
// at event time.
//** VCache_CreateLookupCache
//
// Creates a new (or opens an existing) lookup cache.
//
// Entry:
// lpszName - name of the lookup cache;
// must be a legal registry key name.
// nMaxElems - maximum number of elements in the cache. Once this
// limit has been reached, the addition of new keys
// will result in old keys being aged out, LRU style.
// Flags - reserved, MBZ.
// phlookup - pointer to DWORD that will receive the opened cache
// handle.
// Exit:
// eax - zero on success, or an appropriate Win32 error value
DWORD VXDINLINE
_VCache_CreateLookupCache(char *lpszName,
DWORD nMaxElems,
DWORD Flags,
HLOOKUP *phlookup)
{
unsigned long retval;
_asm push phlookup
_asm push Flags
_asm push nMaxElems
_asm push lpszName
VxDCall( _VCache_CreateLookupCache )
_asm add esp, 4*4
_asm mov retval, eax
return retval;
}
//** _VCache_CloseLookupCache
//
// Closes an open lookup cache.
//
// Exit:
// eax - zero on success, or an appropriate Win32 error value
unsigned long VXDINLINE
_VCache_CloseLookupCache(HLOOKUP _hnd_)
{
unsigned long retval;
_asm mov eax, _hnd_
_asm push eax
VxDCall( _VCache_CloseLookupCache )
_asm add esp, 4
_asm mov retval, eax
return retval;
}
//** _VCache_DeleteLookupCache
//
// Deletes a lookup cache
//
// Entry:
// _hnd_ - handle of previously opened cache.
//
// Exit:
// eax - zero on success, or an appropriate Win32 error value
unsigned long VXDINLINE
_VCache_DeleteLookupCache(char *lpszName)
{
unsigned long retval;
_asm push lpszName
VxDCall( _VCache_DeleteLookupCache )
_asm add esp, 4
_asm mov retval, eax
return retval;
}
//** _VCache_Lookup
//
// Given an existing key value, moves that key to the head of the cache's
// LRU list and retrieves the associated data.
//
// Entry:
// hLookup - handle of previously opened cache
// keylen - length of supplied key value
// pKey - pointer to key value
// datalen - length of destination data buffer
// pData - pointer to destination data buffer
//
// Exit:
// eax - zero on success, or an appropriate Win32 error value
unsigned long VXDINLINE
_VCache_Lookup(HLOOKUP hLookup, unsigned long keylen, void *pKey, unsigned long *pdatalen,void *pData)
{
unsigned long retval;
_asm push pData
_asm push pdatalen
_asm push pKey
_asm push keylen
_asm push hLookup
VxDCall( _VCache_Lookup )
_asm add esp, 5*4
_asm mov retval, eax
return retval;
}
//** _VCache_UpdateLookup
//
// If an existing key is present, its associated data is updated with
// pData. Otherwise a new key entry is generated, aging the LRU entry if
// the cache is full.
//
// Entry:
// hLookup - handle of previously opened cache
// keylen - length of supplied key value
// pKey - pointer to key value
// datalen - length of destination data buffer
// pData - pointer to destination data buffer
//
// Exit:
// eax - zero on success, or an appropriate Win32 error value
unsigned long VXDINLINE
_VCache_UpdateLookup(HLOOKUP hLookup, unsigned long keylen, void *pKey, unsigned long datalen, void *pData)
{
unsigned long retval;
_asm push pData
_asm push datalen
_asm push pKey
_asm push keylen
_asm push hLookup
VxDCall( _VCache_UpdateLookup )
_asm add esp, 5*4
_asm mov retval, eax
return retval;
}
#ifdef MAPCACHE
//** VCache_UnmapCacheBlock - unmap the cache block previously mapped by the memory manager
//
// UnmapCacheBlock returns with CARRY indicating the state of the unmap operation
//
// Entry (esi) = cache block handle
// Exit Carry clr - indicates cache block was unmapped
// Carry set - indicates cache block was NOT unmapped
//
// A failure due to the cache block handle being invalid or a failure
// due to the fact that a VCACHE client has not registered a callback
// routine to perform the unmapping.
//
// Uses eax,flags
#endif
#pragma warning (default:4035) // default "no return value"
#pragma warning (default:4003) // not enough params
/*XLATON*/
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?