From: "Vladimir 'φ-coder/phcoder' Serbinenko" <phcoder@gmail.com>
To: The development of GNU GRUB <grub-devel@gnu.org>
Subject: Re: [PATCH] Add support for passing EFI framebuffer into FreeBSD 10.1 and later
Date: Sun, 07 Dec 2014 22:45:45 +0100 [thread overview]
Message-ID: <5484CA89.30903@gmail.com> (raw)
In-Reply-To: <544FFD67.9000102@pcbsd.org>
[-- Attachment #1: Type: text/plain, Size: 5387 bytes --]
On 28.10.2014 21:32, Kris Moore wrote:
> Got another patch for review today.
>
> This patch adds support for FreeBSD's new VT console driver when booting
> in EFI mode on FreeBSD 10.1 and later.
>
> Please let me know any comments, or things that need addressed to get
> this merged in.
>
> Thanks!
>
> -- Kris Moore PC-BSD Software iXsystems
>
>
> patch-grub-fb
>
>
> From a9c20c1640cdea0ba902095cb18760f5ebe98875 Mon Sep 17 00:00:00 2001
> From: Kris Moore <kris@pcbsd.org>
> Date: Tue, 28 Oct 2014 15:59:59 -0400
> Subject: [PATCH 1/2] Add support for passing EFI framebuffer information to
> FreeBSD kernel on FreeBSD 10.1 and later.
>
> ---
> grub-core/loader/i386/bsd.c | 75 ++++++++++++++++++++++++++++++++++++
> grub-core/video/efi_gop.c | 14 +++++++
> include/grub/i386/bsd.h | 1 +
> include/grub/i386/freebsd_bootinfo.h | 33 ++++++++++++++++
> include/grub/video.h | 18 +++++++++
> 5 files changed, 141 insertions(+)
> create mode 100644 include/grub/i386/freebsd_bootinfo.h
>
> diff --git grub-core/loader/i386/bsd.c grub-core/loader/i386/bsd.c
> index 8f691e0..c685552 100644
> --- grub-core/loader/i386/bsd.c
> +++ grub-core/loader/i386/bsd.c
> @@ -48,6 +48,7 @@ GRUB_MOD_LICENSE ("GPLv3+");
> #ifdef GRUB_MACHINE_EFI
> #include <grub/efi/efi.h>
> #define NETBSD_DEFAULT_VIDEO_MODE "800x600"
> +#define FREEBSD_DEFAULT_VIDEO_MODE "800x600"
> #else
> #define NETBSD_DEFAULT_VIDEO_MODE "text"
> #include <grub/i386/pc/vbe.h>
> @@ -584,6 +585,63 @@ freebsd_get_zfs (void)
> grub_free (uuid);
> }
>
> +#ifdef GRUB_MACHINE_EFI
> +
> +static grub_err_t
> +grub_freebsd_setup_video (void)
> +{
> + struct grub_video_mode_info mode_info;
> + void *framebuffer;
> + const char *modevar;
> + struct grub_freebsd_btinfo_framebuf efifb;
> + grub_err_t err;
> + grub_video_driver_id_t driv_id;
> +
> + modevar = grub_env_get ("gfxpayload");
> +
> + /* Now all graphical modes are acceptable.
> + May change in future if we have modes without framebuffer. */
> + if (modevar && *modevar != 0)
> + {
> + char *tmp;
> + tmp = grub_xasprintf ("%s;" FREEBSD_DEFAULT_VIDEO_MODE, modevar);
> + if (! tmp)
> + return grub_errno;
> + err = grub_video_set_mode (tmp, 0, 0);
> + grub_free (tmp);
> + }
> + else
> + err = grub_video_set_mode (FREEBSD_DEFAULT_VIDEO_MODE, 0, 0);
> +
> + if (err)
> + return err;
> +
> + driv_id = grub_video_get_driver_id ();
> + if (driv_id == GRUB_VIDEO_DRIVER_NONE)
> + return GRUB_ERR_NONE;
> +
> + err = grub_video_get_info_and_fini (&mode_info, &framebuffer);
> +
> + if (err)
> + return err;
> +
> + efifb.fb_width = mode_info.width;
> + efifb.fb_height = mode_info.height;
> + efifb.fb_stride = mode_info.stride;
> +
> + efifb.fb_addr = (grub_addr_t) framebuffer;
> + efifb.fb_size = ALIGN_UP (mode_info.pitch * efifb.fb_height, 65536);
> +
> + efifb.fb_mask_red = mode_info.red_mask;
> + efifb.fb_mask_green = mode_info.green_mask;
> + efifb.fb_mask_blue = mode_info.blue_mask;
> + efifb.fb_mask_reserved = mode_info.reserved_mask;
> +
> + err = grub_bsd_add_meta ( FREEBSD_MODINFO_METADATA | FREEBSD_BTINFO_FRAMEBUF, &efifb, sizeof (efifb));
> + return err;
> +}
> +#endif
> +
> static grub_err_t
> grub_freebsd_boot (void)
> {
> @@ -687,6 +745,10 @@ grub_freebsd_boot (void)
> *(grub_uint32_t *) p_tag = bootflags;
> break;
>
> + case FREEBSD_MODINFO_METADATA | FREEBSD_BTINFO_FRAMEBUF:
> + grub_memcpy (p_tag, tag->data, tag->len);
> + break;
> +
> case FREEBSD_MODINFO_METADATA | FREEBSD_MODINFOMD_ENVP:
> if (is_64bit)
> *(grub_uint64_t *) p_tag = bi.environment;
> @@ -716,7 +778,10 @@ grub_freebsd_boot (void)
>
> bi.kern_end = kern_end;
>
> +#ifndef GRUB_MACHINE_EFI
> + /* Don't set text mode on EFI boot */
> grub_video_set_mode ("text", 0, 0);
> +#endif
>
> if (is_64bit)
> {
> @@ -1560,6 +1625,16 @@ grub_cmd_freebsd (grub_extcmd_context_t ctxt, int argc, char *argv[])
> FREEBSD_MODINFOMD_KERNEND, &data, len);
> if (err)
> return err;
> +
> +#ifdef GRUB_MACHINE_EFI
> + err = grub_freebsd_setup_video ();
> + if (err)
> + {
> + grub_print_error ();
> + grub_puts_ (N_("Booting in EFI blind mode"));
> + grub_errno = GRUB_ERR_NONE;
> + }
> +#endif
> }
> grub_bsd_get_device (&freebsd_biosdev, &unit, &slice, &part);
> freebsd_zfsguid = 0;
> diff --git grub-core/video/efi_gop.c grub-core/video/efi_gop.c
> index 7f9d1c2..cfe0119 100644
> --- grub-core/video/efi_gop.c
> +++ grub-core/video/efi_gop.c
> @@ -180,6 +180,8 @@ grub_video_gop_fill_real_mode_info (unsigned mode,
> out->mode_type = GRUB_VIDEO_MODE_TYPE_RGB;
> out->bpp = grub_video_gop_get_bpp (in);
> out->bytes_per_pixel = out->bpp >> 3;
> + out->stride = in->pixels_per_scanline;
> + out->pixel_format = in->pixel_format;
Please, don't add redundant fields to structs. All this info can be
inferred from available fields in FreeBSD code. As a bonus it will work
with other gfx drivers.
Another point: is this driver usable on non-EFI? It's of particular
interest on coreboot where changing video mode currently requires reflash.
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 213 bytes --]
next prev parent reply other threads:[~2014-12-07 21:45 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-28 20:32 [PATCH] Add support for passing EFI framebuffer into FreeBSD 10.1 and later Kris Moore
2014-11-02 5:44 ` Kris Moore
2015-01-22 20:44 ` Vladimir 'φ-coder/phcoder' Serbinenko
2014-12-07 21:45 ` Vladimir 'φ-coder/phcoder' Serbinenko [this message]
2014-12-30 19:49 ` Kris Moore
2015-01-22 20:49 ` Vladimir 'φ-coder/phcoder' Serbinenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5484CA89.30903@gmail.com \
--to=phcoder@gmail.com \
--cc=grub-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.