/*++

Copyright (c) Microsoft Corporation. All rights reserved.

Module Name:

    Wdfhwaccess.h

Environment:

    user mode

NOTE: This header is generated by stubwork.

      To modify contents, add or remove <shared> or <umdf>
      tags in the corresponding .x and .y template files.

--*/

#pragma once

#ifndef WDF_EXTERN_C
  #ifdef __cplusplus
    #define WDF_EXTERN_C       extern "C"
    #define WDF_EXTERN_C_START extern "C" {
    #define WDF_EXTERN_C_END   }
  #else
    #define WDF_EXTERN_C
    #define WDF_EXTERN_C_START
    #define WDF_EXTERN_C_END
  #endif
#endif

WDF_EXTERN_C_START

#if (NTDDI_VERSION >= NTDDI_WIN2K)

#define WDF_NO_BUFFER          (NULL)
#define WDF_ZERO_BUFFER_COUNT  (0)
#define WDF_UNUSED_VALUE       (0)

//
// Types
//


//
// Functions for HwAccess 
//

//
// Read Register functions
//
UCHAR
FORCEINLINE
WDF_READ_REGISTER_UCHAR(
    _In_ WDFDEVICE Device,
    _In_ _Notliteral_ PUCHAR Register
    )
{
    return (UCHAR) WdfDeviceReadFromHardware(
                        Device,
                        WdfDeviceHwAccessTargetTypeRegister, 
                        WdfDeviceHwAccessTargetSizeUchar, 
                        Register, 
                        WDF_NO_BUFFER,
                        WDF_ZERO_BUFFER_COUNT 
                        );
}

USHORT
FORCEINLINE
WDF_READ_REGISTER_USHORT(
    _In_ WDFDEVICE Device,
    _In_ _Notliteral_ PUSHORT Register
    )
{
    return (USHORT) WdfDeviceReadFromHardware(
                        Device,
                        WdfDeviceHwAccessTargetTypeRegister, 
                        WdfDeviceHwAccessTargetSizeUshort, 
                        Register, 
                        WDF_NO_BUFFER,
                        WDF_ZERO_BUFFER_COUNT 
                        );
}

ULONG
FORCEINLINE
WDF_READ_REGISTER_ULONG(
    _In_ WDFDEVICE Device,
    _In_ _Notliteral_ PULONG Register
    )
{
    return (ULONG) WdfDeviceReadFromHardware(
                        Device,
                        WdfDeviceHwAccessTargetTypeRegister, 
                        WdfDeviceHwAccessTargetSizeUlong, 
                        Register, 
                        WDF_NO_BUFFER,
                        WDF_ZERO_BUFFER_COUNT 
                        );
}

#if defined(_WIN64)

ULONG64
FORCEINLINE
WDF_READ_REGISTER_ULONG64(
    _In_ WDFDEVICE Device,
    _In_ _Notliteral_ PULONG64 Register
    )
{
    return (ULONG64) WdfDeviceReadFromHardware(
                        Device,
                        WdfDeviceHwAccessTargetTypeRegister, 
                        WdfDeviceHwAccessTargetSizeUlong64, 
                        Register, 
                        WDF_NO_BUFFER,
                        WDF_ZERO_BUFFER_COUNT 
                        );
}

#endif

VOID
FORCEINLINE
WDF_READ_REGISTER_BUFFER_UCHAR(
    _In_ WDFDEVICE Device,
    _In_ _Notliteral_ PUCHAR Register,
    _Out_writes_all_(Count) PUCHAR Buffer,
    _In_ ULONG Count
    )
{
    WdfDeviceReadFromHardware(
                        Device,
                        WdfDeviceHwAccessTargetTypeRegisterBuffer, 
                        WdfDeviceHwAccessTargetSizeUchar, 
                        Register, 
                        Buffer,
                        Count 
                        );
}

VOID
FORCEINLINE
WDF_READ_REGISTER_BUFFER_USHORT(
    _In_ WDFDEVICE Device,
    _In_ _Notliteral_ PUSHORT Register,
    _Out_writes_all_(Count) PUSHORT Buffer,
    _In_ ULONG Count
    )
{
    WdfDeviceReadFromHardware(
                        Device,
                        WdfDeviceHwAccessTargetTypeRegisterBuffer, 
                        WdfDeviceHwAccessTargetSizeUshort, 
                        Register, 
                        Buffer,
                        Count 
                        );
}

