attrib.c

来自「Windows CE 6.0 BSP for the Beagle Board.」· C语言 代码 · 共 85 行

C
85
字号
/*
================================================================================
*             Texas Instruments OMAP(TM) Platform Software
* (c) Copyright Texas Instruments, Incorporated. All Rights Reserved.
*
* Use of this software is controlled by the terms and conditions found
* in the license agreement under which this software has been supplied.
*
================================================================================
*/

//------------------------------------------------------------------------------
//
//  File:  attrib.c
//
//  This file implements OALSetMemoryAttributes function 
//
#include <windows.h>
#include <nkintr.h>
#include <ceddk.h>
#include <oal.h>


//
//  Defines
//

#define CACHE_MASK              0x0C
#define CACHE_WRITETHRU         0x08


//
//  Functions
//

//
//  Globals
//


//------------------------------------------------------------------------------
//
//  Function:  OALSetMemoryAttributes
//
//  This function supports setting memory attributes via the CeSetMemoryAttributes
//  The only attributes supported are:
//
//      PAGE_WRITECOMBINE -     Maps to Cache Write Thru / Buffered / No write allocate
//
BOOL 
OALSetMemoryAttributes(
    LPVOID pVirtAddr,           // Virtual address of region
    LPVOID pPhysAddrShifted,    // PhysicalAddress >> 8 (to support up to 40 bit address)
    DWORD  cbSize,              // Size of the region
    DWORD  dwAttributes         // attributes to be set
    )
{
    BOOL    bResult = FALSE;

    OALMSG(OAL_MEMORY&&OAL_VERBOSE, (
        L"+OALSetMemoryAttributes()\r\n"
    ));


    //  Set the specific atrributes for the given address
    switch( dwAttributes )
    {
        case PAGE_WRITECOMBINE:
            //  Set the write combine attributes
            bResult = NKVirtualSetAttributes(pVirtAddr, cbSize, CACHE_WRITETHRU, CACHE_MASK, &dwAttributes );
            break;
            
        default:
            //  Ignore
            break;            
    }

    OALMSG(OAL_MEMORY&&OAL_VERBOSE, (L"-OALSetMemoryAttributes\r\n"));
    
    return bResult;
}

//------------------------------------------------------------------------------

⌨️ 快捷键说明

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