How do you change the display mode after enter protect mode

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
benji
Posts: 22
Joined: Fri Nov 23, 2018 10:53 pm
Libera.chat IRC: os student

How do you change the display mode after enter protect mode

Post by benji »

Hello every one. I am a OS developer beginner. As we all know we can change the display mode in real mode(X86) like this

Code: Select all

MOV AL, 0x13
MOV AH, 0x00
INT 0x10
The 0x13 means 24bits color mode in BIOS.
But How to change the display mode after you enter protect mode?
And, How to use the video card(GPU) to display picture on screen quickly?
I really like the beautiful GUI. I'd like to add GUI in my OS.
Octocontrabass
Member
Member
Posts: 5581
Joined: Mon Mar 25, 2013 7:01 pm

Re: How do you change the display mode after enter protect m

Post by Octocontrabass »

Both of those questions have the same answer: write a driver for the video card.

Writing a driver is a lot of work, though, and you need a separate driver for each kind of video card. If you want to make your GUI now and worry about the drivers later, have your bootloader set up a linear frame buffer.
LtG
Member
Member
Posts: 384
Joined: Thu Aug 13, 2015 4:57 pm

Re: How do you change the display mode after enter protect m

Post by LtG »

Graphics adapter display pretty pictures.

GPU calculates (renders) those pretty pictures.

If you want GPU support, you need hardware specific drivers, as mentioned.

Switching to LFB is relatively easy (lookup BIOS and VESA, or UEFI).

Simply put, don't change graphics mode after boot, instead choose one during boot, Win95 did that IIRC (you had to boot to change resolution). Realistically, by the time this becomes a problem you're OS has millions of users so then it's not an issue anymore.

As for good graphics, you don't need GPU support for that. Games needs GPU support, but your OS won't support pre-existing games for a long time, and if they ever do, it's likely thru emulation/virtualization, and at that point you can also emulate/virtualize drivers from other OS's.

Fast bitblit is relatively easy, so again, no issues there. You don't have to worry about any of the issues here yet.
benji
Posts: 22
Joined: Fri Nov 23, 2018 10:53 pm
Libera.chat IRC: os student

Re: How do you change the display mode after enter protect m

Post by benji »

Octocontrabass wrote:Both of those questions have the same answer: write a driver for the video card.

Writing a driver is a lot of work, though, and you need a separate driver for each kind of video card. If you want to make your GUI now and worry about the drivers later, have your bootloader set up a linear frame buffer.
Could you tell me the detials about writing driver and set up the linear frame buffer?
benji
Posts: 22
Joined: Fri Nov 23, 2018 10:53 pm
Libera.chat IRC: os student

Re: How do you change the display mode after enter protect m

Post by benji »

LtG wrote:Graphics adapter display pretty pictures.

GPU calculates (renders) those pretty pictures.

If you want GPU support, you need hardware specific drivers, as mentioned.

Switching to LFB is relatively easy (lookup BIOS and VESA, or UEFI).

Simply put, don't change graphics mode after boot, instead choose one during boot, Win95 did that IIRC (you had to boot to change resolution). Realistically, by the time this becomes a problem you're OS has millions of users so then it's not an issue anymore.

As for good graphics, you don't need GPU support for that. Games needs GPU support, but your OS won't support pre-existing games for a long time, and if they ever do, it's likely thru emulation/virtualization, and at that point you can also emulate/virtualize drivers from other OS's.

Fast bitblit is relatively easy, so again, no issues there. You don't have to worry about any of the issues here yet.
Could you tell me the details about the vesa?
and How do I use this?
Octocontrabass
Member
Member
Posts: 5581
Joined: Mon Mar 25, 2013 7:01 pm

Re: How do you change the display mode after enter protect m

Post by Octocontrabass »

benji wrote:Could you tell me the detials about writing driver and set up the linear frame buffer?
To write a driver, find the documentation for the video card you want to write a driver for, then follow that documentation.

