Page 2 of 7
Re: Setting VESA/VBE Mode
Posted: Fri Jul 15, 2016 8:08 am
by Octacone
DeezRamChips wrote:DeezRamChips wrote:thehardcoreOS wrote:Update:
I downloaded and included multiboot header file.
kernel_main(multiboot_info_t *mbit)
{
...
}
Now how do I set mbit.width and mbit.height mbi.mod_type mbi.depth?
I can not do that directly because compiler throws errors.
Is there any special assembly related code I need to do before that?
Update 2: I just discovered that you can set multiboot flags inside assembly and that they co-respond with those declared inside my C file.
Since I am using NASM I can not use stuff like .long and .set and I need to use equ and dd but I can not compiler that.
Update 3: I set all the flags for my graphics mode and trust me nothing happens:
Code: Select all
section .text
align 4
dd MAGIC
dd FLAGS
dd CHECKSUM
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 1360
dd 768
dd 32
Exaclty the same problem !
i'm sure you use grub legacy do you ?
You need grub 2 or a patched version of grub legacy
And add that to your grub.cfg file:
Wow, I do not have grub.cfg file. That is really weird, my grub does not want to create an iso image for my OS.
Re: Setting VESA/VBE Mode
Posted: Fri Jul 15, 2016 8:25 am
by DeezRamChips
So, here is how you do:
Step 1:
Create a Directory names "iso"
Step 2:
Put your compiled kernel in this directory
Step 3:
in this directory (iso) create a sub directory called "boot" and in that directory (boot) create a sub directory called "grub"
You should now have something like:
Code: Select all
iso/boot
iso/boot/grub
iso/kernel.bin
Step 4:
in the directory iso/boot/grub , create a file called grub.cfg and write this in it:
Code: Select all
set default=0
set timeout=0
insmod vbe
insmod vga
menuentry "nameOfYourOs" {
multiboot /yourKernel.bin
boot
}
Step 5:
In the terminal type:
Code: Select all
sudo grub-mkrescue --output=boot.iso iso
Here you go ^_^
Re: Setting VESA/VBE Mode
Posted: Fri Jul 15, 2016 8:31 am
by DeezRamChips
And here is how you plot a pixel: (it's the vesa driver I just wrote
)
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;
char* vram = (char*)0xB8000;
void init(long addr, int pitch, int width, int height, char bpp){
vram = (char*)addr;
fb_pitch = pitch;
fb_width = width;
fb_height = height;
fb_bpp = bpp;
}
void putPixel(int x, int y, int r, int g, int b){
unsigned where = x*pitch + y*fb_width;
vram[where + 0] = b; // BLUE
vram[where + 1] = g; // GREEN
vram[where + 2] = r; // RED
vram[where + 3] = 0xFF; // ALPHA
}
Re: Setting VESA/VBE Mode
Posted: Fri Jul 15, 2016 8:40 am
by DeezRamChips
Wowowow there is and error in the vesa drive, let me correct it
Re: Setting VESA/VBE Mode
Posted: Fri Jul 15, 2016 8:42 am
by Octacone
DeezRamChips wrote:So, here is how you do:
Step 1:
Create a Directory names "iso"
Step 2:
Put your compiled kernel in this directory
Step 3:
in this directory (iso) create a sub directory called "boot" and in that directory (boot) create a sub directory called "grub"
You should now have something like:
Code: Select all
iso/boot
iso/boot/grub
iso/kernel.bin
Step 4:
in the directory iso/boot/grub , create a file called grub.cfg and write this in it:
Code: Select all
set default=0
set timeout=0
insmod vbe
insmod vga
menuentry "nameOfYourOs" {
multiboot /yourKernel.bin
boot
}
Step 5:
In the terminal type:
Code: Select all
sudo grub-mkrescue --output=boot.iso iso
Here you go ^_^
Interesting, I've already had a setup like this. Now I added those two commands to grub.cfg and nothing, my .iso does not get created for some reason. What do you use for your emulator. I use qemu-system-i386 with -vga std flag and then I just get no bootable media can't boot from cd floppy hdd etc, but when I use -kernel it works but only kernel shell without any graphics mode.
Re: Setting VESA/VBE Mode
Posted: Fri Jul 15, 2016 8:49 am
by DeezRamChips
Yes, qemu does not work with grub for some reason, i'm using Oracle Virtual Box 4.1
EDIT: No, it works fine now lol, You CAN use qemu
Re: Setting VESA/VBE Mode
Posted: Fri Jul 15, 2016 8:53 am
by Octacone
DeezRamChips wrote:Yes, qemu does not work with grub for some reason, i'm using Oracle Virtual Box 4.1
EDIT: No, it works fine now lol, You CAN use qemu
What flags do you use (for qemu)?
Can you show me a screenshot of your working GUI?
Re: Setting VESA/VBE Mode
Posted: Fri Jul 15, 2016 8:59 am
by DeezRamChips
I dont have a working gui yet, but I plot pixels at the right place.
and, here is the qemu command:
Re: Setting VESA/VBE Mode
Posted: Fri Jul 15, 2016 9:01 am
by DeezRamChips
Could you try the the grub command with my iso directory, it's in an attachement
Re: Setting VESA/VBE Mode
Posted: Fri Jul 15, 2016 9:05 am
by Octacone
DeezRamChips wrote:Could you try the the grub command with my iso directory, it's in an attachement
I will try to boot that file, but first I need to make an iso from it using grbu.
Re: Setting VESA/VBE Mode
Posted: Fri Jul 15, 2016 9:08 am
by DeezRamChips
well, it's in the iso.zip file (I gave you my "iso" directory).
have you installed grub 2 or grub legacy
try:
Re: Setting VESA/VBE Mode
Posted: Fri Jul 15, 2016 9:11 am
by Octacone
DeezRamChips wrote:well, it's in the iso.zip file (I gave you my "iso" directory).
have you installed grub 2 or grub legacy
try:
Looks like I was using grub legacy....
I started connection the peaces together.
Re: Setting VESA/VBE Mode
Posted: Fri Jul 15, 2016 9:17 am
by Octacone
Okay:
1.Grub2 is installed
2.I have a folder inside my osdev one called iso insde it I have folder called boot inside boot I have grub.cfg and my os compiles into an image called kernel.bin that is located inside iso folder and that qemu uses to boot from
3.When I boot that kernel.bin with qemu without -kernel flag I get no boot media and stuff like that = can not boot anything
4.My grub still does not want to make .iso file
5.Looks like there is more into it then I thought
Re: Setting VESA/VBE Mode
Posted: Fri Jul 15, 2016 9:22 am
by Octacone
Code: Select all
Here is my makefile:
COMPILER = gcc
LINKER = ld
ASSEMBLER = nasm
CFLAGS = -m32 -c -ffreestanding -O2 -Wall -Wextra -std=gnu99
ASFLAGS = -f elf32
LDFLAGS = -m elf_i386 -T src/link.ld
EMULATOR = qemu-system-i386
EMULATOR_FLAGS = -vga std
OBJS = not important
OUTPUT = iso/kernel.bin
run: all
$(EMULATOR) $(EMULATOR_FLAGS) $(OUTPUT)
all:$(OBJS)
mkdir iso/ -p
mkdir iso/boot/ -p
$(LINKER) $(LDFLAGS) -o $(OUTPUT) $(OBJS)
obj/etc.o:src/etc.asm
$(ASSEMBLER) $(ASFLAGS) -o obj/etc.o src/kernel.etc my way of compiling etc does not matter for this case cause it works
build:all
rm iso/boot/grub/ -r -f
mkdir iso/boot/grub/
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
grub-mkrescue -o BasicOS.iso iso/
clear:
rm -f obj/*.o
rm -r -f iso/
My folder tree:
iso/boot/grub/grub.cfg
iso/kernel.bin //this is where my os gets compiled
Re: Setting VESA/VBE Mode
Posted: Fri Jul 15, 2016 9:27 am
by DeezRamChips
do you want that I upload my os so you can try to compile it ?(the build.sh also creates the iso)
If my os compiles, I means you have an error of some sort :/