Thanks Martin.
Yes that’s more or less what I gathering here, the OS is a means of policing access to the peripherals, preventing chaos basically. If such policing was taken care of by some other software component though, that problem could (at least in principle) be solved without the OS needing to do that.
What I’m seeing as I dig into all this, is a bit of an unclear landscape, the design of these abstractions seems to be non-standardized, what I mean is if we look at the WDM in Windows there is a very formal and solid standard pattern that a driver must conform too, note (from that article I linked to)
There is no formal framework for Linux device drivers, but Linux kernel includes numerous subsystems that provide common services like driver registration.
Creating some new or improved driver here, say for SPI (for no particular reason) forces us to dive into Linux driver development and either take some existing driver from some place and extend it or create a new one from scratch, this could be a lot of work and if we are for any reason dissatisfied with some existing abstraction we will be unlikely to want to do much about it and just make do.
The past few weeks when I’ve had time to explore, I’ve seen that we have these Linux drivers like spidev
for SPI and also stuff like Libgpiod
as well, I’m still far from clear on exactly how these all play together too.
I’m wondering how one could design “drivers” outside of Linux, away from the OS.
If one commits to a “Let Linux do it” approach then it seems to me that we are somewhat at the mercy of whatever exists with whatever abstractions it offers, for example as you will know spidev
offers no support for asynchronous (nor it seems, full duplex) operation.
Under the hood of course, in any OS I’ve ever worked on, all IO is ultimately asynchronous, not synchronous. A synchronous interface is often exposed on top of the asynchronous one because it’s all that most users might need (this was the case some years ago anyway).
Unlike traditional PCs running Windows and Linux etc, these ST devices (for example) do have a very uniform devices model, they expose very well documented IO registers and these are very easy to access by code without any nececsity of some intervening OS, so its easier to get at the hardware than it typically is on a PC.
Some of the work I’ve been doing the past couple weeks too, is suggesting that C# has now reached the stage where interacting with such hardware is now much easier than in the old days and the performance of this is no longer a major cost.
The ST32MP1X devices though are far from simple, they are pretty sophisticated and I don’t want to imply they are not!
I should add, that I know that I’m looking at all this very idealistically, I do not work professionally on these kinds of systems but I do have considerable experience in low level software and OS internals, so I’m probably just dumb enough to try ridiculous ideas!