+2010-01-12 Vladimir Serbinenko <phcoder@gmail.com>
+2010-01-12 Robert Millan <rmh.grub@aybabtu.com>
+
+ Video mode amendment by Vladimir Serbinenko. See NEWS file for
+ details.
+
+ * NEWS: Document video mode amendment.
+ * doc/multiboot.texi: Video mode ammendment.
+ * doc/multiboot.h (MULTIBOOT_INFO_VIDEO_INFO): Remove macro.
+ (MULTIBOOT_INFO_VBE_INFO, MULTIBOOT_INFO_FRAMEBUFFER_INFO): New macros.
+ (multiboot_uint8_t): New type.
+ (struct multiboot_color): New structure.
+ (struct multiboot_info): Add new video mode fields.
+ (MULTIBOOT_FRAMEBUFFER_TYPE_INDEXED)
+ (MULTIBOOT_FRAMEBUFFER_TYPE_RGB): New macros.
+
+ * doc/boot.S (MULTIBOOT_HEADER_FLAGS): Add `MULTIBOOT_VIDEO_MODE'.
+ (multiboot_header): Include video mode information.
+ * doc/kernel.c (cmain): Draw a blue diagonal line when video mode
+ information is provided.
+
2010-01-07 Robert Millan <rmh.grub@aybabtu.com>
* doc/multiboot.h (MULTIBOOT_UNSUPPORTED): Remove macro (moved to
/* boot.S - bootstrap the kernel */
-/* Copyright (C) 1999, 2001 Free Software Foundation, Inc.
+/* Copyright (C) 1999, 2001, 2010 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
#else
# define AOUT_KLUDGE MULTIBOOT_AOUT_KLUDGE
#endif
-#define MULTIBOOT_HEADER_FLAGS MULTIBOOT_PAGE_ALIGN | MULTIBOOT_MEMORY_INFO | AOUT_KLUDGE
+#define MULTIBOOT_HEADER_FLAGS MULTIBOOT_PAGE_ALIGN | MULTIBOOT_MEMORY_INFO | MULTIBOOT_VIDEO_MODE | AOUT_KLUDGE
.text
.long _end
/* entry_addr */
.long multiboot_entry
-#endif /* ! __ELF__ */
+#else /* ! __ELF__ */
+ .long 0
+ .long 0
+ .long 0
+ .long 0
+ .long 0
+#endif /* __ELF__ */
+ .long 0
+ .long 1024
+ .long 768
+ .long 32
multiboot_entry:
/* Initialize the stack pointer. */
/* kernel.c - the C part of the kernel */
-/* Copyright (C) 1999 Free Software Foundation, Inc.
+/* Copyright (C) 1999, 2010 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
(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:
+ {
+ unsigned best_distance, distance;
+ struct multiboot_color *palette;
+
+ palette = (struct multiboot_color *) mbi->framebuffer_palette_addr;
+
+ color = 0;
+ best_distance = 4*256*256;
+
+ for (i = 0; i < mbi->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 << mbi->framebuffer_blue_mask_size) - 1)
+ << mbi->framebuffer_blue_field_position;
+ 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;
+ }
+ }
+ }
+
}
/* Clear the screen and initialize VIDEO, XPOS and YPOS. */
/* multiboot.h - Multiboot header file. */
-/* Copyright (C) 1999,2003,2007,2008,2009 Free Software Foundation, Inc.
+/* Copyright (C) 1999,2003,2007,2008,2009,2010 Free Software Foundation, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
#define MULTIBOOT_INFO_APM_TABLE 0x00000400
/* Is there video information? */
-#define MULTIBOOT_INFO_VIDEO_INFO 0x00000800
+#define MULTIBOOT_INFO_VBE_INFO 0x00000800
+#define MULTIBOOT_INFO_FRAMEBUFFER_INFO 0x00001000
#ifndef ASM_FILE
+typedef unsigned char multiboot_uint8_t;
typedef unsigned short multiboot_uint16_t;
typedef unsigned int multiboot_uint32_t;
typedef unsigned long long multiboot_uint64_t;
};
typedef struct multiboot_elf_section_header_table multiboot_elf_section_header_table_t;
+struct multiboot_color
+{
+ multiboot_uint8_t red;
+ multiboot_uint8_t green;
+ multiboot_uint8_t blue;
+};
+
struct multiboot_info
{
/* Multiboot info version number */
multiboot_uint16_t vbe_interface_seg;
multiboot_uint16_t vbe_interface_off;
multiboot_uint16_t vbe_interface_len;
+
+ multiboot_uint64_t framebuffer_addr;
+ multiboot_uint32_t framebuffer_pitch;
+ multiboot_uint32_t framebuffer_width;
+ multiboot_uint32_t framebuffer_height;
+ multiboot_uint8_t framebuffer_bpp;
+#define MULTIBOOT_FRAMEBUFFER_TYPE_INDEXED 0
+#define MULTIBOOT_FRAMEBUFFER_TYPE_RGB 1
+ multiboot_uint8_t framebuffer_type;
+ union
+ {
+ /* Indexed color. */
+ struct
+ {
+ struct multiboot_color *framebuffer_palette_addr;
+ multiboot_uint16_t framebuffer_palette_num_colors;
+ };
+
+ /* Direct RGB color. */
+ struct
+ {
+ multiboot_uint8_t framebuffer_red_field_position;
+ multiboot_uint8_t framebuffer_red_mask_size;
+ multiboot_uint8_t framebuffer_green_field_position;
+ multiboot_uint8_t framebuffer_green_mask_size;
+ multiboot_uint8_t framebuffer_blue_field_position;
+ multiboot_uint8_t framebuffer_blue_mask_size;
+ };
+ };
};
typedef struct multiboot_info multiboot_info_t;
Copyright @copyright{} 1995,96 Erich Stefan Boleyn <erich@@uruk.org>
-Copyright @copyright{} 1999,2000,2001,2002,2005,2006,2009 Free Software Foundation, Inc.
+Copyright @copyright{} 1999,2000,2001,2002,2005,2006,2009,2010 Free Software Foundation, Inc.
@quotation
Permission is granted to make and distribute verbatim copies of
All of the graphics fields are enabled by flag bit 2. They specify the
preferred graphics mode. Note that that is only a @emph{recommended}
-mode by the OS image. If the mode exists, the boot loader should set
-it, when the user doesn't specify a mode explicitly. Otherwise, the
-boot loader should fall back to a similar mode, if available.
+mode by the OS image. Boot loader may choose a different mode if it sees fit.
The meaning of each is as follows:
@item mode_type
Contains @samp{0} for linear graphics mode or @samp{1} for
EGA-standard text mode. Everything else is reserved for future
-expansion. Note that the boot loader may set a text mode, even if this
-field contains @samp{0}.
+expansion. Note that the boot loader may set a text mode even if this
+field contains @samp{0}, or set a video mode even if this field contains
+@samp{1}.
@item width
Contains the number of the columns. This is specified in pixels in a
84 | vbe_interface_off |
86 | vbe_interface_len |
+-------------------+
+88 | framebuffer_addr | (present if flags[12] is set)
+96 | framebuffer_pitch |
+100 | framebuffer_width |
+104 | framebuffer_height|
+108 | framebuffer_bpp |
+109 | framebuffer_type |
+110-115 | color_info |
+ +-------------------+
+
@end group
@end example
@uref{http://www.microsoft.com/hwdev/busbios/amp_12.htm, Advanced Power
Management (APM) BIOS Interface Specification}, for more information.
-If bit 11 in the @samp{flags} is set, the graphics table is available.
-This must only be done if the kernel has indicated in the
-@samp{Multiboot Header} that it accepts a graphics mode.
+If bit 11 in the @samp{flags} is set, the @sc{vbe} table is available.
The fields @samp{vbe_control_info} and @samp{vbe_mode_info} contain
the physical addresses of @sc{vbe} control information returned by the
Multiboot boot loaders may simulate @sc{vbe} on non-@sc{vbe} modes, as
if they were @sc{vbe} modes.
+If bit 12 in the @samp{flags} is set, the @sc{Framebuffer} table is available.
+
+The field @samp{framebuffer_addr} contains framebuffer physical address. This
+field is 64-bit wide but bootloader @dfn{should} set it under 4 GiB if possible
+for compatibility with kernels which aren't aware of PAE or AMD64. The field
+@samp{framebuffer_pitch} contains the framebuffer pitch in bytes. The fields
+@samp{framebuffer_width}, @samp{framebuffer_height} contain the framebuffer
+dimensions in pixels. The field @samp{framebuffer_bpp} contains the number of
+bits per pixel. If @samp{framebuffer_type} is set to @samp{0} it means
+indexed color will be used. In this case color_info is defined as follows:
+@example
+@group
+ +----------------------------------+
+110 | framebuffer_palette_addr |
+114 | framebuffer_palette_num_colors |
+ +----------------------------------+
+@end group
+@end example
+@samp{framebuffer_palette_addr} contains the address of the color palette,
+which is an array of color descriptors. Each color descriptor has the
+following structure:
+@example
+@group
+ +-------------+
+0 | red_value |
+1 | green_value |
+2 | blue_value |
+ +-------------+
+@end group
+@end example
+If @samp{framebuffer_type} is set to @samp{1} it means direct RGB color will
+be used. Then color_type is defined as follows:
+
+@example
+@group
+ +----------------------------------+
+110 | framebuffer_red_field_position |
+111 | framebuffer_red_mask_size |
+112 | framebuffer_green_field_position |
+113 | framebuffer_green_mask_size |
+114 | framebuffer_blue_field_position |
+115 | framebuffer_blue_mask_size |
+ +----------------------------------+
+@end group
+@end example
+
+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.
@node Examples
@chapter Examples