TianoCore EDK2 master
CpuDxe.h File Reference

Go to the source code of this file.

Macros

#define HEAP_GUARD_NONSTOP_MODE    ((PcdGet8 (PcdHeapGuardPropertyMask) & (BIT6|BIT4|BIT1|BIT0)) > BIT6)
 
#define NULL_DETECTION_NONSTOP_MODE    ((PcdGet8 (PcdNullPointerDetectionPropertyMask) & (BIT6|BIT0)) > BIT6)
 

Functions

EFI_STATUS EFIAPI CpuFlushCpuDataCache (IN EFI_CPU_ARCH_PROTOCOL *This, IN EFI_PHYSICAL_ADDRESS Start, IN UINT64 Length, IN EFI_CPU_FLUSH_TYPE FlushType)
 
EFI_STATUS EFIAPI CpuEnableInterrupt (IN EFI_CPU_ARCH_PROTOCOL *This)
 
EFI_STATUS EFIAPI CpuDisableInterrupt (IN EFI_CPU_ARCH_PROTOCOL *This)
 
EFI_STATUS EFIAPI CpuGetInterruptState (IN EFI_CPU_ARCH_PROTOCOL *This, OUT BOOLEAN *State)
 
EFI_STATUS EFIAPI CpuInit (IN EFI_CPU_ARCH_PROTOCOL *This, IN EFI_CPU_INIT_TYPE InitType)
 
EFI_STATUS EFIAPI CpuRegisterInterruptHandler (IN EFI_CPU_ARCH_PROTOCOL *This, IN EFI_EXCEPTION_TYPE InterruptType, IN EFI_CPU_INTERRUPT_HANDLER InterruptHandler)
 
EFI_STATUS EFIAPI CpuGetTimerValue (IN EFI_CPU_ARCH_PROTOCOL *This, IN UINT32 TimerIndex, OUT UINT64 *TimerValue, OUT UINT64 *TimerPeriod OPTIONAL)
 
EFI_STATUS EFIAPI CpuSetMemoryAttributes (IN EFI_CPU_ARCH_PROTOCOL *This, IN EFI_PHYSICAL_ADDRESS BaseAddress, IN UINT64 Length, IN UINT64 Attributes)
 
VOID InitGlobalDescriptorTable (VOID)
 
VOID EFIAPI SetCodeSelector (UINT16 Selector)
 
VOID EFIAPI SetDataSelectors (UINT16 Selector)
 
VOID RefreshGcdMemoryAttributesFromPaging (VOID)
 
VOID EFIAPI DebugExceptionHandler (IN EFI_EXCEPTION_TYPE ExceptionType, IN EFI_SYSTEM_CONTEXT SystemContext)
 
VOID EFIAPI PageFaultExceptionHandler (IN EFI_EXCEPTION_TYPE ExceptionType, IN EFI_SYSTEM_CONTEXT SystemContext)
 

Variables

BOOLEAN mIsAllocatingPageTable
 
UINTN mNumberOfProcessors
 

Detailed Description

CPU DXE Module to produce CPU ARCH Protocol and CPU MP Protocol.

Copyright (c) 2008 - 2019, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file CpuDxe.h.

Macro Definition Documentation

◆ HEAP_GUARD_NONSTOP_MODE

#define HEAP_GUARD_NONSTOP_MODE    ((PcdGet8 (PcdHeapGuardPropertyMask) & (BIT6|BIT4|BIT1|BIT0)) > BIT6)

Definition at line 42 of file CpuDxe.h.

◆ NULL_DETECTION_NONSTOP_MODE

#define NULL_DETECTION_NONSTOP_MODE    ((PcdGet8 (PcdNullPointerDetectionPropertyMask) & (BIT6|BIT0)) > BIT6)

Definition at line 45 of file CpuDxe.h.

Function Documentation

◆ CpuDisableInterrupt()

EFI_STATUS EFIAPI CpuDisableInterrupt ( IN EFI_CPU_ARCH_PROTOCOL This)

Disables CPU interrupts.

Parameters
ThisProtocol instance structure
Return values
EFI_SUCCESSIf interrupts were disabled in the CPU.
EFI_DEVICE_ERRORIf interrupts could not be disabled on the CPU.

This function disables interrupt processing by the processor.

