OpenCore  1.0.4
OpenCore Bootloader
Loading...
Searching...
No Matches
OcLegacyThunkLib.c File Reference
#include <Uefi.h>
#include <IndustryStandard/Pci.h>
#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/DebugLib.h>
#include <Library/IoLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/OcDeviceMiscLib.h>
#include <Library/OcLegacyThunkLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiLib.h>
#include <Protocol/PciIo.h>
#include <Protocol/Timer.h>

Go to the source code of this file.

Macros

#define TIMER0_COUNT_PORT   0x40
 
#define TIMER1_COUNT_PORT   0x41
 
#define TIMER2_COUNT_PORT   0x42
 
#define TIMER_CONTROL_PORT   0x43
 
#define TIMER0_CONTROL_WORD   0x36
 
#define LEGACY_MODE_BASE_VECTOR_MASTER   0x08
 
#define LEGACY_MODE_BASE_VECTOR_SLAVE   0x70
 
#define PROTECTED_MODE_BASE_VECTOR_MASTER   0x68
 
#define PROTECTED_MODE_BASE_VECTOR_SLAVE   0x70
 

Functions

EFI_STATUS OcLegacyThunkInitializeBiosIntCaller (THUNK_CONTEXT *ThunkContext)
 
EFI_STATUS OcLegacyThunkInitializeInterruptRedirection (IN EFI_LEGACY_8259_PROTOCOL *Legacy8259)
 
VOID OcLegacyThunkDisconnectEfiGraphics (VOID)
 
BOOLEAN EFIAPI OcLegacyThunkBiosInt86 (IN THUNK_CONTEXT *ThunkContext, IN EFI_LEGACY_8259_PROTOCOL *Legacy8259, IN UINT8 BiosInt, IN IA32_REGISTER_SET *Regs)
 
BOOLEAN EFIAPI OcLegacyThunkFarCall86 (IN THUNK_CONTEXT *ThunkContext, IN EFI_LEGACY_8259_PROTOCOL *Legacy8259, IN UINT16 Segment, IN UINT16 Offset, IN IA32_REGISTER_SET *Regs, IN VOID *Stack, IN UINTN StackSize)
 

Detailed Description

This file implements thunking to legacy 16-bit environment.

Copyright (c) 2023, Goldfish64. All rights reserved.
Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause

Definition in file OcLegacyThunkLib.c.

Macro Definition Documentation

◆ LEGACY_MODE_BASE_VECTOR_MASTER

#define LEGACY_MODE_BASE_VECTOR_MASTER   0x08

Definition at line 41 of file OcLegacyThunkLib.c.

◆ LEGACY_MODE_BASE_VECTOR_SLAVE

#define LEGACY_MODE_BASE_VECTOR_SLAVE   0x70

Definition at line 42 of file OcLegacyThunkLib.c.

◆ PROTECTED_MODE_BASE_VECTOR_MASTER

#define PROTECTED_MODE_BASE_VECTOR_MASTER   0x68

Definition at line 50 of file OcLegacyThunkLib.c.

◆ PROTECTED_MODE_BASE_VECTOR_SLAVE

#define PROTECTED_MODE_BASE_VECTOR_SLAVE   0x70

Definition at line 51 of file OcLegacyThunkLib.c.

◆ TIMER0_CONTROL_WORD

#define TIMER0_CONTROL_WORD   0x36

Definition at line 33 of file OcLegacyThunkLib.c.

◆ TIMER0_COUNT_PORT

#define TIMER0_COUNT_PORT   0x40

Definition at line 29 of file OcLegacyThunkLib.c.

◆ TIMER1_COUNT_PORT

#define TIMER1_COUNT_PORT   0x41

Definition at line 30 of file OcLegacyThunkLib.c.

◆ TIMER2_COUNT_PORT

#define TIMER2_COUNT_PORT   0x42

Definition at line 31 of file OcLegacyThunkLib.c.

◆ TIMER_CONTROL_PORT

#define TIMER_CONTROL_PORT   0x43

Definition at line 32 of file OcLegacyThunkLib.c.

Function Documentation

◆ OcLegacyThunkBiosInt86()

BOOLEAN EFIAPI OcLegacyThunkBiosInt86 ( IN THUNK_CONTEXT * ThunkContext,
IN EFI_LEGACY_8259_PROTOCOL * Legacy8259,
IN UINT8 BiosInt,
IN IA32_REGISTER_SET * Regs )

Thunk to 16-bit real mode and execute a software interrupt with a vector of BiosInt. Regs will contain the 16-bit register context on entry and exit.

Parameters
ThunkContextThe instance pointer of THUNK_CONTEXT.
Legacy8259Instance pointer for EFI_LEGACY_8259_PROTOCOL.
BiosIntProcessor interrupt vector to invoke
RegRegister contexted passed into (and returned) from thunk to 16-bit mode
Return values
TRUEThunk completed, and there were no BIOS errors in the target code. See Regs for status.
FALSEThere was a BIOS error in the target code.

Definition at line 241 of file OcLegacyThunkLib.c.

◆ OcLegacyThunkDisconnectEfiGraphics()

VOID OcLegacyThunkDisconnectEfiGraphics ( VOID )

Disconnect all EFI graphics device handles in preparation for calling to legacy mode.

Definition at line 168 of file OcLegacyThunkLib.c.

◆ OcLegacyThunkFarCall86()

BOOLEAN EFIAPI OcLegacyThunkFarCall86 ( IN THUNK_CONTEXT * ThunkContext,
IN EFI_LEGACY_8259_PROTOCOL * Legacy8259,
IN UINT16 Segment,
IN UINT16 Offset,
IN IA32_REGISTER_SET * Regs,
IN VOID * Stack,
IN UINTN StackSize )

Definition at line 328 of file OcLegacyThunkLib.c.

◆ OcLegacyThunkInitializeBiosIntCaller()

EFI_STATUS OcLegacyThunkInitializeBiosIntCaller ( THUNK_CONTEXT * ThunkContext)

Initialize legacy environment for BIOS INI caller.

Parameters
ThunkContextThe instance pointer of THUNK_CONTEXT.

Definition at line 59 of file OcLegacyThunkLib.c.

◆ OcLegacyThunkInitializeInterruptRedirection()

EFI_STATUS OcLegacyThunkInitializeInterruptRedirection ( IN EFI_LEGACY_8259_PROTOCOL * Legacy8259)

Initialize interrupt redirection code and entries, because IDT Vectors 0x68-0x6f must be redirected to IDT Vectors 0x08-0x0f. Or the interrupt will lost when we do thunk. NOTE: We do not reset 8259 vector base, because it will cause pending interrupt lost.

Parameters
Legacy8259Instance pointer for EFI_LEGACY_8259_PROTOCOL.

Definition at line 105 of file OcLegacyThunkLib.c.