From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1YEOhC-0001A3-QT for mharc-grub-devel@gnu.org; Thu, 22 Jan 2015 15:49:42 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56956) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YEOh9-00018Y-4X for grub-devel@gnu.org; Thu, 22 Jan 2015 15:49:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YEOh7-0001dG-BL for grub-devel@gnu.org; Thu, 22 Jan 2015 15:49:39 -0500 Received: from mail-wi0-x230.google.com ([2a00:1450:400c:c05::230]:51847) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YEOh7-0001ch-0W for grub-devel@gnu.org; Thu, 22 Jan 2015 15:49:37 -0500 Received: by mail-wi0-f176.google.com with SMTP id em10so27064932wid.3 for ; Thu, 22 Jan 2015 12:49:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type; bh=isugqpMMapESCzwryEwKqDbvY4VmRRXX/0gz/wcOZEo=; b=ixJZ3ltkOd19JlAzKT4DG5h6cPsOEhDr3Kip3K9SVWhnzzSbzMjsPNF8hp61R1ZPAU ThEEJkurg2wACVJmSo74NLIazginQZVmV31HtRGTJ85dlsHJ2Za2mTRIN7BP00k60yM+ 9yPTQ3puzDTNZcTQl4fIu8KXETDGbxhF4cFIrceK3YVr/42x5iNlPJbywuHE5qvTuO/r IbYzjYvuK8qCwoSkuahh1f/bsm7982GfVvnSshI3HHB+dwLhbpk3L4LbxkTc5ARNeza1 LtXCrQia0h6JiLmRiRR03ZkNZvVRgYZK7pw6S8Dl67+jiQbQyIr3XpfX25WldqAwYevG ziqA== X-Received: by 10.180.5.131 with SMTP id s3mr19217915wis.82.1421959776315; Thu, 22 Jan 2015 12:49:36 -0800 (PST) Received: from ?IPv6:2a02:1205:501d:9210:c6e9:2fff:fe57:96ed? ([2a02:1205:501d:9210:c6e9:2fff:fe57:96ed]) by mx.google.com with ESMTPSA id cs8sm4532455wib.1.2015.01.22.12.49.35 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Jan 2015 12:49:35 -0800 (PST) Message-ID: <54C1625F.7070904@gmail.com> Date: Thu, 22 Jan 2015 21:49:35 +0100 From: =?UTF-8?B?VmxhZGltaXIgJ8+GLWNvZGVyL3BoY29kZXInIFNlcmJpbmVua28=?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.3.0 MIME-Version: 1.0 To: The development of GNU GRUB Subject: Re: [PATCH] Add support for passing EFI framebuffer into FreeBSD 10.1 and later References: <544FFD67.9000102@pcbsd.org> <5484CA89.30903@gmail.com> <54A301C2.50403@pcbsd.org> In-Reply-To: <54A301C2.50403@pcbsd.org> Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="6ETw7INLcmpulvi3RxmMbBMELNX27X6gB" X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c05::230 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 22 Jan 2015 20:49:41 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --6ETw7INLcmpulvi3RxmMbBMELNX27X6gB Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable > Attached is a cleaned up version of the patch which doesn't add to any > existing structs now. Let me know if this is closer to what you had in > mind. >=20 > I don't think this driver is usable on non-EFI FreeBSD yet. They have a= > new VT console driver, but I'm not sure their loader does video mode > passthrough outside of EFI. I'm sure it will in the future, probably > sometime in 11.X. >=20 > --=20 > Kris Moore > PC-BSD Software > iXsystems >=20 >=20 > patch-grub-efi-framebuffer >=20 >=20 > From 997363ec7698f34d74769960c4e76cf8b369052e Mon Sep 17 00:00:00 2001 > From: Kris Moore > Date: Tue, 30 Dec 2014 14:34:58 -0500 > Subject: [PATCH] Add the patch for FreeBSD UEFI booting / framebuffer > passthrough, add fixes to ACPI environment variables while here >=20 > --- > ChangeLog | 9 +++ > grub-core/loader/i386/bsd.c | 134 +++++++++++++++++++++++++++= ++++++++ > include/grub/i386/bsd.h | 1 + > include/grub/i386/freebsd_bootinfo.h | 33 +++++++++ > 4 files changed, 177 insertions(+) > create mode 100644 include/grub/i386/freebsd_bootinfo.h >=20 > diff --git ChangeLog ChangeLog > index c38917b..b717a2d 100644 > --- ChangeLog > +++ ChangeLog > @@ -1,3 +1,12 @@ > +2014-12-30 Kris Moore > + * grub-core/loader/i386/bsd.c: Set FreeBSD specific ACPI hints when b= ooting > + in EFI mode > + * grub-core/loader/i386/bsd.c: Add default FreeBSD EFI video mode, an= d > + structure to pass information into EFI booted kernel > + * include/grub/i386/bsd.h: Include new freebsd_bootinfo.h > + * include/grub/i386/freebsd_bootinfo.h: Add grub_freebsd_btinfo_frame= buf > + structure for FreeBSD EFI framebuffer passthrough > + > 2014-12-09 Andrei Borzenkov > =20 > * grub-core/term/serial.c (grub_cmd_serial): Fix --rtscts > diff --git grub-core/loader/i386/bsd.c grub-core/loader/i386/bsd.c > index 8f691e0..9d51cff 100644 > --- grub-core/loader/i386/bsd.c > +++ grub-core/loader/i386/bsd.c > @@ -42,12 +42,14 @@ > GRUB_MOD_LICENSE ("GPLv3+"); > =20 > #include > +#include > #ifdef GRUB_MACHINE_PCBIOS > #include > #endif > #ifdef GRUB_MACHINE_EFI > #include > #define NETBSD_DEFAULT_VIDEO_MODE "800x600" > +#define FREEBSD_DEFAULT_VIDEO_MODE "800x600" > #else > #define NETBSD_DEFAULT_VIDEO_MODE "text" > #include > @@ -584,6 +586,72 @@ freebsd_get_zfs (void) > grub_free (uuid); > } > =20 > +#ifdef GRUB_MACHINE_EFI > + This shouldn't be limited to EFI. Just EFI would use GFX default while BIOS would use text. > +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 =3D grub_env_get ("gfxpayload"); > + > + /* Now all graphical modes are acceptable. > + May change in future if we have modes without framebuffer. */ > + if (modevar && *modevar !=3D 0) > + { > + char *tmp; > + tmp =3D grub_xasprintf ("%s;" FREEBSD_DEFAULT_VIDEO_MODE, modeva= r); > + if (! tmp) > + return grub_errno; > + err =3D grub_video_set_mode (tmp, 0, 0); > + grub_free (tmp); > + } > + else > + err =3D grub_video_set_mode (FREEBSD_DEFAULT_VIDEO_MODE, 0, 0); > + > + if (err) > + return err; > + > + driv_id =3D grub_video_get_driver_id (); > + if (driv_id =3D=3D GRUB_VIDEO_DRIVER_NONE) > + return GRUB_ERR_NONE; > + > + err =3D grub_video_get_info_and_fini (&mode_info, &framebuffer); > + > + if (err) > + return err; > + > + efifb.fb_width =3D mode_info.width; > + efifb.fb_height =3D mode_info.height; > + efifb.fb_stride =3D mode_info.pitch / mode_info.bytes_per_pixel; > + Is bytes_per_pixel checked against 0 somewhere? > + efifb.fb_addr =3D (grub_addr_t) framebuffer; > + efifb.fb_size =3D ALIGN_UP (mode_info.pitch * efifb.fb_height, 65536= ); > + > + if ( mode_info.blue_field_pos =3D=3D 16 ) { > + efifb.fb_mask_red =3D 0x000000ff; > + efifb.fb_mask_green =3D 0x0000ff00; > + efifb.fb_mask_blue =3D 0x00ff0000; > + } > + > + if ( mode_info.blue_field_pos =3D=3D 0 ) { > + efifb.fb_mask_red =3D 0x00ff0000; > + efifb.fb_mask_green =3D 0x0000ff00; > + efifb.fb_mask_blue =3D 0x000000ff; > + } > + > + efifb.fb_mask_reserved =3D 0xff000000; > + Why these conditions? Why not use universal function? efifb.fb_mask_red =3D ((1 << mode_info.red_size) - 1) << mode_info.red_field_pos and so on > + err =3D grub_bsd_add_meta ( FREEBSD_MODINFO_METADATA | FREEBSD_BTINF= O_FRAMEBUF, &efifb, sizeof (efifb)); > + return err; > +} > +#endif > + > static grub_err_t > grub_freebsd_boot (void) > { > @@ -602,6 +670,55 @@ grub_freebsd_boot (void) > =20 > bi.boot_device =3D freebsd_biosdev; > =20 > +#ifdef GRUB_MACHINE_EFI > + /* When booting in EFI mode, we need to export some additional kerne= l ACPI hints */ > + struct grub_acpi_rsdp_v10 *v1; > + struct grub_acpi_rsdp_v20 *v2; > + v1 =3D grub_acpi_get_rsdpv1 (); > + v2 =3D grub_acpi_get_rsdpv2 (); > + if (v2 && v2->length > 40) > + v2 =3D 0; > + > + int revision; > + char acpiBuf[24]; > + > + if (v1) > + { > + revision =3D v1->revision; > + if ( revision =3D=3D 0 ) > + revision =3D 1; > + grub_snprintf (acpiBuf, sizeof (acpiBuf), "%d", revision); > + grub_env_set("kFreeBSD.hint.acpi.0.revision", acpiBuf); > + > + grub_snprintf (acpiBuf, sizeof (acpiBuf), "%s", v1->oemid); > + grub_env_set("kFreeBSD.hint.acpi.0.oem", acpiBuf); > + > + grub_snprintf (acpiBuf, sizeof (acpiBuf), "0x%016x", v1->rsdt_add= r); > + grub_env_set("kFreeBSD.hint.acpi.0.rsdt", acpiBuf); > + > + grub_snprintf (acpiBuf, sizeof (acpiBuf), "0x%016llx", (unsigned = long long)v1); > + grub_env_set("kFreeBSD.hint.acpi.0.rsdp", acpiBuf); > + } > + > + if (v2) > + { > + revision =3D v2->rsdpv1.revision; > + if ( revision =3D=3D 0 ) > + revision =3D 1; > + > + grub_snprintf (acpiBuf, sizeof (acpiBuf), "%d", revision); > + grub_env_set("kFreeBSD.hint.acpi.0.revision", acpiBuf); > + > + grub_snprintf (acpiBuf, sizeof (acpiBuf), "0x%016llx", (unsigned = long long)v2->xsdt_addr); > + grub_env_set("kFreeBSD.hint.acpi.0.xsdt", acpiBuf); > + > + grub_snprintf (acpiBuf, sizeof (acpiBuf), "%d", v2->length); > + grub_env_set("kFreeBSD.hint.acpi.0.xsdt_length", acpiBuf); > + } > + This has to be a separate commit > + > +#endif > + > p_size =3D 0; > FOR_SORTED_ENV (var) > if ((grub_memcmp (var->name, "kFreeBSD.", sizeof("kFreeBSD.") - 1)= =3D=3D 0) && (var->name[sizeof("kFreeBSD.") - 1])) > @@ -687,6 +804,10 @@ grub_freebsd_boot (void) > *(grub_uint32_t *) p_tag =3D bootflags; > break; > =20 > + 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 =3D bi.environment; > @@ -716,7 +837,10 @@ grub_freebsd_boot (void) > =20 > bi.kern_end =3D kern_end; > =20 > +#ifndef GRUB_MACHINE_EFI > + /* Don't set text mode on EFI boot */ > grub_video_set_mode ("text", 0, 0); > +#endif > =20 > if (is_64bit) > { > @@ -1560,6 +1684,16 @@ grub_cmd_freebsd (grub_extcmd_context_t ctxt, in= t argc, char *argv[]) > FREEBSD_MODINFOMD_KERNEND, &data, len); > if (err) > return err; > + > +#ifdef GRUB_MACHINE_EFI > + err =3D grub_freebsd_setup_video (); > + if (err) > + { > + grub_print_error (); > + grub_puts_ (N_("Booting in EFI blind mode")); > + grub_errno =3D GRUB_ERR_NONE; > + } > +#endif > } > grub_bsd_get_device (&freebsd_biosdev, &unit, &slice, &part); > freebsd_zfsguid =3D 0; > diff --git include/grub/i386/freebsd_bootinfo.h include/grub/i386/freeb= sd_bootinfo.h > new file mode 100644 > index 0000000..17e5997 > --- /dev/null > +++ include/grub/i386/freebsd_bootinfo.h > @@ -0,0 +1,33 @@ > +/* > + * GRUB -- GRand Unified Bootloader > + * Copyright (C) 2008,2009 Free Software Foundation, Inc. > + * > + * GRUB is free software: you can redistribute it and/or modify > + * it under the terms of the GNU General Public License as published = by > + * the Free Software Foundation, either version 3 of the License, or > + * (at your option) any later version. > + * > + * GRUB is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > + * GNU General Public License for more details. > + * > + * You should have received a copy of the GNU General Public License > + * along with GRUB. If not, see . > + */ > + > +#include > + > +#define FREEBSD_BTINFO_FRAMEBUF 0x1005 > + > +struct grub_freebsd_btinfo_framebuf { > + grub_uint64_t fb_addr; > + grub_uint64_t fb_size; > + grub_int32_t fb_height; > + grub_int32_t fb_width; > + grub_int32_t fb_stride; > + grub_uint32_t fb_mask_red; > + grub_uint32_t fb_mask_green; > + grub_uint32_t fb_mask_blue; > + grub_uint32_t fb_mask_reserved; > +}; This file looks copied. Please provide correct attribution. > -- 2.2.1 >=20 >=20 >=20 > _______________________________________________ > Grub-devel mailing list > Grub-devel@gnu.org > https://lists.gnu.org/mailman/listinfo/grub-devel >=20 --6ETw7INLcmpulvi3RxmMbBMELNX27X6gB Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iF4EAREKAAYFAlTBYl8ACgkQmBXlbbo5nOtqQgD+PIqGAHiC01aqK0k+6dRWjhHY qN8nlUiNiP0QlvKrF8UA/3R4veb0X/1l9Rym1aFtFmuWKRE+KvzXaDK6pWN7uI38 =81AV -----END PGP SIGNATURE----- --6ETw7INLcmpulvi3RxmMbBMELNX27X6gB--