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

📄 memory.c

📁 WinCE 3.0 BSP, 包含Inter SA1110, Intel_815E, Advantech_PCM9574 等
💻 C
字号:
/*++
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, 1996, 1997  Microsoft Corporation
Copyright (c) 1998  NEC Electronics Inc.

Module Name:  

    memory.c

Abstract:

    This file implements the PCMCIA platform dependent memory access functions.

Functions:

    PDCardReadAttrByte()
    PDCardWriteAttrByte()
    PDCardReadCmnByte()
    PDCardWriteCmnByte()
    PDCardReadIOByte()
    PDCardWriteIOByte()

Notes:
    
    These functions are only used by the PCMCIA MDD.  There are no memory
    access functions exported by PCMCIA card services.

--*/

#include <windows.h>
#include <types.h>
#include <cardserv.h>
#include <sockserv.h>
#include <sockpd.h>



//
// @doc DRIVERS
//
// @topic PC card memory | In the memory access functions the uOffset parameter is treated
// as an offset into the specific memory space in order to hide the details of how the data
// is spaced.
//
// To ensure that separate threads will not end up accessing the wrong memory space the PCMCIA
// socket controller should implement memory windows that when addressed assert the correct control
// signals to access the desired memory space.  Then separate threads can access PC card
// memory directly.  On memory mapped architectures, independent addressing can
// be achieved by supplying three separate physical regions for the three PCMCIA
// memory spaces (common memory, attribute memory and I/O memory).
//
// @xref <f PDCardReadAttrByte> <f PDCardWriteAttrByte> <f PDCardReadCmnByte> <f PDCardWriteCmnByte>
//       <f PDCardReadIOByte> <f PDCardWriteIOByte>
//

//
// PDCardReadAttrByte
//
// @func    UINT8 | PDCardReadAttrByte | Read the byte at the specified offset in a card's
//                                       attribute memory space.
// @rdesc   Returns the byte read.
//
// @comm    This function should be called within a try/except statement in case the
// card is removed and the memory access results in a fault.  Card services calls
// PDCardReadAttrByte within a try/except clause in its <f CardReadAttrByte> function.
//
// @xref <f PDCardWriteAttrByte> <f PDCardReadCmnByte> <f PDCardWriteCmnByte>
//       <f PDCardReadIOByte> <f PDCardWriteIOByte>
//
UINT8
PDCardReadAttrByte(
    PVOID pCardMem,     // @parm Pointer to PC card attribute memory obtained from <f CardMapMemory>
    UINT32 uOffset      // @parm Offset into card's attribute memory
    )
{
    UINT8 uByte;
    PUCHAR pAttr = (PUCHAR)pCardMem;

    pAttr += uOffset * 2;
    uByte = *pAttr;
    return uByte;
}


//
// PDCardWriteAttrByte
//
// @func    VOID | PDCardWriteAttrByte | Write a byte to the specified offset in a card's
//                                       attribute memory space.
//
// @comm    This function should be called within a try/except statement in case the
// card is removed and the memory access results in a fault.  Card services calls
// PDCardWriteAttrByte within a try/except clause in its <f CardWriteAttrByte> function.
//
// @xref <f PDCardReadAttrByte> <f PDCardReadCmnByte> <f PDCardWriteCmnByte>
//       <f PDCardReadIOByte> <f PDCardWriteIOByte>
//
VOID
PDCardWriteAttrByte(
    PVOID pCardMem,     // @parm Pointer to PC card attribute memory obtained from <f CardMapMemory>
    UINT32 uOffset,     // @parm Offset into card's attribute memory
    UINT8 uByte         // @parm Byte to write
    )
{
    PUCHAR pAttr = (PUCHAR)pCardMem;

    pAttr += uOffset * 2;
    *pAttr = uByte;
}


