Windows System Software -- Consulting, Training, Development -- Unique Expertise, Guaranteed Results

Before Posting... Please check out the Community Guidelines in the
Announcements and Administration Category.

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

PKPK Posts: 15
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

Comments

  • Tim_RobertsTim_Roberts Posts: 12,623
    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.

    Tim Roberts, [email protected]
    Providenza & Boekelheide, Inc.

  • PKPK Posts: 15
    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.
  • Mark_RoddyMark_Roddy Posts: 4,269
    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: showlists.cfm?list=ntdev>
    >
    > MONTHLY seminars on crash dump analysis, WDF, Windows internals and
    > software drivers!
    > Details at
    >
    > To unsubscribe, visit the List Server section of OSR Online at <
    > http://www.osronline.com/page.cfm?name=ListServer>;
    >
  • PKPK Posts: 15
    Thanks. I will use StorPortReadRegister* with DeviceExtension and register as registerBase.doorBell
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!