[Closed] Setting VESA/VBE 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.
User avatar
Octacone
Member
Member
Posts: 1138
Joined: Fri Aug 07, 2015 6:13 am

Re: Setting VESA/VBE Mode

Post by Octacone »

Good news:

Grub can finally make an iso of my OS
QEMU can boot that iso and even recognizes grub


Bad news:
Getting error you need to load the kernel first.
I really don't understand since my linker and kernel.c and kernel.asm are all compiled and connected
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
User avatar
DeezRamChips
Member
Member
Posts: 132
Joined: Fri Apr 08, 2016 5:03 am
Location: atapio.cpp - why won't you work :(
Contact:

Re: Setting VESA/VBE Mode

Post by DeezRamChips »

Oh, I see !!!!!!

You forgot the boot instruction xDDDD
User avatar
DeezRamChips
Member
Member
Posts: 132
Joined: Fri Apr 08, 2016 5:03 am
Location: atapio.cpp - why won't you work :(
Contact:

Re: Setting VESA/VBE Mode

Post by DeezRamChips »

try this:

Code: Select all

menuentry "BasicOS" {	
  multiboot /kernel.bin
  boot
}
User avatar
Octacone
Member
Member
Posts: 1138
Joined: Fri Aug 07, 2015 6:13 am

Re: Setting VESA/VBE Mode

Post by Octacone »

DeezRamChips wrote:try this:

Code: Select all

menuentry "BasicOS" {	
  multiboot /kernel.bin
  boot
}
I already have that
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
User avatar
DeezRamChips
Member
Member
Posts: 132
Joined: Fri Apr 08, 2016 5:03 am
Location: atapio.cpp - why won't you work :(
Contact:

Re: Setting VESA/VBE Mode

Post by DeezRamChips »

You said you had

Code: Select all

   echo set default=0 >> iso/boot/grub/grub.cfg
   echo set timeout=0 >> iso/boot/grub/grub.cfg
   echo menuentry "BasicOS" { >> iso/boot/grub/grub.cfg
   echo         set root='(hd96)' >> iso/boot/grub/grub.cfg
   echo         multiboot /boot/kernel.bin >> iso/boot/grub/grub.cfg
   echo } >> iso/boot/grub/grub.cfg
Where is the boot instruction ?

it should be:

Code: Select all

   echo set default=0 >> iso/boot/grub/grub.cfg
   echo set timeout=0 >> iso/boot/grub/grub.cfg
   echo menuentry "BasicOS" { >> iso/boot/grub/grub.cfg
   echo         multiboot /boot/kernel.bin >> iso/boot/grub/grub.cfg
   echo         boot >> iso/boot/grub/grub.cfg
   echo } >> iso/boot/grub/grub.cfg
User avatar
Octacone
Member
Member
Posts: 1138
Joined: Fri Aug 07, 2015 6:13 am

Re: Setting VESA/VBE Mode

Post by Octacone »

When I make my iso file from make file and then try to run it, it does not work, qemu says no bootable media

When I use terminal to make my iso and to start qemu it boots, but with error you need to load the kernel first
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
User avatar
DeezRamChips
Member
Member
Posts: 132
Joined: Fri Apr 08, 2016 5:03 am
Location: atapio.cpp - why won't you work :(
Contact:

Re: Setting VESA/VBE Mode

Post by DeezRamChips »

Could you give me a .zip file with all your os (your work directory)

I'll try to see what's wrong
User avatar
Octacone
Member
Member
Posts: 1138
Joined: Fri Aug 07, 2015 6:13 am

Re: Setting VESA/VBE Mode

Post by Octacone »

Yes!


Fixed my makefile!
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
User avatar
DeezRamChips
Member
Member
Posts: 132
Joined: Fri Apr 08, 2016 5:03 am
Location: atapio.cpp - why won't you work :(
Contact:

Re: Setting VESA/VBE Mode

Post by DeezRamChips »

It's working ?
User avatar
DeezRamChips
Member
Member
Posts: 132
Joined: Fri Apr 08, 2016 5:03 am
Location: atapio.cpp - why won't you work :(
Contact:

Re: Setting VESA/VBE Mode

