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

📄 ddk_map.c

📁 WinCE 3.0 BSP, 包含Inter SA1110, Intel_815E, Advantech_PCM9574 等
💻 C
字号:
/* -*-C-*-
 *
 * $Revision: 1.1 $
 *   $Author: kwelton $
 *     $Date: 2000/04/13 22:20:14 $
 *
 *  Module Name:   ceddk.c
 *
 *  Abstract:
 *
 *     WINCE device driver support routines.  This file supports
 *     a very minimal subset of the routines from ntddk.h
 *
 * 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
 * Copyright (c) 2000 ARM Limited
 * All Rights Reserved
 */

#include <windows.h>
#include <types.h>
#include "ceddk.h"

// LAM - platform\cepc\wdmhal\wdmhal.c
PVOID MmMapIoSpace (PHYSICAL_ADDRESS PhysicalAddress, ULONG NumberOfBytes,
                    BOOLEAN CacheEnable)
{
    PVOID   pVirtualAddress;
    ULONG   SourcePhys;
    ULONG   SourceSize;
    BOOL    bSuccess;

    //
    // Page align source and adjust size to compensate
    //
    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, SourceSize, MEM_RELEASE);
            pVirtualAddress = NULL;
        }
    }

    return pVirtualAddress;
}

VOID MmUnmapIoSpace (PVOID BaseAddress, ULONG NumberOfBytes)
{
    ULONG SourceSize;

#ifdef TODO
    // Need to account for page alignment issues
    SourceSize = NumberOfBytes + (PhysicalAddress.LowPart & (PAGE_SIZE - 1));
#else
    SourceSize = NumberOfBytes;
#endif

    VirtualFree(BaseAddress, SourceSize, MEM_RELEASE);
}


/* EOF ddk_map.c */

⌨️ 快捷键说明

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