+++ /dev/null
-\r
-TITLE Cpu.asm: Assembly code for the x64 resources\r
-\r
-;\r
-; This file contains an 'Intel Sample Driver' and is\r
-; licensed for Intel CPUs and chipsets under the terms of your\r
-; license agreement with Intel or your vendor. This file may\r
-; be modified by the user, subject to additional terms of the\r
-; license agreement\r
-;\r
-;\r
-; Copyright (c) 1999 - 2014, Intel Corporation. All rights reserved\r
-; \r\r
-; SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-; \r\r
-;\r
-;\r
-;\r
-;\r
-;* Module Name:\r
-;*\r
-;* Cpu.asm\r
-;*\r
-;* Abstract:\r
-;*\r
-;------------------------------------------------------------------------------\r
-\r
-text SEGMENT\r
-\r
-\r
-;------------------------------------------------------------------------------\r
-; VOID\r
-; EfiHalt (\r
-; VOID\r
-; )\r
-;------------------------------------------------------------------------------\r
-EfiHalt PROC PUBLIC\r
- hlt\r
- ret\r
-EfiHalt ENDP\r
-\r
-\r
-;------------------------------------------------------------------------------\r
-; VOID\r
-; EfiWbinvd (\r
-; VOID\r
-; )\r
-;------------------------------------------------------------------------------\r
-EfiWbinvd PROC PUBLIC\r
- wbinvd\r
- ret\r
-EfiWbinvd ENDP\r
-\r
-\r
-;------------------------------------------------------------------------------\r
-; VOID\r
-; EfiInvd (\r
-; VOID\r
-; )\r
-;------------------------------------------------------------------------------\r
-EfiInvd PROC PUBLIC\r
- invd\r
- ret\r
-EfiInvd ENDP\r
-\r
-;------------------------------------------------------------------------------\r
-; VOID\r
-; EfiCpuid (\r
-; IN UINT32 RegisterInEax, // rcx\r
-; OUT EFI_CPUID_REGISTER *Reg OPTIONAL // rdx\r
-; )\r
-;------------------------------------------------------------------------------\r
-EfiCpuid PROC PUBLIC\r
- push rbx\r
-\r
- mov r8, rdx ; r8 = *Reg\r
- mov rax, rcx ; RegisterInEax\r
- cpuid\r
- cmp r8, 0\r
- je _Exit\r
- mov [r8 + 0], eax ; Reg->RegEax\r
- mov [r8 + 4], ebx ; Reg->RegEbx\r
- mov [r8 + 8], ecx ; Reg->RegEcx\r
- mov [r8 + 12], edx ; Reg->RegEdx\r
-\r
-_Exit:\r
- pop rbx\r
- ret\r
-EfiCpuid ENDP\r
-\r
-;------------------------------------------------------------------------------\r
-; UINT64\r
-; EfiReadMsr (\r
-; IN UINT32 Index, // rcx\r
-; )\r
-;------------------------------------------------------------------------------\r
-EfiReadMsr PROC PUBLIC\r
- rdmsr\r
- sal rdx, 32 ; edx:eax -> rax\r
- or rax, rdx ; rax = edx:eax\r
- ret\r
-EfiReadMsr ENDP\r
-\r
-;------------------------------------------------------------------------------\r
-; VOID\r
-; EfiWriteMsr (\r
-; IN UINT32 Index, // rcx\r
-; IN UINT64 Value // rdx\r
-; )\r
-;------------------------------------------------------------------------------\r
-EfiWriteMsr PROC PUBLIC\r
- mov rax, rdx ; rdx = Value\r
- sar rdx, 32 ; convert rdx to edx upper 32-bits\r
- wrmsr ; wrmsr[ecx] result = edx:eax\r
- ret\r
-EfiWriteMsr ENDP\r
-\r
-\r
-;------------------------------------------------------------------------------\r
-; UINT64\r
-; EfiReadTsc (\r
-; VOID\r
-; );\r
-;------------------------------------------------------------------------------\r
-EfiReadTsc PROC PUBLIC\r
- rdtsc\r
- shl rax, 32\r
- shrd rax, rdx, 32\r
- ret\r
-EfiReadTsc ENDP\r
-\r
-;------------------------------------------------------------------------------\r
-; VOID\r
-; EfiDisableCache (\r
-; VOID\r
-; );\r
-;------------------------------------------------------------------------------\r
-EfiDisableCache PROC PUBLIC\r
-; added a check to see if cache is already disabled. If it is, then skip.\r
- mov rax, cr0\r
- and rax, 060000000h\r
- cmp rax, 0\r
- jne @f\r
- mov rax, cr0\r
- or rax, 060000000h\r
- mov cr0, rax\r
- wbinvd\r
-@@:\r
- ret\r
-EfiDisableCache ENDP\r
-\r
-;------------------------------------------------------------------------------\r
-; VOID\r
-; EfiEnableCache (\r
-; VOID\r
-; );\r
-;------------------------------------------------------------------------------\r
-EfiEnableCache PROC PUBLIC\r
- wbinvd\r
- mov rax, cr0\r
- and rax, 09fffffffh\r
- mov cr0, rax\r
- ret\r
-EfiEnableCache ENDP\r
-\r
-;------------------------------------------------------------------------------\r
-; UINTN\r
-; EfiGetEflags (\r
-; VOID\r
-; );\r
-;------------------------------------------------------------------------------\r
-EfiGetEflags PROC PUBLIC\r
- pushfq\r
- pop rax\r
- ret\r
-EfiGetEflags ENDP\r
-\r
-;------------------------------------------------------------------------------\r
-; VOID\r
-; EfiDisableInterrupts (\r
-; VOID\r
-; );\r
-;------------------------------------------------------------------------------\r
-EfiDisableInterrupts PROC PUBLIC\r
- cli\r
- ret\r
-EfiDisableInterrupts ENDP\r
-\r
-;------------------------------------------------------------------------------\r
-; VOID\r
-; EfiEnableInterrupts (\r
-; VOID\r
-; );\r
-;------------------------------------------------------------------------------\r
-EfiEnableInterrupts PROC PUBLIC\r
- sti\r
- ret\r
-EfiEnableInterrupts ENDP\r
-;------------------------------------------------------------------------------\r
-; VOID\r
-; EfiCpuidExt (\r
-; IN UINT32 RegisterInEax,\r
-; IN UINT32 CacheLevel,\r
-; OUT EFI_CPUID_REGISTER *Regs\r
-; )\r
-;------------------------------------------------------------------------------\r
-EfiCpuidExt PROC PUBLIC\r
- push rbx\r
- mov rax, rcx ; rax = RegisterInEax\r
- mov rcx, rdx ; rcx = CacheLevel\r
-\r
- cpuid\r
- mov [r8 + 0 ], eax ; Reg->RegEax\r
- mov [r8 + 4 ], ebx ; Reg->RegEbx\r
- mov [r8 + 8 ], ecx ; Reg->RegEcx\r
- mov [r8 + 12], edx ; Reg->RegEdx\r
-\r
- pop rbx\r
- ret\r
-EfiCpuidExt ENDP\r
-END\r