Port SMBus device's driver from WDM to WDF

I suspect that your WDM driver would be tough to get running on this
particular platform. In fact, all of your frustrations so far have had
nothing to do with WDF, but rather general PnP resource management.

So let me lay out a few things for you:

  1. In general, chipsets have “IRQ steering devices” within them that allow
    the motherboard to route PCI interrupts to various interrupt controller
    inputs.

  2. The BIOS controls the IRQ steering devices and either programs them
    statically (Ethernet is attached to IRQ 19, for example) or it exposes “Link
    nodes” in the ACPI namespace which are used for dynamically choosing the IRQ
    at run time.

  3. If your SMBus device is wired into the IRQ Steering device, there’s no
    way to tell Windows (through the ACPI spec) that its IRQ will change if the
    OS reprograms the link node. Only PCI devices can express this connection.
    This event will be rare and hard to test, though it can happen. (PnpDTest
    will force it.)

  4. If your SMBus device is wired past the steering device and directly to
    an interrupt controller input, that’s better and you can’t be screwed if the
    OS decides to move some PCI devices to a different IRQ.

  5. In either case, you need to express your IRQ (which is sort of an
    antiquated term with ambiguous meaning) in terms that your ACPI BIOS can
    deal with, or Windows won’t connect your interrupt internally. You have
    only two choices in ACPI. Your device is either PCI or it conforms to the
    rules of the ISA bus. Your device is not PCI.

  6. The ISA bus had only IRQs 0 through 15. You say your device is
    connected to IRQ 19 or maybe 21. This is impossible to directly express.

  7. ACPI allows that some ISA IRQs might be wired to I/O APIC inputs that
    aren’t numbered the same way that ISA IRQs are numbered. For example, it’s
    fairly common for ISA IRQ 0 to be wired to I/O APIC input 2. ACPI allows
    these to be specified as “ISA Vector Overrides.” See Chapter 5.

  8. You can convince Windows that your non-PCI device can have “system IRQ
    19” by modifying the BIOS to say that some (presumably unused) ISA IRQ
    actually maps to I/O APIC input 19. Then you claim that ISA IRQ in your
    driver. For instance, you might claim IRQ 5, where the BIOS says 5 maps to

  1. This entire design is kind of dumb, because it’s going to force you to
    send SMBus commands in your ISR to get your device to deassert its
    interrupt, and SMBus commands are generally slow while ISRs should generally
    be very fast.

Good luck anyhow.

Jake Oshins
Hyper-V I/O Architect (former interrupt guy)
Windows Kernel Group

This post implies no warranties and confers no rights.


wrote in message news:xxxxx@ntdev…

Yes, my driver talks directly to the SMBus controller on the Intel chipset.
My driver builds the messages and directly programs the SMBus controller.

Since nobody else will ever use the SMBus there is no SMBus bus driver. From
what I could find Microsoft has never provided a generic SMBus bus driver
for Windows-XP (like Microsoft does for other buses). Writing a standalone
device driver that controls the SMBus seemed like the quickest and easiest
approach.

The IRQ (shared PCI, level triggered) connects directly to the device, not
the SMBus controller. Neither the BIOS nor any other code programs the SMBus
controller to generate any type of interrupt. Since this is the only device
on the SMBus there is no worry about collisions with other SMBus devices.
The device in question is a (custom) user-interface whose inputs are
completely asynchronous. That’s why it was designed to share an IRQ.

As far as I can tell Windows-XP does not provide generic PnP services to the
SMBus. I would have to write a bus driver to provide PnP, and then I would
have to write a device driver for my device to work with that bus driver.
Since this is a custom, locked-down, platform which will never have another
device on the SMBus this seemed like the long way around.

Hello Peter and Jake,

The platform is not MY design but was designed by the company I’m working with. They design custom embedded devices. This ‘appliance’

was designed for a large corporation, for a specific commercial niche.

