From owner-freebsd-questions@FreeBSD.ORG Fri Oct 31 00:21:34 2014 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id D417EDB; Fri, 31 Oct 2014 00:21:34 +0000 (UTC) Received: from mail.firstyear.id.au (2001-44b8-016a-0004-0000-0000-0000-0001.static.ipv6.internode.on.net [IPv6:2001:44b8:16a:4::1]) by mx1.freebsd.org (Postfix) with ESMTP id 03C98927; Fri, 31 Oct 2014 00:21:33 +0000 (UTC) Received: from [129.127.46.250] (ammy.its.adelaide.edu.au [129.127.46.250]) by mail.firstyear.id.au (Postfix) with ESMTPSA id 9B3B3453B064; Fri, 31 Oct 2014 10:51:25 +1030 (ACDT) Message-ID: <1414714882.16625.43.camel@ammy.its.adelaide.edu.au> Subject: Re: Loader vs loader efi ficl incompatibility From: William To: Ed Maste Date: Fri, 31 Oct 2014 10:51:22 +1030 In-Reply-To: References: <1414622725.16625.22.camel@ammy.its.adelaide.edu.au> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.10.4 (3.10.4-4.fc20) Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=1.3 required=5.0 tests=RDNS_NONE,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 X-Spam-Level: * X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lyra.ipa.blackhats.net.au Cc: FreeBSD Questions X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 31 Oct 2014 00:21:35 -0000 On Thu, 2014-10-30 at 10:59 -0400, Ed Maste wrote: > On 29 October 2014 18:45, William wrote: > > Hi, > > > > To get my laptop working (Macbook pro) with freebsd, at boot you need to > > outb to some memory locations before boot so that graphics works. > > Do you happen to have a good reference for the io ports you mention? I > see them described on a number of Linux forums, but a canonical source > would be nice. So, I should explain. In the MacBookPro 15" 8,2, it has two graphics cards. The i915 intel and a radeon 6770. These are connected to a multiplexer (gmux) and that is connected to the laptop panel via LVDS. When the system boots, the ati card is selected on the gmux, and both powered on. I wish to preboot change to the i915 then boot the system. The reason for doing this preboot is that efifb doesn't support re-probing the display after a switch. As I say this, I mean that FreeBSD doesn't currently appear to support gmux switching, I wrote my own kernel module to do this, so it's very rough and doesn't interact with efifb at all. The obvious reason for the gpu swap and power down of the inactive card is battery and heat. The radeon idle runs at 60+ degrees, and halves the battery. There is no canonical source that I know of, merely reverse engineering. If you want the details of the specific addresses I can provide these, as each one of those 4 has a unique function in the gmux. > > > Are there differences in the ficl interpreter between loader and > > loader.efi? Is this perhaps a bug? > > The loader only includes inb and outb for i386 (the non-UEFI loader is > 32-bit for both i386 and amd64): > > #ifdef __i386__ > dictAppendWord(dp, "outb", ficlOutb, FW_DEFAULT); > dictAppendWord(dp, "inb", ficlInb, FW_DEFAULT); > #endif > > We'd need to make these available in the 64-bit loader.efi, although Removing the ifdef would be enough to make this work for my own personal use? Or would there be unintended consequences. > I'd really like to have MBP support be handled automatically in the > loader itself. > _______________________________________________ Each Mac revision slightly tweaks the gmux, which makes it harder to support. IIRC the linux kernel apple-gmux implementation has this working. The correct way to do this really would be early in loader before the display is setup, change to the intel, and reinit the framebuffer. This relies on Mac hardware detection, the programmatic gmux base address detection, and loader being able to completely reinit the frame buffer in efi. Alternately, you do it just after loader, but just before the freebsd kernel runs so that you don't worry about the screen going black before the efifb gets reinitialised. Then freebsd itself needs a graphics swapping kernel module. You need to be able to carry out a swap, do an LVDS reprobe, and redraw the fb / display. radeon supports this, i915 does not (It's been broken in linux for years and no developers are willing to look at it). For tty with KMS/DRM which does not use these drivers, you likely could just do some handling in efifb. All in all, it would be far more than just a quick "loader" fix imo, and for my specific use case I just need the intel gpu working. I'm quite happy to just drop the outb commands into boot.4th. I'd love to see the fix be done "properly" for all, but I don't have the knowledge to do it, the time etc. I'd be happy some of the work into the loader components for this, but I don't know enough about KMS/DRM to fix those components. Finally, I want to ask if hardware-specific detection should go into loader? I'm not 100% familiar with this architecture and if this very targeted hardware manipulation should go in it. -- William