Home | History | Annotate | Download | only in IA32
      1 ;/*++
      2 ;
      3 ;Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
      4 ;This program and the accompanying materials                          
      5 ;are licensed and made available under the terms and conditions of the BSD License         
      6 ;which accompanies this distribution.  The full text of the license may be found at        
      7 ;http://opensource.org/licenses/bsd-license.php                                            
      8 ;                                                                                          
      9 ;THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     
     10 ;WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             
     11 ;
     12 ;Module Name:
     13 ;
     14 ;  CpuIA32.c
     15 ;
     16 ;Abstract:
     17 ;
     18 ;--*/
     19 
     20 ;#include "CpuIA32.h"
     21 
     22 ;---------------------------------------------------------------------------
     23     .586p
     24     .model  flat,C
     25     .code
     26 
     27 ;---------------------------------------------------------------------------
     28 ;VOID
     29 ;EfiHalt (
     30 ;  VOID
     31 ;)
     32 EfiHalt PROC C PUBLIC
     33     hlt
     34     ret
     35 EfiHalt ENDP    
     36 
     37 ;VOID
     38 ;EfiWbinvd (
     39 ;  VOID
     40 ;)
     41 EfiWbinvd PROC C PUBLIC
     42     wbinvd
     43     ret
     44 EfiWbinvd ENDP
     45 
     46 ;VOID
     47 ;EfiInvd (
     48 ; VOID
     49 ;)
     50 EfiInvd PROC C PUBLIC
     51     invd
     52     ret
     53 EfiInvd ENDP
     54 
     55 ;VOID
     56 ;EfiCpuid (IN UINT32 RegisterInEax,
     57 ;          OUT EFI_CPUID_REGISTER *Reg OPTIONAL)
     58 EfiCpuid PROC C PUBLIC
     59     push ebp
     60     mov  ebp, esp
     61     push ebx
     62     push esi
     63     push edi
     64     pushad
     65 
     66     mov    eax, dword ptr[ebp + 8] ;egisterInEax
     67     cpuid
     68     cmp    dword ptr[ebp + 0Ch], 0 ; Reg
     69     je     @F
     70     mov         edi,dword ptr [ebp+0Ch] ; Reg 
     71 
     72     mov         dword ptr [edi],eax ; Reg->RegEax
     73     mov         dword ptr [edi+4],ebx ; Reg->RegEbx
     74     mov         dword ptr [edi+8],ecx ; Reg->RegEcx
     75     mov         dword ptr [edi+0Ch],edx ; Reg->RegEdx
     76 
     77 @@:
     78     popad
     79     pop         edi
     80     pop         esi
     81     pop         ebx
     82     pop         ebp
     83     
     84     ret
     85 EfiCpuid ENDP
     86 
     87 
     88 ;UINT64
     89 ;EfiReadMsr (
     90 ;  IN UINT32 Index
     91 ;  );
     92 EfiReadMsr PROC C PUBLIC
     93     mov    ecx, dword ptr [esp + 4]; Index
     94     rdmsr
     95     ret
     96 EfiReadMsr ENDP
     97 
     98 ;VOID
     99 ;EfiWriteMsr (
    100 ;  IN   UINT32  Index,
    101 ;  IN   UINT64  Value
    102 ;  );
    103 EfiWriteMsr PROC C PUBLIC
    104     mov    ecx, dword ptr [esp+4]; Index
    105     mov    eax, dword ptr [esp+8]; DWORD PTR Value[0]
    106     mov    edx, dword ptr [esp+0Ch]; DWORD PTR Value[4]
    107     wrmsr            
    108     ret
    109 EfiWriteMsr  ENDP
    110 
    111 ;UINT64
    112 ;EfiReadTsc (
    113 ;  VOID
    114 ;  )
    115 EfiReadTsc PROC C PUBLIC
    116     rdtsc
    117     ret
    118 EfiReadTsc  ENDP
    119 
    120 ;VOID
    121 ;EfiDisableCache (
    122 ;  VOID
    123 ;)
    124 EfiDisableCache PROC C PUBLIC
    125     mov   eax, cr0
    126     bswap eax
    127     and   al, 60h
    128     cmp   al, 60h
    129     je    @F
    130     mov   eax, cr0
    131     or    eax, 060000000h     
    132     mov   cr0, eax
    133     wbinvd
    134 @@:
    135     ret
    136 EfiDisableCache  ENDP
    137 
    138 ;VOID
    139 ;EfiEnableCache (
    140 ;  VOID
    141 ;  )
    142 EfiEnableCache PROC C PUBLIC
    143     wbinvd
    144     mov   eax, cr0
    145     and   eax, 09fffffffh         
    146     mov   cr0, eax
    147     ret
    148 EfiEnableCache  ENDP
    149 
    150 ;UINT32
    151 ;EfiGetEflags (
    152 ;  VOID
    153 ;  )
    154 EfiGetEflags PROC C PUBLIC
    155     pushfd
    156     pop  eax
    157     ret
    158 EfiGetEflags  ENDP
    159 
    160 ;VOID
    161 ;EfiDisableInterrupts (
    162 ;  VOID
    163 ;  )
    164 EfiDisableInterrupts PROC C PUBLIC
    165     cli
    166     ret
    167 EfiDisableInterrupts  ENDP
    168 
    169 ;VOID
    170 ;EfiEnableInterrupts (
    171 ;  VOID
    172 ;  )
    173 EfiEnableInterrupts  PROC C PUBLIC
    174     sti
    175     ret
    176 EfiEnableInterrupts   ENDP
    177 
    178 ;VOID
    179 ;EfiCpuidExt (
    180 ;  IN   UINT32              RegisterInEax,
    181 ;  IN   UINT32              CacheLevel,
    182 ;  OUT  EFI_CPUID_REGISTER  *Regs              
    183 ;  )
    184 EfiCpuidExt PROC C PUBLIC USES ebx edi esi
    185     pushad
    186 
    187     mov    eax, dword ptr [esp + 30h] ; RegisterInEax
    188     mov    ecx, dword ptr [esp + 34h] ; CacheLevel
    189     cpuid
    190     mov    edi, dword ptr [esp + 38h] ; DWORD PTR Regs 
    191 
    192     mov    dword ptr [edi], eax   	; Reg->RegEax
    193     mov    dword ptr [edi + 4], ebx   	; Reg->RegEbx
    194     mov    dword ptr [edi + 8], ecx   	; Reg->RegEcx
    195     mov    dword ptr [edi + 0Ch], edx   ; Reg->RegEdx
    196 
    197     popad
    198     ret
    199 EfiCpuidExt  ENDP
    200 
    201 	END
    202 	
    203