Parameters
ThisThe EFI_CPU_ARCH_PROTOCOL instance.
Return values
EFI_SUCCESSInterrupts are disabled on the processor.
EFI_DEVICE_ERRORInterrupts could not be disabled on the processor.

Definition at line 100 of file CpuDxe.c.

◆ CpuEnableInterrupt()

EFI_STATUS EFIAPI CpuEnableInterrupt ( IN EFI_CPU_ARCH_PROTOCOL This)

Enables CPU interrupts.

Parameters
ThisProtocol instance structure
Return values
EFI_SUCCESSIf interrupts were enabled in the CPU
EFI_DEVICE_ERRORIf interrupts could not be enabled on the CPU.

This function enables interrupt processing by the processor.

Parameters
ThisThe EFI_CPU_ARCH_PROTOCOL instance.
Return values
EFI_SUCCESSInterrupts are enabled on the processor.
EFI_DEVICE_ERRORInterrupts could not be enabled on the processor.

Definition at line 80 of file CpuDxe.c.

◆ CpuFlushCpuDataCache()

EFI_STATUS EFIAPI CpuFlushCpuDataCache ( IN EFI_CPU_ARCH_PROTOCOL This,
IN EFI_PHYSICAL_ADDRESS  Start,
IN UINT64  Length,
IN EFI_CPU_FLUSH_TYPE  FlushType 
)

Flush CPU data cache. If the instruction cache is fully coherent with all DMA operations then function can just return EFI_SUCCESS.

Parameters
ThisProtocol instance structure
StartPhysical address to start flushing from.
LengthNumber of bytes to flush. Round up to chipset granularity.
FlushTypeSpecifies the type of flush operation to perform.
Return values
EFI_SUCCESSIf cache was flushed
EFI_UNSUPPORTEDIf flush type is not supported.
EFI_DEVICE_ERRORIf requested range could not be flushed.

This function flushes the range of addresses from Start to Start+Length from the processor's data cache. If Start is not aligned to a cache line boundary, then the bytes before Start to the preceding cache line boundary are also flushed. If Start+Length is not aligned to a cache line boundary, then the bytes past Start+Length to the end of the next cache line boundary are also flushed. The FlushType of EfiCpuFlushTypeWriteBackInvalidate must be supported. If the data cache is fully coherent with all DMA operations, then this function can just return EFI_SUCCESS. If the processor does not support flushing a range of the data cache, then the entire data cache can be flushed.

Parameters
ThisThe EFI_CPU_ARCH_PROTOCOL instance.
StartThe beginning physical address to flush from the processor's data cache.
LengthThe number of bytes to flush from the processor's data cache. This function may flush more bytes than Length specifies depending upon the granularity of the flush operation that the processor supports.
FlushTypeSpecifies the type of flush operation to perform.
Return values
EFI_SUCCESSThe address range from Start to Start+Length was flushed from the processor's data cache.
EFI_UNSUPPORTEDThe processor does not support the cache flush type specified by FlushType.
EFI_DEVICE_ERRORThe address range from Start to Start+Length could not be flushed from the processor's data cache.

Definition at line 45 of file CpuDxe.c.

◆ CpuGetInterruptState()

EFI_STATUS EFIAPI CpuGetInterruptState ( IN EFI_CPU_ARCH_PROTOCOL This,
OUT BOOLEAN State 
)

Return the state of interrupts.

Parameters
ThisProtocol instance structure
StatePointer to the CPU's current interrupt state
Return values
EFI_SUCCESSIf interrupts were disabled in the CPU.
EFI_INVALID_PARAMETERState is NULL.

This function retrieves the processor's current interrupt state a returns it in State. If interrupts are currently enabled, then TRUE is returned. If interrupts are currently disabled, then FALSE is returned.

Parameters
ThisThe EFI_CPU_ARCH_PROTOCOL instance.
StateA pointer to the processor's current interrupt state. Set to TRUE if interrupts are enabled and FALSE if interrupts are disabled.
Return values
EFI_SUCCESSThe processor's current interrupt state was returned in State.
EFI_INVALID_PARAMETERState is NULL.

Definition at line 124 of file CpuDxe.c.

◆ CpuGetTimerValue()

EFI_STATUS EFIAPI CpuGetTimerValue ( IN EFI_CPU_ARCH_PROTOCOL This,
IN UINT32  TimerIndex,
OUT UINT64 TimerValue,
OUT UINT64 *TimerPeriod  OPTIONAL 
)

