]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
merge multiboot2 into mbtaf-spec
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Sat, 16 Jan 2010 16:34:38 +0000 (17:34 +0100)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Sat, 16 Jan 2010 16:34:38 +0000 (17:34 +0100)
1  2 
doc/kernel.c
doc/multiboot.texi

diff --cc doc/kernel.c
index 2480574019cad09c4587430bbaaf6165f76328fc,57881b6ea6aa24d29d391616b168f4c525cfa241..bd2c5193d86e442942f0272f8d5ec3d20b939062
@@@ -62,150 -64,177 +62,155 @@@ cmain (unsigned long magic, unsigned lo
        return;
      }
  
 -  /* Set MBI to the address of the Multiboot information structure.  */
 -  mbi = (multiboot_info_t *) addr;
 -
 -  /* Print out the flags.  */
 -  printf ("flags = 0x%x\n", (unsigned) mbi->flags);
 -
 -  /* Are mem_* valid?  */
 -  if (CHECK_FLAG (mbi->flags, 0))
 -    printf ("mem_lower = %uKB, mem_upper = %uKB\n",
 -          (unsigned) mbi->mem_lower, (unsigned) mbi->mem_upper);
 -
 -  /* Is boot_device valid?  */
 -  if (CHECK_FLAG (mbi->flags, 1))
 -    printf ("boot_device = 0x%x\n", (unsigned) mbi->boot_device);
 -  
 -  /* Is the command line passed?  */
 -  if (CHECK_FLAG (mbi->flags, 2))
 -    printf ("cmdline = %s\n", (char *) mbi->cmdline);
 -
 -  /* Are mods_* valid?  */
 -  if (CHECK_FLAG (mbi->flags, 3))
 -    {
 -      multiboot_module_t *mod;
 -      int i;
 -      
 -      printf ("mods_count = %d, mods_addr = 0x%x\n",
 -            (int) mbi->mods_count, (int) mbi->mods_addr);
 -      for (i = 0, mod = (multiboot_module_t *) mbi->mods_addr;
 -         i < mbi->mods_count;
 -         i++, mod++)
 -      printf (" mod_start = 0x%x, mod_end = 0x%x, cmdline = %s\n",
 -              (unsigned) mod->mod_start,
 -              (unsigned) mod->mod_end,
 -              (char *) mod->cmdline);
 -    }
 -
 -  /* Bits 4 and 5 are mutually exclusive!  */
 -  if (CHECK_FLAG (mbi->flags, 4) && CHECK_FLAG (mbi->flags, 5))
 -    {
 -      printf ("Both bits 4 and 5 are set.\n");
 -      return;
 -    }
 -
 -  /* Is the symbol table of a.out valid?  */
 -  if (CHECK_FLAG (mbi->flags, 4))
 -    {
 -      multiboot_aout_symbol_table_t *multiboot_aout_sym = &(mbi->u.aout_sym);
 -      
 -      printf ("multiboot_aout_symbol_table: tabsize = 0x%0x, "
 -            "strsize = 0x%x, addr = 0x%x\n",
 -            (unsigned) multiboot_aout_sym->tabsize,
 -            (unsigned) multiboot_aout_sym->strsize,
 -            (unsigned) multiboot_aout_sym->addr);
 -    }
 -
 -  /* Is the section header table of ELF valid?  */
 -  if (CHECK_FLAG (mbi->flags, 5))
 +  size = *(unsigned *) addr;
 +  printf ("Announced mbi size 0x%x\n", size);
 +  for (tag = (struct multiboot_tag *) (addr + 4);
 +       tag->type != MULTIBOOT_TAG_TYPE_END;
 +       tag = (struct multiboot_tag *) ((multiboot_uint8_t *) tag + tag->size))
      {
 -      multiboot_elf_section_header_table_t *multiboot_elf_sec = &(mbi->u.elf_sec);
 -
 -      printf ("multiboot_elf_sec: num = %u, size = 0x%x,"
 -            " addr = 0x%x, shndx = 0x%x\n",
 -            (unsigned) multiboot_elf_sec->num, (unsigned) multiboot_elf_sec->size,
 -            (unsigned) multiboot_elf_sec->addr, (unsigned) multiboot_elf_sec->shndx);
 -    }
 +      printf ("Tag 0x%x, Size 0x%x\n", tag->type, tag->size);
 +      switch (tag->type)
 +      {
 +      case MULTIBOOT_TAG_TYPE_CMDLINE:
 +        printf ("Command line = %s\n",
 +                ((struct multiboot_tag_string *) tag)->string);
 +        break;
 +      case MULTIBOOT_TAG_TYPE_BOOT_LOADER_NAME:
 +        printf ("Boot loader name = %s\n",
 +                ((struct multiboot_tag_string *) tag)->string);
 +        break;
 +      case MULTIBOOT_TAG_TYPE_MODULE:
 +        printf ("Module at 0x%x-0x%x. Command line %s\n",
 +                ((struct multiboot_tag_module *) tag)->mod_start,
 +                ((struct multiboot_tag_module *) tag)->mod_end,
 +                ((struct multiboot_tag_module *) tag)->cmdline);
 +        break;
 +      case MULTIBOOT_TAG_TYPE_BASIC_MEMINFO:
 +        printf ("mem_lower = %uKB, mem_upper = %uKB\n",
 +                ((struct multiboot_tag_basic_meminfo *) tag)->mem_lower,
 +                ((struct multiboot_tag_basic_meminfo *) tag)->mem_upper);
 +        break;
 +      case MULTIBOOT_TAG_TYPE_BOOTDEV:
 +        printf ("Boot device 0x%x,%u,%u\n",
 +                ((struct multiboot_tag_bootdev *) tag)->biosdev,
 +                ((struct multiboot_tag_bootdev *) tag)->slice,
 +                ((struct multiboot_tag_bootdev *) tag)->part);
 +        break;
 +      case MULTIBOOT_TAG_TYPE_MMAP:
 +        {
 +          multiboot_memory_map_t *mmap;
  
 -  /* Are mmap_* valid?  */
 -  if (CHECK_FLAG (mbi->flags, 6))
 -    {
 -      multiboot_memory_map_t *mmap;
 +          printf ("mmap\n");
        
 -      printf ("mmap_addr = 0x%x, mmap_length = 0x%x\n",
 -            (unsigned) mbi->mmap_addr, (unsigned) mbi->mmap_length);
 -      for (mmap = (multiboot_memory_map_t *) mbi->mmap_addr;
 -         (unsigned long) mmap < mbi->mmap_addr + mbi->mmap_length;
 -         mmap = (multiboot_memory_map_t *) ((unsigned long) mmap
 -                                  + mmap->size + sizeof (mmap->size)))
 -      printf (" size = 0x%x, base_addr = 0x%x%x,"
 -              " length = 0x%x%x, type = 0x%x\n",
 -              (unsigned) mmap->size,
 -              (unsigned) (mmap->addr >> 32),
 -              (unsigned) (mmap->addr & 0xffffffff),
 -              (unsigned) (mmap->len >> 32),
 -              (unsigned) (mmap->len & 0xffffffff),
 -              (unsigned) mmap->type);
 -    }
 -
 -  /* Draw diagonal blue line.  */
 -  if (CHECK_FLAG (mbi->flags, 12))
 -    {
 -      multiboot_uint32_t color;
 -      unsigned i;
 -      void *fb = (void *) (unsigned long) mbi->framebuffer_addr;
 -
 -      switch (mbi->framebuffer_type)
 -      {
 -      case MULTIBOOT_FRAMEBUFFER_TYPE_INDEXED:
 +          for (mmap = ((struct multiboot_tag_mmap *) tag)->entries;
 +               (multiboot_uint8_t *) mmap 
 +                 < (multiboot_uint8_t *) tag + tag->size;
 +               mmap = (multiboot_memory_map_t *) ((unsigned long) mmap
 +                                                  + mmap->size
 +                                                  + sizeof (mmap->size)))
 +            printf (" size = 0x%x, base_addr = 0x%x%x,"
 +                    " length = 0x%x%x, type = 0x%x\n",
 +                    (unsigned) mmap->size,
 +                    (unsigned) (mmap->addr >> 32),
 +                    (unsigned) (mmap->addr & 0xffffffff),
 +                    (unsigned) (mmap->len >> 32),
 +                    (unsigned) (mmap->len & 0xffffffff),
 +                    (unsigned) mmap->type);
 +        }
 +        break;
 +      case MULTIBOOT_TAG_TYPE_FRAMEBUFFER:
          {
 -          unsigned best_distance, distance;
 -          struct multiboot_color *palette;
 +          multiboot_uint32_t color;
 +          unsigned i;
 +          struct multiboot_tag_framebuffer *tagfb
 +            = (struct multiboot_tag_framebuffer *) tag;
 +          void *fb = (void *) (unsigned long) tagfb->common.framebuffer_addr;
 +
 +          switch (tagfb->common.framebuffer_type)
 +            {
 +            case MULTIBOOT_FRAMEBUFFER_TYPE_INDEXED:
 +              {
 +                unsigned best_distance, distance;
 +                struct multiboot_color *palette;
            
 -          palette = (struct multiboot_color *) mbi->framebuffer_palette_addr;
 +                palette = tagfb->framebuffer_palette;
  
 -          color = 0;
 -          best_distance = 4*256*256;
 +                color = 0;
 +                best_distance = 4*256*256;
 +          
 +                for (i = 0; i < tagfb->framebuffer_palette_num_colors; i++)
 +                  {
 +                    distance = (0xff - palette[i].blue) 
 +                      * (0xff - palette[i].blue)
 +                      + palette[i].red * palette[i].red
 +                      + palette[i].green * palette[i].green;
 +                    if (distance < best_distance)
 +                      {
 +                        color = i;
 +                        best_distance = distance;
 +                      }
 +                  }
 +              }
 +              break;
 +
 +            case MULTIBOOT_FRAMEBUFFER_TYPE_RGB:
 +              color = ((1 << tagfb->framebuffer_blue_mask_size) - 1) 
 +                << tagfb->framebuffer_blue_field_position;
 +              break;
 +
++            case MULTIBOOT_FRAMEBUFFER_TYPE_EGA_TEXT:
++              color = '\\' | 0x0100;
++              break;
++
 +            default:
 +              color = 0xffffffff;
 +              break;
 +            }
            
 -          for (i = 0; i < mbi->framebuffer_palette_num_colors; i++)
 +          for (i = 0; i < tagfb->common.framebuffer_width
 +                 && i < tagfb->common.framebuffer_height; i++)
              {
 -              distance = (0xff - palette[i].blue) * (0xff - palette[i].blue)
 -                + palette[i].red * palette[i].red
 -                + palette[i].green * palette[i].green;
 -              if (distance < best_distance)
 +              switch (tagfb->common.framebuffer_bpp)
                  {
 -                  color = i;
 -                  best_distance = distance;
 +                case 8:
 +                  {
 +                    multiboot_uint8_t *pixel = fb
 +                      + tagfb->common.framebuffer_pitch * i + i;
 +                    *pixel = color;
 +                  }
 +                  break;
 +                case 15:
 +                case 16:
 +                  {
 +                    multiboot_uint16_t *pixel
 +                      = fb + tagfb->common.framebuffer_pitch * i + 2 * i;
 +                    *pixel = color;
 +                  }
 +                  break;
 +                case 24:
 +                  {
 +                    multiboot_uint32_t *pixel
 +                      = fb + tagfb->common.framebuffer_pitch * i + 3 * i;
 +                    *pixel = (color & 0xffffff) | (*pixel & 0xff000000);
 +                  }
 +                  break;
 +
 +                case 32:
 +                  {
 +                    multiboot_uint32_t *pixel
 +                      = fb + tagfb->common.framebuffer_pitch * i + 4 * i;
 +                    *pixel = color;
 +                  }
 +                  break;
                  }
              }
 +          break;
          }
 -        break;
 -
 -      case MULTIBOOT_FRAMEBUFFER_TYPE_RGB:
 -        color = ((1 << mbi->framebuffer_blue_mask_size) - 1) 
 -          << mbi->framebuffer_blue_field_position;
 -        break;
 -      case MULTIBOOT_FRAMEBUFFER_TYPE_EGA_TEXT:
 -        color = '\\' | 0x0100;
 -        break;
 -
 -      default:
 -        color = 0xffffffff;
 -        break;
 -      }
 -      for (i = 0; i < mbi->framebuffer_width
 -           && i < mbi->framebuffer_height; i++)
 -      {
 -        switch (mbi->framebuffer_bpp)
 -          {
 -          case 8:
 -            {
 -              multiboot_uint8_t *pixel = fb + mbi->framebuffer_pitch * i + i;
 -              *pixel = color;
 -            }
 -            break;
 -          case 15:
 -          case 16:
 -            {
 -              multiboot_uint16_t *pixel
 -                = fb + mbi->framebuffer_pitch * i + 2 * i;
 -              *pixel = color;
 -            }
 -            break;
 -          case 24:
 -            {
 -              multiboot_uint32_t *pixel
 -                = fb + mbi->framebuffer_pitch * i + 3 * i;
 -              *pixel = (color & 0xffffff) | (*pixel & 0xff000000);
 -            }
 -            break;
 -
 -          case 32:
 -            {
 -              multiboot_uint32_t *pixel
 -                = fb + mbi->framebuffer_pitch * i + 4 * i;
 -              *pixel = color;
 -            }
 -            break;
 -          }
        }
      }
 -
 +  tag = (struct multiboot_tag *) ((multiboot_uint8_t *) tag + tag->size);
 +  printf ("Total mbi size 0x%x\n", (unsigned) tag - addr);
  }    
  
  /* Clear the screen and initialize VIDEO, XPOS and YPOS.  */
