Is it possible to use existing GPU drivers?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
SevcLuka
Posts: 2
Joined: Sun May 10, 2020 3:34 am

Is it possible to use existing GPU drivers?

Post by SevcLuka »

I would like to add full HD resolution to mz Operating System, but I don't want to use UEFI. Is it possible to use existing GPU drivers from NVidia and Intel to make it possible? IS there some documentation for them, in terms of usage, functions, ...? Or is there some complete tutorial how to achieve this? Thanks for response!
Octocontrabass
Member
Member
Posts: 5575
Joined: Mon Mar 25, 2013 7:01 pm

Re: Is it possible to use existing GPU drivers?

Post by Octocontrabass »

It's not possible to use existing drivers. You will have to either use firmware (BIOS VBE, UEFI GOP) to set the resolution, or write your own driver using the available documentation.

Why don't you want to use UEFI? Modern PCs don't support BIOS, only UEFI.
User avatar
bzt
Member
Member
Posts: 1584
Joined: Thu Oct 13, 2016 4:55 pm
Contact:

Re: Is it possible to use existing GPU drivers?

Post by bzt »

Well, in theory you could use. All you need to do is to implement the same ABI/API as Linux, and you'll able to use the binary drivers provided for Linux. But in practice this is extremely hard, and requires to inherit Linux structures into your kernel, therefore I agree with @Octocontrabass, in practice it's not possible.

BTW, Intel has a good documentation and an Open Source driver under Linux, so you can implement or port a device driver for it in your OS. As for Nvidia, the documentation is not available, only a binary kernel driver blob. However there's a reverse engineered Open Source driver, nouveau, which you can study and/or port. Not an easy task, but doable.

Cheers,
bzt
User avatar
eekee
Member
Member
Posts: 892
Joined: Mon May 22, 2017 5:56 am
Location: Kerbin
Discord: eekee
Contact:

Re: Is it possible to use existing GPU drivers?

Post by eekee »

nVidia do release some information which, if I remember right, is enough to set modes. (I'm assuming nvidia hasn't stopped dong this since they started a few years ago.) The information will have been incorporated into Linux's noveau driver, so that's a valid place to look as bzt suggested.

You could probably port the full nvidia drivers if you sign a non-disclosure agreement (NDA) with nvidia. You'd have to distribute your ported driver in binary form, but you could see the source yourself - or enough of it to interface with. They'd expect you to have professional-level understanding, but that's not really as high as it sounds.

nvidia have been enthusiastic about helping port their drivers to FreeBSD, but I can't remember if that was a full port or if it involved FreeBSD's Linux compatibility layer.


Regarding the suggestion of UEFI, it's not the panacea it should be. Some graphics chipsets set the wrong resolution under VBE and UEFI to try to force you to use their drivers. Some nVidia cards do this; not sure about ATI. Some even set it to 800x600 which is below the minimum specified in the UEFI standard, as far as I know.
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
Korona
Member
Member
Posts: 1000
Joined: Thu May 17, 2007 1:27 pm
Contact:

Re: Is it possible to use existing GPU drivers?

Post by Korona »

Due to the nature of the NVIDIA drivers, they might actually be the most reusable ones. If you supported an appropriate /dev/nvidiactl and /dev/nvidia0, it might be possible to run the userspace binary blob unchanged (provided that you also have the other components of the Linux graphics stack, like X11). The NVIDIA device nodes are open source (e.g., the FreeBSD code is quite readable) and mostly expose ACPI power management and PCI BAR access.
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].
User avatar
eekee
Member
Member
Posts: 892
Joined: Mon May 22, 2017 5:56 am
Location: Kerbin
Discord: eekee
Contact:

Re: Is it possible to use existing GPU drivers?

Post by eekee »

Korona wrote:Due to the nature of the NVIDIA drivers, they might actually be the most reusable ones. If you supported an appropriate /dev/nvidiactl and /dev/nvidia0, it might be possible to run the userspace binary blob unchanged (provided that you also have the other components of the Linux graphics stack, like X11). The NVIDIA device nodes are open source (e.g., the FreeBSD code is quite readable) and mostly expose ACPI power management and PCI BAR access.
I was thinking this, but didn't say it because it's been more than 10 years since I looked into it. At the time, the license didn't actually allow me to look into it as literally as I did, ;) but I can confirm there's a source-code wrapper around the blob.

I'm not even sure you'd actually need X11, just something providing the functionality of GLX: coordinating the OpenGL-drawn regions with the window system.
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
SevcLuka
Posts: 2
Joined: Sun May 10, 2020 3:34 am

Re: Is it possible to use existing GPU drivers?

Post by SevcLuka »

Octocontrabass wrote:It's not possible to use existing drivers. You will have to either use firmware (BIOS VBE, UEFI GOP) to set the resolution, or write your own driver using the available documentation.

Why don't you want to use UEFI? Modern PCs don't support BIOS, only UEFI.
I would like to use it test it on my one of my old computers, that's why. Can I ask where can I find the documentation?
Octocontrabass
Member
Member
Posts: 5575
Joined: Mon Mar 25, 2013 7:01 pm

Re: Is it possible to use existing GPU drivers?

Post by Octocontrabass »

SevcLuka wrote:Can I ask where can I find the documentation?
What do you need documentation for?

If you're using GRUB, use a framebuffer tag in your multiboot2 header and GRUB will use the firmware to set up the framebuffer for you.

If you're writing your own bootloader (or doing something silly like calling the BIOS after you've switched to protected mode), you'll want to refer to the VBE core specification, version 3. It may also be helpful to refer to older versions, so here's version 2 as well. There are some related documents listed on the last page; use your favorite search engine if you feel like reading those as well.
User avatar
eekee
Member
Member
Posts: 892
Joined: Mon May 22, 2017 5:56 am
Location: Kerbin
Discord: eekee
Contact:

Re: Is it possible to use existing GPU drivers?

Post by eekee »

Octocontrabass wrote:
SevcLuka wrote:If you're using GRUB, use a framebuffer tag in your multiboot2 header and GRUB will use the firmware to set up the framebuffer for you.
This will work if you build your kernel with Grub's headers, but if you don't, then you should be aware of a bug in Grub: It makes one of the framebuffer fields 32 bits wide when the spec says 16 bits.
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
Post Reply