Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 24 Feb 2013 11:24:08 +0000 (UTC)
From:      Benno Rice <benno@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-projects@freebsd.org
Subject:   svn commit: r247216 - in projects/uefi/sys/boot: efi/include i386/efi
Message-ID:  <201302241124.r1OBO899010452@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: benno
Date: Sun Feb 24 11:24:08 2013
New Revision: 247216
URL: http://svnweb.freebsd.org/changeset/base/247216

Log:
  Use the UEFI Graphics Output Protocol to get the parameters of the framebuffer.
  
  This is handed over to be used by the syscons framebuffer.

Added:
  projects/uefi/sys/boot/efi/include/efigop.h
  projects/uefi/sys/boot/i386/efi/efifb.c
  projects/uefi/sys/boot/i386/efi/efifb.h
Modified:
  projects/uefi/sys/boot/efi/include/efi.h
  projects/uefi/sys/boot/i386/efi/efimd.c

Modified: projects/uefi/sys/boot/efi/include/efi.h
==============================================================================
--- projects/uefi/sys/boot/efi/include/efi.h	Sun Feb 24 11:22:29 2013	(r247215)
+++ projects/uefi/sys/boot/efi/include/efi.h	Sun Feb 24 11:24:08 2013	(r247216)
@@ -52,6 +52,7 @@ Revision History
 #include "efiapi.h"
 #include "efifs.h"
 #include "efierr.h"
+#include "efigop.h"
 
 #define EFI_STRINGIZE(a)                #a 
 #define EFI_PROTOCOL_DEFINITION(a)      EFI_STRINGIZE(Protocol/a/a.h) 

Added: projects/uefi/sys/boot/efi/include/efigop.h
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ projects/uefi/sys/boot/efi/include/efigop.h	Sun Feb 24 11:24:08 2013	(r247216)
@@ -0,0 +1,122 @@
+/* $FreeBSD$ */
+/*++
+
+Copyright (c)  1999 - 2002 Intel Corporation. All rights reserved
+This software and associated documentation (if any) is furnished
+under a license and may only be used or copied in accordance
+with the terms of the license. Except as permitted by such
+license, no part of this software or documentation may be
+reproduced, stored in a retrieval system, or transmitted in any
+form or by any means without the express written consent of
+Intel Corporation.
+
+Module Name:
+
+    efigop.h
+    
+Abstract:   
+    Info about framebuffers
+
+
+
+
+Revision History
+
+--*/
+
+#ifndef _EFIGOP_H
+#define _EFIGOP_H
+
+#define EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID				\
+    { 0x9042a9de, 0x23dc, 0x4a38, 0x96, 0xfb, 0x7a, 0xde, 0xd0, 0x80,	\
+      0x51, 0x6a }
+
+INTERFACE_DECL(_EFI_GRAPHICS_OUTPUT);
+
+typedef struct {
+	UINT32	RedMask;
+	UINT32	GreenMask;
+	UINT32	BlueMask;
+	UINT32	ReservedMask;
+} EFI_PIXEL_BITMASK;
+
+typedef enum {
+	PixelRedGreenBlueReserved8BitPerColor,
+	PixelBlueGreenRedReserved8BitPerColor,
+	PixelBitMask,
+	PixelBltOnly,
+	PixelFormatMax,
+} EFI_GRAPHICS_PIXEL_FORMAT;
+
+typedef struct {
+	UINT32				Version;
+	UINT32				HorizontalResolution;
+	UINT32				VerticalResolution;
+	EFI_GRAPHICS_PIXEL_FORMAT	PixelFormat;
+	EFI_PIXEL_BITMASK		PixelInformation;
+	UINT32				PixelsPerScanLine;
+} EFI_GRAPHICS_OUTPUT_MODE_INFORMATION;
+
+typedef struct {
+	UINT32					MaxMode;
+	UINT32					Mode;
+	EFI_GRAPHICS_OUTPUT_MODE_INFORMATION	*Info;
+	UINTN					SizeOfInfo;
+	EFI_PHYSICAL_ADDRESS			FrameBufferBase;
+	UINTN					FrameBufferSize;
+} EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_GRAPHICS_OUTPUT_PROTOCOL_QUERY_MODE) (
+    IN  struct _EFI_GRAPHICS_OUTPUT		*This,
+    IN  UINT32					ModeNumber,
+    OUT UINTN					*SizeOfInfo,
+    OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION	**Info
+    );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_GRAPHICS_OUTPUT_PROTOCOL_SET_MODE) (
+    IN  struct _EFI_GRAPHICS_OUTPUT	*This,
+    IN  UINT32				ModeNumber
+    );
+
+typedef struct {
+	UINT8	Blue;
+	UINT8	Green;
+	UINT8	Red;
+	UINT8	Reserved;
+} EFI_GRAPHICS_OUTPUT_BLT_PIXEL;
+
+typedef enum {
+	EfiBltVideoFill,
+	EfiBltVideoToBltBuffer,
+	EfiBltBufferToVideo,
+	EfiBltVideoToVideo,
+	EfiGraphcisOutputBltOperationMax,
+} EFI_GRAPHICS_OUTPUT_BLT_OPERATION;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_GRAPHICS_OUTPUT_PROTOCOL_BLT) (
+    IN struct _EFI_GRAPHICS_OUTPUT		*This,
+    IN OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL	*BltBuffer,
+    IN EFI_GRAPHICS_OUTPUT_BLT_OPERATION	BltOperation,
+    IN UINTN					SourceX,
+    IN UINTN					SourceY,
+    IN UINTN					DestinationX,
+    IN UINTN					DestinationY,
+    IN UINTN					Width,
+    IN UINTN					Height,
+    IN UINTN					Delta
+    );
+
+typedef struct _EFI_GRAPHICS_OUTPUT {
+	EFI_GRAPHICS_OUTPUT_PROTOCOL_QUERY_MODE	QueryMode;
+	EFI_GRAPHICS_OUTPUT_PROTOCOL_SET_MODE	SetMode;
+	EFI_GRAPHICS_OUTPUT_PROTOCOL_BLT	Blt;
+	EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE	*Mode;
+} EFI_GRAPHICS_OUTPUT;
+
+#endif /* _EFIGOP_H */

