Cpu.h

Go to the documentation of this file.
00001 /** @file
00002   CPU Architectural Protocol as defined in PI spec Volume 2 DXE
00003 
00004   This code abstracts the DXE core from processor implementation details.
00005 
00006   Copyright (c) 2006 - 2008, Intel Corporation
00007   All rights reserved. This program and the accompanying materials
00008   are licensed and made available under the terms and conditions of the BSD License
00009   which accompanies this distribution.  The full text of the license may be found at
00010   http://opensource.org/licenses/bsd-license.php
00011 
00012   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
00013   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
00014 
00015 **/
00016 
00017 #ifndef __ARCH_PROTOCOL_CPU_H__
00018 #define __ARCH_PROTOCOL_CPU_H__
00019 
00020 #include <gpxe/efi/Protocol/DebugSupport.h>
00021 
00022 #define EFI_CPU_ARCH_PROTOCOL_GUID \
00023   { 0x26baccb1, 0x6f42, 0x11d4, {0xbc, 0xe7, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 } }
00024 
00025 typedef struct _EFI_CPU_ARCH_PROTOCOL   EFI_CPU_ARCH_PROTOCOL;
00026 
00027 typedef enum {
00028   EfiCpuFlushTypeWriteBackInvalidate,
00029   EfiCpuFlushTypeWriteBack,
00030   EfiCpuFlushTypeInvalidate,
00031   EfiCpuMaxFlushType
00032 } EFI_CPU_FLUSH_TYPE;
00033 
00034 typedef enum {
00035   EfiCpuInit,
00036   EfiCpuMaxInitType
00037 } EFI_CPU_INIT_TYPE;
00038 
00039 /**
00040   EFI_CPU_INTERRUPT_HANDLER that is called when a processor interrupt occurs.
00041 
00042   @param  InterruptType    Defines the type of interrupt or exception that
00043                            occurred on the processor.This parameter is processor architecture specific.
00044   @param  SystemContext    A pointer to the processor context when
00045                            the interrupt occurred on the processor.
00046 
00047   @return None
00048 
00049 **/
00050 typedef
00051 VOID
00052 (EFIAPI *EFI_CPU_INTERRUPT_HANDLER)(
00053   IN CONST  EFI_EXCEPTION_TYPE  InterruptType,
00054   IN CONST  EFI_SYSTEM_CONTEXT  SystemContext
00055   );
00056 
00057 /**
00058   This function flushes the range of addresses from Start to Start+Length
00059   from the processor's data cache. If Start is not aligned to a cache line
00060   boundary, then the bytes before Start to the preceding cache line boundary
00061   are also flushed. If Start+Length is not aligned to a cache line boundary,
00062   then the bytes past Start+Length to the end of the next cache line boundary
00063   are also flushed. The FlushType of EfiCpuFlushTypeWriteBackInvalidate must be
00064   supported. If the data cache is fully coherent with all DMA operations, then
00065   this function can just return EFI_SUCCESS. If the processor does not support
00066   flushing a range of the data cache, then the entire data cache can be flushed.
00067 
00068   @param  This             The EFI_CPU_ARCH_PROTOCOL instance.
00069   @param  Start            The beginning physical address to flush from the processor's data
00070                            cache.
00071   @param  Length           The number of bytes to flush from the processor's data cache. This
00072                            function may flush more bytes than Length specifies depending upon
00073                            the granularity of the flush operation that the processor supports.
00074   @param  FlushType        Specifies the type of flush operation to perform.
00075 
00076   @retval EFI_SUCCESS           The address range from Start to Start+Length was flushed from
00077                                 the processor's data cache.
00078   @retval EFI_UNSUPPORTEDT      The processor does not support the cache flush type specified
00079                                 by FlushType.
00080   @retval EFI_DEVICE_ERROR      The address range from Start to Start+Length could not be flushed
00081                                 from the processor's data cache.
00082 
00083 **/
00084 typedef
00085 EFI_STATUS
00086 (EFIAPI *EFI_CPU_FLUSH_DATA_CACHE)(
00087   IN EFI_CPU_ARCH_PROTOCOL              *This,
00088   IN EFI_PHYSICAL_ADDRESS               Start,
00089   IN UINT64                             Length,
00090   IN EFI_CPU_FLUSH_TYPE                 FlushType
00091   );
00092 
00093 
00094 /**
00095   This function enables interrupt processing by the processor.
00096 
00097   @param  This             The EFI_CPU_ARCH_PROTOCOL instance.
00098 
00099   @retval EFI_SUCCESS           Interrupts are enabled on the processor.
00100   @retval EFI_DEVICE_ERROR      Interrupts could not be enabled on the processor.
00101 
00102 **/
00103 typedef
00104 EFI_STATUS
00105 (EFIAPI *EFI_CPU_ENABLE_INTERRUPT)(
00106   IN EFI_CPU_ARCH_PROTOCOL              *This
00107   );
00108 
00109 
00110 /**
00111   This function disables interrupt processing by the processor.
00112 
00113   @param  This             The EFI_CPU_ARCH_PROTOCOL instance.
00114 
00115   @retval EFI_SUCCESS           Interrupts are disabled on the processor.
00116   @retval EFI_DEVICE_ERROR      Interrupts could not be disabled on the processor.
00117 
00118 **/
00119 typedef
00120 EFI_STATUS
00121 (EFIAPI *EFI_CPU_DISABLE_INTERRUPT)(
00122   IN EFI_CPU_ARCH_PROTOCOL              *This
00123   );
00124 
00125 
00126 /**
00127   This function retrieves the processor's current interrupt state a returns it in
00128   State. If interrupts are currently enabled, then TRUE is returned. If interrupts
00129   are currently disabled, then FALSE is returned.
00130 
00131   @param  This             The EFI_CPU_ARCH_PROTOCOL instance.
00132   @param  State            A pointer to the processor's current interrupt state. Set to TRUE if
00133                            interrupts are enabled and FALSE if interrupts are disabled.
00134 
00135   @retval EFI_SUCCESS           The processor's current interrupt state was returned in State.
00136   @retval EFI_INVALID_PARAMETER State is NULL.
00137 
00138 **/
00139 typedef
00140 EFI_STATUS
00141 (EFIAPI *EFI_CPU_GET_INTERRUPT_STATE)(
00142   IN EFI_CPU_ARCH_PROTOCOL              *This,
00143   OUT BOOLEAN                           *State
00144   );
00145 
00146 
00147 /**
00148   This function generates an INIT on the processor. If this function succeeds, then the
00149   processor will be reset, and control will not be returned to the caller. If InitType is
00150   not supported by this processor, or the processor cannot programmatically generate an
00151   INIT without help from external hardware, then EFI_UNSUPPORTED is returned. If an error
00152   occurs attempting to generate an INIT, then EFI_DEVICE_ERROR is returned.
00153 
00154   @param  This             The EFI_CPU_ARCH_PROTOCOL instance.
00155   @param  InitType         The type of processor INIT to perform.
00156 
00157   @retval EFI_SUCCESS           The processor INIT was performed. This return code should never be seen.
00158   @retval EFI_UNSUPPORTED       The processor INIT operation specified by InitType is not supported
00159                                 by this processor.
00160   @retval EFI_DEVICE_ERROR      The processor INIT failed.
00161 
00162 **/
00163 typedef
00164 EFI_STATUS
00165 (EFIAPI *EFI_CPU_INIT)(
00166   IN EFI_CPU_ARCH_PROTOCOL              *This,
00167   IN EFI_CPU_INIT_TYPE                  InitType
00168   );
00169 
00170 
00171 /**
00172   This function registers and enables the handler specified by InterruptHandler for a processor
00173   interrupt or exception type specified by InterruptType. If InterruptHandler is NULL, then the
00174   handler for the processor interrupt or exception type specified by InterruptType is uninstalled.
00175   The installed handler is called once for each processor interrupt or exception.
00176 
00177   @param  This             The EFI_CPU_ARCH_PROTOCOL instance.
00178   @param  InterruptType    A pointer to the processor's current interrupt state. Set to TRUE if interrupts
00179                            are enabled and FALSE if interrupts are disabled.
00180   @param  InterruptHandler A pointer to a function of type EFI_CPU_INTERRUPT_HANDLER that is called
00181                            when a processor interrupt occurs. If this parameter is NULL, then the handler
00182                            will be uninstalled.
00183 
00184   @retval EFI_SUCCESS           The handler for the processor interrupt was successfully installed or uninstalled.
00185   @retval EFI_ALREADY_STARTED   InterruptHandler is not NULL, and a handler for InterruptType was
00186                                 previously installed.
00187   @retval EFI_INVALID_PARAMETER InterruptHandler is NULL, and a handler for InterruptType was not
00188                                 previously installed.
00189   @retval EFI_UNSUPPORTED       The interrupt specified by InterruptType is not supported.
00190 
00191 **/
00192 typedef
00193 EFI_STATUS
00194 (EFIAPI *EFI_CPU_REGISTER_INTERRUPT_HANDLER)(
00195   IN EFI_CPU_ARCH_PROTOCOL              *This,
00196   IN EFI_EXCEPTION_TYPE                 InterruptType,
00197   IN EFI_CPU_INTERRUPT_HANDLER          InterruptHandler
00198   );
00199 
00200 
00201 /**
00202   This function reads the processor timer specified by TimerIndex and returns it in TimerValue.
00203 
00204   @param  This             The EFI_CPU_ARCH_PROTOCOL instance.
00205   @param  TimerIndex       Specifies which processor timer is to be returned in TimerValue. This parameter
00206                            must be between 0 and NumberOfTimers-1.
00207   @param  TimerValue       Pointer to the returned timer value.
00208   @param  TimerPeriod      A pointer to the amount of time that passes in femtoseconds for each increment
00209                            of TimerValue.
00210 
00211   @retval EFI_SUCCESS           The processor timer value specified by TimerIndex was returned in TimerValue.
00212   @retval EFI_DEVICE_ERROR      An error occurred attempting to read one of the processor's timers.
00213   @retval EFI_INVALID_PARAMETER TimerValue is NULL or TimerIndex is not valid.
00214   @retval EFI_UNSUPPORTED       The processor does not have any readable timers.
00215 
00216 **/
00217 typedef
00218 EFI_STATUS
00219 (EFIAPI *EFI_CPU_GET_TIMER_VALUE)(
00220   IN EFI_CPU_ARCH_PROTOCOL              *This,
00221   IN UINT32                             TimerIndex,
00222   OUT UINT64                            *TimerValue,
00223   OUT UINT64                            *TimerPeriod OPTIONAL
00224   );
00225 
00226 
00227 /**
00228   This function modifies the attributes for the memory region specified by BaseAddress and
00229   Length from their current attributes to the attributes specified by Attributes.
00230 
00231   @param  This             The EFI_CPU_ARCH_PROTOCOL instance.
00232   @param  BaseAddress      The physical address that is the start address of a memory region.
00233   @param  Length           The size in bytes of the memory region.
00234   @param  Attributes       The bit mask of attributes to set for the memory region.
00235 
00236   @retval EFI_SUCCESS           The attributes were set for the memory region.
00237   @retval EFI_ACCESS_DENIED     The attributes for the memory resource range specified by
00238                                 BaseAddress and Length cannot be modified.
00239   @retval EFI_INVALID_PARAMETER Length is zero.
00240   @retval EFI_OUT_OF_RESOURCES  There are not enough system resources to modify the attributes of
00241                                 the memory resource range.
00242   @retval EFI_UNSUPPORTED       The processor does not support one or more bytes of the memory
00243                                 resource range specified by BaseAddress and Length.
00244                                 The bit mask of attributes is not support for the memory resource
00245                                 range specified by BaseAddress and Length.
00246 
00247 **/
00248 typedef
00249 EFI_STATUS
00250 (EFIAPI *EFI_CPU_SET_MEMORY_ATTRIBUTES)(
00251   IN EFI_CPU_ARCH_PROTOCOL              *This,
00252   IN  EFI_PHYSICAL_ADDRESS              BaseAddress,
00253   IN  UINT64                            Length,
00254   IN  UINT64                            Attributes
00255   );
00256 
00257 
00258 ///
00259 /// The EFI_CPU_ARCH_PROTOCOL is used to abstract processor-specific functions from the DXE
00260 /// Foundation. This includes flushing caches, enabling and disabling interrupts, hooking interrupt
00261 /// vectors and exception vectors, reading internal processor timers, resetting the processor, and
00262 /// determining the processor frequency.
00263 ///
00264 struct _EFI_CPU_ARCH_PROTOCOL {
00265   EFI_CPU_FLUSH_DATA_CACHE            FlushDataCache;
00266   EFI_CPU_ENABLE_INTERRUPT            EnableInterrupt;
00267   EFI_CPU_DISABLE_INTERRUPT           DisableInterrupt;
00268   EFI_CPU_GET_INTERRUPT_STATE         GetInterruptState;
00269   EFI_CPU_INIT                        Init;
00270   EFI_CPU_REGISTER_INTERRUPT_HANDLER  RegisterInterruptHandler;
00271   EFI_CPU_GET_TIMER_VALUE             GetTimerValue;
00272   EFI_CPU_SET_MEMORY_ATTRIBUTES       SetMemoryAttributes;
00273   ///
00274   /// The number of timers that are available in a processor. The value in this
00275   /// field is a constant that must not be modified after the CPU Architectural
00276   /// Protocol is installed. All consumers must treat this as a read-only field.
00277   ///
00278   UINT32                              NumberOfTimers;
00279   ///
00280   /// The size, in bytes, of the alignment required for DMA buffer allocations.
00281   /// This is typically the size of the largest data cache line in the platform.
00282   /// The value in this field is a constant that must not be modified after the
00283   /// CPU Architectural Protocol is installed. All consumers must treat this as
00284   /// a read-only field.
00285   ///
00286   UINT32                              DmaBufferAlignment;
00287 };
00288 
00289 extern EFI_GUID gEfiCpuArchProtocolGuid;
00290 
00291 #endif

Generated on Tue Apr 6 20:01:07 2010 for gPXE by  doxygen 1.5.7.1