locked
Is there any method whic is equivalent of linux's kfifo? RRS feed

  • Question

  • Hi

    I'm a green hand in Windows device driver. I want to create a fifo to manage the buffers got from the device(an HW encoder) via PCIE. The driver, at present, is a linux driver. And I want to port it to windows.

    • Moved by Pavel Celba Tuesday, March 18, 2014 10:19 PM Driver related question
    Tuesday, March 18, 2014 2:44 AM

Answers

  • No there is no equivalent.  More importantly as someone who has ported over a dozen Linux drivers to Windows you do not want to try to take the Linux code.  What you want to do is understand the basics of how to interact with the device, which Linux drivers do a great job of showing you, and then recast the driver design to KMDF and Windows approaches.   Trying to convert specific code with things like kfifo is a way to madness, or at least to a driver that crashes more than it works.


    Don Burn Windows Filesystem and Driver Consulting Website: http://www.windrvr.com Blog: http://msmvps.com/blogs/WinDrvr

    Tuesday, March 18, 2014 10:54 PM

All replies

  • As you work on a hardware driver, you're posting to the wrong forum.

    See: http://msdn.microsoft.com/de-de/vfoxpro/bb190225.aspx

    Perhaps visit http://social.msdn.microsoft.com/Forums/windowshardware/en-US/home?category=windowshardwaredev

    Bye, Olaf.


    Olaf Doschke - TMN Systemberatung GmbH http://www.tmn-systemberatung.de

    Tuesday, March 18, 2014 7:10 AM
  • No there is no equivalent.  More importantly as someone who has ported over a dozen Linux drivers to Windows you do not want to try to take the Linux code.  What you want to do is understand the basics of how to interact with the device, which Linux drivers do a great job of showing you, and then recast the driver design to KMDF and Windows approaches.   Trying to convert specific code with things like kfifo is a way to madness, or at least to a driver that crashes more than it works.


    Don Burn Windows Filesystem and Driver Consulting Website: http://www.windrvr.com Blog: http://msmvps.com/blogs/WinDrvr

    Tuesday, March 18, 2014 10:54 PM
  • Thanks for your reply. I am a linux hacker and that linux driver is designed by myself. But I do not work with the windows kernel ever before.

    According to your reply, should I implement the KFIFO in windows by myself? Or there is already something similarity in windows. So would please tell me which method or object can be used to let it works like the linux's KFIFO.

    In Linux, I use the kfifo to manage the buffers get from the device. I put the buffer(an address point to the buffer) into the KFIFO get from the devide. When user APP is idle, it will get the buffer from the KFIFO with the help of the linux kernel driver.

    Wednesday, March 19, 2014 5:49 AM
  • It shouldn't be too difficult to implement something similar by yourself using KMDF. You can use WDF Collections to hold the buffers and map or copy kernel mode buffers to user mode buffers if needed.

    Ian Bakshan, Sr. Software Engineer at Jungo Connectivity LTD
    WinDriver – Driver Development Tool
    DriverCore – PC USB Drivers



    • Edited by Ian Bakshan Wednesday, March 19, 2014 7:54 AM
    Wednesday, March 19, 2014 7:53 AM
  • As was pointed out above, you can use things like WDFCOLLECTION's or a linked list with the ExInterlockedXXXList calls, since that is protected at interrupt time.

    But the real message is to think about how Windows does things.  I've seen a number of Linux drivers that use kfifo then have synchronous calls from user space to collect the data.  This is totally alien for Windows, where the common approach is to have the user space program send a number of requests with buffers to the kernel, these requests go on a KMDF queue and as the data comes in it goes directly to the buffer and the request completed.

    I've taken code others have converted from Linux to Windows where they followed the Linux interface design, and significantly improved performance (double or triple) by making things use a Windows interface model.  This is not a reflection on either OS, just that they chose different design tradeoffs.


    Don Burn Windows Filesystem and Driver Consulting Website: http://www.windrvr.com Blog: http://msmvps.com/blogs/WinDrvr

    Wednesday, March 19, 2014 11:20 AM
  • Thank you very much! After evaluating, I'll use link-list to build the design.
    Thursday, March 20, 2014 1:50 AM