index 960bf852d8e72560ef67d2e9f1e1bc72470f89d5,5fbff712bd0063e2b320e2157538a3c8b6f2141d..5a8bad239705814d0b29fb4aabf613c92fc4c2fe
@@@ -915,7 -971,8 +914,8 @@@ Each colour descriptor has following st
          +-------------+
  @end group
  @end example
- If @samp{framebuffer_type} is set to 1 it means direct RGB color. Then color_type is defined as follows:
 -If @samp{framebuffer_type} is set to @samp{1} it means direct RGB color will
 -be used. Then color_type is defined as follows:
++If @samp{framebuffer_type} is set to @samp{1} it means direct RGB color.
++Then color_type is defined as follows:
  
  @example
  @group
  @end group
  @end example
  
- If @samp{framebuffer_type} is set to 2 it means EGA text. In this case @samp{framebuffer_width} and @samp{framebuffer_height} are expressed in characters and not in pixels. @samp{framebuffer_bpp} is equal 16 (16 bits per character) and @samp{framebuffer_pitch} is expressed in bytes per text line.
 -If @samp{framebuffer_type} is set to @samp{2} it means EGA-standard text mode
 -will be used. In this case @samp{framebuffer_width} and
 -@samp{framebuffer_height} are expressed in characters instead of pixels.
 -@samp{framebuffer_bpp} is equal to 16 (bits per character) and
 -@samp{framebuffer_pitch} is expressed in bytes per text line.
 -All further values of @samp{framebuffer_type} are reserved for future expansion.
++If @samp{framebuffer_type} is set to @samp{2} it means EGA text. In this case @samp{framebuffer_width} and @samp{framebuffer_height} are expressed in characters and not in pixels. @samp{framebuffer_bpp} is equal 16 (16 bits per character) and @samp{framebuffer_pitch} is expressed in bytes per text line.
 +All further values of @samp{framebuffer_type} are reserved for future expansion
  
  @node Examples
  @chapter Examples