VOID
FORCEINLINE
WDF_READ_REGISTER_BUFFER_ULONG(
    _In_ WDFDEVICE Device,
    _In_ _Notliteral_ PULONG Register,
    _Out_writes_all_(Count) PULONG Buffer,
    _In_ ULONG Count
    )
{
    WdfDeviceReadFromHardware(
                        Device,
                        WdfDeviceHwAccessTargetTypeRegisterBuffer, 
                        WdfDeviceHwAccessTargetSizeUlong, 
                        Register, 
                        Buffer,
                        Count 
                        );
}

#if defined(_WIN64)

VOID
FORCEINLINE
WDF_READ_REGISTER_BUFFER_ULONG64(
    _In_ WDFDEVICE Device,
    _In_ _Notliteral_ PULONG64 Register,
    _Out_writes_all_(Count) PULONG64 Buffer,
    _In_ ULONG Count
    )
{
    WdfDeviceReadFromHardware(
                        Device,
                        WdfDeviceHwAccessTargetTypeRegisterBuffer, 
                        WdfDeviceHwAccessTargetSizeUlong64, 
                        Register, 
                        Buffer,
                        Count 
                        );
}

#endif

//
// Write register functions
//
VOID
FORCEINLINE
WDF_WRITE_REGISTER_UCHAR(
    _In_ WDFDEVICE Device,
    _In_ _Notliteral_ PUCHAR Register,
    _In_ UCHAR Value
    )
{
    WdfDeviceWriteToHardware(
                        Device,
                        WdfDeviceHwAccessTargetTypeRegister, 
                        WdfDeviceHwAccessTargetSizeUchar, 
                        Register,
                        Value,
                        WDF_NO_BUFFER, 
                        WDF_ZERO_BUFFER_COUNT
                        );
}

VOID
FORCEINLINE
WDF_WRITE_REGISTER_USHORT(
    _In_ WDFDEVICE Device,
    _In_ _Notliteral_ PUSHORT Register,
    _In_ USHORT Value
    )
{
    WdfDeviceWriteToHardware(
                        Device,
                        WdfDeviceHwAccessTargetTypeRegister, 
                        WdfDeviceHwAccessTargetSizeUshort, 
                        Register,
                        Value,
                        WDF_NO_BUFFER, 
                        WDF_ZERO_BUFFER_COUNT
                        );
}

VOID
FORCEINLINE
WDF_WRITE_REGISTER_ULONG(
    _In_ WDFDEVICE Device,
    _In_ _Notliteral_ PULONG Register,
    _In_ ULONG Value
    )
{
    WdfDeviceWriteToHardware(
                        Device,
                        WdfDeviceHwAccessTargetTypeRegister, 
                        WdfDeviceHwAccessTargetSizeUlong, 
                        Register,
                        Value,
                        WDF_NO_BUFFER, 
                        WDF_ZERO_BUFFER_COUNT
                        );
}

#if defined(_WIN64)

VOID
FORCEINLINE
WDF_WRITE_REGISTER_ULONG64(
    _In_ WDFDEVICE Device,
    _In_ _Notliteral_ PULONG64 Register,
    _In_ ULONG64 Value
    )
{
    WdfDeviceWriteToHardware(
                        Device,
                        WdfDeviceHwAccessTargetTypeRegister, 
                        WdfDeviceHwAccessTargetSizeUlong64, 
                        Register,
                        Value,
                        WDF_NO_BUFFER, 
                        WDF_ZERO_BUFFER_COUNT
                        );
}

#endif

VOID
FORCEINLINE
WDF_WRITE_REGISTER_BUFFER_UCHAR(
    _In_ WDFDEVICE Device,
    _In_ _Notliteral_ PUCHAR Register,
    _In_reads_(Count) PUCHAR Buffer,
    _In_ ULONG Count
    )
{
    WdfDeviceWriteToHardware(
                        Device,
                        WdfDeviceHwAccessTargetTypeRegisterBuffer, 
                        WdfDeviceHwAccessTargetSizeUchar, 
                        Register,
                        WDF_UNUSED_VALUE,
                        Buffer, 
                        Count
                        );
}

