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

📄 deviceinfo.c

📁 Lido PXA270平台开发板的最新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:  deviceinfo.c
//
//  This file implements the IOCTL_HAL_GET_DEVICE_INFO handler.
//
#include <windows.h>
#include <bldver.h>
#include <oal.h>


//------------------------------------------------------------------------------
//
//  Function:  OALIoCtlGetDeviceInfo
//
//  Implements the IOCTL_HAL_GET_DEVICE_INFO handler
//
BOOL OALIoCtlHalGetDeviceInfo( 
    UINT32 code, VOID *pInpBuffer, UINT32 inpSize, VOID *pOutBuffer, 
    UINT32 outSize, UINT32 *pOutSize
) {
    BOOL rc = FALSE;
    UINT32 length;
    PLATFORMVERSION *pVersion = (PLATFORMVERSION*)pOutBuffer;


    OALMSG(OAL_IOCTL&&OAL_FUNC, (L"+OALIoCtlHalGetDeviceInfo(...)\r\n"));

    // Validate inputs
    if (pInpBuffer == NULL || inpSize < sizeof(UINT32)) {
        NKSetLastError(ERROR_INVALID_PARAMETER);
        OALMSG(OAL_ERROR, (
            L"ERROR: OALIoCtlHalGetDeviceInfo: Invalid parameter\r\n"
        ));
        goto cleanUp;
    }

    // Process according to input request
    switch (*(UINT32*)pInpBuffer) {
    case SPI_GETPLATFORMTYPE:
        // Validate output buffer size
        length = (NKwcslen(g_oalIoCtlPlatformType) + 1) * sizeof(WCHAR);
        // Return required size
        if (pOutSize != NULL) *pOutSize = length;
        // If there isn't output buffer or it is small return error
        if (pOutBuffer == NULL || outSize < length) {
            NKSetLastError(ERROR_INSUFFICIENT_BUFFER);
            OALMSG(OAL_WARN, (
                L"WARN: OALIoCtlHalGetDeviceInfo: Insufficient buffer\r\n"
            ));
            break;
        }
        // Copy requested data to caller's buffer, set output length
        memcpy(pOutBuffer, g_oalIoCtlPlatformType, length);
        rc = TRUE;
        break;

    case SPI_GETOEMINFO:
        // Validate output buffer size
        length = (NKwcslen(g_oalIoCtlPlatformOEM) + 1) * sizeof(WCHAR);
        // Return required size
        if (pOutSize != NULL) *pOutSize = length;
        // If there isn't output buffer or it is small return error
        if (pOutBuffer == NULL || outSize < length) {
            NKSetLastError(ERROR_INSUFFICIENT_BUFFER);
            OALMSG(OAL_WARN, (
                L"WARN: OALIoCtlHalGetDeviceInfo: Insufficient buffer\r\n"
            ));
            break;
        }
        // Copy requested data to caller's buffer, set output length
        memcpy(pOutBuffer, g_oalIoCtlPlatformOEM, length);
        rc = TRUE;
        break;

    case SPI_GETPLATFORMVERSION:
        // Return required size
        if (pOutSize != NULL) *pOutSize = sizeof(PLATFORMVERSION);
        if (outSize < sizeof(PLATFORMVERSION)) {
            NKSetLastError(ERROR_INSUFFICIENT_BUFFER);
            OALMSG(OAL_WARN, (
                L"WARN: OALIoCtlHalGetDeviceInfo: Insufficient buffer\r\n"
            ));
            break;
        }
        pVersion->dwMajor = CE_MAJOR_VER;
        pVersion->dwMinor = CE_MINOR_VER;
        rc = TRUE;
        break;
    default:
        OALMSG(OAL_ERROR, (
            L"ERROR: OALIoCtlHalGetDeviceInfo: Invalid request\r\n"
        ));
        break;
    }

cleanUp:
    // Indicate status
    OALMSG(OAL_FUNC&&OAL_IOCTL, (
        L"-OALIoCtlHalGetDeviceInfo(rc = %d)\r\n", rc
    ));
    return rc;
}

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

⌨️ 快捷键说明

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