=== modified file 'doc/boot.S' --- doc/boot.S 2009-12-24 13:34:49 +0000 +++ doc/boot.S 2010-01-02 17:13:52 +0000 @@ -30,9 +30,9 @@ /* The flags for the Multiboot header. */ #ifdef __ELF__ -# define MULTIBOOT_HEADER_FLAGS 0x00000003 +# define MULTIBOOT_HEADER_FLAGS 0x00000007 #else -# define MULTIBOOT_HEADER_FLAGS 0x00010003 +# define MULTIBOOT_HEADER_FLAGS 0x00010007 #endif .text @@ -64,7 +64,17 @@ .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. */ === modified file 'doc/kernel.c' --- doc/kernel.c 2009-12-24 14:25:44 +0000 +++ doc/kernel.c 2010-01-02 17:04:15 +0000 @@ -150,6 +150,87 @@ 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. */ === modified file 'doc/multiboot.h' --- doc/multiboot.h 2009-12-24 14:25:44 +0000 +++ doc/multiboot.h 2010-01-02 12:58:41 +0000 @@ -32,7 +32,7 @@ #define MULTIBOOT_BOOTLOADER_MAGIC 0x2BADB002 /* The bits in the required part of flags field we don't support. */ -#define MULTIBOOT_UNSUPPORTED 0x0000fffc +#define MULTIBOOT_UNSUPPORTED 0x0000fff8 /* Alignment of multiboot modules. */ #define MULTIBOOT_MOD_ALIGN 0x00001000 @@ -88,10 +88,12 @@ #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; @@ -190,9 +192,43 @@ 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; + multiboot_uint8_t framebuffer_type; + union + { + struct + { + multiboot_uint32_t framebuffer_palette_addr; + multiboot_uint16_t framebuffer_palette_num_colors; + }; + 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; + }; + }; +}; + +struct multiboot_color +{ + multiboot_uint8_t red; + multiboot_uint8_t green; + multiboot_uint8_t blue; }; typedef struct multiboot_info multiboot_info_t; +#define MULTIBOOT_FRAMEBUFFER_TYPE_INDEXED 0 +#define MULTIBOOT_FRAMEBUFFER_TYPE_RGB 1 + struct multiboot_mmap_entry { multiboot_uint32_t size; === modified file 'doc/multiboot.texi' --- doc/multiboot.texi 2010-01-01 20:02:24 +0000 +++ doc/multiboot.texi 2010-01-02 16:58:33 +0000 @@ -479,7 +479,8 @@ 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. +boot loader should fall back to a similar mode, if available. Boot loader +may also choose another mode if it sees fit. The meaning of each is as follows: @@ -488,7 +489,9 @@ 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}. +field contains @samp{0}. If video adapter doesn't support EGA text mode or +bootloader doesn't know how to initialise this mode it may set video +mode even if field contains @samp{1} @item width Contains the number of the columns. This is specified in pixels in a @@ -635,6 +638,15 @@ 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 @@ -911,9 +923,7 @@ @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 @@ -935,6 +945,42 @@ 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 4GiB if possible for compatibility with payloads which aren't aware of PAE or amd64. The field @samp{framebuffer_pitch} contains pitch in bytes. The fields @samp{framebuffer_width}, @samp{framebuffer_height} contain framebuffer dimensions in pixels. The field @samp{framebuffer_bpp} contains number of bits per pixel. If @samp{framebuffer_type} is set to 0 it means indexed color. In this case color_info is defined as following: +@example +@group + +----------------------------------+ +110 | framebuffer_palette_addr | +114 | framebuffer_palette_num_colors | + +----------------------------------+ +@end group +@end example +@samp{framebuffer_palette_addr} contains address of array of @samp{framebuffer_palette_num_colors} following structures: +@example +@group + +-------------+ +0 | red_value | +1 | green_value | +2 | blue_value | + +-------------+ +@end group +@end example +If @samp{framebuffer_type} is set to 1 it direct RGB color. Then color_type is defined as following: + +@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 +All further values of @samp{framebuffer_type} are reserved for future expansion @node Examples @chapter Examples