Multiboot ammendment: non-VBE video
Hello. I'm implementing video part of multiboot specification. Currently the only defined interface is for providing VBE info. I propose following way to set fields if video is non VBE:
vbe_control_info=0xffffffff
When vbe_control_info is set to 0xffffffff all VBE-specific fields are invalid vbe_mode set to 0xffff
vbe_interface_seg=0xffff
vbe_interface_off=0xffff
vbe_interface_len=0xffvbe_mode_info points to structure similar to vbe_mode_info but with all vbe-specific fields set to zero. Remaining (valid) fields are (full structur is in include/grub/i386/pc/vbe.h)
grub_uint16_t bytes_per_scan_line;
grub_uint16_t x_resolution;
grub_uint16_t y_resolution;
grub_uint8_t bits_per_pixel;
grub_uint8_t memory_model;
grub_uint8_t red_mask_size;
grub_uint8_t red_field_position;
grub_uint8_t green_mask_size;
grub_uint8_t green_field_position;
grub_uint8_t blue_mask_size;
grub_uint8_t blue_field_position;
grub_uint8_t rsvd_mask_size;
grub_uint8_t rsvd_field_position;
grub_uint8_t direct_color_mode_info;
grub_vbe_physptr_t phys_base_addr;
grub_uint16_t lin_bytes_per_scan_line;
grub_uint8_t lin_red_mask_size;
grub_uint8_t lin_red_field_position;
grub_uint8_t lin_green_mask_size;
grub_uint8_t lin_green_field_position;
grub_uint8_t lin_blue_mask_size;
grub_uint8_t lin_blue_field_position;
grub_uint8_t lin_rsvd_mask_size;
grub_uint8_t lin_rsvd_field_position;
Signature · 4 lines
Regards Vladimir 'phcoder' Serbinenko Personal git repository: http://repo.or.cz/w/grub2/phcoder.git
Quoted 4 lines · Vladimir 'phcoder' Serbinenko
Hello. I'm implementing video part of multiboot specification. Currently the only defined interface is for providing VBE info. I propose following way to set fields if video is non VBE:
vbe_control_info=0xffffffff
Quoted 8 lines
When
vbe_control_infois set to0xffffffffall VBE-specific fields are invalidvbe_modeset to0xffff
vbe_interface_seg=0xffff
vbe_interface_off=0xffff
vbe_interface_len=0xffvbe_mode_infopoints to structure similar tovbe_mode_infobut with all vbe-specific fields set to zero. Remaining (valid) fields are (full structur is ininclude/grub/i386/pc/vbe.h)
This seems like one of these cases in which legacy gets in the way. Why don't we just replace the legacy structure with something that doesn't need dummy fields?
Signature · 3 lines
Robert Millan "Be the change you want to see in the world" -- Gandhi
Quoted 16 lines · Robert Millan
Quoted 4 lines · Vladimir 'phcoder' Serbinenko
Hello. I'm implementing video part of multiboot specification. Currently the only defined interface is for providing VBE info. I propose following way to set fields if video is non VBE:
vbe_control_info=0xffffffffQuoted 9 lines
When
vbe_control_infois set to0xffffffffall VBE-specific fields are invalidvbe_modeset to0xffff
vbe_interface_seg=0xffff
vbe_interface_off=0xffff
vbe_interface_len=0xffvbe_mode_infopoints to structure similar tovbe_mode_infobut with all vbe-specific fields set to zero. Remaining (valid) fields are (full structur is ininclude/grub/i386/pc/vbe.h)
Quoted 4 lines
This seems like one of these cases in which legacy gets in the way. Why don't we just replace the legacy structure with something that doesn't need dummy fields?
Actually it seems like we already define possible dummy fields if vbe_interface isn't available. vbe_mode_info although contains some vbe callback info and framebuffer information info. We need only second. My idea was that payloads that only use info for framebuffer may be readily working on non-VBE. Alternatively we may define a structure which contains only framebuffer info. This would avoid the requirement to set vbe display line to 0 before calling the payload. The draft I have locally is the following:
=== modified file 'docs/multiboot.texi'
multiboot.texi 2009-12-17 20:04:47 +0000 renamed from multiboot.texi 2008-09-03 20:15:15 +0000 +7 -5
@@ -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
@@ -917,16 +920,62 @@ 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. The fields @samp{vbe_control_info} and @samp{vbe_mode_info} contain the physical addresses of @sc{vbe} control information returned by the @sc{vbe} Function 00h and @sc{vbe} mode information returned by the -@sc{vbe} Function 01h, respectively. +@sc{vbe} Function 01h, respectively. In case of non-@sc{vbe} video driver +@samp{vbe_control_info} contains zero and @samp{vbe_mode_info} points
to the
+following 256-byte structure:
+
+@example
+@group
+ +----------------------+ +0 | flags | +2 | zeros | +16 | pitch | +18 | width | +20 | height | +22 | zeros | +25 | bits per pixel | +26 | zeros | +27 | memory model | +28 | zeros | +31 | red mask size | +32 | red field position | +33 | green mask size | +34 | green field position | +35 | blue mask size | +36 | blue field position | +37 | alpha mask size | +38 | alpha field position | +39 | zero | +40 | framebuffer address | +44 | zero | +50 | pitch | +52 | zero | +54 | red mask size | +55 | red field position | +56 | green mask size | +57 | green field position | +58 | blue mask size | +59 | blue field position | +60 | alpha mask size | +61 | alpha field position | +62 | zeros | + +----------------------+
+@end group
+@end example
+
+All fields have the same meaning as the corresponding VBE mode info +structure except fields marked as zeros which are zero-filled. +
+If video is a linear framebuffer boot loader has to ensure that +displayed region starts at offset @samp{0} of linear framebuffer.
The field @samp{vbe_mode} indicates current video mode in the format
-specified in @sc{vbe} 3.0.
+specified in @sc{vbe} 3.0. In case of non-@sc{vbe} video driver +@samp{vbe_mode} contains 0xffff.
The rest fields @samp{vbe_interface_seg}, @samp{vbe_interface_off}, and @samp{vbe_interface_len} contain the table of a protected mode interface
Signature · 2 lines
Regards Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 17 lines · Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 16 lines · Robert Millan
Quoted 13 lines · Vladimir 'phcoder' Serbinenko
Hello. I'm implementing video part of multiboot specification. Currently the only defined interface is for providing VBE info. I propose following way to set fields if video is non VBE:
vbe_control_info=0xffffffff
Whenvbe_control_infois set to0xffffffffall VBE-specific fields are invalidvbe_modeset to0xffff
vbe_interface_seg=0xffff
vbe_interface_off=0xffff
vbe_interface_len=0xffvbe_mode_infopoints to structure similar tovbe_mode_infobut with all vbe-specific fields set to zero. Remaining (valid) fields are (full structur is ininclude/grub/i386/pc/vbe.h)
Quoted 6 lines
Quoted 4 lines
This seems like one of these cases in which legacy gets in the way. Why don't we just replace the legacy structure with something that doesn't need dummy fields?
Actually it seems like we already define possible dummy fields if
vbe_interfaceisn't available.
Yes. That's the case for vbe_interface_* fields. But extending this to vbe_control_info and vbe_mode_info is backward-incompatible.
I don't object to backward-incompatible changes, but I would expect that when we make one, we get the benefit of a clean, legacy-free interface. In this case we carry on with legacy baggage to archieve half-way backward compatibility.
In purely practical terms, all of this only has a minimal effect. GRUB Legacy didn't implement these extensions, and GRUB 2 hasn't yet, so use of this feature in loadees isn't widespread. But it has a major impact when it comes to reputation. If we make incompatible changes in the text, we should be honest about it. I don't want people to think they can't rely on Multiboot because its maintainers sometimes stretch the definitions in ways not permitted by the text.
Since it's obvious we want to change something (rather than implement VBE-specific extensions), I propose we start with:
-If bit 11 in the @samp{flags} is set, the graphics table is available. +If bit 12 in the @samp{flags} is set, the graphics table is available.
at this point, we can change anything we like.
Signature · 3 lines
Robert Millan "Be the change you want to see in the world" -- Gandhi
Quoted 52 lines · Robert Millan
Quoted 19 lines · Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 17 lines · Robert Millan
Quoted 14 lines · Vladimir 'phcoder' Serbinenko
Hello. I'm implementing video part of multiboot specification. Currently the only defined interface is for providing VBE info. I propose following way to set fields if video is non VBE:
vbe_control_info=0xffffffff
Whenvbe_control_infois set to0xffffffffall VBE-specific fields are invalidvbe_modeset to0xffff
vbe_interface_seg=0xffff
vbe_interface_off=0xffff
vbe_interface_len=0xffvbe_mode_infopoints to structure similar tovbe_mode_infobut with all vbe-specific fields set to zero. Remaining (valid) fields are (full structur is ininclude/grub/i386/pc/vbe.h)Quoted 8 lines
Quoted 5 lines
This seems like one of these cases in which legacy gets in the way. Why don't we just replace the legacy structure with something that doesn't need dummy fields?
Actually it seems like we already define possible dummy fields if
vbe_interfaceisn't available.Yes. That's the case for vbe_interface_* fields. But extending this to
vbe_control_infoandvbe_mode_infois backward-incompatible.I don't object to backward-incompatible changes, but I would expect that when we make one, we get the benefit of a clean, legacy-free interface. In this case we carry on with legacy baggage to archieve half-way backward compatibility.
In purely practical terms, all of this only has a minimal effect. GRUB Legacy didn't implement these extensions, and GRUB 2 hasn't yet, so use of this feature in loadees isn't widespread. But it has a major impact when it comes to reputation. If we make incompatible changes in the text, we should be honest about it. I don't want people to think they can't rely on Multiboot because its maintainers sometimes stretch the definitions in ways not permitted by the text.
Since it's obvious we want to change something (rather than implement VBE-specific extensions), I propose we start with:
(quoted diff) +1
-1-If bit 11 in the @samp{flags} is set, the graphics table is available. +If bit 12 in the @samp{flags} is set, the graphics table is available.
Quoted 3 lines
at this point, we can change anything we like.
I followed your suggestions. I attach new draft together with drawing of a blue diagonal line in example kernel (it would be way better to make it use it for output but it's intended to just show how to use passed info). I also attach an implementation of multiboot on EFI which uses this draft. Note that this ammendment is nothing EFI-specific and can be used with any linear framebuffer driver. The only reason it's in the same patch is because it was the branch in which I was working on multiboot improvements and haven't yet splitted individual changes yet
Signature · 2 lines
Regards Vladimir 'φ-coder/phcoder' Serbinenko
=== modified file 'doc/boot.S'
boot.S +13 -3
@@ -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'
kernel.c +81 -0
87 lines not on this page · raw message
=== modified file 'doc/multiboot.h'
multiboot.h +38 -2
@@ -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'
multiboot.texi +51 -5
86 lines not on this page · raw message
=== added file 'ChangeLog.efiboot'
ChangeLog.efiboot +19 -0
@@ -0,0 +1,19 @@ +2009-11-28 Vladimir Serbinenko <[email protected]> + + Multiboot support on i386-efi. + + * conf/i386-efi.rmk (pkglib_MODULES): Add multiboot.mod. + (multiboot_mod_SOURCES): New variable. + (multiboot_mod_CFLAGS): Likewise. + (multiboot_mod_LDFLAGS): Likewise. + (multiboot_mod_ASFLAGS): Likewise. + * include/grub/i386/multiboot.h (grub_multiboot_real_boot): Explicitly + declare as regparm (3). + (grub_multiboot2_real_boot): Likewise. + (grub_multiboot_boot): Finish boot services. + (grub_fill_multiboot_mmap): Explicitly parse memory map types. + (grub_multiboot): Declare as noreturn to avoid finishing console. + * loader/multiboot_loader.c (grub_cmd_multiboot_loader): Enable + multiboot1 on i386-efi and disable multiboot2 on this platform. + (grub_cmd_module_loader): Likewise. +
=== modified file 'conf/i386-coreboot.rmk'
i386-coreboot.rmk +1 -0
@@ -142,6 +142,7 @@ # For multiboot.mod. multiboot_mod_SOURCES = loader/i386/multiboot.c \ + loader/i386/multiboot_mbi.c \ loader/i386/multiboot_helper.S \ loader/i386/pc/multiboot2.c \ loader/multiboot2.c \
=== modified file 'conf/i386-efi.rmk'
i386-efi.rmk +9 -1
@@ -33,7 +33,15 @@ pkglib_MODULES = kernel.img chain.mod appleldr.mod \ linux.mod halt.mod reboot.mod pci.mod lspci.mod \ datetime.mod date.mod datehook.mod loadbios.mod \ - fixvideo.mod mmap.mod acpi.mod + fixvideo.mod mmap.mod acpi.mod multiboot.mod + +# For multiboot.mod. +multiboot_mod_SOURCES = loader/i386/multiboot.c \ + loader/i386/multiboot_mbi.c \ + loader/multiboot_loader.c +multiboot_mod_CFLAGS = $(COMMON_CFLAGS) +multiboot_mod_LDFLAGS = $(COMMON_LDFLAGS) +multiboot_mod_ASFLAGS = $(COMMON_ASFLAGS) # For kernel.img. kernel_img_EXPORTS = no
=== modified file 'conf/i386-pc.rmk'
i386-pc.rmk +1 -0
@@ -206,6 +206,7 @@ # For multiboot.mod. multiboot_mod_SOURCES = loader/i386/multiboot.c \ + loader/i386/multiboot_mbi.c \ loader/i386/multiboot_helper.S \ loader/i386/pc/multiboot2.c \ loader/multiboot2.c \
=== modified file 'conf/x86_64-efi.rmk'
x86_64-efi.rmk +9 -0
@@ -172,4 +172,13 @@ relocator_mod_ASFLAGS = $(COMMON_ASFLAGS) relocator_mod_LDFLAGS = $(COMMON_LDFLAGS) +# For multiboot.mod. +pkglib_MODULES += multiboot.mod +multiboot_mod_SOURCES = loader/i386/multiboot.c \ + loader/multiboot_loader.c \ + loader/i386/multiboot_mbi.c +multiboot_mod_CFLAGS = $(COMMON_CFLAGS) +multiboot_mod_LDFLAGS = $(COMMON_LDFLAGS) +multiboot_mod_ASFLAGS = $(COMMON_ASFLAGS) + include $(srcdir)/conf/common.mk
=== modified file 'include/grub/i386/multiboot.h'
grub/i386/multiboot.h +12 -5
@@ -20,16 +20,23 @@#define GRUB_MULTIBOOT_CPU_HEADER 1/* The asm part of the multiboot loader. */ -void grub_multiboot_real_boot (grub_addr_t entry, -struct multiboot_info *mbi) - __attribute__ ((noreturn));void grub_multiboot2_real_boot (grub_addr_t entry,struct multiboot_info *mbi) - __attribute__ ((noreturn)); + __attribute__ ((noreturn,regparm (3 )));extern grub_uint32_t grub_multiboot_payload_eip;extern char *grub_multiboot_payload_orig;extern grub_addr_t grub_multiboot_payload_dest; -extern grub_size_t grub_multiboot_payload_size; +extern grub_size_t grub_multiboot_pure_size; + +grub_size_t grub_multiboot_get_mbi_size (void ); +grub_err_t grub_multiboot_make_mbi (void *orig,grub_uint32_t dest, +grub_off_t buf_off,grub_size_t bufsize); +void grub_multiboot_free_mbi (void ); +grub_err_t grub_multiboot_init_mbi (int argc,char *argv[]); +grub_err_t grub_multiboot_add_module (grub_off_t start,grub_size_t size, +int argc,char *argv[]); +void grub_multiboot_set_bootdev (void ); +void grub_multiboot_set_accepts_video (int val);#endif /* ! GRUB_MULTIBOOT_CPU_HEADER */
=== modified file 'include/grub/video.h'
grub/video.h +2 -0
@@ -234,6 +234,8 @@ };typedef struct grub_video_adapter *grub_video_adapter_t ; +const char *grub_video_get_active_adapter_name (void ); +void grub_video_register (grub_video_adapter_t adapter);void grub_video_unregister (grub_video_adapter_t adapter);void grub_video_iterate (int (*hook) (grub_video_adapter_t adapter));
=== added file 'include/grub/x86_64/multiboot.h'
grub/x86_64/multiboot.h +1 -0
@@ -0,0 +1,1 @@ +#include <grub/i386/multiboot.h>
=== modified file 'include/multiboot.h'
multiboot.h +38 -2
@@ -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 'loader/i386/multiboot.c'
i386/multiboot.c +96 -258
474 lines not on this page · raw message
=== modified file 'loader/i386/multiboot_elfxx.c'
i386/multiboot_elfxx.c +3 -2
@@ -100,10 +100,11 @@ code_size = (phdr (highest_segment)->p_paddr +phdr (highest_segment)->p_memsz) -phdr (lowest_segment)->p_paddr; grub_multiboot_payload_dest =phdr (lowest_segment)->p_paddr; - grub_multiboot_payload_size += code_size; + grub_multiboot_pure_size += code_size; + alloc_mbi =grub_multiboot_get_mbi_size (); grub_multiboot_payload_orig - =grub_relocator32_alloc (grub_multiboot_payload_size); + =grub_relocator32_alloc (grub_multiboot_pure_size + alloc_mbi);if (!grub_multiboot_payload_orig)return grub_errno;
=== added file 'loader/i386/multiboot_mbi.c'
i386/multiboot_mbi.c +518 -0
518 lines not on this page · raw message
=== modified file 'loader/i386/pc/xnu.c'
i386/pc/xnu.c +3 -3
@@ -43,7 +43,8 @@ {struct grub_video_mode_info mode_info;int ret; -char *tmp, *modevar; +char *tmp; +const char *modevar;void *framebuffer;grub_err_t err;
@@ -55,8 +56,7 @@ tmp =grub_malloc (grub_strlen (modevar) +sizeof (DEFAULT_VIDEO_MODE ) +1 );if (! tmp) -return grub_error (GRUB_ERR_OUT_OF_MEMORY , -"couldn't allocate temporary storag" ); +return grub_errno;grub_sprintf (tmp,"%s;" DEFAULT_VIDEO_MODE , modevar); err =grub_video_set_mode (tmp, video_hook);grub_free (tmp);
=== modified file 'loader/multiboot_loader.c'
multiboot_loader.c +6 -3
@@ -139,7 +139,7 @@/* XXX Find a better way to identify this. This is for i386-pc */ #if defined(GRUB_MACHINE_PCBIOS ) || defined(GRUB_MACHINE_COREBOOT ) || \ - defined(GRUB_MACHINE_QEMU ) + defined(GRUB_MACHINE_QEMU ) || defined(GRUB_MACHINE_EFI )if (header_multi_ver_found ==1 ) { grub_dprintf ("multiboot_loader",
@@ -148,6 +148,7 @@ module_version_status =1 ; }#endif +#if !defined(GRUB_MACHINE_EFI )if (header_multi_ver_found ==0 || header_multi_ver_found ==2 ) { grub_dprintf ("multiboot_loader",
@@ -155,6 +156,7 @@grub_multiboot2 (argc, argv); module_version_status = 2; } +#endif return grub_errno;
@@ -173,7 +175,7 @@ {#if defined(GRUB_MACHINE_PCBIOS ) || defined(GRUB_MACHINE_COREBOOT ) || \ - defined(GRUB_MACHINE_QEMU ) + defined(GRUB_MACHINE_QEMU ) || defined(GRUB_MACHINE_EFI )if (module_version_status ==1 ) { grub_dprintf("multiboot_loader",
@@ -181,13 +183,14 @@ grub_module (argc, argv); }#endif +#if !defined(GRUB_MACHINE_EFI )if (module_version_status ==2 ) {grub_dprintf ("multiboot_loader" ,"Launching multiboot 2 grub_module2() function\n" );grub_module2 (argc, argv); } - +#endif return grub_errno; }
=== modified file 'video/video.c'
video.c +9 -0
@@ -399,6 +399,15 @@return grub_video_adapter_active->get_active_render_target (target); } +const char * +grub_video_get_active_adapter_name (void ) +{ +if (grub_video_adapter_active) +return grub_video_adapter_active->name; +return NULL ; +} + + grub_err_t grub_video_set_mode (const char *modestring, int NESTED_FUNC_ATTR (*hook) (grub_video_adapter_t p,
Quoted 8 lines · Vladimir 'φ-coder/phcoder' Serbinenko
I followed your suggestions. I attach new draft together with drawing of a blue diagonal line in example kernel (it would be way better to make it use it for output but it's intended to just show how to use passed info). I also attach an implementation of multiboot on EFI which uses this draft. Note that this ammendment is nothing EFI-specific and can be used with any linear framebuffer driver. The only reason it's in the same patch is because it was the branch in which I was working on multiboot improvements and haven't yet splitted individual changes yet
Excellent. I'll review the Multiboot part first.
boot.S line 36
Quoted 8 lines
/* The flags for the Multiboot header. */
#ifdef__ELF__boot.S +2
-2-# define MULTIBOOT_HEADER_FLAGS 0x00000003 +# define MULTIBOOT_HEADER_FLAGS 0x00000007 #else -# define MULTIBOOT_HEADER_FLAGS 0x00010003 +# define MULTIBOOT_HEADER_FLAGS 0x00010007 #endif
This was a bit messy. I just replaced it with an ORed macro list. I should have done this before, but I didn't have time to. Sorry to break your patch, but it's a trivial fix ;-)
boot.S line 77
Quoted 4 lines
boot.S +4
-0+ .long 0 + .long 1024 + .long 768 + .long 32
Maybe better to use 640x480 instead? Not everyone has a large display.
Review
Quoted 3 lines
/* The bits in the required part of flags field we don't support. */
(quoted diff) +1
-1-#define MULTIBOOT_UNSUPPORTED 0x0000fffc +#define MULTIBOOT_UNSUPPORTED 0x0000fff8
Shouldn't this be 0xeffc ? (0xfffc & ~0x1000)
multiboot.texi line 483
Quoted 10 lines
=== modified file 'doc/multiboot.texi'
multiboot.texi +2
-1@@ -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.
I agree with changing this, but the phrases seem to contradict each other. If the mode exists, what should bootloader do?
I suggest we remove from "If the mode exists..." untill "...if available", leaving your "Boot loader may also..." only.
multiboot.texi line 494
Quoted 8 lines
multiboot.texi +3
-1@@ -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}
If the EGA option is obsolete/useless, I'd just make it:
Reserved for backward compatibility. Always contains @samp{0}.
and schedule it for removal in next major version.
multiboot.texi line 647
Quoted 10 lines
multiboot.texi +7
-084 | 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 |
Perhaps it would be simpler for us to arrange it so that flags 11 and 12 can't be used at the same time. We could just say that flag 11 is reserved and unused, and then put these declarations in the offset that used to be for VBE. IIRC there were no possible sections after VBE, so the Framebuffer section size wouldn't be constrained by that.
But if you prefer to keep flag 11 operational, I don't object. I would probably object to GRUB implementing it though.
Quoted 1 line
In this case
color_infois defined as following:
I'd appreciate if a native English speaker confirms this, but I believe this should say "as follows" (same for the other instances of this construct).
Quoted 1 line
+@samp{framebuffer_palette_addr} contains address of array of @samp{framebuffer_palette_num_colors} following structures:
There seems to be some word missing here.
Signature · 3 lines
Robert Millan "Be the change you want to see in the world" -- Gandhi
Quoted 5 lines · Robert Millan
Quoted 1 line
In this case
color_infois defined as following:I'd appreciate if a native English speaker confirms this, but I believe this should say "as follows" (same for the other instances of this construct).
"as follows" reads naturally to me, as a native speaker (also checked: online dictionaries mention the phrase "as follows" without saying it's specific to my area -- northeast U.S. -- so I think it's right to use)
Quoted 3 lines
Quoted 1 line
+@samp{framebuffer_palette_addr} contains address of array of @samp{framebuffer_palette_num_colors} following structures:
There seems to be some word missing here.
"the following structures"?
"as follows" would also work well if "structures" isn't an important word to keep?
wait, it's like saying "array of 3 following structures", each of the same type. hmm. "@samp{framebuffer_palette_num_colors} structures as follows"?
-Isaac
Quoted 11 lines · Isaac Dupree
Quoted 6 lines · Robert Millan
Quoted 2 lines
In this case
color_infois defined as following:I'd appreciate if a native English speaker confirms this, but I believe this should say "as follows" (same for the other instances of this construct).
"as follows" reads naturally to me, as a native speaker (also checked:
online dictionaries mention the phrase "as follows" without saying it's specific to my area -- northeastU.S. -- so I think it's right to use)
+1 for as follows
Quoted 11 lines
Quoted 5 lines
Quoted 3 lines
+@samp{framebuffer_palette_addr} contains address of array of @samp{framebuffer_palette_num_colors} following structures:
There seems to be some word missing here.
"the following structures"?
"as follows" would also work well if "structures" isn't an important word to keep?
wait, it's like saying "array of 3 following structures", each of the same type. hmm. "@samp{framebuffer_palette_num_colors} structures as follows"?
How about this?
XYZZY contains _the_ address of _an_ array of N structures which follow
Quoted 9 lines
-Isaac
_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel
Quoted 10 lines · Robert Millan
boot.S line 77
Quoted 6 lines
boot.S +4
-0+ .long 0 + .long 1024 + .long 768 + .long 32Maybe better to use 640x480 instead? Not everyone has a large display.
It's only a recommended resolution. Bootloader will use a mode it chooses. Perhaps we should remove recommended mode fields from the spec altogether or make them somehow optional
Quoted 8 lines
Review
Quoted 4 lines
/* The bits in the required part of flags field we don't support. */
(quoted diff) +1
-1-#define MULTIBOOT_UNSUPPORTED 0x0000fffc +#define MULTIBOOT_UNSUPPORTED 0x0000fff8Shouldn't this be
0xeffc? (0xfffc& ~0x1000)
AOUT_KLUDGE field is 0x10000 and not 0x1000
Quoted 15 lines
multiboot.texi line 484
Quoted 11 lines
=== modified file 'doc/multiboot.texi'
multiboot.texi +2
-1@@ -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.I agree with changing this, but the phrases seem to contradict each other. If the mode exists, what should bootloader do?
Quoted 4 lines
I suggest we remove from "If the mode exists..." untill "...if available", leaving your "Boot loader may also..." only.
Actually they were contradicting because "should" means that loader may choose not to follow the rule
Quoted 12 lines
multiboot.texi line 495
Quoted 9 lines
multiboot.texi +3
-1@@ -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}If the EGA option is obsolete/useless, I'd just make it:
Quoted 5 lines
Reserved for backward compatibility. Always contains @samp{0}.
and schedule it for removal in next major version.
It is useful. It allows payload to say: "I'm ok with video mode but prefer text one"
Quoted 12 lines
Quoted 11 lines
multiboot.texi +0
-084 | 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 |
Quoted 10 lines
Perhaps it would be simpler for us to arrange it so that flags 11 and 12 can't be used at the same time. We could just say that flag 11 is reserved and unused, and then put these declarations in the offset that used to be for VBE. IIRC there were no possible sections after VBE, so the Framebuffer section size wouldn't be constrained by that.
But if you prefer to keep flag 11 operational, I don't object. I would probably object to GRUB implementing it though.
If payload wants to use VBE it will. I think that providing this informtion saves payload a trip to real mode. So this way we encourage saner real-mode-free OS design.
Do you think it would be useful to make flag 12 structure describe EGA text too? I attach new diff for multiboot.texi. If it's approved it should be simple to implement in grub2 and example kernel
Signature · 2 lines
Regards Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 11 lines · Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 10 lines · Robert Millan
boot.S line 77
Quoted 6 lines
boot.S +4
-0+ .long 0 + .long 1024 + .long 768 + .long 32Maybe better to use 640x480 instead? Not everyone has a large display.
Quoted 1 line
It's only a recommended resolution.
Ok then, no big deal.
Quoted 3 lines
Bootloader will use a mode it
chooses. Perhaps we should remove recommended mode fields from the spec altogether or make them somehow optional
Is that important? I'm hesitant to do that untill we have better understanding on what lead to this decision.
Quoted 9 lines
Quoted 8 lines
Review
Quoted 4 lines
/* The bits in the required part of flags field we don't support. */
(quoted diff) +1
-1-#define MULTIBOOT_UNSUPPORTED 0x0000fffc +#define MULTIBOOT_UNSUPPORTED 0x0000fff8Shouldn't this be
0xeffc? (0xfffc& ~0x1000)
AOUT_KLUDGEfield is0x10000and not0x1000
But that's a completely different bit? I'm a bit confused.
Btw, as you pointed out on IRC, MULTIBOOT_UNSUPPORTED is a GRUB-specific mask and shouldn't be part of <multiboot.h> anyway.
Quoted 11 lines
Quoted 11 lines
multiboot.texi line 483
Quoted 7 lines
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
multiboot.texi +2
-1-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.I agree with changing this, but the phrases seem to contradict each other. If the mode exists, what should bootloader do?
Quoted 6 lines
Quoted 4 lines
I suggest we remove from "If the mode exists..." untill "...if available", leaving your "Boot loader may also..." only.
Actually they were contradicting because "should" means that loader may choose not to follow the rule
Sorry, my oversight. Well it is redundant, not contradictory. I didn't express it properly :-) (some part of my brain doesn't play well with the rest).
Quoted 11 lines
Quoted 11 lines
multiboot.texi line 494
Quoted 8 lines
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
multiboot.texi +3
-1-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}If the EGA option is obsolete/useless, I'd just make it:
Quoted 7 lines
Quoted 5 lines
Reserved for backward compatibility. Always contains @samp{0}.
and schedule it for removal in next major version.
It is useful. It allows payload to say: "I'm ok with video mode but prefer text one"
Oh, I think I missunderstood what "EGA-standard text mode" means. Is this the same text mode that survived to this day, and is known in GRUB codebase as "vga_text"?
Quoted 6 lines
Quoted 6 lines
Perhaps it would be simpler for us to arrange it so that flags 11 and 12 can't be used at the same time. We could just say that flag 11 is reserved and unused, and then put these declarations in the offset that used to be for VBE. IIRC there were no possible sections after VBE, so the Framebuffer section size wouldn't be constrained by that.
Quoted 7 lines
Quoted 4 lines
But if you prefer to keep flag 11 operational, I don't object. I would probably object to GRUB implementing it though.
If payload wants to use VBE it will. I think that providing this informtion saves payload a trip to real mode. So this way we encourage saner real-mode-free OS design.
I'd rather encourage them to use modern flag 12 instead. In any case, it doesn't to keep flag 11 as part of the standard as long as it's optional. I'm still not convinced GRUB should implement it, but that's a separate discussion.
Quoted 3 lines
Do you think it would be useful to make flag 12 structure describe EGA text too? I attach new diff for multiboot.texi. If it's approved it should be simple to implement in grub2 and example kernel
You forgot to attach it.
Signature · 3 lines
Robert Millan "Be the change you want to see in the world" -- Gandhi
Quoted 11 lines · Robert Millan
Quoted 5 lines
Bootloader will use a mode it
chooses. Perhaps we should remove recommended mode fields from the spec altogether or make them somehow optionalIs that important? I'm hesitant to do that untill we have better understanding on what lead to this decision.
Quoted 2 lines
Quoted 2 lines
Quoted 9 lines
Quoted 3 lines
It is useful. It allows payload to say: "I'm ok with video mode but prefer text one"
Oh, I think I missunderstood what "EGA-standard text mode" means. Is this the same text mode that survived to this day, and is known in GRUB codebase as "
vga_text"?
Yes
Quoted 16 lines
Quoted 6 lines
Quoted 6 lines
Perhaps it would be simpler for us to arrange it so that flags 11 and 12 can't be used at the same time. We could just say that flag 11 is reserved and unused, and then put these declarations in the offset that used to be for VBE. IIRC there were no possible sections after VBE, so the Framebuffer section size wouldn't be constrained by that.
Quoted 9 lines
Quoted 5 lines
But if you prefer to keep flag 11 operational, I don't object. I would probably object to GRUB implementing it though.
If payload wants to use VBE it will. I think that providing this informtion saves payload a trip to real mode. So this way we encourage saner real-mode-free OS design.
Quoted 6 lines
I'd rather encourage them to use modern flag 12 instead. In any case, it doesn't to keep flag 11 as part of the standard as long as it's optional. I'm still not convinced GRUB should implement it, but that's a separate discussion.
Flag 12 doesn't allow to e.g. change the resolution or do the double buffering.
Quoted 8 lines
Quoted 4 lines
Do you think it would be useful to make flag 12 structure describe EGA text too? I attach new diff for multiboot.texi. If it's approved it should be simple to implement in grub2 and example kernel
You forgot to attach it.
Fixed
Signature · 2 lines
Regards Vladimir 'φ-coder/phcoder' Serbinenko
=== modified file 'doc/multiboot.texi'
multiboot.texi +52 -7
@@ -477,9 +477,7 @@ 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 also choose another mode if it sees fit. The meaning of each is as follows:
@@ -488,7 +486,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 +635,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 +920,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 +942,44 @@ 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 follows: +@example +@group + +----------------------------------+ +110 | framebuffer_palette_addr | +114 | framebuffer_palette_num_colors | + +----------------------------------+ +@end group +@end example +@samp{framebuffer_palette_addr} contains address of palette. Palette is an array of colour descriptors. Each colour descriptor has following structure: +@example +@group + +-------------+ +0 | red_value | +1 | green_value | +2 | blue_value | + +-------------+ +@end group +@end example +If @samp{framebuffer_type} is set to 1 it means direct RGB color. 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 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
Hi,
I committed your last patch with some minor stylistic adjustments, plus your changes to the example kernel.
Signature · 3 lines
Robert Millan "Be the change you want to see in the world" -- Gandhi
Multiboot video in GRUB (Re: [RFC] Multiboot ammendment: non-VBE video)
In reply to Vladimir 'φ-coder/phcoder' SerbinenkoQuoted 12 lines · Vladimir 'φ-coder/phcoder' Serbinenko
=== added file 'ChangeLog.efiboot'
ChangeLog.efiboot +8
-0@@ -0,0 +1,19 @@ +2009-11-28 Vladimir Serbinenko <[email protected]> + + Multiboot support on i386-efi. + + * conf/i386-efi.rmk (pkglib_MODULES): Add multiboot.mod. + (multiboot_mod_SOURCES): New variable. + (multiboot_mod_CFLAGS): Likewise. + (multiboot_mod_LDFLAGS): Likewise.
ChangeLog.efiboot line 18
Quoted 10 lines
ChangeLog.efiboot +10
-0+ (multiboot_mod_ASFLAGS): Likewise. + * include/grub/i386/multiboot.h (grub_multiboot_real_boot): Explicitly + declare as regparm (3). + (grub_multiboot2_real_boot): Likewise. + (grub_multiboot_boot): Finish boot services. + (grub_fill_multiboot_mmap): Explicitly parse memory map types. + (grub_multiboot): Declare as noreturn to avoid finishing console. + * loader/multiboot_loader.c (grub_cmd_multiboot_loader): Enable + multiboot1 on i386-efi and disable multiboot2 on this platform. + (grub_cmd_module_loader): Likewise.
Could the EFI parts be split into a separate patch? I definitely want both things, but they're separate changes, would be good to have the additional granularity if possible.
Signature · 3 lines
Robert Millan "Be the change you want to see in the world" -- Gandhi