ddk_map.c
来自「WinCE 3.0 BSP, 包含Inter SA1110, Intel_815」· C语言 代码 · 共 81 行
C
81 行
/*++
THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
PARTICULAR PURPOSE.
Copyright (c) 1995-1998 Microsoft Corporation
Module Name:
ddk_map.c
Abstract:
WINCE device driver support routines. This file supports
a very minimal subset of the routines from ntddk.h
Functions:
Notes:
--*/
#include <windows.h>
#include <types.h>
#include "ceddk.h"
#define VERBOSE 0
// LAM - platform\cepc\wdmhal\wdmhal.c
PVOID
MmMapIoSpace (
IN PHYSICAL_ADDRESS PhysicalAddress,
IN ULONG NumberOfBytes,
IN BOOLEAN CacheEnable
)
{
PVOID pVirtualAddress;
ULONG SourcePhys;
ULONG SourceSize;
BOOL bSuccess;
//
// Page align source and adjust size to compensate
//
//RETAILMSG (1, (TEXT("ddk_map.c:MmMapIoSpace():: Phy = 0x%x - NoOfBytes = %d - Cache = %d\r\n"),
// PhysicalAddress.LowPart, NumberOfBytes, CacheEnable));
SourcePhys = PhysicalAddress.LowPart & ~(PAGE_SIZE - 1);
SourceSize = NumberOfBytes + (PhysicalAddress.LowPart & (PAGE_SIZE - 1));
pVirtualAddress = VirtualAlloc(0, SourceSize, MEM_RESERVE, PAGE_NOACCESS);
if ( pVirtualAddress != NULL ) {
bSuccess = VirtualCopy(
pVirtualAddress, (PVOID)(SourcePhys >> 8), SourceSize,
PAGE_PHYSICAL | PAGE_READWRITE | (CacheEnable ? 0 : PAGE_NOCACHE));
if ( bSuccess ) {
(ULONG)pVirtualAddress += PhysicalAddress.LowPart & (PAGE_SIZE - 1);
} else {
VirtualFree(pVirtualAddress, 0, MEM_RELEASE);
pVirtualAddress = NULL;
}
}
return (pVirtualAddress);
}
VOID
MmUnmapIoSpace (
IN PVOID BaseAddress,
IN ULONG NumberOfBytes
)
{
VirtualFree((PVOID)((ULONG)BaseAddress & ~(PAGE_SIZE - 1)), 0, MEM_RELEASE);
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?