So in this case the SMBus does not connect to DIMM SEEPROMs or anything else but the unique user interface device controlled by my

driver.

This device generates an interrupt on user input, a shared PCI interrupt. My WDM version of the driver had to use depecated functions

to share the IRQ, but it works. Since the appliance is locked-down, both hardware and the WinXPe image, using deprecated functions is

not a concern.

I do have access to the BIOS. But officially modifying the BIOS is not an option. I might do it on my own, but since I have a workng

driver (WDM) this issue would not rise to the level of requiring a BIOS change.

In this case the interrupt pin of the device is connected directly to a specific PIRQ line. No other intterupt/IRQ is physically

possible. The connection is outbound of steering logic.

Jake, I’m studying your post. I have access to the BIOS/ACPI sources, so when I get a little time I might give it a try.

Thanks to both you for you help.

ulyxb12x+xxxxx@gmail.com wrote:

I do have access to the BIOS. But officially modifying the BIOS is not an option. I might do it on my own, but since I have a workng driver (WDM) this issue would not rise to the level of requiring a BIOS change.

I’m not sure that’s the right attitude. This is exactly the kind of
thing ACPI was designed to solve. It lets the BIOS hand information to
the operating system that the OS would not otherwise be able to extract
on its own. The ACPI tree can identify specific IRQs assigned to
specific devices. The ACPI tree is exposed to Windows, and Windows can
assign resources to drivers based on that.


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

Hello Tim,

I understand your attitude, but as I said, there already is a working WDM driver, or a way to use deprecated functions in my KMDF version of the driver. Modifying the BIOS is not under my control, or even under the control of the design company I work with. This product belongs to the large corporation that pays for it. Convincing them to accept BIOS mods, along with all that entails, at this time in the product’s life-cycle, is just unreasonable to expect. And by ‘unreasonable’ I mean ‘impossible’.

But thanks for your input.

> to share the IRQ, but it works. Since the appliance is locked-down, both hardware and the WinXPe

image, using deprecated functions is

Probably using such deprecated functions is not supported by KMDF at all.

KMDF is a commodity framework for drivers (and thus hardware) developed according to MS’s guidelines.

If we are speaking about SMBus device (which is probably soldered to the motherboard) and ACPI, proper registration of the device (and its IRQ) in the ACPI BIOS will help.

Probably going this way will leave you still in the scope of MS’s recommendations and allow a KMDF driver. In this case, at least the ACPI table must be remade in a way the WDM driver can drop deprecated functions and use PnP interrupt resource.

In modern days (since Windows 98 or so) - any device soldered to the motherboard must be properly described by ACPI. Failure to get this - means probably failure to support device in Windows at all, not only KMDF.

Also, I see at least one other possible rules violation: hardcoded IRQs for SATA and Ethernet.

Since Windows NT family never ever supported PCI IRQ steering hardware (only Win95/98 supported it) - there must not be such hardware, or at least it must be programmed by the BIOS once and forever to be never visible to the OS. At least it is so for non-ACPI hardware - IRQ steering via ACPI is supported.

So, if you violate the ACPI spec (and I think this is what you do) - you’re in a gray area, where all bets are off. Windows is strictly an ACPI-based OS.

Probably you can do hacks like writing the second driver, the bus filter driver, which will filter the resource requirements and provide an IRQ for your device.

But, such covering a BIOS issue with a massive hack seems to be not-so-logical way. Fixing the ACPI BIOS is simpler.

Also note: PCI hardware design guidelines were published by MS in 1999, if not earlier. It’s a pity hardware designers do not read this document.


Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com

>that pays for it. Convincing them to accept BIOS mods, along with all that entails, at this time in the

product’s life-cycle, is just unreasonable to expect.

Then maybe drop the idea of remaking the driver to KMDF. After all, WDM version works :slight_smile:

Probably KMDF version will go with the new fixed BIOS.


Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com