OpenCore  1.0.4
OpenCore Bootloader
Loading...
Searching...
No Matches
OcConsoleLib.h File Reference
#include <Protocol/AppleFramebufferInfo.h>
#include <Protocol/AppleEg2Info.h>
#include <Protocol/ConsoleControl.h>
#include <Protocol/GraphicsOutput.h>
#include <Library/OcBootManagementLib.h>
#include <Library/OcFileLib.h>

Go to the source code of this file.

Data Structures

struct  _OC_CONSOLE_FONT_PAGE
 
struct  _OC_CONSOLE_FONT
 
struct  _OC_CONSOLE_FONT_RANGE
 

Macros

#define OC_CONSOLE_MARK_UNCONTROLLED   L"MarkUncontrolled"
 
#define ISO_CHAR_WIDTH   (8u)
 
#define ISO_CHAR_HEIGHT   (16u)
 
#define OC_CONSOLE_FONT_FALLBACK_CHAR   (L'_')
 

Typedefs

typedef struct _OC_CONSOLE_FONT_PAGE OC_CONSOLE_FONT_PAGE
 
typedef struct _OC_CONSOLE_FONT OC_CONSOLE_FONT
 
typedef struct _OC_CONSOLE_FONT_RANGE OC_CONSOLE_FONT_RANGE
 

Enumerations

enum  OC_CONSOLE_RENDERER {
  OcConsoleRendererBuiltinGraphics , OcConsoleRendererBuiltinText , OcConsoleRendererSystemGraphics , OcConsoleRendererSystemText ,
  OcConsoleRendererSystemGeneric
}
 

Functions

VOID OcSetupConsole (IN EFI_CONSOLE_CONTROL_SCREEN_MODE InitialMode, IN OC_CONSOLE_RENDERER Renderer, IN OC_STORAGE_CONTEXT *Storage OPTIONAL, IN CONST CHAR8 *Font OPTIONAL, IN BOOLEAN IgnoreTextOutput, IN BOOLEAN SanitiseClearScreen, IN BOOLEAN ClearScreenOnModeSwitch, IN BOOLEAN ReplaceTabWithSpace, IN UINT32 Width, IN UINT32 Height)
 
EFI_CONSOLE_CONTROL_SCREEN_MODE OcConsoleControlSetMode (IN EFI_CONSOLE_CONTROL_SCREEN_MODE Mode)
 
EFI_CONSOLE_CONTROL_SCREEN_MODE OcConsoleControlGetMode (VOID)
 
VOID OcParseScreenResolution (IN CONST CHAR8 *String, OUT UINT32 *Width, OUT UINT32 *Height, OUT UINT32 *Bpp, OUT BOOLEAN *Max)
 
VOID OcParseConsoleMode (IN CONST CHAR8 *String, OUT UINT32 *Width, OUT UINT32 *Height, OUT BOOLEAN *Max)
 
EFI_STATUS OcSetGopBurstMode (VOID)
 
EFI_STATUS OcGopModeBytesPerPixel (IN EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE *Mode, OUT UINTN *BytesPerPixel)
 
EFI_STATUS OcGopModeSafeFrameBufferSize (IN EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE *Mode, OUT UINTN *FrameBufferSize)
 
EFI_STATUS OcSetConsoleResolution (IN UINT32 Width OPTIONAL, IN UINT32 Height OPTIONAL, IN UINT32 Bpp OPTIONAL, IN BOOLEAN Force)
 
EFI_STATUS OcSetConsoleMode (IN UINT32 Width, IN UINT32 Height)
 
EFI_STATUS OcProvideConsoleGop (IN BOOLEAN Route)
 
VOID OcReconnectConsole (VOID)
 
EFI_STATUS OcUseDirectGop (IN INT32 CacheType)
 
EFI_SYSTEM_TABLE * AllocateNullTextOutSystemTable (IN EFI_SYSTEM_TABLE *SystemTable)
 
EFI_STATUS OcProvideUgaPassThrough (VOID)
 
EFI_STATUS OcProvideGopPassThrough (IN BOOLEAN ForAll)
 