Post by DeezRamChips »

How did you get it to work ?
User avatar
Octacone
Member
Member
Posts: 1138
Joined: Fri Aug 07, 2015 6:13 am

Re: Setting VESA/VBE Mode

Post by Octacone »

DeezRamChips wrote:How did you get it to work ?
I just made another variable that servers as boot.iso location for qemu.
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
User avatar
DeezRamChips
Member
Member
Posts: 132
Joined: Fri Apr 08, 2016 5:03 am
Location: atapio.cpp - why won't you work :(
Contact:

Re: Setting VESA/VBE Mode

Post by DeezRamChips »

Weel greate !

Also, here is the working version of the VESA driver (fixed for all resolutions ^_^)

vesa.h

Code: Select all

#ifndef __VESA_H__
#define __VESA_H__

#include <types.h>

extern void init(long addr, int pitch, int width, int height, char bpp, int xres, int yres);
extern void putPixel(int x, int y, int r, int g, int b);

#endif
vesa.c

Code: Select all

#include <vesa.h>
#include <types.h>
#include <io.h>

long fb_addr;
int fb_pitch;
int fb_width;
int fb_height;
char fb_bpp;
int fb_xres;
int fb_yres;

char* vram = (char*)0xB8000;

void init(long addr, int pitch, int width, int height, char bpp, int xres, int yres){
	vram = (char*)addr;
	fb_pitch = pitch;
	fb_width = width;
	fb_height = height;
	fb_bpp = bpp;
	fb_xres = xres;
	fb_yres = yres;
}

void putPixel(int x, int y, int r, int g, int b){
    unsigned where = x*(fb_width/fb_xres) + y*fb_width;
	vram[where + 0] = b;  // BLUE
    vram[where + 1] = g;  // GREEN
    vram[where + 2] = r;  // RED
	vram[where + 3] = 0xFF;  // ALPHA
}
User avatar
Octacone
Member
Member
Posts: 1138
Joined: Fri Aug 07, 2015 6:13 am

Re: Setting VESA/VBE Mode

Post by Octacone »

DeezRamChips wrote:Weel greate !

Also, here is the working version of the VESA driver (fixed for all resolutions ^_^)

vesa.h

Code: Select all

#ifndef __VESA_H__
#define __VESA_H__

#include <types.h>

extern void init(long addr, int pitch, int width, int height, char bpp, int xres, int yres);
extern void putPixel(int x, int y, int r, int g, int b);

#endif
vesa.c

Code: Select all

#include <vesa.h>
#include <types.h>
#include <io.h>

long fb_addr;
int fb_pitch;
int fb_width;
int fb_height;
char fb_bpp;
int fb_xres;
int fb_yres;

char* vram = (char*)0xB8000;

void init(long addr, int pitch, int width, int height, char bpp, int xres, int yres){
	vram = (char*)addr;
	fb_pitch = pitch;
	fb_width = width;
	fb_height = height;
	fb_bpp = bpp;
	fb_xres = xres;
	fb_yres = yres;
}

void putPixel(int x, int y, int r, int g, int b){
    unsigned where = x*(fb_width/fb_xres) + y*fb_width;
	vram[where + 0] = b;  // BLUE
    vram[where + 1] = g;  // GREEN
    vram[where + 2] = r;  // RED
	vram[where + 3] = 0xFF;  // ALPHA
}
I am fine with that, I already have my own way to drawing to the screen and making shapes etc.
One of the main problems is my makefile, let me tweak it a bit. I doesn't work again. :|
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
User avatar
DeezRamChips
Member
Member
Posts: 132
Joined: Fri Apr 08, 2016 5:03 am
Location: atapio.cpp - why won't you work :(
Contact:

Re: Setting VESA/VBE Mode

Post by DeezRamChips »

I hate makefile, I prefer using scipts
User avatar
Octacone
Member
Member
Posts: 1138
Joined: Fri Aug 07, 2015 6:13 am

Re: Setting VESA/VBE Mode

Post by Octacone »

And finally I fixed my makefile, this time for real.
So this is my problem:
Attachments
QEMU_010.png
QEMU_010.png (6.6 KiB) Viewed 3973 times
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
Post Reply