0

I'm looking for information how to insert a pixel into the screen in my own operating system. I care about the resolution of 1920x1080, 16K colors and to do it without bios interruptions. Ideally, the resolution and number of colors will depend on my system

I wrote bootloader and procedure to draw pixel on screen but its only 320x200 resolution and have 256 colors;/ when i try use text modes, its run on VM, but when i start it on real device i have only black screen so i dont want to use bios interruptions (it depend on bios version)

Michael Petch
  • 46,082
  • 8
  • 107
  • 198
  • Are you doing this in real mode? If so then if the hardware (or virtual machine) supports it you might wish to consider using [VBE](https://en.wikipedia.org/wiki/VESA_BIOS_Extensions) – Michael Petch May 06 '17 at 17:52
  • 1
    Problems with real hardware are usually tied to some unspoken assumption - like the value of the register at boot. It's certainly possible to set the video mode without the BIOS but be warned that you need SVGA and that's not standardised (being a very broad term). VBE is your only resort, or alternatively, Intel HD graphics which is more documented. – Margaret Bloom May 06 '17 at 17:56
  • Protected mode x86-64 – user7973714 May 06 '17 at 17:58
  • would It help information as it is done in linux, minix etc.? Somebody knows where can i find that – user7973714 May 06 '17 at 18:01
  • sure the sources for linux, minix, etc show how to do it. You will need to get into very specific details for you video card, the code will only support that video card or ones with a similar chip, as with linux, minux, windows, etc you will need a kernel driver for each video card you support. – old_timer May 06 '17 at 18:12
  • Thus the reason for bios calls in the first place from the early days and later VESA, to hide the details. – old_timer May 06 '17 at 18:14
  • @old_timer You can also write a generic VESA based driver, but it won't support high resolutions. – fuz May 06 '17 at 18:34
  • when VESA came out it did, but I have not used it since then. The OP seems like they want to write to the video card directly is what I assume by not wanting to make bios calls. if they dont already understand how that works, that is not the first peripheral they need to be messing with, use a uart to communicate with your operating system, and get networking and media up first, then tackle video. – old_timer May 06 '17 at 18:44
  • 3
    Actually you should use BIOS - VESA BIOS Extensions to be specific for hi-res modes. This will allow you to setup desired mode (if supported) in generic way without need of writing your own custom driver which does it low level. Make sure it supports linear framebuffer mode (planar/banked is PITA). Start looking for VBE 3.0 information. – Anty May 06 '17 at 20:40
  • 1
    VESA BIOS Extensions are the way to go. But it won't be clean. The modes aren't standardized, so as Wikipedia advises: *"The correct way for software to discover available display modes is to obtain a list of modes (using "Function 00h - Return VBE Controller Information") and then to check each mode (using "Function 01h: Return VBE Mode Information") until it finds the mode/s it requires."* Sorry, we won't write this code for you. :-) It makes no sense to me why you are trying to avoid using BIOS interrupts. They make your life easier. What's wrong with them? – Cody Gray - on strike May 07 '17 at 09:48
  • (hardware) versatility, standardization, unification.. Making life easier is fun when it is not necessary. – user7973714 May 07 '17 at 13:58
  • Sales OS or make universal OS is not my job. i want to have fun with my computer and do what i want to do with that. i prefer create my own driver and kernel for video card to understand how it works. Computer is something more than personal computer. i would plug devices makes by me and i want to know how can i do it. Bios wont help me. – user7973714 May 07 '17 at 16:04
  • so, to be sure.. looking for VBE for create simply procedure to put pixel on screen. looking for UART for make directly communications with video card and next put pixel on screen. Thats correct? – user7973714 May 07 '17 at 16:24

1 Answers1

1
  1. When still in Real Mode, scan all available VESA video modes.
  2. Pick the mode of interest
  3. Select it and switch to it using interrupt
  4. Save all required data - framebuffer, width, height, bits per pixel, pitch etc. and enter real mode
  5. Write pixel at an exact memory address:
    Pixel offset: framebuffer address + pixelPosX * BitsPerPixel + PixelPosY * ScrWidth * BitsPerPixel
    when you have calculated this, just use:

mov [address], 0x00ff00ff ; [00][red][green][blue]

my example will set the pixel to the color pink (max red and blue)


By the way, this might help: http://forum.osdev.org/viewtopic.php?f=2&t=30186
And, you have to do it using interrupts. If it is not running on real PC you are missing something in your bootloader. Try to run your OS with Bochs, if it runs on Bochs it will probably run on a Real PC. Qemu or VirtualBox might make things that should not be working do work

You can post your bootloader code so maybe we can figure out whats wrong with your interrupts