Working on an alternative to UDI, EDI, and other such things

This forums is for OS project announcements including project openings, new releases, update notices, test requests, and job openings (both paying and volunteer).
Post Reply
User avatar
AnotherIdiot
Member
Member
Posts: 45
Joined: Sat Sep 28, 2024 8:00 pm
Location: Ohio, USA
GitHub: https://github.com/apixeldev
Contact:

Working on an alternative to UDI, EDI, and other such things

Post by AnotherIdiot »

I am working on an alternative to UDI, EDI, and other such attempts to make drivers more portable, I want to find a balance between the complexity of UDI and the simplicity of EDI, I plan to write and release a few drivers, I am still working on the spec and the headers, I just want some advice on the idea, and anything you might add (I am going to add in more functions like PCI, ISA, and architecture specific tables within the ops table passed to the system), the idea is to make it have enough functions for most drivers to work easily, without having an ungodly amount of issues, I do plan to also add in driver_ops so that the drivers can expose their functions. You can get the spec (and link to the header) at https://stackunderflow.org/spec/usg-0002.html.

Summary of the whole thing:
- Each architecture is assigned an ABI so that things are compatible at a binary level (this can be ignored if you plan to compile every driver yourself, however).
- All drivers SHOULD be an ELF file that is relocatable and is not dynamically linked.
- The entry function should look like

Code: Select all

USG_RET entryfunc(struct ops_table* ops_tbl);
- The entry function should return USG_OK if it was able to register.
- Each OS SHOULD (you don't HAVE to, but its gonna save RAM anyways, and design time) have a single table, and assume that drivers do not attempt to modify it, if you really want to be safe you can write it, then remap it into read only memory so you can kill drivers which try to access it.
- The whole thing follows semver, the ops table and any major spec things will be fully backwards compatible unless on a higher major version.
- There is a function so you can get specific versions of the ops_table (say the kernel provides 1.15 but the driver needs 1.16, the driver can attempt to request 1.16 and see if the kernel hands it over).

This system is MEANT to load things into kernel space however in theory it is entirely possible that someone could write a kernel which loads drivers into userland, YMMV if you decide to do that. Also yes I do understand that this idea is a bit out there and it will be pretty hard to get support. I have not actually named the system yet other than its "spec name" of USG-0002, with USG-0001 defining USG spec language and USG-0003 is a spec for 6502 calling conventions (not really important unless you are writing an OS for a 6502 system, which I think only a few people here have done before).
Every CPU manufacturer sucks, make your own CPU :D
Kevin
Member
Member
Posts: 1075
Joined: Sun Feb 01, 2009 6:11 am
Location: Germany
Contact:

Re: Working on an alternative to UDI, EDI, and other such things

Post by Kevin »

I feel it's a bit early to give any substantial feedback because the spec doesn't really contain much yet. So far it seems you can write "drivers" with a single entry point that can allocate and free memory and otherwise not communicate with the outside world at all.

USG-0003 suggests that you're planning to let drivers have raw interrupt handlers that the CPU calls directly. This is not only obviously incompatible with userspace drivers, but probably also a bad idea in a monolithic kernel because then the kernel itself is completely bypassed and can't run any code itself before or after calling the driver. I'd suggest to make this a normal function and leave the raw interrupt handler to the specific OS. (Of course, as long as you can't register interrupt handlers, it doesn't matter either way.)

In general, I would advise to write a simple driver and make sure that it works on two very different OSes/environments, and then come back and update the spec accordingly. Ideally one with kernel space drivers and one with user space drivers, but definitely at least one that wasn't written or heavily influenced by yourself. This way you can avoid making assumptions that seem reasonable to you, but are really specific to your own OS. Best is if you can actually find a few people who already have an OS and are interested in sharing drivers with yours, so everyone will make sure the driver interface actually works for the design of their OS.
Developer of tyndur - community OS of Lowlevel (German)
nullplan
Member
Member
Posts: 2061
Joined: Wed Aug 30, 2017 8:24 am

Re: Working on an alternative to UDI, EDI, and other such things

Post by nullplan »

I think the spec so far misses the point of drivers entirely. Drivers are in principle function libraries. For them to be useful, they need to hook their functions into the kernel they participate in, and vice versa, call interfaces into the kernel. The precise functions required are obviously different for each type of driver. A network driver is going to have functions for sending packets and some callback for registering incoming ones, while a video driver is going to have functions for mode switching and maybe managing a hardware mouse cursor or some such.

It is for this reason that I think any initiative to unify drivers between different operating systems will fail. No two people here will be able to agree on the specifics of the layers, and any attempt to standardize it is going to force all participating OSes into a corset. So in the end, I think most of us will stick to isolated libraries for functionality we don't want to implement ourselves (such as ACPI by way of ACPICA), without bothering with another layer on top of the isolated library.
Carpe diem!
User avatar
AnotherIdiot
Member
Member
Posts: 45
Joined: Sat Sep 28, 2024 8:00 pm
Location: Ohio, USA
GitHub: https://github.com/apixeldev
Contact:

Re: Working on an alternative to UDI, EDI, and other such things

Post by AnotherIdiot »

nullplan wrote: ↑Tue Nov 17, 2026 1:41 pm I think the spec so far misses the point of drivers entirely. Drivers are in principle function libraries. For them to be useful, they need to hook their functions into the kernel they participate in, and vice versa, call interfaces into the kernel. The precise functions required are obviously different for each type of driver. A network driver is going to have functions for sending packets and some callback for registering incoming ones, while a video driver is going to have functions for mode switching and maybe managing a hardware mouse cursor or some such.

It is for this reason that I think any initiative to unify drivers between different operating systems will fail. No two people here will be able to agree on the specifics of the layers, and any attempt to standardize it is going to force all participating OSes into a corset. So in the end, I think most of us will stick to isolated libraries for functionality we don't want to implement ourselves (such as ACPI by way of ACPICA), without bothering with another layer on top of the isolated library.
The point is to provide the bare minimum and make drivers forwards compatible so code is easier to share and reference with, and also to understand and manipulate. Which is why I want to strike a balance between the two, because I think it would be quite useful, many people on the subreddit have stated it would be far easier for them to do that, because in the sad reality not all of us can afford to read 900 page long specs just to figure out how to get NVMe to function, or any other really complicated hardware, or god forbid system chipsets.

Though I do get it, esp for people who have really unique Operating Systems. And as for the point of Drivers being function libraries, that is correct, which is why I plan to expose some functions which let you register drivers for say, Ethernet, WiFi, etc, of course I do understand that this can only work so much before it begins to fail. Because many drivers only need to expose specific things, for example for Ethernet you need to send and receive packets, so those can become two functions, for say Storage you need to read and write blocks, and expose the block sizes. Same goes for most drivers. Though I do still get your point.
Every CPU manufacturer sucks, make your own CPU :D
Post Reply