OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Nov 21, 2019 5:23 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 12 posts ] 
Author Message
 Post subject: How to use framebuffer SVGA in the BIOS?
PostPosted: Sun Jul 21, 2019 4:49 pm 
Offline
Member
Member

Joined: Sun Jul 21, 2019 7:34 am
Posts: 36
Hey. I apologize for this stupid question.
With the text output in text mode, when working in protected mode, writing 2 bits(character + color) in with 0x000B8000 I figured out. But how do I work in SVGA mode? I want access to pixels or something. To create a drawing. To work, as I understand it, you have in memory from 0x000A0000. How's the recording going? Where to read about it?


Top
 Profile  
 
 Post subject: Re: How to use framebuffer SVGA in the BIOS?
PostPosted: Sun Jul 21, 2019 7:09 pm 
Offline
Member
Member

Joined: Wed Aug 29, 2018 4:42 pm
Posts: 122
hi,
mrjbom wrote:
But how do I work in SVGA mode?
First, you'll need to set a video mode. This can be done by grub(https://www.gnu.org/software/grub/manua ... iboot.html for multiboot 1 specification, or https://www.gnu.org/software/grub/manua ... iboot.html for multiboot 2 specification) or can be done by bios int 0x10.
mrjbom wrote:
To create a drawing. To work, as I understand it, you have in memory from 0x000A0000
That's only for VGA Graphics mode, let me explain. In VGA modes, you have memory from 0xB0000-0xB7FFF(monochrome text), 0xB8000-0xBFFFF(color text, the one you were using) and 0xA0000-0xAFFFF(VGA Graphics mode). However, for SVGA there is a framebuffer address, and you won't know the exact address since it might change, for example: the qemu framebuffer address is 0xFD000000, the bochs fb address is 0xE0000000. The address can be given pretty much the same way you'd set a video mode. In grub, you'll pass a flag wich will give you the fb address, or can be also given through the bios int 0x10.

There are some useful links
Drawing In Protected Mode and VESA Video Modes

hope this helped.


Top
 Profile  
 
 Post subject: Re: How to use framebuffer SVGA in the BIOS?
PostPosted: Mon Jul 22, 2019 4:15 am 
Offline
Member
Member

Joined: Sun Jul 21, 2019 7:34 am
Posts: 36
Can I boot into VESA mode? How do I do this with GRUB? What flag for GRUB to specify?


Top
 Profile  
 
 Post subject: Re: How to use framebuffer SVGA in the BIOS?
PostPosted: Mon Jul 22, 2019 9:10 am 
Offline
Member
Member

Joined: Wed Aug 29, 2018 4:42 pm
Posts: 122
b
Code:
mrjbom wrote:
Can I boot into VESA mode?
Well, if you say that you start your computer and instantly you have a video mode, then not. But if you say by setting it up with grub or your own bootloader, then yes.
mrjbom wrote:
How do I do this with GRUB?
For grub, it depends what multiboot specification you use. If multiboot one, you'll need to add the 1 << 2 flag, and then below the checksum, you'll need to pass the options for the flag, which are:
Code:
dd 0
dd 0
dd 0
dd 0
dd 0
Those are for other flags, which you can see in the mboot specification 1.

Then you have 4 options more. The first one, will indicate grub if it haves to use graphics mode or text mode. put
Code:
dd 1
for text mode, and
Code:
dd 0
for graphics mode. The next will indicate the width of the video mode, in case of
Code:
dd 0
, that means no preference to you. The same goes to the next option, but with the width. and the last option, is the bpp(bits per pixel), wich an zero means no preference(note that all the last 4 options have to be with "dd" and then the value.)

For multiboot 2, you need to declare a separate header wich you'll need to include. The header needs to be declared like this:
Code:
dw 5
dw 0
dd 20


And the last three as dd, wich will declare the width, height and bpp. I strongly recommend you to read the specification that i gave you.

btw http://www.ctyme.com/intr/int.htm there you have a page with all the interrupts. in 0x10, search for svga, and you'll have what you can do with the bios int 0x10.


Top
 Profile  
 
 Post subject: Re: How to use framebuffer SVGA in the BIOS?
PostPosted: Mon Jul 22, 2019 10:22 am 
Offline
Member
Member

Joined: Sun Jul 21, 2019 7:34 am
Posts: 36
alberinfo wrote:
For grub, it depends what multiboot specification you use. If multiboot one, you'll need to add the 1 << 2 flag

I use the first GRUB specification.
My
Code:
bootloader.asm
code looks like this:
Code:
bits 32
section .text
        ;multiboot spec
        align 4
        dd 0x1BADB002              ;magic
        dd 1 << 2                       ;flags
        dd - (0x1BADB002 + 1 << 2)      ;checksum
        dd 0
        dd 0
        dd 0
        dd 0
        dd 0

global start
extern kmain

start:
  mov ah, 00h
  mov al, 13h
  int 10h
  cli
  mov esp, stack_space
  call kmain
  hlt

section .bss
resb 8192
stack_space:


After loaded GRUB gives me an error:
Code:
no multiboot headers found
.
What's wrong?


Top
 Profile  
 
 Post subject: Re: How to use framebuffer SVGA in the BIOS?
