zoukankan      html  css  js  c++  java
  • KernelIoControl和OEMIoControl的分析和使用(作者:wogoyixikexie@gliet)

    KernelIoControl和OEMIoControl的分析和使用(作者:wogoyixikexie@gliet)

    对于KernelIoControl这个函数我们并不陌生,在2440 5.0BSP当中,这个函数在很多驱动中出现了,主要是用来申请中断,比如下面

    BOOL RetVal = KernelIoControl( IOCTL_HAL_REQUEST_SYSINTR,
                                       &Irq,
                                       sizeof( Irq ),
                                       pSysIntr,
                                       sizeof( *pSysIntr ),
                                       NULL );

    -------------------其实他的作用远远不止申请/释放中断那么简单,下面来看看PB的帮助文档。

    This function provides the kernel with a generic I/O control for carrying out I/O operations.

    BOOL KernelIoControl( DWORD dwIoControlCode,LPVOID lpInBuf,DWORD nInBufSize,LPVOID lpOutBuf,DWORD nOutBufSize,LPDWORD lpBytesReturned );

    对于这个函数的参数,非常类似EVC中的DeviceIoControl,从说明可以了解参数的使用方法。

    Parameters

    dwIoControlCode
    [in] I/O control code, which should support the OAL I/O controls. For a list of these I/O controls, see OAL IOCTLs.
    lpInBuf
    [out] Pointer to a buffer that contains the data required to perform the operation.

    Set to NULL if the dwIoControlCode parameter specifies an operation that does not require input data.

    nInBufSize
    [in] Size, in bytes, of the buffer pointed to by lpInBuf.
    lpOutBuf
    [out] Pointer to a buffer that receives the output data for the operation.

    Set to NULL if the dwIoControlCode parameter specifies an operation that does not produce output data.

    nOutBufSize
    [in] Size, in bytes, of the buffer pointed to by lpOutBuf.
    lpBytesReturned
    [in] Long pointer to a variable that receives the size, in bytes, of the data stored in the buffer pointed to by lpOutBuf. Even when an operation produces no output data, and lpOutBuf is NULL, the KernelIoControl function uses the variable pointed to by lpBytesReturned. After such an operation, the value of the variable has no meaning.

    Return Values

    TRUE indicates success; FALSE indicates failure.

    Remarks

    The kernel calls the OEMIoControl function when a device driver or application calls the kernel function KernelIoControl and passes an I/O control code.

    (当应用程序或者驱动调用KernelIoControl 的时候,KernelIoControl 就会调用OEMIoControl 去实现。)

    This function is also called when the SystemParametersInfo function is called with SPI_GETOEMINFO or SPI_GETPLATFORMINFO.

    The system is fully preemptible when this function is called. The kernel does no processing, but it passes all parameters directly to the function supplied by you. (当这个函数被调用的时候系统完全可能被抢占,内核没有处理,直接传递参数到你提供的函数。这个我觉得说的很别扭,估计是直接传递参数到OEMIoControl )

    This function is provided solely to allow your device driver or application to communicate with an OAL and its specific functionality.

    (该函数用来提供驱动/应用程序和OAL的通信)

    Requirements

    OS Versions: Windows CE 2.10 and later.
    Header: Pkfuncs.h.(原来是个不开源的函数)
    Link Library: Coredll.lib.

    OEMIoControl
  • 相关阅读:
    深度分析:SpringBoot异常捕获与封装处理,看完你学会了吗?
    去年去阿里面试,面试官居然问我Java类和对象,我是这样回答的!
    面试官:小伙子,你给我详细说一下线程的状态有哪些吧?
    新鲜出炉!JAVA线程池精华篇深度讲解,看完你还怕面试被问到吗?
    面试官:小伙子,你给我讲一下java类加载机制和内存模型吧
    深度分析:面试90%被问到的多线程、创建线程、线程状态、线程安全,一次性帮你全搞定!
    close与shutdown
    select模型(二 改进服务端)
    select模型(一 改进客户端)
    5种IO模型
  • 原文地址:https://www.cnblogs.com/gooogleman/p/1869749.html
Copyright © 2011-2022 走看看