Added: projects/uefi/sys/boot/i386/efi/efifb.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ projects/uefi/sys/boot/i386/efi/efifb.c	Sun Feb 24 11:24:08 2013	(r247216)
@@ -0,0 +1,88 @@
+/*-
+ * Copyright (c) 2013 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * This software was developed by Benno Rice under sponsorship from
+ * the FreeBSD Foundation.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <stand.h>
+
+#include <efi.h>
+#include <efilib.h>
+
+#include <machine/efi.h>
+
+static EFI_GUID gop_guid = EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID;
+
+void
+efi_find_framebuffer(struct efi_header *efihdr)
+{
+	EFI_GRAPHICS_OUTPUT			*gop;
+	EFI_STATUS				status;
+	EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE	*mode;
+	EFI_GRAPHICS_OUTPUT_MODE_INFORMATION	*info;
+
+	status = BS->LocateProtocol(&gop_guid, NULL, (VOID **)&gop);
+	if (EFI_ERROR(status)) {
+		efihdr->fb.fb_present = 0;
+		return;
+	}
+
+	mode = gop->Mode;
+	info = gop->Mode->Info;
+
+	efihdr->fb.fb_present = 1;
+	efihdr->fb.fb_addr = mode->FrameBufferBase;
+	efihdr->fb.fb_size = mode->FrameBufferSize;
+	efihdr->fb.fb_height = info->VerticalResolution;
+	efihdr->fb.fb_width = info->HorizontalResolution;
+	efihdr->fb.fb_stride = info->PixelsPerScanLine;
+
+	switch (info->PixelFormat) {
+	case PixelRedGreenBlueReserved8BitPerColor:
+		efihdr->fb.fb_mask_red = 0x000000ff;
+		efihdr->fb.fb_mask_green = 0x0000ff00;
+		efihdr->fb.fb_mask_blue = 0x00ff0000;
+		efihdr->fb.fb_mask_reserved = 0xff000000;
+		break;
+	case PixelBlueGreenRedReserved8BitPerColor:
+		efihdr->fb.fb_mask_red = 0x00ff0000;
+		efihdr->fb.fb_mask_green = 0x0000ff00;
+		efihdr->fb.fb_mask_blue = 0x000000ff;
+		efihdr->fb.fb_mask_reserved = 0xff000000;
+		break;
+	case PixelBitMask:
+		efihdr->fb.fb_mask_red = info->PixelInformation.RedMask;
+		efihdr->fb.fb_mask_green = info->PixelInformation.GreenMask;
+		efihdr->fb.fb_mask_blue = info->PixelInformation.BlueMask;
+		efihdr->fb.fb_mask_reserved =
+		    info->PixelInformation.ReservedMask;
+		break;
+	default:
+		efihdr->fb.fb_present = 0;
+	}
+}

Added: projects/uefi/sys/boot/i386/efi/efifb.h
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ projects/uefi/sys/boot/i386/efi/efifb.h	Sun Feb 24 11:24:08 2013	(r247216)
@@ -0,0 +1,6 @@
+#ifndef	_EFIFB_H_
+#define	_EFIFB_H_
+
+void	efi_find_framebuffer(struct efi_header *efihdr);
+
+#endif /* _EFIFB_H_ */

Modified: projects/uefi/sys/boot/i386/efi/efimd.c
==============================================================================
--- projects/uefi/sys/boot/i386/efi/efimd.c	Sun Feb 24 11:22:29 2013	(r247215)
+++ projects/uefi/sys/boot/i386/efi/efimd.c	Sun Feb 24 11:24:08 2013	(r247216)
@@ -37,6 +37,7 @@ __FBSDID("$FreeBSD$");
 #include <machine/metadata.h>
 
 #include "bootstrap.h"
+#include "efifb.h"
 
 static UINTN mapkey;
 
@@ -101,6 +102,8 @@ ldr_bootinfo(struct preloaded_file *kfp)
 	efihdr->descriptor_size = mmsz;
 	efihdr->descriptor_version = mmver;
 
+	efi_find_framebuffer(efihdr);
+
 	file_addmetadata(kfp, MODINFOMD_EFI, efisz + sz, efihdr);
 
 	return (0);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201302241124.r1OBO899010452>