APPLE_FRAMEBUFFER_INFO_PROTOCOLOcAppleFbInfoInstallProtocol (IN BOOLEAN Reinstall)
 
APPLE_EG2_INFO_PROTOCOLOcAppleEg2InfoInstallProtocol (IN BOOLEAN Reinstall)
 
EFI_STATUS OcGopInfoDump (IN EFI_FILE_PROTOCOL *Root)
 

Variables

OC_CONSOLE_FONT gDefaultConsoleFont
 
OC_CONSOLE_FONT_RANGE gEfiRequiredUnicodeChars []
 
OC_CONSOLE_FONT_RANGE gExtendedUnicodeChars []
 

Detailed Description

Copyright (C) 2019, vit9696. All rights reserved.

All rights reserved.

This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php

THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.

Definition in file OcConsoleLib.h.

Macro Definition Documentation

◆ ISO_CHAR_HEIGHT

#define ISO_CHAR_HEIGHT   (16u)

Definition at line 50 of file OcConsoleLib.h.

◆ ISO_CHAR_WIDTH

#define ISO_CHAR_WIDTH   (8u)

Console font.

Definition at line 49 of file OcConsoleLib.h.

◆ OC_CONSOLE_FONT_FALLBACK_CHAR

#define OC_CONSOLE_FONT_FALLBACK_CHAR   (L'_')

Definition at line 52 of file OcConsoleLib.h.

◆ OC_CONSOLE_MARK_UNCONTROLLED

#define OC_CONSOLE_MARK_UNCONTROLLED   L"MarkUncontrolled"

Special commands sent to Builtin text renderer through TestString. Extension to notify OpenCore builtin renderer that any text it may have produced on screen is mixed with graphics which it did not control.

Definition at line 44 of file OcConsoleLib.h.

Typedef Documentation

◆ OC_CONSOLE_FONT

◆ OC_CONSOLE_FONT_PAGE

◆ OC_CONSOLE_FONT_RANGE

Enumeration Type Documentation

◆ OC_CONSOLE_RENDERER

Console renderer to use.

Enumerator
OcConsoleRendererBuiltinGraphics 
OcConsoleRendererBuiltinText 
OcConsoleRendererSystemGraphics 
OcConsoleRendererSystemText 
OcConsoleRendererSystemGeneric 

Definition at line 29 of file OcConsoleLib.h.

Function Documentation

◆ AllocateNullTextOutSystemTable()

EFI_SYSTEM_TABLE * AllocateNullTextOutSystemTable ( IN EFI_SYSTEM_TABLE * SystemTable)

Allocate new System Table with disabled text output.

Parameters
[in]SystemTableBase System Table.
Return values
nonNULL The System Table table was allocated successfully.

Definition at line 147 of file TextOutputNull.c.

◆ OcAppleEg2InfoInstallProtocol()

APPLE_EG2_INFO_PROTOCOL * OcAppleEg2InfoInstallProtocol ( IN BOOLEAN Reinstall)

Install and initialise Apple EG2 Info protocol on top of GOP protocol. For newer EfiBoot this is the way to obtain screen rotation angle.

Parameters
[in]ReinstallOverwrite installed protocol.
Return values
installedor located protocol or NULL.

Definition at line 108 of file Eg2Info.c.

◆ OcAppleFbInfoInstallProtocol()

APPLE_FRAMEBUFFER_INFO_PROTOCOL * OcAppleFbInfoInstallProtocol ( IN BOOLEAN Reinstall)

Install and initialise Apple Framebuffer Info protocol on top of GOP protocol. For EfiBoot 10.4, which can only use UGA, this is the only way to obtain framebuffer base for XNU kernel PE Boot_args.

Parameters
[in]ReinstallOverwrite installed protocol.
Return values
installedor located protocol or NULL.

Definition at line 106 of file FramebufferInfo.c.

◆ OcConsoleControlGetMode()

EFI_CONSOLE_CONTROL_SCREEN_MODE OcConsoleControlGetMode ( VOID )

Get existing console control screen mode, default to text if no existing console control protocol.

Return values
existingconsole control mode.

Definition at line 74 of file ConsoleControl.c.

◆ OcConsoleControlSetMode()

Update console control screen mode.

Parameters
[in]ModeDesired mode.
Return values
previousconsole control mode.

Definition at line 29 of file ConsoleControl.c.

◆ OcGopInfoDump()

EFI_STATUS OcGopInfoDump ( IN EFI_FILE_PROTOCOL * Root)

Dump GOP info to the specified directory.

Parameters
[in]RootDirectory to write CPU data.
Return values
EFI_SUCCESSon success.

Definition at line 26 of file GopInfoDump.c.

◆ OcGopModeBytesPerPixel()

EFI_STATUS OcGopModeBytesPerPixel ( IN EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE * Mode,
OUT UINTN * BytesPerPixel )

Return the bytes per pixel for the current GOP mode.

GOP mode information does not include anything directly containing the bytes per pixel, but there is a defined algorithm for working out this size, even for non-standard pixel masks, and also a defined situation (PixelBltOnly pixel format) where there is no such size.

Parameters
[in]ModeGOP mode.
[in]BytesPerPixelBytes per pixel for the mode in use.
Return values
EFI_SUCCESSSuccess.
EFI_UNSUPPORTEDThere is no frame buffer.
EFI_INVALID_PARAMETERMode info parameters are outside valid ranges.

Definition at line 29 of file GopUtils.c.

◆ OcGopModeSafeFrameBufferSize()

EFI_STATUS OcGopModeSafeFrameBufferSize ( IN EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE * Mode,
OUT UINTN * FrameBufferSize )

Return the frame buffer size in use for the current GOP mode, even where Gop->Mode->FrameBufferSize misreports this.

Occasional GOP implementations report a frame buffer size far larger (e.g. ~100x) than required for the actual mode in use.

Parameters
[in]ModeGOP mode.
[in]FrameBufferSizeFrame buffer size in use.
Return values
EFI_SUCCESSSuccess.
EFI_UNSUPPORTEDThere is no frame buffer.
EFI_INVALID_PARAMETERSize parameters are outside valid ranges.

Definition at line 85 of file GopUtils.c.

◆ OcParseConsoleMode()

VOID OcParseConsoleMode ( IN CONST CHAR8 * String,
OUT UINT32 * Width,
OUT UINT32 * Height,
OUT BOOLEAN * Max )

Parse console mode from string.

Parameters
[in]StringResolution in WxH format.
[out]WidthParsed mode width or 0.
[out]HeightParsed mode height or 0.
[out]MaxSet to TRUE when String equals to Max.

Definition at line 121 of file ResolutionParsing.c.

◆ OcParseScreenResolution()

VOID OcParseScreenResolution ( IN CONST CHAR8 * String,
OUT UINT32 * Width,
OUT UINT32 * Height,
OUT UINT32 * Bpp,
OUT BOOLEAN * Max )

Parse screen resolution from string.

Parameters
[in]StringResolution in WxH@B or WxH format.
[out]WidthParsed resolution width or 0.
[out]HeightParsed resolution height or 0.
[out]BppParsed resolution bpp or 0.
[out]MaxSet to TRUE when String equals to Max.

Definition at line 103 of file ResolutionParsing.c.

◆ OcProvideConsoleGop()

EFI_STATUS OcProvideConsoleGop ( IN BOOLEAN Route)

Ensure installed GOP protocol on ConOut handle.

Definition at line 81 of file ConsoleGop.c.

◆ OcProvideGopPassThrough()

EFI_STATUS OcProvideGopPassThrough ( IN BOOLEAN ForAll)

Provide GOP protocol instances on top of existing UGA instances.

Parameters
[in]ForAllFor all instances, otherwises for AppleFramebuffer-enabled only.
Return values
EFI_SUCCESSon success.

< or PixelBlueGreenRedReserved8BitPerColor?

Definition at line 108 of file GopPassThrough.c.

◆ OcProvideUgaPassThrough()

EFI_STATUS OcProvideUgaPassThrough ( VOID )

Provide UGA protocol instances on top of existing GOP instances.