//
// PDCardReadCmnByte
//
// @func    UINT8 | PDCardReadCmnByte | Read the byte at the specified offset in a card's
//                                       common memory space.
// @rdesc   Returns the byte read.
//
// @comm    This function should be called within a try/except statement in case the
// card is removed and the memory access results in a fault.  Card services calls
// PDCardReadCmnByte within a try/except clause in its <f CardReadCmnByte> function.
//
// @xref <f PDCardReadAttrByte> <f PDCardWriteAttrByte> <f PDCardWriteCmnByte>
//       <f PDCardReadIOByte> <f PDCardWriteIOByte>
//
UINT8
PDCardReadCmnByte(
    PVOID pCardMem,     // @parm Pointer to PC card common memory obtained from <f CardMapMemory>
    UINT32 uOffset
    )
{
    UINT8 uByte;
    PUCHAR pCmn = (PUCHAR)pCardMem;

    pCmn += uOffset;
    uByte = *pCmn;
    return uByte;
}


//
// PDCardWriteCmnByte
//
// @func    VOID | PDCardWriteCmnByte | Write a byte to the specified offset in a card's
//                                       common memory space.
//
// @comm    This function should be called within a try/except statement in case the
// card is removed and the memory access results in a fault.  Card services calls
// PDCardWriteCmnByte within a try/except clause in its <f CardWriteCmnByte> function.
//
// @xref <f PDCardReadAttrByte> <f PDCardWriteAttrByte> <f PDCardReadCmnByte>
//       <f PDCardReadIOByte> <f PDCardWriteIOByte>
//
VOID
PDCardWriteCmnByte(
    PVOID pCardMem,     // @parm Pointer to PC card common memory obtained from <f CardMapMemory>
    UINT32 uOffset,     // @parm Offset into card's common memory
    UINT8 uByte         // @parm Byte to write
    )
{
    PUCHAR pCmn = (PUCHAR)pCardMem;

    pCmn += uOffset;
    *pCmn = uByte;
}


//
// PDCardReadIOByte
//
// @func    UINT8 | PDCardReadIOByte | Read the byte at the specified offset in a card's
//                                       I/O space.
// @rdesc   Returns the byte read.
//
// @comm    This function should be called within a try/except statement in case the
// card is removed and the memory access results in a fault.  Card services calls
// PDCardReadIOByte within a try/except clause in its <f CardReadIOByte> function.
//
// @xref <f PDCardReadAttrByte> <f PDCardWriteAttrByte> <f PDCardWriteCmnByte>
//       <f PDCardReadCmnByte> <f PDCardWriteIOByte>
//
UINT8
PDCardReadIOByte(
    PVOID pCardMem,     // @parm Pointer to PC card I/O space obtained from <f CardMapMemory>
    UINT32 uOffset
    )
{
    UINT8 uByte;
    PUCHAR pIO = (PUCHAR)pCardMem;

    pIO += uOffset;
    uByte = *pIO;
    return uByte;
}


//
// PDCardWriteIOByte
//
// @func    VOID | PDCardWriteIOByte | Write a byte to the specified offset in a card's
//                                       I/O space.
//
// @comm    This function should be called within a try/except statement in case the
// card is removed and the memory access results in a fault.  Card services calls
// PDCardWriteIOByte within a try/except clause in its <f CardWriteIOByte> function.
//
// @xref <f PDCardReadAttrByte> <f PDCardWriteAttrByte> <f PDCardWriteCmnByte>
//       <f PDCardReadCmnByte> <f PDCardReadIOByte>
//
VOID
PDCardWriteIOByte(
    PVOID pCardMem,     // @parm Pointer to PC card I/O space obtained from <f CardMapMemory>
    UINT32 uOffset,     // @parm Offset into card's I/O space
    UINT8 uByte         // @parm Byte to write
    )
{
    PUCHAR pIO = (PUCHAR)pCardMem;

    pIO += uOffset;
    *pIO = uByte;
}

⌨️ 快捷键说明

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