[SOS]GRUB et VBE

Guillaume DELESTIC guillaume.delestic at neuf.fr
Mer 24 Aou 18:18:53 CEST 2005


Bonjour,

J'ai modifié SOS article 1 pour avoir des informations concernant VBE.
D'apres les information du multiboot de GRUB ces information sont 
présentes si le bits 2 du FLAGS est à 1

multiboot.h  :
#define MULTIBOOT_HEADER_FLAGS        0x00010007

j'ai également modifié la structure multiboot_info
multiboot.h  :

typedef struct multiboot_info
{
  ...
  unsigned long drives_addr;
  /* Gedd 24/08/2005 */
  unsigned long config_table;
  unsigned long boot_loader_name;
  unsigned long apm_table;
  unsigned long vbe_control_info;
  unsigned long vbe_mode_info;
  unsigned short vbe_interface_seg;
  unsigned short vbe_interface_off;
  unsigned short vbe_interface_len;
} multiboot_info_t;

Il faut aussi préciser dans le Stage1 le mode désiré à la suite du 
multiboot_header
multiboot.S :
multiboot_header:
  ...
  /* entry_addr=   */     .long multiboot_entry
  /* Gedd 24/08/2005 */
  /* mode type= */    .long 0
  /* width= */            .long 640
  /* height= */            .long 400
  /* depth= */            .long 8

