Windows 7 - How to read and write using doorbell interface register

Hello,
I want to use the doorbell interface to read and write from the chip.
For this the Linux driver has a call
/* make sure doorbell is not in use */
if ((readl(&chip->Doorbell) & DOORBELL_USED))

What is the Windows equivalent of the readl() function call?

Thanks

xxxxx@gmail.com wrote:

I want to use the doorbell interface to read and write from the chip.
For this the Linux driver has a call
/* make sure doorbell is not in use */
if ((readl(&chip->Doorbell) & DOORBELL_USED))

What is the Windows equivalent of the readl() function call?

A few seconds with Google would have answered this question.  “readl”
reads a 32-bit value from a memory-mapped register.  The statement above
is essentially equivament to
    if( *chip->Doorbell & DOORBELL_USED)

The Windows equivalent is READ_REGISTER_ULONG.

Note that you’ll still have to map the registers into memory so you have
the board’s address to begin with.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

Thanks for your response. I am unclear about a lot of things in the problem I am trying to solve and hence asked the question. From your response, I am kind of confused about how to deal with problem of memory mapping.
In my storport miniport driver, I am able to get the base address register using StorPortGetDeviceBase(). This address is set to point to a buffer that is of size and type of the chip’s interface register structure.
For e.g:
typedef interface_t
{
u32 doorbell;
U32 WriteSequence;
U32 HostDiagnostic;


}SystemInterfaceRegs_t;

SystemInterfaceRegs_t registerBase;

registerBase = (SystemInterfaceRegs_t )StorPortGetDeviceBase(…); With last parameter = False indicating that the mapped range is in memory space.

Now, I want to read registerBase.doorBell which I believe is already memory mapped.

Is the implementation I listed above correct ?
Where should I be calling in the MmMapIoSpace() call here?

Thanks.

You don’t call MmMapIoSpace.

StorPortGetDeviceBase returns: “A mapped, logical base address
corresponding to the bus-relative address supplied in the IoAddress
parameter.”. You can then use that returned value directly in a call to
the StorPortReadRegister* routines.

See the sample driver at

https://github.com/Microsoft/Windows-driver-samples/blob/aa6e0b36eb932099fa4eb950a6f5e289a23b6d6e/storage/miniports/lsi_u3/src/lsi_u3.c

Mark Roddy

On Wed, Feb 7, 2018 at 4:24 PM, xxxxx@gmail.com
wrote:

> Thanks for your response. I am unclear about a lot of things in the
> problem I am trying to solve and hence asked the question. From your
> response, I am kind of confused about how to deal with problem of memory
> mapping.
> In my storport miniport driver, I am able to get the base address register
> using StorPortGetDeviceBase(). This address is set to point to a buffer
> that is of size and type of the chip’s interface register structure.
> For e.g:
> typedef interface_t
> {
> u32 doorbell;
> U32 WriteSequence;
> U32 HostDiagnostic;
> …
> …
> }SystemInterfaceRegs_t;
>
> SystemInterfaceRegs_t registerBase;
>
> registerBase = (SystemInterfaceRegs_t )StorPortGetDeviceBase(…); With
> last parameter = False indicating that the mapped range is in memory space.
>
> Now, I want to read registerBase.doorBell which I believe is already
> memory mapped.
>
> Is the implementation I listed above correct ?
> Where should I be calling in the MmMapIoSpace() call here?
>
> Thanks.
>
>
>
>
>
>
>
> —
> NTDEV is sponsored by OSR
>
> Visit the list online at: http:> showlists.cfm?list=ntdev>
>
> MONTHLY seminars on crash dump analysis, WDF, Windows internals and
> software drivers!
> Details at http:
>
> To unsubscribe, visit the List Server section of OSR Online at <
> http://www.osronline.com/page.cfm?name=ListServer&gt;
></http:></http:>

Thanks. I will use StorPortReadRegister* with DeviceExtension and register as registerBase.doorBell