Returns a timer value from one of the CPU's internal timers. There is no inherent time interval between ticks but is a function of the CPU frequency.

Parameters
This- Protocol instance structure.
TimerIndex- Specifies which CPU timer is requested.
TimerValue- Pointer to the returned timer value.
TimerPeriod- A pointer to the amount of time that passes in femtoseconds (10-15) for each increment of TimerValue. If TimerValue does not increment at a predictable rate, then 0 is returned. The amount of time that has passed between two calls to GetTimerValue() can be calculated with the formula (TimerValue2 - TimerValue1) * TimerPeriod. This parameter is optional and may be NULL.
Return values
EFI_SUCCESS- If the CPU timer count was returned.
EFI_UNSUPPORTED- If the CPU does not have any readable timers.
EFI_DEVICE_ERROR- If an error occurred while reading the timer.
EFI_INVALID_PARAMETER- TimerIndex is not valid or TimerValue is NULL.

Definition at line 176 of file CpuDxe.c.

◆ CpuInit()

EFI_STATUS EFIAPI CpuInit ( IN EFI_CPU_ARCH_PROTOCOL This,
IN EFI_CPU_INIT_TYPE  InitType 
)

Generates an INIT to the CPU.

Parameters
ThisProtocol instance structure
InitTypeType of CPU INIT to perform
Return values
EFI_SUCCESSIf CPU INIT occurred. This value should never be seen.
EFI_DEVICE_ERRORIf CPU INIT failed.
EFI_UNSUPPORTEDRequested type of CPU INIT not supported.

This function generates an INIT on the processor. If this function succeeds, then the processor will be reset, and control will not be returned to the caller. If InitType is not supported by this processor, or the processor cannot programmatically generate an INIT without help from external hardware, then EFI_UNSUPPORTED is returned. If an error occurs attempting to generate an INIT, then EFI_DEVICE_ERROR is returned.

Parameters
ThisThe EFI_CPU_ARCH_PROTOCOL instance.
InitTypeThe type of processor INIT to perform.
Return values
EFI_SUCCESSThe processor INIT was performed. This return code should never be seen.
EFI_UNSUPPORTEDThe processor INIT operation specified by InitType is not supported by this processor.
EFI_DEVICE_ERRORThe processor INIT failed.

Definition at line 155 of file CpuDxe.c.

◆ CpuRegisterInterruptHandler()

EFI_STATUS EFIAPI CpuRegisterInterruptHandler ( IN EFI_CPU_ARCH_PROTOCOL This,
IN EFI_EXCEPTION_TYPE  InterruptType,
IN EFI_CPU_INTERRUPT_HANDLER  InterruptHandler 
)

Registers a function to be called from the CPU interrupt handler.

Parameters
ThisProtocol instance structure
InterruptTypeDefines which interrupt to hook. IA-32 valid range is 0x00 through 0xFF
InterruptHandlerA pointer to a function of type EFI_CPU_INTERRUPT_HANDLER that is called when a processor interrupt occurs. A null pointer is an error condition.
Return values
EFI_SUCCESSIf handler installed or uninstalled.
EFI_ALREADY_STARTEDInterruptHandler is not NULL, and a handler for InterruptType was previously installed.
EFI_INVALID_PARAMETERInterruptHandler is NULL, and a handler for InterruptType was not previously installed.
EFI_UNSUPPORTEDThe interrupt specified by InterruptType is not supported.

Definition at line 165 of file CpuDxe.c.

◆ CpuSetMemoryAttributes()

EFI_STATUS EFIAPI CpuSetMemoryAttributes ( IN EFI_CPU_ARCH_PROTOCOL This,
IN EFI_PHYSICAL_ADDRESS  BaseAddress,
IN UINT64  Length,
IN UINT64  Attributes 
)

Set memory cacheability attributes for given range of memory.

Parameters
ThisProtocol instance structure
BaseAddressSpecifies the start address of the memory range
LengthSpecifies the length of the memory range
AttributesThe memory cacheability for the memory range
Return values
EFI_SUCCESSIf the cacheability of that memory range is set successfully
EFI_UNSUPPORTEDIf the desired operation cannot be done
EFI_INVALID_PARAMETERThe input parameter is not correct, such as Length = 0

This function modifies the attributes for the memory region specified by BaseAddress and Length from their current attributes to the attributes specified by Attributes.

Parameters
ThisThe EFI_CPU_ARCH_PROTOCOL instance.
BaseAddressThe physical address that is the start address of a memory region.
LengthThe size in bytes of the memory region.
AttributesThe bit mask of attributes to set for the memory region.
Return values
EFI_SUCCESSThe attributes were set for the memory region.
EFI_ACCESS_DENIEDThe attributes for the memory resource range specified by BaseAddress and Length cannot be modified.
EFI_INVALID_PARAMETERLength is zero.
EFI_OUT_OF_RESOURCESThere are not enough system resources to modify the attributes of the memory resource range.
EFI_UNSUPPORTEDThe processor does not support one or more bytes of the memory resource range specified by BaseAddress and Length. The bit mask of attributes is not support for the memory resource range specified by BaseAddress and Length.

Implementation of SetMemoryAttributes() service of CPU Architecture Protocol.

This function modifies the attributes for the memory region specified by BaseAddress and Length from their current attributes to the attributes specified by Attributes.

Parameters
ThisThe EFI_CPU_ARCH_PROTOCOL instance.
BaseAddressThe physical address that is the start address of a memory region.
LengthThe size in bytes of the memory region.
AttributesThe bit mask of attributes to set for the memory region.
Return values
EFI_SUCCESSThe attributes were set for the memory region.
EFI_ACCESS_DENIEDThe attributes for the memory resource range specified by BaseAddress and Length cannot be modified.
EFI_INVALID_PARAMETERLength is zero. Attributes specified an illegal combination of attributes that cannot be set together.
EFI_OUT_OF_RESOURCESThere are not enough system resources to modify the attributes of the memory resource range.
EFI_UNSUPPORTEDThe processor does not support one or more bytes of the memory resource range specified by BaseAddress and Length. The bit mask of attributes is not support for the memory resource range specified by BaseAddress and Length.

Definition at line 185 of file CpuMmuCommon.c.

◆ DebugExceptionHandler()

VOID EFIAPI DebugExceptionHandler ( IN EFI_EXCEPTION_TYPE  InterruptType,
IN EFI_SYSTEM_CONTEXT  SystemContext 
)

Special handler for #DB exception, which will restore the page attributes (not-present). It should work with #PF handler which will set pages to 'present'.

Parameters
ExceptionTypeException type.
SystemContextPointer to EFI_SYSTEM_CONTEXT.

SMM profile specific INT 1 (single-step) exception handler.

Parameters
InterruptTypeDefines the type of interrupt or exception that occurred on the processor.This parameter is processor architecture specific.
SystemContextA pointer to the processor context when the interrupt occurred on the processor.

Definition at line 1248 of file CpuPageTable.c.

◆ InitGlobalDescriptorTable()

VOID InitGlobalDescriptorTable ( VOID  )

Initialize Global Descriptor Table.

Definition at line 123 of file CpuGdt.c.

◆ PageFaultExceptionHandler()

VOID EFIAPI PageFaultExceptionHandler ( IN EFI_EXCEPTION_TYPE  ExceptionType,
IN EFI_SYSTEM_CONTEXT  SystemContext 
)

Special handler for #PF exception, which will set the pages which caused #PF to be 'present'. The attribute of those pages should be restored in the subsequent #DB handler.

Parameters
ExceptionTypeException type.
SystemContextPointer to EFI_SYSTEM_CONTEXT.

Definition at line 1308 of file CpuPageTable.c.

◆ RefreshGcdMemoryAttributesFromPaging()

VOID RefreshGcdMemoryAttributesFromPaging ( VOID  )

Update GCD memory space attributes according to current page table setup.

Definition at line 958 of file CpuPageTable.c.

◆ SetCodeSelector()

VOID EFIAPI SetCodeSelector ( UINT16  Selector)

Sets the code selector (CS).

Parameters
SelectorValue of code selector.

◆ SetDataSelectors()

VOID EFIAPI SetDataSelectors ( UINT16  Selector)

Sets the data selector (DS).

Parameters
SelectorValue of data selector.

Variable Documentation

◆ mIsAllocatingPageTable

BOOLEAN mIsAllocatingPageTable
extern

Definition at line 21 of file CpuDxe.c.

◆ mNumberOfProcessors

UINTN mNumberOfProcessors
extern

Definition at line 13 of file CpuMp.c.