VOID
FORCEINLINE
WDF_WRITE_REGISTER_BUFFER_USHORT(
    _In_ WDFDEVICE Device,
    _In_ _Notliteral_ PUSHORT Register,
    _In_reads_(Count) PUSHORT Buffer,
    _In_ ULONG Count
    )
{
    WdfDeviceWriteToHardware(
                        Device,
                        WdfDeviceHwAccessTargetTypeRegisterBuffer, 
                        WdfDeviceHwAccessTargetSizeUshort, 
                        Register,
                        WDF_UNUSED_VALUE,
                        Buffer, 
                        Count
                        );
}

VOID
FORCEINLINE
WDF_WRITE_REGISTER_BUFFER_ULONG(
    _In_ WDFDEVICE Device,
    _In_ _Notliteral_ PULONG Register,
    _In_reads_(Count) PULONG Buffer,
    _In_ ULONG Count
    )
{
    WdfDeviceWriteToHardware(
                        Device,
                        WdfDeviceHwAccessTargetTypeRegisterBuffer, 
                        WdfDeviceHwAccessTargetSizeUlong, 
                        Register,
                        WDF_UNUSED_VALUE,
                        Buffer, 
                        Count
                        );
}

#if defined(_WIN64)

VOID
FORCEINLINE
WDF_WRITE_REGISTER_BUFFER_ULONG64(
    _In_ WDFDEVICE Device,
    _In_ _Notliteral_ PULONG64 Register,
    _In_reads_(Count) PULONG64 Buffer,
    _In_ ULONG Count
    )
{
    WdfDeviceWriteToHardware(
                        Device,
                        WdfDeviceHwAccessTargetTypeRegisterBuffer, 
                        WdfDeviceHwAccessTargetSizeUlong64, 
                        Register,
                        WDF_UNUSED_VALUE,
                        Buffer, 
                        Count
                        );
}

#endif

//
//
// Read Port functions
//
UCHAR
FORCEINLINE
WDF_READ_PORT_UCHAR(
    _In_ WDFDEVICE Device,
    _In_ _Notliteral_ PUCHAR Port
    )
{
    return (UCHAR) WdfDeviceReadFromHardware(
                        Device,
                        WdfDeviceHwAccessTargetTypePort, 
                        WdfDeviceHwAccessTargetSizeUchar, 
                        Port, 
                        WDF_NO_BUFFER,
                        WDF_ZERO_BUFFER_COUNT 
                        );
}

USHORT
FORCEINLINE
WDF_READ_PORT_USHORT(
    _In_ WDFDEVICE Device,
    _In_ _Notliteral_ PUSHORT Port
    )
{
    return (USHORT) WdfDeviceReadFromHardware(
                        Device,
                        WdfDeviceHwAccessTargetTypePort, 
                        WdfDeviceHwAccessTargetSizeUshort, 
                        Port, 
                        WDF_NO_BUFFER,
                        WDF_ZERO_BUFFER_COUNT 
                        );
}

ULONG
FORCEINLINE
WDF_READ_PORT_ULONG(
    _In_ WDFDEVICE Device,
    _In_ _Notliteral_ PULONG Port
    )
{
    return (ULONG) WdfDeviceReadFromHardware(
                        Device,
                        WdfDeviceHwAccessTargetTypePort, 
                        WdfDeviceHwAccessTargetSizeUlong, 
                        Port, 
                        WDF_NO_BUFFER,
                        WDF_ZERO_BUFFER_COUNT 
                        );
}

VOID
FORCEINLINE
WDF_READ_PORT_BUFFER_UCHAR(
    _In_ WDFDEVICE Device,
    _In_ _Notliteral_ PUCHAR Port,
    _Out_writes_all_(Count) PUCHAR Buffer,
    _In_ ULONG Count
    )
{
    WdfDeviceReadFromHardware(
                        Device,
                        WdfDeviceHwAccessTargetTypePortBuffer, 
                        WdfDeviceHwAccessTargetSizeUchar, 
                        Port, 
                        Buffer,
                        Count 
                        );
}

VOID
FORCEINLINE
WDF_READ_PORT_BUFFER_USHORT(
    _In_ WDFDEVICE Device,
    _In_ _Notliteral_ PUSHORT Port,
    _Out_writes_all_(Count) PUSHORT Buffer,
    _In_ ULONG Count
    )
{
    WdfDeviceReadFromHardware(
                        Device,
                        WdfDeviceHwAccessTargetTypePortBuffer, 
                        WdfDeviceHwAccessTargetSizeUshort, 
                        Port, 
                        Buffer,
                        Count 
                        );
}

