?? virtualalloccopy.c
字號:
//
// Copyright (c) Chrontel Inc. All rights reserved.
//
//
// Use of this source code is subject to the terms of the Chrontel end-user
// license agreement (EULA) under which you licensed this SOFTWARE PRODUCT.
// If you did not accept the terms of the EULA, you are not authorized to use
// this source code. For a copy of the EULA, please see the LICENSE.RTF on your
// install media.
//
/*++
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.
Module Name:
VirtualAllocCopy.c
Abstract:
Mapping physical memory & register to virtual memory under Windows CE
Revision:
11/11/02 Created by Roger Yu.
Notes:
--*/
#include <windows.h>
#include <ceddk.h>
#include <devload.h>
#include <winreg.h>
#include "chrontel.h"
#define PHY_PAGE_SIZE 0x1000
#define ALIGNMENT_MASK (PHY_PAGE_SIZE-1)
PVOID VirtualAllocCopy(unsigned size,PVOID *vpBase,PVOID pPhysicalAddress)
{
PVOID ptr;
unsigned offset;
offset = (unsigned)pPhysicalAddress & ALIGNMENT_MASK;
size +=offset ? PHY_PAGE_SIZE : 0;
*vpBase = NULL;
ptr = VirtualAlloc(0,size,MEM_RESERVE,PAGE_NOACCESS);
if (ptr == NULL) {
ERRORMSG(1,(TEXT("VirtualAlloc [0x%x] failed : size=0x%x, (0x%x)\r\n"),
pPhysicalAddress,size,GetLastError()));
return(0);
}
if (!wrapVirtualCopy((PVOID)ptr,(PVOID)((unsigned)pPhysicalAddress - offset),size,PAGE_READWRITE|PAGE_NOCACHE)) {
ERRORMSG(1,(TEXT("VirtualCopy [0x%x] failed to addr=0x%x, offset=0x%x(0x%x)\r\n"),(unsigned)pPhysicalAddress, ptr, offset,GetLastError()));
return(0);
}
*vpBase = ptr;
return((PVOID)((PBYTE)ptr+offset));
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -