Skip to content
This repository has been archived by the owner on Dec 14, 2023. It is now read-only.

Commit

Permalink
Merge pull request #7 from d-scott-phillips/bhyve/edk2-stable201903
Browse files Browse the repository at this point in the history
bhyve/edk2-stable201903
  • Loading branch information
araujobsd authored Apr 1, 2019
2 parents 89910a3 + 976fc1f commit 4c7c2a5
Show file tree
Hide file tree
Showing 97 changed files with 19,610 additions and 2,923 deletions.
55 changes: 55 additions & 0 deletions BaseTools/Conf/tools_def.template
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,10 @@ DEFINE DTC_BIN = ENV(DTC_PREFIX)dtc
# Note:
# Building of XIP firmware images for ARM/ARM64 is not currently supported (only applications).
# /FILEALIGN:4096 and other changes are needed for ARM firmware builds.
# FBSDGCC -FreeBSD- Requires:
# GCC 4.8
# Intel(r) ACPI Compiler iasl from the base system.
# TODO: there needs to be a ports version of acpi tools v20101013.
# GCC48 -Linux,Windows- Requires:
# GCC 4.8 targeting x86_64-linux-gnu, aarch64-linux-gnu, or arm-linux-gnueabi
# Optional:
Expand Down Expand Up @@ -3209,6 +3213,57 @@ DEFINE GCC5_ARM_ASLDLINK_FLAGS = DEF(GCC49_ARM_ASLDLINK_FLAGS)
DEFINE GCC5_AARCH64_ASLDLINK_FLAGS = DEF(GCC49_AARCH64_ASLDLINK_FLAGS)
DEFINE GCC5_ASLCC_FLAGS = DEF(GCC49_ASLCC_FLAGS) -fno-lto

####################################################################################
#
# FreeBSD GCC And Intel Linux ACPI Compiler
#
####################################################################################
# FBSDGCC - FreeBSD GCC, currently gcc 4.8
# ASL - Intel Linux ACPI Source Language Compiler (iasl)
*_FBSDGCC_*_*_FAMILY = GCC

*_FBSDGCC_*_MAKE_PATH = /usr/local/bin/gmake
*_FBSDGCC_*_ASL_PATH = /usr/sbin/iasl

*_FBSDGCC_X64_DLINK_FLAGS = DEF(GCC_IA32_X64_DLINK_FLAGS) --image-base=0
*_FBSDGCC_X64_ASLDLINK_FLAGS = DEF(GCC_IA32_X64_ASLDLINK_FLAGS)
*_FBSDGCC_*_ASM_FLAGS = DEF(GCC_ASM_FLAGS)
*_FBSDGCC_*_PP_FLAGS = DEF(GCC_PP_FLAGS)
*_FBSDGCC_*_ASLPP_FLAGS = DEF(GCC_ASLPP_FLAGS)
*_FBSDGCC_*_ASLCC_FLAGS = DEF(GCC_ASLCC_FLAGS)
*_FBSDGCC_*_VFRPP_FLAGS = DEF(GCC_VFRPP_FLAGS)
*_FBSDGCC_*_APP_FLAGS =
*_FBSDGCC_*_ASL_FLAGS = DEF(IASL_FLAGS)
*_FBSDGCC_*_ASL_OUTFLAGS = DEF(IASL_OUTFLAGS)

##################
# No FreeBSD IA32 definitions
##################

##################
# X64 definitions
##################
# Env vars are needed for other locations in the build (e.g. tools)
*_FBSDGCC_X64_OBJCOPY_PATH = ENV(OBJCOPY)
*_FBSDGCC_X64_CC_PATH = ENV(CC)
*_FBSDGCC_X64_SLINK_PATH = ENV(AR)
*_FBSDGCC_X64_DLINK_PATH = ENV(LD)
*_FBSDGCC_X64_ASLDLINK_PATH = ENV(LD)
*_FBSDGCC_X64_ASM_PATH = ENV(CC)
*_FBSDGCC_X64_PP_PATH = ENV(CC)
*_FBSDGCC_X64_VFRPP_PATH = ENV(CC)
*_FBSDGCC_X64_ASLCC_PATH = ENV(CC)
*_FBSDGCC_X64_ASLPP_PATH = ENV(CC)
*_FBSDGCC_X64_RC_PATH = ENV(OBJCOPY)

*_FBSDGCC_X64_ASLCC_FLAGS = DEF(GCC_ASLCC_FLAGS) -m64
*_FBSDGCC_X64_ASLDLINK_FLAGS = DEF(GCC48_IA32_X64_ASLDLINK_FLAGS) -m elf_x86_64
*_FBSDGCC_X64_ASM_FLAGS = DEF(GCC48_ASM_FLAGS) -m64
*_FBSDGCC_X64_CC_FLAGS = DEF(GCC48_X64_CC_FLAGS)
*_FBSDGCC_X64_DLINK_FLAGS = DEF(GCC48_X64_DLINK_FLAGS)
*_FBSDGCC_X64_RC_FLAGS = DEF(GCC_X64_RC_FLAGS)
*_FBSDGCC_X64_OBJCOPY_FLAGS =

####################################################################################
#
# GCC 4.8 - This configuration is used to compile under Linux to produce
Expand Down
47 changes: 1 addition & 46 deletions EmulatorPkg/EmuGopDxe/ComponentName.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,50 +201,5 @@ EmuGopComponentNameGetControllerName (
OUT CHAR16 **ControllerName
)
{
EFI_STATUS Status;
EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
GOP_PRIVATE_DATA *Private;

//
// This is a device driver, so ChildHandle must be NULL.
//
if (ChildHandle != NULL) {
return EFI_UNSUPPORTED;
}

//
// Make sure this driver is currently managing ControllerHandle
//
Status = EfiTestManagedDevice (
ControllerHandle,
gEmuGopDriverBinding.DriverBindingHandle,
&gEmuIoThunkProtocolGuid
);
if (EFI_ERROR (Status)) {
return EFI_UNSUPPORTED;
}
//
// Get our context back
//
Status = gBS->OpenProtocol (
ControllerHandle,
&gEfiGraphicsOutputProtocolGuid,
(VOID **)&GraphicsOutput,
gEmuGopDriverBinding.DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
if (EFI_ERROR (Status)) {
return EFI_UNSUPPORTED;
}

Private = GOP_PRIVATE_DATA_FROM_THIS (GraphicsOutput);

return LookupUnicodeString2 (
Language,
This->SupportedLanguages,
Private->ControllerNameTable,
ControllerName,
(BOOLEAN)(This == &gEmuGopComponentName)
);
return EFI_UNSUPPORTED;
}
38 changes: 22 additions & 16 deletions EmulatorPkg/EmuGopDxe/EmuGopDxe.inf
Original file line number Diff line number Diff line change
Expand Up @@ -36,34 +36,40 @@
ComponentName.c
GopScreen.c
GopDriver.c
GopInput.c
Gop.h
VbeShim.c


[Packages]
MdePkg/MdePkg.dec
EmulatorPkg/EmulatorPkg.dec
OptionRomPkg/OptionRomPkg.dec
OvmfPkg/OvmfPkg.dec
IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec
MdeModulePkg/MdeModulePkg.dec


[LibraryClasses]
UefiBootServicesTableLib
MemoryAllocationLib
BaseLib
BaseMemoryLib
BltLib
DebugLib
DevicePathLib
MemoryAllocationLib
PciLib
PcdLib
PrintLib
UefiLib
UefiBootServicesTableLib
UefiDriverEntryPoint
BaseLib
DebugLib
KeyMapLib


[Guids]
gEfiEventExitBootServicesGuid # SOMETIMES_CONSUMED Create Event: EVENT_GROUP_GUID
[Protocols]
gEfiGraphicsOutputProtocolGuid # PROTOCOL BY_START
gEfiDevicePathProtocolGuid # PROTOCOL TO_START
gEfiPciIoProtocolGuid # PROTOCOL TO_START

[Pcd]
gOptionRomPkgTokenSpaceGuid.PcdDriverSupportedEfiVersion
gEfiMdeModulePkgTokenSpaceGuid.PcdVideoHorizontalResolution
gEfiMdeModulePkgTokenSpaceGuid.PcdVideoVerticalResolution

[Protocols]
gEfiGraphicsOutputProtocolGuid
gEfiSimpleTextInProtocolGuid # PROTOCOL BY_START
gEfiSimpleTextInputExProtocolGuid # PROTOCOL BY_START
gEfiSimplePointerProtocolGuid # PROTOCOL BY_START
gEmuIoThunkProtocolGuid # PROTOCOL TO_START
gEmuGraphicsWindowProtocolGuid # PROTOCOL TO_START
148 changes: 53 additions & 95 deletions EmulatorPkg/EmuGopDxe/Gop.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,47 +15,27 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#ifndef __UGA_H_
#define __UGA_H_

#include <PiDxe.h>

#include <Uefi.h>
#include <Protocol/GraphicsOutput.h>
#include <Protocol/SimpleTextIn.h>
#include <Protocol/SimpleTextInEx.h>
#include <Protocol/SimplePointer.h>
#include <Protocol/EmuIoThunk.h>
#include <Protocol/EmuGraphicsWindow.h>
#include <Protocol/PciIo.h>
#include <Protocol/DriverSupportedEfiVersion.h>
#include <Protocol/DevicePath.h>

#include <Guid/EventGroup.h>

#include <Library/DebugLib.h>
#include <Library/BaseLib.h>
#include <Library/PcdLib.h>
#include <Library/UefiDriverEntryPoint.h>
#include <Library/UefiLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/KeyMapLib.h>

#include <Library/DevicePathLib.h>

#define MAX_Q 256
#include <IndustryStandard/Pci.h>

typedef struct {
UINTN Front;
UINTN Rear;
UINTN Count;
EFI_INPUT_KEY Q[MAX_Q];
} GOP_QUEUE_FIXED;

#define EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY_SIGNATURE SIGNATURE_32 ('U', 'g', 'S', 'n')
typedef struct _EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY {
UINTN Signature;
EFI_HANDLE NotifyHandle;
EFI_KEY_DATA KeyData;
EFI_KEY_NOTIFY_FUNCTION KeyNotificationFn;
EFI_EVENT Event;
LIST_ENTRY NotifyEntry;
} EMU_GOP_SIMPLE_TEXTIN_EX_NOTIFY;

#define GRAPHICS_OUTPUT_INVALIDE_MODE_NUMBER 0xffff
#define GRAPHICS_OUTPUT_INVALID_MODE_NUMBER 0xffff

typedef struct {
UINT32 HorizontalResolution;
Expand All @@ -64,7 +44,27 @@ typedef struct {
UINT32 RefreshRate;
} GOP_MODE_DATA;

#define PIXEL_RED_SHIFT 0
#define PIXEL_GREEN_SHIFT 3
#define PIXEL_BLUE_SHIFT 6

#define PIXEL_RED_MASK (BIT7 | BIT6 | BIT5)
#define PIXEL_GREEN_MASK (BIT4 | BIT3 | BIT2)
#define PIXEL_BLUE_MASK (BIT1 | BIT0)

#define PIXEL_TO_COLOR_BYTE(pixel, mask, shift) ((UINT8) ((pixel & mask) << shift))
#define PIXEL_TO_RED_BYTE(pixel) PIXEL_TO_COLOR_BYTE(pixel, PIXEL_RED_MASK, PIXEL_RED_SHIFT)
#define PIXEL_TO_GREEN_BYTE(pixel) PIXEL_TO_COLOR_BYTE(pixel, PIXEL_GREEN_MASK, PIXEL_GREEN_SHIFT)
#define PIXEL_TO_BLUE_BYTE(pixel) PIXEL_TO_COLOR_BYTE(pixel, PIXEL_BLUE_MASK, PIXEL_BLUE_SHIFT)

#define RGB_BYTES_TO_PIXEL(Red, Green, Blue) \
(UINT8) ( (((Red) >> PIXEL_RED_SHIFT) & PIXEL_RED_MASK) | \
(((Green) >> PIXEL_GREEN_SHIFT) & PIXEL_GREEN_MASK) | \
(((Blue) >> PIXEL_BLUE_SHIFT) & PIXEL_BLUE_MASK) )

#define PIXEL24_RED_MASK 0x00ff0000
#define PIXEL24_GREEN_MASK 0x0000ff00
#define PIXEL24_BLUE_MASK 0x000000ff

extern EFI_DRIVER_BINDING_PROTOCOL gEmuGopDriverBinding;
extern EFI_COMPONENT_NAME_PROTOCOL gEmuGopComponentName;
Expand All @@ -76,49 +76,32 @@ typedef struct {
UINT64 Signature;

EFI_HANDLE Handle;
EFI_PCI_IO_PROTOCOL *PciIo;
EFI_GRAPHICS_OUTPUT_PROTOCOL GraphicsOutput;
EFI_SIMPLE_TEXT_INPUT_PROTOCOL SimpleTextIn;
EFI_SIMPLE_POINTER_PROTOCOL SimplePointer;

EMU_IO_THUNK_PROTOCOL *EmuIoThunk;
EMU_GRAPHICS_WINDOW_PROTOCOL *EmuGraphicsWindow;
EFI_DEVICE_PATH_PROTOCOL *GopDevicePath;

EFI_UNICODE_STRING_TABLE *ControllerNameTable;

EFI_SIMPLE_POINTER_MODE PointerMode;
//
// GOP Private Data for QueryMode ()
//
GOP_MODE_DATA *ModeData;


//
// UGA Private Data knowing when to start hardware
//
BOOLEAN HardwareNeedsStarting;

CHAR16 *WindowName;

GOP_QUEUE_FIXED Queue;

EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL SimpleTextInEx;
EFI_KEY_STATE KeyState;
LIST_ENTRY NotifyList;
UINT64 FbAddr;
UINT32 FbSize;
} GOP_PRIVATE_DATA;


#define GOP_PRIVATE_DATA_FROM_THIS(a) \
CR(a, GOP_PRIVATE_DATA, GraphicsOutput, GOP_PRIVATE_DATA_SIGNATURE)

#define GOP_PRIVATE_DATA_FROM_TEXT_IN_THIS(a) \
CR(a, GOP_PRIVATE_DATA, SimpleTextIn, GOP_PRIVATE_DATA_SIGNATURE)

#define GOP_PRIVATE_DATA_FROM_TEXT_IN_EX_THIS(a) \
CR(a, GOP_PRIVATE_DATA, SimpleTextInEx, GOP_PRIVATE_DATA_SIGNATURE)

#define GOP_PRIVATE_DATA_FROM_POINTER_MODE_THIS(a) \
CR(a, GOP_PRIVATE_DATA, SimplePointer, GOP_PRIVATE_DATA_SIGNATURE)

typedef struct {
UINT32 FbSize;
UINT16 Width;
UINT16 Height;
UINT16 Depth;
UINT16 RefreshRate;
} BHYVE_FBUF_MEMREGS;

//
// Global Protocol Variables
Expand All @@ -130,11 +113,6 @@ extern EFI_COMPONENT_NAME2_PROTOCOL gEmuGopComponentName2;
//
// Gop Hardware abstraction internal worker functions
//
EFI_STATUS
EmuGopSupported (
IN EMU_IO_THUNK_PROTOCOL *EmuIoThunk
);

EFI_STATUS
EmuGopConstructor (
IN GOP_PRIVATE_DATA *Private
Expand All @@ -145,32 +123,6 @@ EmuGopDestructor (
IN GOP_PRIVATE_DATA *Private
);


EFI_STATUS
GopPrivateAddQ (
IN GOP_PRIVATE_DATA *Private,
IN EFI_INPUT_KEY Key
);

EFI_STATUS
EmuGopInitializeSimpleTextInForWindow (
IN GOP_PRIVATE_DATA *Private
);

EFI_STATUS
EmuGopInitializeSimplePointerForWindow (
IN GOP_PRIVATE_DATA *Private
);

EFI_STATUS
EmuGopStartWindow (
IN GOP_PRIVATE_DATA *Private,
IN UINT32 HorizontalResolution,
IN UINT32 VerticalResolution,
IN UINT32 ColorDepth,
IN UINT32 RefreshRate
);

VOID
EFIAPI
ShutdownGopEvent (
Expand All @@ -179,17 +131,23 @@ ShutdownGopEvent (
);

VOID
EFIAPI
GopPrivateMakeCallbackFunction (
IN VOID *Context,
IN EFI_KEY_DATA *KeyData
BhyveSetGraphicsMode (
GOP_PRIVATE_DATA *Private,
UINT16 Width,
UINT16 Height,
UINT16 Depth
);

VOID
EFIAPI
GopPrivateBreakCallbackFunction (
IN VOID *Context,
IN EFI_KEY_DATA *KeyData
BhyveGetMemregs (
GOP_PRIVATE_DATA *Private,
BHYVE_FBUF_MEMREGS *Memregs
);

VOID
InstallVbeShim (
IN CONST CHAR16 *CardName,
IN EFI_PHYSICAL_ADDRESS FrameBufferBase
);

#endif
Loading

0 comments on commit 4c7c2a5

Please sign in to comment.