PostPosted: Mon Jul 22, 2019 12:12 pm 
Offline
Member
Member

Joined: Wed Aug 29, 2018 4:42 pm
Posts: 122
well, it seems that you're not putting
mrjbom wrote:
dd 0x1BADB002              ;magic
        dd 1 << 2                       ;flags
        dd - (0x1BADB002 + 1 << 2)      ;checksum
        dd 0
        dd 0
        dd 0
        dd 0
        dd 0
this into a header. also, just if you want(it will make your life easier) declare the flags apart, and then use them into the header, so after all it should look like this.
Code:
%define MULTIBOOT_MAGIC 0x1BADB002
%define MULTIBOOT_FLAGS (1<<0 | 1<<1 | 1<<2)

section .text
align 4
multiboot_header:
  dd MULTIBOOT_MAGIC
  dd MULTIBOOT_FLAGS
  dd -(MULTIBOOT_MAGIC + MULTIBOOT_FLAGS)
  dd 0
  dd 0
  dd 0
  dd 0
  dd 0
  dd 0
  dd 800 ; here you put the width you want
  dd 600 ; here you put the height you want
  dd 8 ; here you put the bpp you want

see how you do align 4, and then you have a header with all you need. also, the last three lines will set up an 800*600 mode with 8 bpp, but you can use the modes available for vesa.(you can see them into the interrupt list, int 0x10, ax 0x4F02)


Top
 Profile  
 
 Post subject: Re: How to use framebuffer SVGA in the BIOS?
PostPosted: Mon Jul 22, 2019 2:25 pm 
Offline
Member
Member

Joined: Sun Jul 21, 2019 7:34 am
Posts: 36
Quote:
800*600 mode with 8 bpp

Great, VESA's on. Now I'm trying to paint the first pixel white. I use QEMU for emulation, its video buffer address is 0xFD000000. I try to record pixels like this
Code:
byte* vesaaddr = (byte*)0xFD000000;
vesaaddr[0] = 255;
vesaaddr[1] = 255;
vesaaddr[2] = 255;
vesaaddr[3] = 255;
vesaaddr[4] = 255;
vesaaddr[5] = 255;
vesaaddr[6] = 255;
vesaaddr[7] = 255;

but it doesn't help, no effect.


Top
 Profile  
 
 Post subject: Re: How to use framebuffer SVGA in the BIOS?
PostPosted: Mon Jul 22, 2019 2:33 pm 
Offline
Member
Member

Joined: Wed Aug 29, 2018 4:42 pm
Posts: 122
Drawing In Protected Mode.


Top
 Profile  
 
 Post subject: Re: How to use framebuffer SVGA in the BIOS?
PostPosted: Mon Jul 22, 2019 3:05 pm 
Offline
Member
Member

Joined: Sun Jul 21, 2019 7:34 am
Posts: 36
It doesn't work. In kernel.asm file I put 800x600 32 bbp. I copied the putpixel function and try to call it like this: putpixel(0xFD000000, 1, 1, 0x7800); I should see a red pixel in the top left corner. But I don't see him.


Top
 Profile  
 
 Post subject: Re: How to use framebuffer SVGA in the BIOS?
PostPosted: Mon Jul 22, 2019 3:37 pm 
Offline
Member
Member

Joined: Wed Aug 29, 2018 4:42 pm
Posts: 122
well, there are a few things. First: you should fill more part of the screen(first of all, for seeing if all is working). What i normally do for this is
Code:
memset(fb, color)
so it will fill the screen with the color. if it doesn't work or crashes, then something is wrong. Second:
mrjbom wrote:
0x7800
i don't know where did you get that red is that color. red is 0xFF0000. https://www.rapidtables.com/web/color/html-color-codes.html, into this page you can see pretty much every color you'd want, and search for your own colors. also remember to use the hex value of the color.


Top
 Profile  
 
 Post subject: Re: How to use framebuffer SVGA in the BIOS?
PostPosted: Mon Jul 22, 2019 4:08 pm 
Offline
Member
Member

Joined: Sun Jul 21, 2019 7:34 am
Posts: 36
No effect it does not.

memset takes three parameters, I tried to use it like this: memset((void*)0xFD000000, 0xFF0000, sizeof(0xFD000000);
alberinfo wrote:
Code:
memset(fb, color)


The color I took from here is "Drawing In Protected Mode", The "Color" section provides examples of colors.
alberinfo wrote:
Second:
mrjbom wrote:
0x7800
i don't know where did you get that red is that color. red is 0xFF0000. https://www.rapidtables.com/web/color/html-color-codes.html, into this page you can see pretty much every color you'd want, and search for your own colors. also remember to use the hex value of the color.


Top
 Profile  
 
 Post subject: Re: How to use framebuffer SVGA in the BIOS?
PostPosted: Mon Jul 22, 2019 4:13 pm 
Offline
Member
Member

Joined: Wed Aug 29, 2018 4:42 pm
Posts: 122
mrjbom wrote:
The color I took from here is "Drawing In Protected Mode", The "Color" section provides examples of colors.
Literaly from the page:
Quote:
E.g. you will have xRRRRRGGGGGBBBBB for 15-bits mode, meaning that #ff0000 red is there 0x7800
Which means that this is for an 15 bpp mode


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 12 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: klange and 13 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group