[英]How windows drivers talk to Hardware?
I am curious about the different ways windows drivers interact with the hardware.我很好奇 windows 驱动程序与硬件交互的不同方式。 For example, some drivers might use a function, others a macro, and others might hard-code the register addresses directly into their code.
例如,某些驱动程序可能使用 function,其他驱动程序可能使用宏,而其他驱动程序可能会将寄存器地址直接硬编码到其代码中。 There are probably other ways as well.
可能还有其他方法。
Any help is really appreciated.非常感谢任何帮助。
TIA. TIA。 :-)
:-)
It depends on the type of device.这取决于设备的类型。 for example, if it is a generic PCI Device then the access to the hardware is done "directly" to the HW, meaning Windows map the PCI MMIO to some virtual address and the driver interacts with it.
例如,如果它是一个通用 PCI 设备,那么对硬件的访问是“直接”对硬件完成的,这意味着 Windows map PCI MMIO 到某个虚拟地址并且驱动程序与之交互。
Microsoft recommended using HAL Function in order to prevent issues with compiler optimization, eg to use READ_REGISTER_UCHAR()
macro to read BYTE from a device register. Microsoft 建议使用 HAL Function 以防止编译器优化问题,例如使用
READ_REGISTER_UCHAR()
宏从设备寄存器读取 BYTE。
USB, for example, is a subsystem that has a big stack and there is a USB controller that manages access to the device.例如,USB 是一个具有大堆栈的子系统,并且有一个 USB controller 管理对设备的访问。 so, in this case, you will need to use a function to access the device register.
因此,在这种情况下,您将需要使用 function 来访问设备寄存器。
You can find a lot of Microsoft driver samples in GitHub您可以在 GitHub 中找到很多Microsoft 驱动程序示例
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.