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

📄 pcihelp_x86.c

📁 LX 800 WindowsCE 6.0 BSP
💻 C
字号:
//
// Copyright (c) Microsoft Corporation.  All rights reserved.
//
//
// Use of this source code is subject to the terms of the Microsoft 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.
//
//------------------------------------------------------------------------------
//
//  File:  id.c
//
//  This file implements helper PCI bus functions.
//
#include <windows.h>
#include <ceddk.h>
#include <oal.h>
#include <nkintr.h>

ULONG PCIReadBusData(IN ULONG BusNumber, IN ULONG DeviceNumber, IN ULONG FunctionNumber, OUT PVOID Buffer, IN ULONG Offset, IN ULONG Length);
ULONG PCIWriteBusData(IN ULONG BusNumber, IN ULONG DeviceNumber, IN ULONG FunctionNumber, IN PVOID Buffer, IN ULONG Offset, IN ULONG Length);
void printPCIConfig(PCI_COMMON_CONFIG* config);

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

UINT32 OALPCIGetId(UINT32 busId, OAL_PCI_LOCATION pciLoc)
{
    // stub function - x86 doesn't use this
    return 0;
}

//------------------------------------------------------------------------------
//
//  Function:  OALPCICfgRead
//
//  This function reads PCI configuration space at location specified by pciLoc.
//  This routine is hardware dependend and in most cases it will be implemented
//  in SoC library or it will platform specific.
//
UINT32 OALPCICfgRead(
   UINT32 busId, OAL_PCI_LOCATION pciLoc, UINT32 offset, UINT32 size,
   VOID *pData
)
{
    OAL_DDK_PARAMS params;

    memset(pData, 0xFF, size);
    
    params.function = IOCTL_OAL_READBUSDATA;
    params.rc = 0;
    params.busData.devLoc.BusNumber = busId;
    params.busData.devLoc.LogicalLoc = pciLoc.logicalLoc;
    params.busData.offset = offset;
    params.busData.length = size;
    params.busData.pBuffer = pData;

    if (!OEMIoControl(
        IOCTL_HAL_DDK_CALL, &params, sizeof(params), NULL, 0, NULL
    ) || !params.rc) return FALSE;

    return params.rc;
}

//------------------------------------------------------------------------------
//
//  Function:  OALPCICfgWrite
//
//  This function write PCI configuration space at location specified by pciLoc.
//  This routine is hardware dependend and in most cases it will be implemented
//  in SoC library or it will be platform specific.
//
UINT32 OALPCICfgWrite(
    UINT32 busId, OAL_PCI_LOCATION pciLoc, UINT32 offset, UINT32 size,
    VOID *pData
)
{
    OAL_DDK_PARAMS params;

    params.function = IOCTL_OAL_WRITEBUSDATA;
    params.rc = 0;
    params.busData.devLoc.BusNumber = busId;
    params.busData.devLoc.LogicalLoc = pciLoc.logicalLoc;
    params.busData.offset = offset;
    params.busData.length = size;
    params.busData.pBuffer = pData;

    if (!OEMIoControl(
        IOCTL_HAL_DDK_CALL, &params, sizeof(params), NULL, 0, NULL
    ) || !params.rc) return FALSE;

    return params.rc;
}

⌨️ 快捷键说明

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