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

📄 haluser.h

📁 CIRRUS 公司EP93XX系列CPU的WINCE下的BSP
💻 H
字号:
//**********************************************************************
//                                                                      
// Filename: halcalls.h
//                                                                      
// Description: Allows driver to call specific hal functions.
//
// 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.
//
// Use of this source code is subject to the terms of the Cirrus 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 
// EULA.RTF on your install media.
//
// Copyright(c) Cirrus Logic Corporation 2003, All Rights Reserved                       
//                                                                      
//**********************************************************************
#ifndef _H_HAL_CALLS
#define _H_HAL_CALLS


#define IOCTL_HAL_WRITE_COMMON_REG        CTL_CODE(FILE_DEVICE_HAL, 67, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_HAL_GET_MAC_ADDRESS         CTL_CODE(FILE_DEVICE_HAL, 68, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_HAL_IS_CS8950_USED_FOR_KITL CTL_CODE(FILE_DEVICE_HAL, 69, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_HAL_AUDIO_GET_POSITION      CTL_CODE(FILE_DEVICE_HAL, 70, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_HAL_AUDIO_SET_POSITION      CTL_CODE(FILE_DEVICE_HAL, 71, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define IOCTL_HAL_AUDIO_START_STOP        CTL_CODE(FILE_DEVICE_HAL, 72, METHOD_BUFFERED, FILE_ANY_ACCESS)  
#define IOCTL_HAL_CRUNCH_ENABLED          CTL_CODE(FILE_DEVICE_HAL, 73, METHOD_BUFFERED, FILE_ANY_ACCESS)    


//
// Common Register Write Structure.
//
typedef struct
{
    volatile ULONG  *   pulRegister;
    ULONG               ulMask;
    ULONG               ulValue;
    volatile ULONG  *   pulLockRegister;
    ULONG               ulCheckSum;
} CommonRegStruct;

typedef struct
{
    BOOL    bPlayback;
    BOOL    bStartStop;
} StartStopStruct;

typedef struct
{
    BOOL    bPlayback;
    ULONG   ulPosition;
} SetPositionStruct;


//****************************************************************************
// HalWriteCommonReg
//****************************************************************************
// This function Writes a Common register.
// Used so that you can write perform a read modify write without worrying
// about getting preempted by another process.
// 
// Used specifically for writting GPIO registers or SYSCON registers.
// Syscon registers are automatically locked when writing to.
//
// *pulRegister = (*pulRegister & ~ulMask) | ( ulValue & ulMask)
//
// pulRegister  - Register that is being written
// ulMask       - Bits that you are modifing.
// ulValue      - New Value
//
__inline BOOL HalWriteCommonReg
(
    volatile ULONG *    pulRegister,
    ULONG               ulMask,
    ULONG               ulValue
)
{
    BOOL fErr;
    CommonRegStruct sCommon;
    ULONG   ulTransferred;


    //
    // Copy the correct information to the IOCTL
    //
    sCommon.pulRegister     = pulRegister;
    sCommon.ulMask          = ulMask;
    sCommon.ulValue         = ulValue;

    if( ((ULONG)pulRegister & 0xFFFF0000) == CSC_BASE)
    {
        sCommon.pulLockRegister = CSC_SYSLOCK;
    }
    else
    {
        sCommon.pulLockRegister = 0;
    }

    //
    // Calculate the proper checksum
    //
    sCommon.ulCheckSum      = (ULONG)pulRegister + ulMask + ulValue +
                              (ULONG)sCommon.pulLockRegister;

    //
    // Send the IOCTL
    //
    fErr = KernelIoControl
    (
        IOCTL_HAL_WRITE_COMMON_REG, 
        &sCommon,  
        sizeof(CommonRegStruct), 
        NULL, 
        0, 
        &ulTransferred
    );
    
    return fErr;
}

//****************************************************************************
// HalGetMacAddress
//****************************************************************************
// This function gets the MAC address from the kernel.  This prevents a 
// colision with the PS/2 SPI keyboard driver.
// 
//
__inline BOOL HalGetMacAddress
(
    PUSHORT pusMacAddress
)
{
    ULONG   ulTransferred;
    BOOL    fErr;

    //
    // Send the IOCTL
    //
    fErr = KernelIoControl
    (
        IOCTL_HAL_GET_MAC_ADDRESS, 
        NULL,  
        0, 
        pusMacAddress, 
        6, 
        &ulTransferred
    );
    
    return  (fErr && (ulTransferred == 6));
}


//****************************************************************************
// HalIsCS8950UsedForKitl
//****************************************************************************
// This functions checks to see if the CS8950 is used for kitl.
// If it is the ethernet ndis driver is prevented from loading.
// 
//
__inline BOOL HalIsCS8950UsedForKitl
(    
    PBOOL    pbIsCS850Used
)
{
    ULONG   ulTransferred;
    BOOL    fErr;

    //
    // Send the IOCTL
    //
    fErr = KernelIoControl
    (
        IOCTL_HAL_IS_CS8950_USED_FOR_KITL, 
        NULL,  
        0, 
        pbIsCS850Used, 
        4, 
        &ulTransferred
    );
    

    return  (fErr && (ulTransferred == 4));
}

//****************************************************************************
// HalAudioGetPosition
//****************************************************************************
// Get the current position of the buffer.
// 
//
__inline HalAudioGetPosition
(
    BOOL    bPlayBack,
    ULONG  * pulPosition
)
{
    ULONG   ulTransferred;
    BOOL    fErr;

    //
    // Send the IOCTL
    //
    fErr = KernelIoControl
    (
        IOCTL_HAL_AUDIO_GET_POSITION, 
        &bPlayBack,  
        sizeof(BOOL), 
        pulPosition, 
        sizeof(ULONG *), 
        &ulTransferred
    );

    return  (fErr && (ulTransferred == 4));
}


//****************************************************************************
// HalAudioSetPosition
//****************************************************************************
// Get the current position of the playback buffer.
// 
//
__inline HalAudioSetPosition
(
    BOOL    bPlayBack,
    ULONG   ulPosition
)
{
    ULONG               ulTransferred;
    BOOL                fErr;
    SetPositionStruct   S;

    //
    // Send the IOCTL
    //
    S.bPlayback     = bPlayBack;
    S.ulPosition    = ulPosition;
    fErr = KernelIoControl
    (
        IOCTL_HAL_AUDIO_SET_POSITION, 
        &S, 
        sizeof(SetPositionStruct), 
        NULL,  
        0, 
        &ulTransferred
    );

    return(fErr );
}


//****************************************************************************
// HalAudioStartStop
//****************************************************************************
// Starts and stops audio.
// 
//
__inline HalAudioStartStop
(
    BOOL    bPlayback,
    BOOL    bStartStop
)
{
    StartStopStruct S;
    ULONG   ulTransferred;
    BOOL    fErr;

    //
    // Send the IOCTL
    //
    S.bPlayback     = bPlayback;
    S.bStartStop    = bStartStop;

    fErr = KernelIoControl
    (
        IOCTL_HAL_AUDIO_START_STOP, 
        (void *)&S, 
        sizeof(StartStopStruct), 
        NULL,  
        0, 
        &ulTransferred
    );

    return(fErr );
}





#endif // _H_HAL_CALLS

⌨️ 快捷键说明

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