Return values
EFI_SUCCESSon success.

Definition at line 154 of file UgaPassThrough.c.

◆ OcReconnectConsole()

VOID OcReconnectConsole ( VOID )

Perform console reconnection.

Definition at line 482 of file ConsoleGop.c.

◆ OcSetConsoleMode()

EFI_STATUS OcSetConsoleMode ( IN UINT32 Width,
IN UINT32 Height )

Set console mode.

Parameters
[in]WidthResolution width or 0 for Max.
[in]HeightResolution height or 0 for Max.
Return values
EFI_SUCCESSon success.

Definition at line 380 of file OcConsoleLib.c.

◆ OcSetConsoleResolution()

EFI_STATUS OcSetConsoleResolution ( IN UINT32 Width OPTIONAL,
IN UINT32 Height OPTIONAL,
IN UINT32 Bpp OPTIONAL,
IN BOOLEAN Force )

Set screen resolution on console handle.

Parameters
[in]WidthResolution width or 0 for Max.
[in]HeightResolution height or 0 for Max.
[in]BppResolution bpp or 0 for automatic.
[in]ForceForce the specified resolution using the OC_FORCE_RESOLUTION protocol.
Return values
EFI_SUCCESSon success.

Definition at line 289 of file OcConsoleLib.c.

◆ OcSetGopBurstMode()

EFI_STATUS OcSetGopBurstMode ( VOID )

Use PAT to enable write-combining caching (burst mode) on GOP memory, when it is suppported but firmware has not set it up.

Return values
EFI_SUCCESSon success.

Definition at line 308 of file GopUtils.c.

◆ OcSetupConsole()

VOID OcSetupConsole ( IN EFI_CONSOLE_CONTROL_SCREEN_MODE InitialMode,
IN OC_CONSOLE_RENDERER Renderer,
IN OC_STORAGE_CONTEXT *Storage OPTIONAL,
IN CONST CHAR8 *Font OPTIONAL,
IN BOOLEAN IgnoreTextOutput,
IN BOOLEAN SanitiseClearScreen,
IN BOOLEAN ClearScreenOnModeSwitch,
IN BOOLEAN ReplaceTabWithSpace,
IN UINT32 Width,
IN UINT32 Height )

Configure console control protocol with given options.

Parameters
[in]InitialModeInitial mode to use, or set max. value to use existing mode.
[in]RendererRenderer to use.
[in]StorageStorage context - only required if Font parameter is used.
[in]FontFont file to load. Use builtin font if NULL or empty string.
[in]IgnoreTextOutputSkip console output in text mode.
[in]SanitiseClearScreenWorkaround ClearScreen breaking resolution.
[in]ClearScreenOnModeSwitchClear graphic screen when switching to text mode.
[in]ReplaceTabWithSpaceReplace invisible tab characters with spaces in OutputString.
[in]WidthWidth to set - applies to builtin renderer only.
[in]HeightHeight to set - applies to builtin renderer only.

Definition at line 389 of file OcConsoleLib.c.

◆ OcUseDirectGop()

EFI_STATUS OcUseDirectGop ( IN INT32 CacheType)

Use direct GOP renderer for console.

Parameters
[in]CacheTypeCaching type, e.g. CacheWriteCombining or -1 to disable.
[in]RotationRotation scheme in degrees (must be one of 0, 90, 180, 270).
Return values
EFI_SUCCESSon success.

Definition at line 536 of file ConsoleGop.c.

Variable Documentation

◆ gDefaultConsoleFont

OC_CONSOLE_FONT gDefaultConsoleFont
extern

Free font used by XNU, plus unicode box drawing chars.

Definition at line 611 of file ConsoleFont.c.

◆ gEfiRequiredUnicodeChars

◆ gExtendedUnicodeChars

OC_CONSOLE_FONT_RANGE gExtendedUnicodeChars[]
extern

List of all chars present in Extended Unicode range. Ref: https://int10h.org/oldschool-pc-fonts/fontlist/font?ibm_vga_8x16

Definition at line 654 of file ConsoleFont.c.