grub vbeset : put pixel bad result
Posted: Sat Aug 29, 2009 2:36 pm
Hello everybody
when i want to use vesa video mode, i let grub set the mode for me with stage2_eltorino and vbeset :
i get :
http://myos.redby.fr/image/vbe.png
normally with vga12h mode, i get :
http://myos.redby.fr/image/novbe.png
this my code for vesa and grub, :
I dont know where is the probleme !!
and the vbe mode struct :
when i want to use vesa video mode, i let grub set the mode for me with stage2_eltorino and vbeset :
Code: Select all
default=0
timeout=30
title=MyOS : free and Open Source OS
kernel /kernel.bin -disk 0 -part 0 -init C:/sys/bin/shell -b
vbeset 771
boot
http://myos.redby.fr/image/vbe.png
normally with vga12h mode, i get :
http://myos.redby.fr/image/novbe.png
this my code for vesa and grub, :
I dont know where is the probleme !!
Code: Select all
static int lfb_px = 0;
static int lfb_py = 0;
static ULONG lfb_width = 0;
static ULONG lfb_height = 0;
static ULONG lfb_depth = 0;
static ULONG lfb_type = 0;
void lfb_clear()
{
memset((char*)lfb,15,lfb_width*lfb_height*lfb_depth);
}
void init_lfb(struct multiboot_info *multiboot )
{
struct vbe_mode *mode_info;
void *lfb_ptr;
lfb_px = 0;
lfb_py = 0;
if ( (multiboot->flags & (1<<11)) == 0 )
{
lfb_width = 0;
lfb_height = 0;
lfb_depth = 0;
lfb_type = 0;
lfb_ptr = 0;
printk("\n Video mode : VGA 12h\n");
}
else
{
setVideoMode(MODEVBE);
mode_info = (struct vbe_mode*) multiboot->vbe_mode_info;
lfb_width = mode_info->x_resolution;
lfb_height = mode_info->y_resolution;
lfb_depth = mode_info->bits_per_pixel;
lfb_type = 0;
lfb_ptr = (void*)mode_info->phys_base;
lfb = (unsigned char*)lfb_ptr;
printk("\n Video mode : VESA grub\n");
}
// set_lfb( lfb_width, lfb_height, lfb_depth, lfb_type, lfb_ptr );
}
#define PIXEL_POINTEUR(x,y) ((char*)(lfb+x \
+((unsigned short int)y*(unsigned short int)lfb_width)))
void putpixel_vbe(ULONG x, ULONG y, ULONG col) {
*PIXEL_POINTEUR(x,y)=(char)col;
}
Code: Select all
/* VBE mode information. */
struct vbe_mode
{
unsigned short mode_attributes;
unsigned char win_a_attributes;
unsigned char win_b_attributes;
unsigned short win_granularity;
unsigned short win_size;
unsigned short win_a_segment;
unsigned short win_b_segment;
unsigned long win_func;
unsigned short bytes_per_scanline;
/* >=1.2 */
unsigned short x_resolution;
unsigned short y_resolution;
unsigned char x_char_size;
unsigned char y_char_size;
unsigned char number_of_planes;
unsigned char bits_per_pixel;
unsigned char number_of_banks;
unsigned char memory_model;
unsigned char bank_size;
unsigned char number_of_image_pages;
unsigned char reserved0;
/* direct color */
unsigned char red_mask_size;
unsigned char red_field_position;
unsigned char green_mask_size;
unsigned char green_field_position;
unsigned char blue_mask_size;
unsigned char blue_field_position;
unsigned char reserved_mask_size;
unsigned char reserved_field_position;
unsigned char direct_color_mode_info;
/* >=2.0 */
unsigned long phys_base;
unsigned long reserved1;
unsigned short reversed2;
/* >=3.0 */
unsigned short linear_bytes_per_scanline;
unsigned char banked_number_of_image_pages;
unsigned char linear_number_of_image_pages;
unsigned char linear_red_mask_size;
unsigned char linear_red_field_position;
unsigned char linear_green_mask_size;
unsigned char linear_green_field_position;
unsigned char linear_blue_mask_size;
unsigned char linear_blue_field_position;
unsigned char linear_reserved_mask_size;
unsigned char linear_reserved_field_position;
unsigned long max_pixel_clock;
unsigned char reserved3[189];
} __attribute__ ((packed));