Setting up the linear frame buffer depends on the bootloader. If you're using GRUB, set the appropriate bits in your multiboot header and tell GRUB what video mode you would like. If you're writing your own legacy BIOS bootloader, follow the VESA VBE Core specification to set the video mode, and maybe VBE/DDC to detect the attached display. If you're writing your own UEFI bootloader, look for Graphics Output Protocol in the UEFI specification, and maybe Universal Graphics Adapter in the EFI specification if you want to support Apple hardware.
benji
Posts: 22
Joined: Fri Nov 23, 2018 10:53 pm
Libera.chat IRC: os student

Re: How do you change the display mode after enter protect m

Post by benji »

Octocontrabass wrote:
benji wrote:Could you tell me the detials about writing driver and set up the linear frame buffer?
To write a driver, find the documentation for the video card you want to write a driver for, then follow that documentation.

Setting up the linear frame buffer depends on the bootloader. If you're using GRUB, set the appropriate bits in your multiboot header and tell GRUB what video mode you would like. If you're writing your own legacy BIOS bootloader, follow the VESA VBE Core specification to set the video mode, and maybe VBE/DDC to detect the attached display. If you're writing your own UEFI bootloader, look for Graphics Output Protocol in the UEFI specification, and maybe Universal Graphics Adapter in the EFI specification if you want to support Apple hardware.
Yeah, I see. Now I chose the BIOS bootloader. I am going to search they in google later on. But I slightly confuse about these words. I really really want to know those conception like VESA VBE. Could you tell me the relationship between VESA, VGA, framebuffer and video card driver? And If I want to write a video card driver. How do I do? IHow am I start this program (I am a beginner). If I got those conception, I ensure I can finish my job quickly. Thank you so much!
User avatar
eekee
Member
Member
Posts: 892
Joined: Mon May 22, 2017 5:56 am
Location: Kerbin
Discord: eekee
Contact:

Re: How do you change the display mode after enter protect m

Post by eekee »

benji wrote:Could you tell me the relationship between VESA, VGA, framebuffer and video card driver?
VESA VBE is a crude video card driver in ROM. All it can do is switch resolutions and set up a linear framebuffer. It doesn't provide access to any of the other features of the video card. A linear framebuffer is just a series of memory locations which correspond pixels on the screen. Write to those memory locations and pixels change.
benji wrote:And If I want to write a video card driver. How do I do? IHow am I start this program (I am a beginner). If I got those conception, I ensure I can finish my job quickly. Thank you so much!
It's up to you to decide how drivers fit into your operating system. A relatively simple way is to build them into your kernel; programs make syscalls which call the functions of your driver.

I think someone already told you how to write a driver. Read the hardware documentation, and see what to do. I will add this: Don't try to understand everything before you start. I tried to understand everything first, and so I made no real progress in 30 years! :lol:
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
User avatar
pvc
Member
Member
Posts: 201
Joined: Mon Jan 15, 2018 2:27 pm

Re: How do you change the display mode after enter protect m

Post by pvc »

To do that you have to make HUUUUGE companies to become user (don't mistake $ for user) friendly.
m7a10a3
Posts: 1
Joined: Tue Mar 20, 2018 9:47 am
Location: Cairo, Egypt

Re: How do you change the display mode after enter protect m

Post by m7a10a3 »

I think someone already told you how to write a driver. Read the hardware documentation, and see what to do. I will add this: Don't try to understand everything before you start. I tried to understand everything first, and so I made no real progress in 30 years! :lol
The same here :(
User avatar
bzt
Member
Member
Posts: 1584
Joined: Thu Oct 13, 2016 4:55 pm
Contact:

Re: How do you change the display mode after enter protect m

Post by bzt »

Hi,

Well, using BIOS assumes you're using VESA too. In the VESA mode description block, there's bit which tells you if the given mode accepts VGA registers. If so, then you can change the resolution using standard VGA IO ports in protected mode. However most VESA modes does not have VGA-compatibility flag set (mostly SVGA modes only, 640x400, 640x480, 800x600, 1024x768 but not higher resolutions), and in those modes writing to VGA IO ports would most likely crash.

Without a VGA compatibility layer, writing a driver is the only option.

Cheers,
bzt
Post Reply