Hello there, all! I'm hoping that any of you could answer my questions that I have here today. I tried asking on StackOverflow, and I got booted out the door like I always do when trying to ask any ****ing questions on that stupid website.
You see, I'm starting a project that is sort of related to operating systems, but not necessarily... it's more of what's called an operating environment, for Linux, and possibly, BSD.
And sorry if this thread is pretty long, but this is a lot to talk about, so please bear with me, thanks!
Okay, so my first question:
I was planning on simply using Linux's DRM+DRI system for graphics. But I recently found out, that DRM+DRI does not work correctly on NVIDIA cards, and therefore I could never get anywhere. I cannot use fbdev, because it's not gonna be what I need it to be in the future, if my project goes beyond just a hobby project. And I'm not using the X.org server, because I don't want there to be any client-server models in my thing, and I don't want the vulnerability of any networks or sockets. So, therefore, I must write my own graphics driver.
So my first question is not necessarily how to go about doing writing the driver, because I can use Intel and AMD specs to do that, but more so, how would I go about testing the driver, and how would I go about interacting with the driver through user-mode programs, because that is my biggest hurdle in trying to do this thing. Linux is kinda funky when doing driver development, in my opinion, so thanks for any help on this subject!
Now, my second question:
I plan to make these all modules, because I'm sure as hell not compiling this crap into the kernel. I think that I would have to use modules anyway, though. But is there anyway to load modules at the startup? If, in the future, I want to make it so that the operating environment can start on its own at boot up (kind of like an autostart script), how would I go about doing this?
Now, my third question:
Does anyone know of any good resources for writing this kind of driver? I know about the wiki, and it's a godsend, but like... anything else, like all of it. anything would help millions. videos, wiki-pages, articles, specs, literally anything that anyone knows of that is related to this kind of driver development. Thanks!
All right, I'll stop taking up too much of you time. Thanks for any help that anyone can give, and have a good day!
-Joe
Linux Graphics Driver Development Questions
Re: Linux Graphics Driver Development Questions
You're worried that DRM does not support Nvidia, yet you want to write your own drivers that will not support Nvidia either? What's the rationale here?
If your goal is to write some program that produces graphical output, use EGL or Vulkan. Those APIs are universally supported, even on Nvidia cards.
For mode setting, adopt whatever the xorg server is doing. A good way to do this might be running the xorg server in a namespace so that your application is the only client, runs in fullscreen and processes all input.
If your goal is to write some program that produces graphical output, use EGL or Vulkan. Those APIs are universally supported, even on Nvidia cards.
For mode setting, adopt whatever the xorg server is doing. A good way to do this might be running the xorg server in a namespace so that your application is the only client, runs in fullscreen and processes all input.
managarm: Microkernel-based OS capable of running a Wayland desktop (Discord: https://discord.gg/7WB6Ur3). My OS-dev projects: [mlibc: Portable C library for managarm, qword, Linux, Sigma, ...] [LAI: AML interpreter] [xbstrap: Build system for OS distributions].
Re: Linux Graphics Driver Development Questions
You are correct that mine won't necessarily support NVIDIA either, but the fact that I cannot get any other the others to work the way that I need them to work, I have no other choice. I don't know if there is any rationale, and that's I am asking this question, because I genuinely need help.Korona wrote:You're worried that DRM does not support Nvidia, yet you want to write your own drivers that will not support Nvidia either? What's the rationale here?
If, in the future, my thing would become useful enough with only Intel and AMD support, NVIDIA might support it, that's the plan, anyway, if I cannot get DRM to work for crap. Even then, I would have lots of market share with just those two.
I could use those, but I want my system to be as separate and free-standing as possible, so I am avoid any other API at all costs. Plus, my thing isn't just for graphical output, it's an entire operating environment, so I need more than just those APIs, anyway. And I want to avoid licensing issues if I can, too.Korona wrote:If your goal is to write some program that produces graphical output, use EGL or Vulkan. Those APIs are universally supported, even on Nvidia cards.
I tried doing what X.org does, and for some reason, it will work with DRM, but not mine. I literally wrote a line-by-line equivalent to do some tests, and still nothing, lol.Korona wrote:For mode setting, adopt whatever the xorg server is doing. A good way to do this might be running the xorg server in a namespace so that your application is the only client, runs in fullscreen and processes all input.
Re: Linux Graphics Driver Development Questions
To me, this sounds like a massive NIH issue. If you want to produce a working product, go for DRM. There are no licensing problems, as you're using only the Linux kernel API (which is not copyrighted) and libdrm/Mesa (which is MIT). Examples of how to use DRM are freely available. For a more advanced example, look at what kmscube or Weston does. If you cannot get DRM to work, the chances are low that you'll be able to write a graphics driver.
The chances that you'll convince Nvidia to write a driver specifically your system are almost zero. In fact, the chance that Nvidia decides to provide an interoperable EGL implementation that you can use are significantly higher - they already have to do that for Wayland compositors.
If you want to write a graphics driver look at the drivers/gpu/drm directory of Linux. The chances that you'll be able to write a graphics driver without looking at Linux' DRM driver code are pretty much zero: the docs by Intel and AMD are not nearly detailed enough to enable you to write drivers from scratch. In particular, while writing a driver for an Intel GPU, I had to look at the Linux code to find out what some undocumented registers did. If you really want to do this, you need to write several 1000s - 10000s of SLoC per GPU generation plus multiple 10000s - 100000s of SLoC for general infrastructure (depending on what features you want to implement). Not to mention that you need to buy hardware from every GPU generation. The cost of implementing a full-blown driver for Intel or AMD GPUs are in the high 100,000$ to multiple millions (again, depending on the features). It would require multiple person years of highly qualified (tertiary education or higher) system-level programmers to do this.
I will repeat my suggestion. Run the xorg server in a network namespace that ensures that nobody else can access it and just use that. Create a fullscreen window and just do all you rendering in that window. Or look at how Wayland compositors like KWin and Mutter deal with this. Everything else is insane from a economical point of view.
The chances that you'll convince Nvidia to write a driver specifically your system are almost zero. In fact, the chance that Nvidia decides to provide an interoperable EGL implementation that you can use are significantly higher - they already have to do that for Wayland compositors.
If you want to write a graphics driver look at the drivers/gpu/drm directory of Linux. The chances that you'll be able to write a graphics driver without looking at Linux' DRM driver code are pretty much zero: the docs by Intel and AMD are not nearly detailed enough to enable you to write drivers from scratch. In particular, while writing a driver for an Intel GPU, I had to look at the Linux code to find out what some undocumented registers did. If you really want to do this, you need to write several 1000s - 10000s of SLoC per GPU generation plus multiple 10000s - 100000s of SLoC for general infrastructure (depending on what features you want to implement). Not to mention that you need to buy hardware from every GPU generation. The cost of implementing a full-blown driver for Intel or AMD GPUs are in the high 100,000$ to multiple millions (again, depending on the features). It would require multiple person years of highly qualified (tertiary education or higher) system-level programmers to do this.
I will repeat my suggestion. Run the xorg server in a network namespace that ensures that nobody else can access it and just use that. Create a fullscreen window and just do all you rendering in that window. Or look at how Wayland compositors like KWin and Mutter deal with this. Everything else is insane from a economical point of view.
managarm: Microkernel-based OS capable of running a Wayland desktop (Discord: https://discord.gg/7WB6Ur3). My OS-dev projects: [mlibc: Portable C library for managarm, qword, Linux, Sigma, ...] [LAI: AML interpreter] [xbstrap: Build system for OS distributions].
Re: Linux Graphics Driver Development Questions
I'm doing something similar myself, although I think my intentions bracket yours: running as an application on other OSs on the one hand, and eventually as an OS on bare hardware on the other. I do not want to be tied to Linux and its cousins because I'm developing a very different architecture anyway. I'm taking Korona's advice and looking into EGL and Vulkan.saltlamp wrote:You see, I'm starting a project that is sort of related to operating systems, but not necessarily... it's more of what's called an operating environment, for Linux, and possibly, BSD.
Kaph — a modular OS intended to be easy and fun to administer and code for.
"May wisdom, fun, and the greater good shine forth in all your work." — Leo Brodie
"May wisdom, fun, and the greater good shine forth in all your work." — Leo Brodie
-
- Member
- Posts: 396
- Joined: Wed Nov 18, 2015 3:04 pm
- Location: San Jose San Francisco Bay Area
- Contact:
Re: Linux Graphics Driver Development Questions
the AMD has opensourced all of its drivers AMDGPU, AMDKFD, and Virtualization (mxgpu) public so you can easily look through source and see how they implemented it. Looks for ROCm during web search.
key takeaway after spending yrs on sw industry: big issue small because everyone jumps on it and fixes it. small issue is big since everyone ignores and it causes catastrophy later. #devilisinthedetails