J'ai egalement modié le main.c afin de recolter et d'afficher ces 
informations
main.c :
...
sos_x86_videomem_printf( 3, 1, SOS_X86_VIDEO_FG_WHITE, "FLAGS  : 0x%x", 
(unsigned)mbi->flags);
  sos_bochs_putstring("Message in a bochs\n");
  //if ((mbi->flags && MULTIBOOT_VBE) == MULTIBOOT_VBE){
  if (1){
      sos_x86_videomem_printf(5, 1, SOS_X86_VIDEO_FG_WHITE ,"VBE HEADER");
      sos_x86_videomem_printf(6, 1, SOS_X86_VIDEO_FG_WHITE 
,"vbe_control_info : 0x%x", (unsigned int)(mbi->vbe_control_info));
      sos_x86_videomem_printf(7, 1, SOS_X86_VIDEO_FG_WHITE 
,"vbe_mode_info : 0x%x", (unsigned int)(mbi->vbe_mode_info));
      sos_x86_videomem_printf(8, 1, SOS_X86_VIDEO_FG_WHITE 
,"vbe_interface_seg : 0x%x", (unsigned short)(mbi->vbe_interface_seg));
      sos_x86_videomem_printf(9, 1, SOS_X86_VIDEO_FG_WHITE 
,"vbe_interface_off : 0x%x", (unsigned short)(mbi->vbe_interface_off));
      sos_x86_videomem_printf(10, 1, SOS_X86_VIDEO_FG_WHITE 
,"vbe_interface_len : 0x%x", (unsigned short)(mbi->vbe_interface_len));
  }
 else {
      sos_x86_videomem_printf(5, 1, SOS_X86_VIDEO_FG_WHITE ,"VBE HEADER 
KO");
  }
...

Si Grub trouve une version de VBE superieure ou égale a 2 il l'indique 
en mettant le bit 11 du flag multiboot_info à 1

Bien evidement apres avoir testé tout ça , les structure sont vide et on 
voit bien que le bit 11 est a 0

En passant par mon os (boot et loader en mode réél puis passage en mode 
protégé pour le noyau avant chargement de celui-ci), j'arrive à recolter 
les information relative au VBE. Et ce sur la meme configuration de qemu 
ou bochs.

GRUB est il buggé sur les fonctions VBE ??

PS: je joins les sources modifié pour ceux que ça interesse





-------------- section suivante --------------
/* Copyright (C) 1999  Free Software Foundation, Inc.

   This program is free software; you can redistribute it and/or
   modify it under the terms of the GNU General Public License
   as published by the Free Software Foundation; either version 2
   of the License, or (at your option) any later version.
   
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.
   
   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
   USA. 
*/

	
/* The operating system is booted by Grub, so we almost have nothing
   to do to boot it. We only have to conform to the Multiboot
   standard, as defined by the Grub documentation */
	
#define ASM 1
/* The multiboot.h header contains a lot of multiboot standard
   definitions */
#include "multiboot.h"

	/* The multiboot header itself. It must come first. */
.section ".multiboot"
	/* Multiboot header must be aligned on a 4-byte boundary */
	.align 4
multiboot_header:
  /* magic=        */ 		.long MULTIBOOT_HEADER_MAGIC
  /* flags=        */ 		.long MULTIBOOT_HEADER_FLAGS
  /* checksum= */ 		.long -(MULTIBOOT_HEADER_MAGIC \
                              		+MULTIBOOT_HEADER_FLAGS)
  /* header_addr= */ 	.long multiboot_header
  /* load_addr=    */ 	.long __b_kernel
  /* load_end_addr=*/ 	.long __e_load
  /* bss_end_addr= */ 	.long __e_kernel
  /* entry_addr=   */ 	.long multiboot_entry
  /* Gedd 24/08/2005 */
  /* mode type= */ 		.long 0
  /* width= */			.long 640
  /* height= */			.long 400
  /* depth= */			.long 8

/* Here is the beginning of the code of our operating system */
.text

.globl start, _start
start:
_start:
multiboot_entry:
	/* Set up a stack */
	movl $(stack + MULTIBOOT_STACK_SIZE), %ebp
	movl %ebp, %esp

	/* Set EFLAGS to 0 */
	pushl $0
	/* pop stack into the EFLAGS register */
	popf

	/* Push the magic and the address on the stack, so that they
	will be the parameters of the cmain function */
	pushl %ebx
	pushl %eax

	/* Call the cmain function (os.c) */
	call EXT_C(sos_main)

	/* Should never get there */
loop:
	hlt
	jmp loop

	/* Here is the stack */
.comm	stack, MULTIBOOT_STACK_SIZE
-------------- section suivante --------------
/* Copyright (C) 2004  The SOS Team
   Copyright (C) 1999  Free Software Foundation, Inc.

   This program is free software; you can redistribute it and/or
   modify it under the terms of the GNU General Public License
   as published by the Free Software Foundation; either version 2
   of the License, or (at your option) any later version.
   
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.
   
   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
   USA. 
*/

/* Include definitions of the multiboot standard */
#include <bootstrap/multiboot.h>
#include <sos/klibc.h>
#include <sos/assert.h>
#include <drivers/x86_videomem.h>
#include <drivers/bochs.h>



/* The C entry point of our operating system */
void sos_main(unsigned long magic, unsigned long addr)
{
  unsigned i;

  /* Grub sends us a structure, called multiboot_info_t with a lot of
     precious informations about the system, see the multiboot
     documentation for more information. */
  multiboot_info_t *mbi;
  mbi = (multiboot_info_t *) addr;

  /* Setup bochs and console, and clear the console */
  sos_bochs_setup();

  sos_x86_videomem_setup();
  sos_x86_videomem_cls(SOS_X86_VIDEO_FG_WHITE);

  /* Greetings from SOS */
  if (magic == MULTIBOOT_BOOTLOADER_MAGIC)
    /* Loaded with Grub */
    sos_x86_videomem_printf(1, 0,
			    SOS_X86_VIDEO_FG_YELLOW ,
			    "Welcome From GRUB to %s%c RAM is %dMB (upper mem = 0x%x kB)",
			    "SOS", ',',
			    (unsigned)(mbi->mem_upper >> 10) + 1,
			    (unsigned)mbi->mem_upper);
  else
    /* Not loaded with grub */
    sos_x86_videomem_printf(1, 0,
			    SOS_X86_VIDEO_FG_YELLOW ,
			    "Welcome to SOS");

  sos_x86_videomem_printf( 3, 1, SOS_X86_VIDEO_FG_WHITE, "FLAGS  : 0x%x", (unsigned)mbi->flags);
  sos_bochs_putstring("Message in a bochs\n");
  //if ((mbi->flags && MULTIBOOT_VBE) == MULTIBOOT_VBE){
  if (1){
  	sos_x86_videomem_printf(5, 1, SOS_X86_VIDEO_FG_WHITE ,"VBE HEADER");
  	sos_x86_videomem_printf(6, 1, SOS_X86_VIDEO_FG_WHITE ,"vbe_control_info : 0x%x", (unsigned int)(mbi->vbe_control_info));
  	sos_x86_videomem_printf(7, 1, SOS_X86_VIDEO_FG_WHITE ,"vbe_mode_info : 0x%x", (unsigned int)(mbi->vbe_mode_info));
  	sos_x86_videomem_printf(8, 1, SOS_X86_VIDEO_FG_WHITE ,"vbe_interface_seg : 0x%x", (unsigned short)(mbi->vbe_interface_seg));
  	sos_x86_videomem_printf(9, 1, SOS_X86_VIDEO_FG_WHITE ,"vbe_interface_off : 0x%x", (unsigned short)(mbi->vbe_interface_off));
  	sos_x86_videomem_printf(10, 1, SOS_X86_VIDEO_FG_WHITE ,"vbe_interface_len : 0x%x", (unsigned short)(mbi->vbe_interface_len));
  }
 else {
  	sos_x86_videomem_printf(5, 1, SOS_X86_VIDEO_FG_WHITE ,"VBE HEADER KO");
  }

  /* An operatig system never ends */
  for (;;)
    continue;

  return;
}
-------------- section suivante --------------
#ifndef __MULTIBOOT_H__
#define __MULTIBOOT_H__

/* multiboot.h - the header for Multiboot */
/* Copyright (C) 1999  Free Software Foundation, Inc.
   
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.
   
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.
   
   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */

/* Macros.  */

/* The magic number for the Multiboot header.  */
#define MULTIBOOT_HEADER_MAGIC		0x1BADB002

/* The flags for the Multiboot header.  */
#define MULTIBOOT_HEADER_FLAGS		0x00010007

/* The magic number passed by a Multiboot-compliant boot loader.  */
#define MULTIBOOT_BOOTLOADER_MAGIC	0x2BADB002

/* The size of our stack (16KB).  */
#define MULTIBOOT_STACK_SIZE	        0x4000

#define MULTIBOOT_CMDLINE 4
#define MULTIBOOT_MODS 8
#define MULTIBOOT_VBE 0x00000800

/* C symbol format. HAVE_ASM_USCORE is defined by configure.  */
#ifdef HAVE_ASM_USCORE
# define EXT_C(sym)			_ ## sym
#else
# define EXT_C(sym)			sym
#endif

#ifndef ASM
/* Do not include here in boot.S.  */



/* Types.  */

/* The Multiboot header.  */
typedef struct multiboot_header
{
  unsigned long magic;
  unsigned long flags;
  unsigned long checksum;
  unsigned long header_addr;
  unsigned long load_addr;
  unsigned long load_end_addr;
  unsigned long bss_end_addr;
  unsigned long entry_addr;
} multiboot_header_t;

/* The symbol table for a.out.  */
typedef struct aout_symbol_table
{
  unsigned long tabsize;
  unsigned long strsize;
  unsigned long addr;
  unsigned long reserved;
} aout_symbol_table_t;

/* The section header table for ELF.  */
typedef struct elf_section_header_table
{
  unsigned long num;
  unsigned long size;
  unsigned long addr;
  unsigned long shndx;
} elf_section_header_table_t;

/* The Multiboot information.  */
typedef struct multiboot_info
{
  unsigned long flags;
  unsigned long mem_lower;
  unsigned long mem_upper;
  unsigned long boot_device;
  unsigned long cmdline;
  unsigned long mods_count;
  unsigned long mods_addr;
  union
  {
    aout_symbol_table_t aout_sym;
    elf_section_header_table_t elf_sec;
  } u;
  unsigned long mmap_length;
  unsigned long mmap_addr;
  unsigned long drives_length;
  unsigned long drives_addr;
  /* Gedd 24/08/2005 */
  unsigned long config_table;
  unsigned long boot_loader_name;
  unsigned long apm_table;
  unsigned long vbe_control_info;
  unsigned long vbe_mode_info;
  unsigned short vbe_interface_seg;
  unsigned short vbe_interface_off;
  unsigned short vbe_interface_len;
} multiboot_info_t;

/* The module structure.  */
typedef struct module
{
  unsigned long mod_start;
  unsigned long mod_end;
  unsigned long string;
  unsigned long reserved;
} module_t;

/* The memory map. Be careful that the offset 0 is base_addr_low
   but no size.  */
typedef struct memory_map
{
  unsigned long size;
  unsigned long base_addr_low;
  unsigned long base_addr_high;
  unsigned long length_low;
  unsigned long length_high;
  unsigned long type;
} memory_map_t;

void dump_multiboot_info(multiboot_info_t *mbi);

#endif /* ! ASM */

#endif /* __MULTIBOOT_H__ */


Plus d'informations sur la liste de diffusion Sos