VOID
FORCEINLINE
WDF_READ_PORT_BUFFER_ULONG(
    _In_ WDFDEVICE Device,
    _In_ _Notliteral_ PULONG Port,
    _Out_writes_all_(Count) PULONG Buffer,
    _In_ ULONG Count
    )
{
    WdfDeviceReadFromHardware(
                        Device,
                        WdfDeviceHwAccessTargetTypePortBuffer, 
                        WdfDeviceHwAccessTargetSizeUlong, 
                        Port, 
                        Buffer,
                        Count 
                        );
}

//
// Write port functions
//
VOID
FORCEINLINE
WDF_WRITE_PORT_UCHAR(
    _In_ WDFDEVICE Device,
    _In_ _Notliteral_ PUCHAR Port,
    _In_ UCHAR Value
    )
{
    WdfDeviceWriteToHardware(
                        Device,
                        WdfDeviceHwAccessTargetTypePort, 
                        WdfDeviceHwAccessTargetSizeUchar, 
                        Port,
                        Value,
                        WDF_NO_BUFFER, 
                        WDF_ZERO_BUFFER_COUNT
                        );
}

VOID
FORCEINLINE
WDF_WRITE_PORT_USHORT(
    _In_ WDFDEVICE Device,
    _In_ _Notliteral_ PUSHORT Port,
    _In_ USHORT Value
    )
{
    WdfDeviceWriteToHardware(
                        Device,
                        WdfDeviceHwAccessTargetTypePort, 
                        WdfDeviceHwAccessTargetSizeUshort, 
                        Port,
                        Value,
                        WDF_NO_BUFFER, 
                        WDF_ZERO_BUFFER_COUNT
                        );
}

VOID
FORCEINLINE
WDF_WRITE_PORT_ULONG(
    _In_ WDFDEVICE Device,
    _In_ _Notliteral_ PULONG Port,
    _In_ ULONG Value
    )
{
    WdfDeviceWriteToHardware(
                        Device,
                        WdfDeviceHwAccessTargetTypePort, 
                        WdfDeviceHwAccessTargetSizeUlong, 
                        Port,
                        Value,
                        WDF_NO_BUFFER, 
                        WDF_ZERO_BUFFER_COUNT
                        );
}

VOID
FORCEINLINE
WDF_WRITE_PORT_BUFFER_UCHAR(
    _In_ WDFDEVICE Device,
    _In_ _Notliteral_ PUCHAR Port,
    _In_reads_(Count) PUCHAR Buffer,
    _In_ ULONG Count
    )
{
    WdfDeviceWriteToHardware(
                        Device,
                        WdfDeviceHwAccessTargetTypePortBuffer, 
                        WdfDeviceHwAccessTargetSizeUchar, 
                        Port,
                        WDF_UNUSED_VALUE,
                        Buffer, 
                        Count
                        );
}

VOID
FORCEINLINE
WDF_WRITE_PORT_BUFFER_USHORT(
    _In_ WDFDEVICE Device,
    _In_ _Notliteral_ PUSHORT Port,
    _In_reads_(Count) PUSHORT Buffer,
    _In_ ULONG Count
    )
{
    WdfDeviceWriteToHardware(
                        Device,
                        WdfDeviceHwAccessTargetTypePortBuffer, 
                        WdfDeviceHwAccessTargetSizeUshort, 
                        Port,
                        WDF_UNUSED_VALUE,
                        Buffer, 
                        Count
                        );
}

VOID
FORCEINLINE
WDF_WRITE_PORT_BUFFER_ULONG(
    _In_ WDFDEVICE Device,
    _In_ _Notliteral_ PULONG Port,
    _In_reads_(Count) PULONG Buffer,
    _In_ ULONG Count
    )
{
    WdfDeviceWriteToHardware(
                        Device,
                        WdfDeviceHwAccessTargetTypePortBuffer, 
                        WdfDeviceHwAccessTargetSizeUlong, 
                        Port,
                        WDF_UNUSED_VALUE,
                        Buffer, 
                        Count
                        );
}





#endif // (NTDDI_VERSION >= NTDDI_WIN2K)

WDF_EXTERN_C_END

