2

Currently, I need to create custom OS to test some ideas. My question is: How to set resolution of video card without interrupts? My system supports multiboot standard and kernel starts in protected mode, so I probably cannot use BIOS services.

I cannot find port number etc. to initialize video cart and set resoultion. I tries to write dword value in VGA graphic address space, but nothing displays.

Edit 1: I have found this snipped of code: http://bos.asmhackers.net/docs/vga_without_bios/snippet_5/vga.php

I don't know on what kind of license it was published, so I cannot use it. Also, I prefer to write custom code in C.

I will rewrite it in C and tell you it works, but somebody could tell me it is good (what's the contraindications). I ask, because you ask me if I can builtin a virtual machine into my kernel.

Edit2

__asm__ (
"cli\n \
mov     %%cr0,%%eax\n\
mov     $1,%%cl \n\
xor     %%cl,%%cl \n\
and     %%cl, %%al \n\
mov     %%eax,%%cr0\n \
sti \n\
xor %%ax,%%ax\n \
mov $0x12,%%ah\n \
int $0x10\n \
cli\n \
mov     %%cr0,%%eax\n \
or      $1,%%al\n \
mov     %%eax,%%cr0\n  \
sti \
" : : : "eax", "ecx")

); I don't know putting there my source code and asking for help is appreciated. I wrote above code, which should switch into real mode, set video mode and return to protected mode. I don't know what I'm doing wrong. Is here description table register clean or something? I'm rather newbie in OS programming. My OS resets in this code segment. Tripple fallout? I have found first error - instead xor cl,cl should be neg/not cl. In both cases OS resets.

nintyfan
  • 386
  • 3
  • 16
  • Do you only need it to work in BOCHS or QEMU, which emulate a specific Cirrus SVGA card? Or do you need something portable to modern Intel / NVidia / AMD hardware? I think VESA VBE might have something for protected mode, but not sure, and maybe BIOS-dependent. – Peter Cordes Jul 05 '18 at 00:42
  • 1
    [BIOS Interrupts in protected mode](https://stackoverflow.com/q/26448480) suggests setting up a VM86 environment from which to invoke BIOS interrupts to set video mode. – Peter Cordes Jul 05 '18 at 00:44
  • 1
    @PeterCordes : VBE2 and VBE3 had protected mode interfaces but very limited and didn't include function that could switch video modes. VM8086 task / Switching to Real mode / Get GRUB to change the default video mode – Michael Petch Jul 05 '18 at 05:18
  • 1
    If one was using UEFI that's also a possibility (UGA and GOP) or of course if you have the video card / chip specs you could program it directly (port io / mmio etc) – Michael Petch Jul 05 '18 at 05:28
  • ~ Peter Cordes Jul 5 at 0:42 : VESA VBE (Virtual Machine) is not working in 64 bit mode. – nintyfan Jul 15 '18 at 09:14

1 Answers1

0

Yes, you don't need the BIOS, but you need to set up the VGA registers to set the resolution, color depth and so on. There is the official technical manual from IBM about VGA and there is a website called "FreeVGA" which also has some documentation about the VGA registers.

But it's nothing you can do on a single weekend.

Some name
  • 39
  • 6