diff options
author | raywu <raywu0301@gmail.com> | 2018-06-15 00:00:50 +0800 |
---|---|---|
committer | raywu <raywu0301@gmail.com> | 2018-06-15 00:00:50 +0800 |
commit | b7c51c9cf4864df6aabb99a1ae843becd577237c (patch) | |
tree | eebe9b0d0ca03062955223097e57da84dd618b9a /Core/CPU/x64/x64AsmLib | |
download | zprj-b7c51c9cf4864df6aabb99a1ae843becd577237c.tar.xz |
Diffstat (limited to 'Core/CPU/x64/x64AsmLib')
42 files changed, 3792 insertions, 0 deletions
diff --git a/Core/CPU/x64/x64AsmLib/CPULIB_GetPageTable.asm b/Core/CPU/x64/x64AsmLib/CPULIB_GetPageTable.asm new file mode 100644 index 0000000..973357f --- /dev/null +++ b/Core/CPU/x64/x64AsmLib/CPULIB_GetPageTable.asm @@ -0,0 +1,80 @@ +;************************************************************************* +;************************************************************************* +;** ** +;** (C)Copyright 1985-2009, American Megatrends, Inc. ** +;** ** +;** All Rights Reserved. ** +;** ** +;** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +;** ** +;** Phone: (770)-246-8600 ** +;** ** +;************************************************************************* +;************************************************************************* + +;************************************************************************* +; $Header: /Alaska/SOURCE/Core/Modules/x64Core/x64AsmLib/CPULIB_GetPageTable.asm 1 10/01/10 5:07p Felixp $ +; +; $Revision: 1 $ +; +; $Date: 10/01/10 5:07p $ +;************************************************************************* +; Revision History +; ---------------- +; $Log: /Alaska/SOURCE/Core/Modules/x64Core/x64AsmLib/CPULIB_GetPageTable.asm $ +; +; 1 10/01/10 5:07p Felixp +; +; 1 8/24/06 12:57p Felixp +; +;************************************************************************* +;<AMI_FHDR_START> +; +; Name: +; +; Description: +; +;<AMI_FHDR_END> +;************************************************************************* +.code + +;************************************************************************* +;<AMI_PHDR_START> +; +; Name: CPULIB_GetPageTable +; +; Description: +; VOID* CPULIB_GetPageTable() retrieves the address of the page table. +; +; Input: +; VOID. +; +; Output: +; VOID* address of the page table. +; +; Modified: +; +; Referrals: +; +; Notes: +; +;<AMI_PHDR_END> +;************************************************************************* +CPULIB_GetPageTable proc + mov rax, cr3 + ret +CPULIB_GetPageTable endp + +END +;************************************************************************* +;************************************************************************* +;** ** +;** (C)Copyright 1985-2009, American Megatrends, Inc. ** +;** ** +;** All Rights Reserved. ** +;** ** +;** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +;** ** +;** Phone: (770)-246-8600 ** +;** ** +;************************************************************************* diff --git a/Core/CPU/x64/x64AsmLib/CPULib_CpuID.asm b/Core/CPU/x64/x64AsmLib/CPULib_CpuID.asm new file mode 100644 index 0000000..53719f2 --- /dev/null +++ b/Core/CPU/x64/x64AsmLib/CPULib_CpuID.asm @@ -0,0 +1,130 @@ +;************************************************************************* +;************************************************************************* +;** ** +;** (C)Copyright 1985-2009, American Megatrends, Inc. ** +;** ** +;** All Rights Reserved. ** +;** ** +;** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +;** ** +;** Phone: (770)-246-8600 ** +;** ** +;************************************************************************* +;************************************************************************* + +;************************************************************************* +; $Header: /Alaska/SOURCE/Core/Modules/x64Core/x64AsmLib/CPULib_CpuID.asm 2 11/11/11 3:40p Artems $ +; +; $Revision: 2 $ +; +; $Date: 11/11/11 3:40p $ +;************************************************************************* +; Revision History +; ---------------- +; $Log: /Alaska/SOURCE/Core/Modules/x64Core/x64AsmLib/CPULib_CpuID.asm $ +; +; 2 11/11/11 3:40p Artems +; Bug fix: Verify pointer is not NULL, when return value +; +; 1 10/01/10 5:07p Felixp +; +; 1 8/24/06 12:57p Felixp +; +;************************************************************************* +;<AMI_FHDR_START> +; +; Name: +; +; Description: +; +;<AMI_FHDR_END> +;************************************************************************* +.code + +;************************************************************************* +;<AMI_PHDR_START> +; +; Name: CPULib_CpuID +; +; Description: +; VOID CPULib_CpuID(IN UINT32 CpuIDIndex, IN UINT32 *pRegEAX, +; IN UINT32 *pRegEBX, IN UINT32 *pRegECX, IN UINT32 *pRegEDX) issues the +; CPUID instruction with the index provided and returns the register values. +; +; Input: +; IN UINT32 CpuIDIndex +; 32-bit CPUID index. +; +; IN UINT32 *pRegEAX +; Value of EAX after CPUID instruction. +; +; IN UINT32 *pRegEBX +; Value of EBX after CPUID instruction. +; +; IN UINT32 *pRegECX +; Value of ECX after CPUID instruction. +; +; IN UINT32 *pRegEDX +; Value of EDX after CPUID instruction. +; +; Output: +; VOID. +; +; Modified: +; +; Referrals: +; +; Notes: +; +;<AMI_PHDR_END> +;************************************************************************* +CPULib_CpuID proc +;rcx = CpuIDIndex +;rdx = pRegEax +;r8 = pRegEBX +;r9 = pRegECX +;[rsp + 8] = pRegEDX:DWORD + + push rbx + mov r11, [rsp + 30h] ;pRegEDX + mov r10, r9 ;pRegECX + mov r9, r8 ;pRegEBX + mov r8, rdx ;pRegEAX + + mov eax, ecx + mov ecx, [r10] + cpuid + + or r8, r8 + jz skip1 + mov [r8], eax +skip1: + or r9, r9 + jz skip2 + mov [r9], ebx +skip2: + or r10, r10 + jz skip3 + mov [r10], ecx +skip3: + or r11, r11 + jz skip4 + mov [r11], edx +skip4: + pop rbx + ret +CPULib_CpuID endp + +END +;************************************************************************* +;************************************************************************* +;** ** +;** (C)Copyright 1985-2009, American Megatrends, Inc. ** +;** ** +;** All Rights Reserved. ** +;** ** +;** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +;** ** +;** Phone: (770)-246-8600 ** +;** ** +;************************************************************************* diff --git a/Core/CPU/x64/x64AsmLib/CPULib_DisableInterrupt.asm b/Core/CPU/x64/x64AsmLib/CPULib_DisableInterrupt.asm new file mode 100644 index 0000000..6c63f8a --- /dev/null +++ b/Core/CPU/x64/x64AsmLib/CPULib_DisableInterrupt.asm @@ -0,0 +1,81 @@ +;************************************************************************* +;************************************************************************* +;** ** +;** (C)Copyright 1985-2009, American Megatrends, Inc. ** +;** ** +;** All Rights Reserved. ** +;** ** +;** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +;** ** +;** Phone: (770)-246-8600 ** +;** ** +;************************************************************************* +;************************************************************************* + +;************************************************************************* +; $Header: /Alaska/SOURCE/Core/Modules/x64Core/x64AsmLib/CPULib_DisableInterrupt.asm 1 10/01/10 5:07p Felixp $ +; +; $Revision: 1 $ +; +; $Date: 10/01/10 5:07p $ +;************************************************************************* +; Revision History +; ---------------- +; $Log: /Alaska/SOURCE/Core/Modules/x64Core/x64AsmLib/CPULib_DisableInterrupt.asm $ +; +; 1 10/01/10 5:07p Felixp +; +; 1 8/24/06 12:57p Felixp +; +;************************************************************************* +;<AMI_FHDR_START> +; +; Name: +; +; Description: +; +;<AMI_FHDR_END> +;************************************************************************* +.code + +;************************************************************************* +;<AMI_PHDR_START> +; +; Name: CPULib_DisableInterrupt +; +; Description: +; VOID CPULib_DisableInterrupt() disables interrupts on the CPU. +; +; Input: +; VOID. +; +; Output: +; VOID. +; +; Modified: +; +; Referrals: +; +; Notes: +; +;<AMI_PHDR_END> +;************************************************************************* +CPULib_DisableInterrupt PROC PUBLIC +; Disable Interrupt + cli + ret +CPULib_DisableInterrupt ENDP + +END +;************************************************************************* +;************************************************************************* +;** ** +;** (C)Copyright 1985-2009, American Megatrends, Inc. ** +;** ** +;** All Rights Reserved. ** +;** ** +;** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +;** ** +;** Phone: (770)-246-8600 ** +;** ** +;************************************************************************* diff --git a/Core/CPU/x64/x64AsmLib/CPULib_EnableInterrupt.asm b/Core/CPU/x64/x64AsmLib/CPULib_EnableInterrupt.asm new file mode 100644 index 0000000..bc43c62 --- /dev/null +++ b/Core/CPU/x64/x64AsmLib/CPULib_EnableInterrupt.asm @@ -0,0 +1,81 @@ +;************************************************************************* +;************************************************************************* +;** ** +;** (C)Copyright 1985-2009, American Megatrends, Inc. ** +;** ** +;** All Rights Reserved. ** +;** ** +;** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +;** ** +;** Phone: (770)-246-8600 ** +;** ** +;************************************************************************* +;************************************************************************* + +;************************************************************************* +; $Header: /Alaska/SOURCE/Core/Modules/x64Core/x64AsmLib/CPULib_EnableInterrupt.asm 1 10/01/10 5:07p Felixp $ +; +; $Revision: 1 $ +; +; $Date: 10/01/10 5:07p $ +;************************************************************************* +; Revision History +; ---------------- +; $Log: /Alaska/SOURCE/Core/Modules/x64Core/x64AsmLib/CPULib_EnableInterrupt.asm $ +; +; 1 10/01/10 5:07p Felixp +; +; 1 8/24/06 12:57p Felixp +; +;************************************************************************* +;<AMI_FHDR_START> +; +; Name: +; +; Description: +; +;<AMI_FHDR_END> +;************************************************************************* +.code + +;************************************************************************* +;<AMI_PHDR_START> +; +; Name: CPULib_EnableInterrupt +; +; Description: +; VOID CPULib_EnableInterrupt() enables interrupts on the CPU. +; +; Input: +; VOID. +; +; Output: +; VOID. +; +; Modified: +; +; Referrals: +; +; Notes: +; +;<AMI_PHDR_END> +;************************************************************************* +CPULib_EnableInterrupt PROC PUBLIC +; Enable Interrupt + sti + ret +CPULib_EnableInterrupt ENDP + +END +;************************************************************************* +;************************************************************************* +;** ** +;** (C)Copyright 1985-2009, American Megatrends, Inc. ** +;** ** +;** All Rights Reserved. ** +;** ** +;** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +;** ** +;** Phone: (770)-246-8600 ** +;** ** +;************************************************************************* diff --git a/Core/CPU/x64/x64AsmLib/CPULib_GetInterruptState.asm b/Core/CPU/x64/x64AsmLib/CPULib_GetInterruptState.asm new file mode 100644 index 0000000..436cba7 --- /dev/null +++ b/Core/CPU/x64/x64AsmLib/CPULib_GetInterruptState.asm @@ -0,0 +1,87 @@ +;************************************************************************* +;************************************************************************* +;** ** +;** (C)Copyright 1985-2009, American Megatrends, Inc. ** +;** ** +;** All Rights Reserved. ** +;** ** +;** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +;** ** +;** Phone: (770)-246-8600 ** +;** ** +;************************************************************************* +;************************************************************************* + +;************************************************************************* +; $Header: /Alaska/SOURCE/Core/Modules/x64Core/x64AsmLib/CPULib_GetInterruptState.asm 1 10/01/10 5:07p Felixp $ +; +; $Revision: 1 $ +; +; $Date: 10/01/10 5:07p $ +;************************************************************************* +; Revision History +; ---------------- +; $Log: /Alaska/SOURCE/Core/Modules/x64Core/x64AsmLib/CPULib_GetInterruptState.asm $ +; +; 1 10/01/10 5:07p Felixp +; +; 1 8/24/06 12:57p Felixp +; +;************************************************************************* +;<AMI_FHDR_START> +; +; Name: +; +; Description: +; +;<AMI_FHDR_END> +;************************************************************************* +.code + +;************************************************************************* +;<AMI_PHDR_START> +; +; Name: CPULib_GetInterruptState +; +; Description: +; BOOLEAN CPULib_GetInterruptState()returns the current CPU interrupt state. +; +; Input: +; VOID. +; +; Output: +; FALSE if interrupts are disabled; otherwise TRUE. +; +; Modified: +; +; Referrals: +; +; Notes: +; +;<AMI_PHDR_END> +;************************************************************************* +CPULib_GetInterruptState PROC PUBLIC + xor cl, cl + pushf ; push flags onto stack. + pop ax ; eax = flags. + bt ax, 9 ; IF (bit 9) if set, set carry flag. + ; Interrupts are allowed if IF is set. + adc cl, 0 ; CL = IF = CF. + + mov al, cl ; Return value + ret +CPULib_GetInterruptState ENDP + +END +;************************************************************************* +;************************************************************************* +;** ** +;** (C)Copyright 1985-2009, American Megatrends, Inc. ** +;** ** +;** All Rights Reserved. ** +;** ** +;** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +;** ** +;** Phone: (770)-246-8600 ** +;** ** +;************************************************************************* diff --git a/Core/CPU/x64/x64AsmLib/CPULib_LoadGdt.asm b/Core/CPU/x64/x64AsmLib/CPULib_LoadGdt.asm new file mode 100644 index 0000000..1fc3c23 --- /dev/null +++ b/Core/CPU/x64/x64AsmLib/CPULib_LoadGdt.asm @@ -0,0 +1,82 @@ +;************************************************************************* +;************************************************************************* +;** ** +;** (C)Copyright 1985-2009, American Megatrends, Inc. ** +;** ** +;** All Rights Reserved. ** +;** ** +;** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +;** ** +;** Phone: (770)-246-8600 ** +;** ** +;************************************************************************* +;************************************************************************* + +;************************************************************************* +; $Header: /Alaska/SOURCE/Core/Modules/x64Core/x64AsmLib/CPULib_LoadGdt.asm 1 10/01/10 5:07p Felixp $ +; +; $Revision: 1 $ +; +; $Date: 10/01/10 5:07p $ +;************************************************************************* +; Revision History +; ---------------- +; $Log: /Alaska/SOURCE/Core/Modules/x64Core/x64AsmLib/CPULib_LoadGdt.asm $ +; +; 1 10/01/10 5:07p Felixp +; +; 1 8/24/06 12:57p Felixp +; +;************************************************************************* +;<AMI_FHDR_START> +; +; Name: +; +; Description: +; +;<AMI_FHDR_END> +;************************************************************************* +.code + +;************************************************************************* +;<AMI_PHDR_START> +; +; Name: CPULib_LoadGdt +; +; Description: +; VOID CPULib_LoadGdt(IN VOID *ptr) loads the GDT at the location pointed to +; by ptr. +; +; Input: +; IN VOID *ptr +; Address of the GDT to be loaded. +; +; Output: +; VOID. +; +; Modified: +; +; Referrals: +; +; Notes: +; +;<AMI_PHDR_END> +;************************************************************************* +CPULib_LoadGdt proc + lgdt fword ptr [rcx] + ret +CPULib_LoadGdt endp + +END +;************************************************************************* +;************************************************************************* +;** ** +;** (C)Copyright 1985-2009, American Megatrends, Inc. ** +;** ** +;** All Rights Reserved. ** +;** ** +;** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +;** ** +;** Phone: (770)-246-8600 ** +;** ** +;************************************************************************* diff --git a/Core/CPU/x64/x64AsmLib/CPULib_LoadIdt.asm b/Core/CPU/x64/x64AsmLib/CPULib_LoadIdt.asm new file mode 100644 index 0000000..3c4afc8 --- /dev/null +++ b/Core/CPU/x64/x64AsmLib/CPULib_LoadIdt.asm @@ -0,0 +1,82 @@ +;************************************************************************* +;************************************************************************* +;** ** +;** (C)Copyright 1985-2009, American Megatrends, Inc. ** +;** ** +;** All Rights Reserved. ** +;** ** +;** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +;** ** +;** Phone: (770)-246-8600 ** +;** ** +;************************************************************************* +;************************************************************************* + +;************************************************************************* +; $Header: /Alaska/SOURCE/Core/Modules/x64Core/x64AsmLib/CPULib_LoadIdt.asm 1 10/01/10 5:07p Felixp $ +; +; $Revision: 1 $ +; +; $Date: 10/01/10 5:07p $ +;************************************************************************* +; Revision History +; ---------------- +; $Log: /Alaska/SOURCE/Core/Modules/x64Core/x64AsmLib/CPULib_LoadIdt.asm $ +; +; 1 10/01/10 5:07p Felixp +; +; 1 8/24/06 12:57p Felixp +; +;************************************************************************* +;<AMI_FHDR_START> +; +; Name: +; +; Description: +; +;<AMI_FHDR_END> +;************************************************************************* +.code + +;************************************************************************* +;<AMI_PHDR_START> +; +; Name: CPULib_LoadIdt +; +; Description: +; VOID CPULib_LoadIdt(IN VOID *ptr) loads the IDT at the location provided +; by ptr. +; +; Input: +; IN VOID *ptr +; Address of the IDT to be loaded. +; +; Output: +; VOID. +; +; Modified: +; +; Referrals: +; +; Notes: +; +;<AMI_PHDR_END> +;************************************************************************* +CPULib_LoadIdt proc + lidt fword ptr [rcx] + ret +CPULib_LoadIdt endp + +END +;************************************************************************* +;************************************************************************* +;** ** +;** (C)Copyright 1985-2009, American Megatrends, Inc. ** +;** ** +;** All Rights Reserved. ** +;** ** +;** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +;** ** +;** Phone: (770)-246-8600 ** +;** ** +;************************************************************************* diff --git a/Core/CPU/x64/x64AsmLib/CPULib_LockByteDec.asm b/Core/CPU/x64/x64AsmLib/CPULib_LockByteDec.asm new file mode 100644 index 0000000..433bd1b --- /dev/null +++ b/Core/CPU/x64/x64AsmLib/CPULib_LockByteDec.asm @@ -0,0 +1,82 @@ +;************************************************************************* +;************************************************************************* +;** ** +;** (C)Copyright 1985-2009, American Megatrends, Inc. ** +;** ** +;** All Rights Reserved. ** +;** ** +;** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +;** ** +;** Phone: (770)-246-8600 ** +;** ** +;************************************************************************* +;************************************************************************* + +;************************************************************************* +; $Header: /Alaska/SOURCE/Core/Modules/x64Core/x64AsmLib/CPULib_LockByteDec.asm 1 10/01/10 5:07p Felixp $ +; +; $Revision: 1 $ +; +; $Date: 10/01/10 5:07p $ +;************************************************************************* +; Revision History +; ---------------- +; $Log: /Alaska/SOURCE/Core/Modules/x64Core/x64AsmLib/CPULib_LockByteDec.asm $ +; +; 1 10/01/10 5:07p Felixp +; +; 1 8/24/06 12:57p Felixp +; +;************************************************************************* +;<AMI_FHDR_START> +; +; Name: +; +; Description: +; +;<AMI_FHDR_END> +;************************************************************************* +.code + +;************************************************************************* +;<AMI_PHDR_START> +; +; Name: CPULib_LockByteDec +; +; Description: +; VOID CPULib_LockByteDec(IN UINT8 *ptr) locks the preceeding byte before +; the address pointed to by ptr. +; +; Input: +; IN UINT8 *ptr +; Address to the byte which follows the desired byte to be locked. +; +; Output: +; VOID. +; +; Modified: +; +; Referrals: +; +; Notes: +; +;<AMI_PHDR_END> +;************************************************************************* +CPULib_LockByteDec proc + lock dec byte ptr [rcx] + ret +CPULib_LockByteDec endp + +END +;************************************************************************* +;************************************************************************* +;** ** +;** (C)Copyright 1985-2009, American Megatrends, Inc. ** +;** ** +;** All Rights Reserved. ** +;** ** +;** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +;** ** +;** Phone: (770)-246-8600 ** +;** ** +;************************************************************************* diff --git a/Core/CPU/x64/x64AsmLib/CPULib_LockByteInc.asm b/Core/CPU/x64/x64AsmLib/CPULib_LockByteInc.asm new file mode 100644 index 0000000..83addc8 --- /dev/null +++ b/Core/CPU/x64/x64AsmLib/CPULib_LockByteInc.asm @@ -0,0 +1,82 @@ +;************************************************************************* +;************************************************************************* +;** ** +;** (C)Copyright 1985-2009, American Megatrends, Inc. ** +;** ** +;** All Rights Reserved. ** +;** ** +;** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +;** ** +;** Phone: (770)-246-8600 ** +;** ** +;************************************************************************* +;************************************************************************* + +;************************************************************************* +; $Header: /Alaska/SOURCE/Core/Modules/x64Core/x64AsmLib/CPULib_LockByteInc.asm 1 10/01/10 5:07p Felixp $ +; +; $Revision: 1 $ +; +; $Date: 10/01/10 5:07p $ +;************************************************************************* +; Revision History +; ---------------- +; $Log: /Alaska/SOURCE/Core/Modules/x64Core/x64AsmLib/CPULib_LockByteInc.asm $ +; +; 1 10/01/10 5:07p Felixp +; +; 1 8/24/06 12:57p Felixp +; +;************************************************************************* +;<AMI_FHDR_START> +; +; Name: +; +; Description: +; +;<AMI_FHDR_END> +;************************************************************************* +.code + +;************************************************************************* +;<AMI_PHDR_START> +; +; Name: CPULib_LockByteInc +; +; Description: +; VOID CPULib_LockByteInc(IN UINT8 *ptr) locks the next byte after the +; address pointed to by ptr. +; +; Input: +; IN UINT8 *ptr +; Address to the byte which preceeds the desired byte to be locked. +; +; Output: +; VOID. +; +; Modified: +; +; Referrals: +; +; Notes: +; +;<AMI_PHDR_END> +;************************************************************************* +CPULib_LockByteInc proc + lock inc byte ptr [rcx] + ret +CPULib_LockByteInc endp + +END +;************************************************************************* +;************************************************************************* +;** ** +;** (C)Copyright 1985-2009, American Megatrends, Inc. ** +;** ** +;** All Rights Reserved. ** +;** ** +;** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +;** ** +;** Phone: (770)-246-8600 ** +;** ** +;************************************************************************* diff --git a/Core/CPU/x64/x64AsmLib/CPULib_Pause.asm b/Core/CPU/x64/x64AsmLib/CPULib_Pause.asm new file mode 100644 index 0000000..c7d2574 --- /dev/null +++ b/Core/CPU/x64/x64AsmLib/CPULib_Pause.asm @@ -0,0 +1,80 @@ +;************************************************************************* +;************************************************************************* +;** ** +;** (C)Copyright 1985-2009, American Megatrends, Inc. ** +;** ** +;** All Rights Reserved. ** +;** ** +;** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +;** ** +;** Phone: (770)-246-8600 ** +;** ** +;************************************************************************* +;************************************************************************* + +;************************************************************************* +; $Header: /Alaska/SOURCE/Core/Modules/x64Core/x64AsmLib/CPULib_Pause.asm 1 10/01/10 5:07p Felixp $ +; +; $Revision: 1 $ +; +; $Date: 10/01/10 5:07p $ +;************************************************************************* +; Revision History +; ---------------- +; $Log: /Alaska/SOURCE/Core/Modules/x64Core/x64AsmLib/CPULib_Pause.asm $ +; +; 1 10/01/10 5:07p Felixp +; +; 1 8/24/06 12:57p Felixp +; +;************************************************************************* +;<AMI_FHDR_START> +; +; Name: +; +; Description: +; +;<AMI_FHDR_END> +;************************************************************************* +.code + +;************************************************************************* +;<AMI_PHDR_START> +; +; Name: CPULib_Pause +; +; Description: +; VOID CPULib_Pause() performs the pause assembly instruction. +; +; Input: +; VOID. +; +; Output: +; VOID. +; +; Modified: +; +; Referrals: +; +; Notes: +; +;<AMI_PHDR_END> +;************************************************************************* +CPULib_Pause Proc + pause + ret +CPULib_Pause endp + +END +;************************************************************************* +;************************************************************************* +;** ** +;** (C)Copyright 1985-2009, American Megatrends, Inc. ** +;** ** +;** All Rights Reserved. ** +;** ** +;** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +;** ** +;** Phone: (770)-246-8600 ** +;** ** +;************************************************************************* diff --git a/Core/CPU/x64/x64AsmLib/CPULib_SaveGdt.asm b/Core/CPU/x64/x64AsmLib/CPULib_SaveGdt.asm new file mode 100644 index 0000000..28258cf --- /dev/null +++ b/Core/CPU/x64/x64AsmLib/CPULib_SaveGdt.asm @@ -0,0 +1,83 @@ +;************************************************************************* +;************************************************************************* +;** ** +;** (C)Copyright 1985-2009, American Megatrends, Inc. ** +;** ** +;** All Rights Reserved. ** +;** ** +;** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +;** ** +;** Phone: (770)-246-8600 ** +;** ** +;************************************************************************* +;************************************************************************* + +;************************************************************************* +; $Header: /Alaska/SOURCE/Core/Modules/x64Core/x64AsmLib/CPULib_SaveGdt.asm 1 10/01/10 5:07p Felixp $ +; +; $Revision: 1 $ +; +; $Date: 10/01/10 5:07p $ +;************************************************************************* +; Revision History +; ---------------- +; $Log: /Alaska/SOURCE/Core/Modules/x64Core/x64AsmLib/CPULib_SaveGdt.asm $ +; +; 1 10/01/10 5:07p Felixp +; +; 1 8/24/06 12:57p Felixp +; +;************************************************************************* +;<AMI_FHDR_START> +; +; Name: +; +; Description: +; +;<AMI_FHDR_END> +;************************************************************************* +.code + +;************************************************************************* +;<AMI_PHDR_START> +; +; Name: CPULib_SaveGdt +; +; Description: +; VOID CPULib_SaveGdt(IN VOID *ptr) stores the loaded GDT at the location +; provided by ptr. +; +; Input: +; IN VOID *ptr +; Address to save the GDT. User is responsible for allocating the necessary +; memory resources. +; +; Output: +; VOID. +; +; Modified: +; +; Referrals: +; +; Notes: +; +;<AMI_PHDR_END> +;************************************************************************* +CPULib_SaveGdt proc + sgdt fword ptr [rcx] + ret +CPULib_SaveGdt endp + +END +;************************************************************************* +;************************************************************************* +;** ** +;** (C)Copyright 1985-2009, American Megatrends, Inc. ** +;** ** +;** All Rights Reserved. ** +;** ** +;** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +;** ** +;** Phone: (770)-246-8600 ** +;** ** +;************************************************************************* diff --git a/Core/CPU/x64/x64AsmLib/CPULib_SaveIdt.asm b/Core/CPU/x64/x64AsmLib/CPULib_SaveIdt.asm new file mode 100644 index 0000000..046b7f6 --- /dev/null +++ b/Core/CPU/x64/x64AsmLib/CPULib_SaveIdt.asm @@ -0,0 +1,83 @@ +;************************************************************************* +;************************************************************************* +;** ** +;** (C)Copyright 1985-2009, American Megatrends, Inc. ** +;** ** +;** All Rights Reserved. ** +;** ** +;** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +;** ** +;** Phone: (770)-246-8600 ** +;** ** +;************************************************************************* +;************************************************************************* + +;************************************************************************* +; $Header: /Alaska/SOURCE/Core/Modules/x64Core/x64AsmLib/CPULib_SaveIdt.asm 1 10/01/10 5:07p Felixp $ +; +; $Revision: 1 $ +; +; $Date: 10/01/10 5:07p $ +;************************************************************************* +; Revision History +; ---------------- +; $Log: /Alaska/SOURCE/Core/Modules/x64Core/x64AsmLib/CPULib_SaveIdt.asm $ +; +; 1 10/01/10 5:07p Felixp +; +; 1 8/24/06 12:57p Felixp +; +;************************************************************************* +;<AMI_FHDR_START> +; +; Name: +; +; Description: +; +;<AMI_FHDR_END> +;************************************************************************* +.code + +;************************************************************************* +;<AMI_PHDR_START> +; +; Name: CPULib_SaveIdt +; +; Description: +; VOID CPULib_SaveIdt(IN VOID *ptr) stores the loaded IDT at the location +; provided by ptr. +; +; Input: +; IN VOID *ptr +; Address to save the IDT. User is responsible for allocating the necessary +; memory resources. +; +; Output: +; VOID. +; +; Modified: +; +; Referrals: +; +; Notes: +; +;<AMI_PHDR_END> +;************************************************************************* +CPULib_SaveIdt proc + sidt fword ptr [rcx] + ret +CPULib_SaveIdt endp + +END +;************************************************************************* +;************************************************************************* +;** ** +;** (C)Copyright 1985-2009, American Megatrends, Inc. ** +;** ** +;** All Rights Reserved. ** +;** ** +;** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +;** ** +;** Phone: (770)-246-8600 ** +;** ** +;************************************************************************* diff --git a/Core/CPU/x64/x64AsmLib/DisableCacheInCR0.asm b/Core/CPU/x64/x64AsmLib/DisableCacheInCR0.asm new file mode 100644 index 0000000..c03cd1f --- /dev/null +++ b/Core/CPU/x64/x64AsmLib/DisableCacheInCR0.asm @@ -0,0 +1,84 @@ +;************************************************************************* +;************************************************************************* +;** ** +;** (C)Copyright 1985-2009, American Megatrends, Inc. ** +;** ** +;** All Rights Reserved. ** +;** ** +;** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +;** ** +;** Phone: (770)-246-8600 ** +;** ** +;************************************************************************* +;************************************************************************* + +;************************************************************************* +; $Header: /Alaska/SOURCE/Core/Modules/x64Core/x64AsmLib/DisableCacheInCR0.asm 1 10/01/10 5:07p Felixp $ +; +; $Revision: 1 $ +; +; $Date: 10/01/10 5:07p $ +;************************************************************************* +; Revision History +; ---------------- +; $Log: /Alaska/SOURCE/Core/Modules/x64Core/x64AsmLib/DisableCacheInCR0.asm $ +; +; 1 10/01/10 5:07p Felixp +; +; 1 8/24/06 12:57p Felixp +; +;************************************************************************* +;<AMI_FHDR_START> +; +; Name: +; +; Description: +; +;<AMI_FHDR_END> +;************************************************************************* +.code + +;************************************************************************* +;<AMI_PHDR_START> +; +; Name: DisableCacheInCR0 +; +; Description: +; VOID DisableCacheInCR0() disables the CPU cache using the CR0 register. +; +; Input: +; VOID. +; +; Output: +; VOID. +; +; Modified: +; +; Referrals: +; +; Notes: +; +;<AMI_PHDR_END> +;************************************************************************* +DisableCacheInCR0 PROC PUBLIC + wbinvd + mov rax, cr0 + or eax, 060000000h ;SET CD, NW + mov cr0, rax + wbinvd ;Invalidate cache + ret +DisableCacheInCR0 ENDP + +END +;************************************************************************* +;************************************************************************* +;** ** +;** (C)Copyright 1985-2009, American Megatrends, Inc. ** +;** ** +;** All Rights Reserved. ** +;** ** +;** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +;** ** +;** Phone: (770)-246-8600 ** +;** ** +;************************************************************************* diff --git a/Core/CPU/x64/x64AsmLib/EnableCacheInCR0.asm b/Core/CPU/x64/x64AsmLib/EnableCacheInCR0.asm new file mode 100644 index 0000000..7633a1f --- /dev/null +++ b/Core/CPU/x64/x64AsmLib/EnableCacheInCR0.asm @@ -0,0 +1,84 @@ +;************************************************************************* +;************************************************************************* +;** ** +;** (C)Copyright 1985-2009, American Megatrends, Inc. ** +;** ** +;** All Rights Reserved. ** +;** ** +;** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +;** ** +;** Phone: (770)-246-8600 ** +;** ** +;************************************************************************* +;************************************************************************* + +;************************************************************************* +; $Header: /Alaska/SOURCE/Core/Modules/x64Core/x64AsmLib/EnableCacheInCR0.asm 1 10/01/10 5:07p Felixp $ +; +; $Revision: 1 $ +; +; $Date: 10/01/10 5:07p $ +;************************************************************************* +; Revision History +; ---------------- +; $Log: /Alaska/SOURCE/Core/Modules/x64Core/x64AsmLib/EnableCacheInCR0.asm $ +; +; 1 10/01/10 5:07p Felixp +; +; 1 8/24/06 12:57p Felixp +; +;************************************************************************* +;<AMI_FHDR_START> +; +; Name: +; +; Description: +; +;<AMI_FHDR_END> +;************************************************************************* +.code + +;************************************************************************* +;<AMI_PHDR_START> +; +; Name: EnableCacheInCR0 +; +; Description: +; VOID EnableCacheInCR0() enables the CPU cache using the CR0 register. +; +; Input: +; VOID. +; +; Output: +; VOID. +; +; Modified: +; +; Referrals: +; +; Notes: +; +;<AMI_PHDR_END> +;************************************************************************* +EnableCacheInCR0 PROC PUBLIC +; Enable cache + mov rax, cr0 + and eax, 09fffffffh ;SET CD, NW + mov cr0, rax + wbinvd + ret +EnableCacheInCR0 ENDP + +END +;************************************************************************* +;************************************************************************* +;** ** +;** (C)Copyright 1985-2009, American Megatrends, Inc. ** +;** ** +;** All Rights Reserved. ** +;** ** +;** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +;** ** +;** Phone: (770)-246-8600 ** +;** ** +;************************************************************************* diff --git a/Core/CPU/x64/x64AsmLib/EnableMachineCheck.asm b/Core/CPU/x64/x64AsmLib/EnableMachineCheck.asm new file mode 100644 index 0000000..b220afd --- /dev/null +++ b/Core/CPU/x64/x64AsmLib/EnableMachineCheck.asm @@ -0,0 +1,83 @@ +;************************************************************************* +;************************************************************************* +;** ** +;** (C)Copyright 1985-2009, American Megatrends, Inc. ** +;** ** +;** All Rights Reserved. ** +;** ** +;** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +;** ** +;** Phone: (770)-246-8600 ** +;** ** +;************************************************************************* +;************************************************************************* + +;************************************************************************* +; $Header: /Alaska/SOURCE/Core/Modules/x64Core/x64AsmLib/EnableMachineCheck.asm 1 10/01/10 5:07p Felixp $ +; +; $Revision: 1 $ +; +; $Date: 10/01/10 5:07p $ +;************************************************************************* +; Revision History +; ---------------- +; $Log: /Alaska/SOURCE/Core/Modules/x64Core/x64AsmLib/EnableMachineCheck.asm $ +; +; 1 10/01/10 5:07p Felixp +; +; 1 8/24/06 12:57p Felixp +; +;************************************************************************* +;<AMI_FHDR_START> +; +; Name: +; +; Description: +; +;<AMI_FHDR_END> +;************************************************************************* +.code + +;************************************************************************* +;<AMI_PHDR_START> +; +; Name: EnableMachineCheck +; +; Description: +; VOID EnableMachineCheck() sets the Machine Check Exception bit in CR4, +; which enables machine check interrupts to occur. +; +; Input: +; VOID. +; +; Output: +; VOID. +; +; Modified: +; +; Referrals: +; +; Notes: +; +;<AMI_PHDR_END> +;************************************************************************* +EnableMachineCheck proc + mov rax, cr4 + or eax, 1 SHL 6 + mov cr4, rax + ret +EnableMachineCheck endp + +END +;************************************************************************* +;************************************************************************* +;** ** +;** (C)Copyright 1985-2009, American Megatrends, Inc. ** +;** ** +;** All Rights Reserved. ** +;** ** +;** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +;** ** +;** Phone: (770)-246-8600 ** +;** ** +;************************************************************************* diff --git a/Core/CPU/x64/x64AsmLib/GetCpuTimer.asm b/Core/CPU/x64/x64AsmLib/GetCpuTimer.asm new file mode 100644 index 0000000..f606744 --- /dev/null +++ b/Core/CPU/x64/x64AsmLib/GetCpuTimer.asm @@ -0,0 +1,82 @@ +;************************************************************************* +;************************************************************************* +;** ** +;** (C)Copyright 1985-2009, American Megatrends, Inc. ** +;** ** +;** All Rights Reserved. ** +;** ** +;** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +;** ** +;** Phone: (770)-246-8600 ** +;** ** +;************************************************************************* +;************************************************************************* + +;************************************************************************* +; $Header: /Alaska/SOURCE/Core/Modules/x64Core/x64AsmLib/GetCpuTimer.asm 1 10/01/10 5:07p Felixp $ +; +; $Revision: 1 $ +; +; $Date: 10/01/10 5:07p $ +;************************************************************************* +; Revision History +; ---------------- +; $Log: /Alaska/SOURCE/Core/Modules/x64Core/x64AsmLib/GetCpuTimer.asm $ +; +; 1 10/01/10 5:07p Felixp +; +; 1 8/24/06 12:57p Felixp +; +;************************************************************************* +;<AMI_FHDR_START> +; +; Name: +; +; Description: +; +;<AMI_FHDR_END> +;************************************************************************* +.code + +;************************************************************************* +;<AMI_PHDR_START> +; +; Name: GetCpuTimer +; +; Description: +; UINT64 GetCpuTimer() returns the value of the CPU timer. +; +; Input: +; None. +; +; Output: +; UINT64 value of the CPU timer. +; +; Modified: +; +; Referrals: +; +; Notes: +; +;<AMI_PHDR_END> +;************************************************************************* +GetCpuTimer proc + rdtsc + shl rdx,32 + or rax, rdx + ret +GetCpuTimer endp + +END +;************************************************************************* +;************************************************************************* +;** ** +;** (C)Copyright 1985-2009, American Megatrends, Inc. ** +;** ** +;** All Rights Reserved. ** +;** ** +;** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +;** ** +;** Phone: (770)-246-8600 ** +;** ** +;************************************************************************* diff --git a/Core/CPU/x64/x64AsmLib/GetCsSegment.asm b/Core/CPU/x64/x64AsmLib/GetCsSegment.asm new file mode 100644 index 0000000..02138c3 --- /dev/null +++ b/Core/CPU/x64/x64AsmLib/GetCsSegment.asm @@ -0,0 +1,79 @@ +;************************************************************************* +;************************************************************************* +;** ** +;** (C)Copyright 1985-2009, American Megatrends, Inc. ** +;** ** +;** All Rights Reserved. ** +;** ** +;** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +;** ** +;** Phone: (770)-246-8600 ** +;** ** +;************************************************************************* +;************************************************************************* + +;************************************************************************* +; $Header: /Alaska/SOURCE/Core/Modules/x64Core/x64AsmLib/GetCsSegment.asm 1 10/01/10 5:07p Felixp $ +; +; $Revision: 1 $ +; +; $Date: 10/01/10 5:07p $ +;************************************************************************* +; Revision History +; ---------------- +; $Log: /Alaska/SOURCE/Core/Modules/x64Core/x64AsmLib/GetCsSegment.asm $ +; +; 1 10/01/10 5:07p Felixp +; +; 1 8/24/06 12:57p Felixp +; +;************************************************************************* +;<AMI_FHDR_START> +; +; Name: +; +; Description: +; +;<AMI_FHDR_END> +;************************************************************************* +.code +;************************************************************************* +;<AMI_PHDR_START> +; +; Name: GetCsSegment +; +; Description: +; UINT16 GetCsSegment() retreives the value of the CS register. +; +; Input: +; VOID. +; +; Output: +; UINT16 value of CS. +; +; Modified: +; +; Referrals: +; +; Notes: +; +;<AMI_PHDR_END> +;************************************************************************* +GetCsSegment proc + mov ax, cs + ret +GetCsSegment endp + +END +;************************************************************************* +;************************************************************************* +;** ** +;** (C)Copyright 1985-2009, American Megatrends, Inc. ** +;** ** +;** All Rights Reserved. ** +;** ** +;** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +;** ** +;** Phone: (770)-246-8600 ** +;** ** +;************************************************************************* diff --git a/Core/CPU/x64/x64AsmLib/GetPowerOfTwo64.asm b/Core/CPU/x64/x64AsmLib/GetPowerOfTwo64.asm new file mode 100644 index 0000000..9cebe72 --- /dev/null +++ b/Core/CPU/x64/x64AsmLib/GetPowerOfTwo64.asm @@ -0,0 +1,84 @@ +;************************************************************************* +;************************************************************************* +;** ** +;** (C)Copyright 1985-2009, American Megatrends, Inc. ** +;** ** +;** All Rights Reserved. ** +;** ** +;** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +;** ** +;** Phone: (770)-246-8600 ** +;** ** +;************************************************************************* +;************************************************************************* + +;************************************************************************* +; $Header: /Alaska/SOURCE/Core/Modules/x64Core/x64AsmLib/GetPowerOfTwo64.asm 1 10/01/10 5:07p Felixp $ +; +; $Revision: 1 $ +; +; $Date: 10/01/10 5:07p $ +;************************************************************************* +; Revision History +; ---------------- +; $Log: /Alaska/SOURCE/Core/Modules/x64Core/x64AsmLib/GetPowerOfTwo64.asm $ +; +; 1 10/01/10 5:07p Felixp +; +; 1 8/24/06 12:57p Felixp +; +;************************************************************************* +;<AMI_FHDR_START> +; +; Name: +; +; Description: +; +;<AMI_FHDR_END> +;************************************************************************* +.code + +;************************************************************************* +;<AMI_PHDR_START> +; +; Name: GetPowerOfTwo64 +; +; Description: +; UINT64 GetPowerOfTwo64(IN UINT64 Input) returns the highest bit set in +; the provided UINT64 Input. Equivalent to 1 << log2(x). +; +; Input: +; IN UINT64 Input +; The 64-bit value to check for its highest bit. +; +; Output: +; UINT64 value of the highest bit; if Input is 0, returns 0. +; +; Modified: +; +; Referrals: +; +; Notes: +; +;<AMI_PHDR_END> +;************************************************************************* +GetPowerOfTwo64 proc + bsr rdx, rcx + xor rax, rax + bts rax, rdx + ret +GetPowerOfTwo64 endp + +END +;************************************************************************* +;************************************************************************* +;** ** +;** (C)Copyright 1985-2009, American Megatrends, Inc. ** +;** ** +;** All Rights Reserved. ** +;** ** +;** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +;** ** +;** Phone: (770)-246-8600 ** +;** ** +;************************************************************************* diff --git a/Core/CPU/x64/x64AsmLib/HltCpu.asm b/Core/CPU/x64/x64AsmLib/HltCpu.asm new file mode 100644 index 0000000..a8c8a6e --- /dev/null +++ b/Core/CPU/x64/x64AsmLib/HltCpu.asm @@ -0,0 +1,83 @@ +;************************************************************************* +;************************************************************************* +;** ** +;** (C)Copyright 1985-2009, American Megatrends, Inc. ** +;** ** +;** All Rights Reserved. ** +;** ** +;** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +;** ** +;** Phone: (770)-246-8600 ** +;** ** +;************************************************************************* +;************************************************************************* + +;************************************************************************* +; $Header: /Alaska/SOURCE/Core/Modules/x64Core/x64AsmLib/HltCpu.asm 1 10/01/10 5:07p Felixp $ +; +; $Revision: 1 $ +; +; $Date: 10/01/10 5:07p $ +;************************************************************************* +; Revision History +; ---------------- +; $Log: /Alaska/SOURCE/Core/Modules/x64Core/x64AsmLib/HltCpu.asm $ +; +; 1 10/01/10 5:07p Felixp +; +; 1 8/24/06 12:57p Felixp +; +;************************************************************************* +;<AMI_FHDR_START> +; +; Name: +; +; Description: +; +;<AMI_FHDR_END> +;************************************************************************* +.code + +;************************************************************************* +;<AMI_PHDR_START> +; +; Name: HltCpu +; +; Description: +; VOID HltCpu() halts the CPU. +; +; Input: +; VOID. +; +; Output: +; VOID. +; +; Modified: +; +; Referrals: +; +; Notes: +; +;<AMI_PHDR_END> +;************************************************************************* +HltCpu Proc +@@: + cli + hlt + jmp @b + ret +HltCpu endp + +END +;************************************************************************* +;************************************************************************* +;** ** +;** (C)Copyright 1985-2009, American Megatrends, Inc. ** +;** ** +;** All Rights Reserved. ** +;** ** +;** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +;** ** +;** Phone: (770)-246-8600 ** +;** ** +;************************************************************************* diff --git a/Core/CPU/x64/x64AsmLib/IoRead16.asm b/Core/CPU/x64/x64AsmLib/IoRead16.asm new file mode 100644 index 0000000..3403a34 --- /dev/null +++ b/Core/CPU/x64/x64AsmLib/IoRead16.asm @@ -0,0 +1,83 @@ +;************************************************************************* +;************************************************************************* +;** ** +;** (C)Copyright 1985-2009, American Megatrends, Inc. ** +;** ** +;** All Rights Reserved. ** +;** ** +;** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +;** ** +;** Phone: (770)-246-8600 ** +;** ** +;************************************************************************* +;************************************************************************* + +;************************************************************************* +; $Header: /Alaska/SOURCE/Core/Modules/x64Core/x64AsmLib/IoRead16.asm 1 10/01/10 5:07p Felixp $ +; +; $Revision: 1 $ +; +; $Date: 10/01/10 5:07p $ +;************************************************************************* +; Revision History +; ---------------- +; $Log: /Alaska/SOURCE/Core/Modules/x64Core/x64AsmLib/IoRead16.asm $ +; +; 1 10/01/10 5:07p Felixp +; +; 1 8/24/06 12:57p Felixp +; +;************************************************************************* +;<AMI_FHDR_START> +; +; Name: +; +; Description: +; +;<AMI_FHDR_END> +;************************************************************************* +.code + +;************************************************************************* +;<AMI_PHDR_START> +; +; Name: IoRead16 +; +; Description: +; UINT16 IoRead16(IN UINT16 Port) reads the 16-bit value stored at the I/O +; port defined by Port. +; +; Input: +; IN UINT16 Port +; I/O port to read 16-bits from. +; +; Output: +; UINT16 value stored at I/O Port. +; +; Modified: +; +; Referrals: +; +; Notes: +; +;<AMI_PHDR_END> +;************************************************************************* +IoRead16 proc + mov dx, cx + in ax, dx + ret +IoRead16 endp + +END +;************************************************************************* +;************************************************************************* +;** ** +;** (C)Copyright 1985-2009, American Megatrends, Inc. ** +;** ** +;** All Rights Reserved. ** +;** ** +;** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +;** ** +;** Phone: (770)-246-8600 ** +;** ** +;************************************************************************* diff --git a/Core/CPU/x64/x64AsmLib/IoRead32.asm b/Core/CPU/x64/x64AsmLib/IoRead32.asm new file mode 100644 index 0000000..510a01f --- /dev/null +++ b/Core/CPU/x64/x64AsmLib/IoRead32.asm @@ -0,0 +1,83 @@ +;************************************************************************* +;************************************************************************* +;** ** +;** (C)Copyright 1985-2009, American Megatrends, Inc. ** +;** ** +;** All Rights Reserved. ** +;** ** +;** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +;** ** +;** Phone: (770)-246-8600 ** +;** ** +;************************************************************************* +;************************************************************************* + +;************************************************************************* +; $Header: /Alaska/SOURCE/Core/Modules/x64Core/x64AsmLib/IoRead32.asm 1 10/01/10 5:07p Felixp $ +; +; $Revision: 1 $ +; +; $Date: 10/01/10 5:07p $ +;************************************************************************* +; Revision History +; ---------------- +; $Log: /Alaska/SOURCE/Core/Modules/x64Core/x64AsmLib/IoRead32.asm $ +; +; 1 10/01/10 5:07p Felixp +; +; 1 8/24/06 12:57p Felixp +; +;************************************************************************* +;<AMI_FHDR_START> +; +; Name: +; +; Description: +; +;<AMI_FHDR_END> +;************************************************************************* +.code + +;************************************************************************* +;<AMI_PHDR_START> +; +; Name: IoRead32 +; +; Description: +; UINT32 IoRead32(IN UINT16 Port) reads the 32-bit value stored at the I/O +; port defined by Port. +; +; Input: +; IN UINT16 Port +; I/O port to read 32-bits from. +; +; Output: +; UINT32 value stored at I/O Port. +; +; Modified: +; +; Referrals: +; +; Notes: +; +;<AMI_PHDR_END> +;************************************************************************* +IoRead32 proc + mov dx, cx + in eax, dx + ret +IoRead32 endp + +END +;************************************************************************* +;************************************************************************* +;** ** +;** (C)Copyright 1985-2009, American Megatrends, Inc. ** +;** ** +;** All Rights Reserved. ** +;** ** +;** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +;** ** +;** Phone: (770)-246-8600 ** +;** ** +;************************************************************************* diff --git a/Core/CPU/x64/x64AsmLib/IoRead64.asm b/Core/CPU/x64/x64AsmLib/IoRead64.asm new file mode 100644 index 0000000..ff1da50 --- /dev/null +++ b/Core/CPU/x64/x64AsmLib/IoRead64.asm @@ -0,0 +1,83 @@ +;************************************************************************* +;************************************************************************* +;** ** +;** (C)Copyright 1985-2009, American Megatrends, Inc. ** +;** ** +;** All Rights Reserved. ** +;** ** +;** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +;** ** +;** Phone: (770)-246-8600 ** +;** ** +;************************************************************************* +;************************************************************************* + +;************************************************************************* +; $Header: /Alaska/SOURCE/Core/Modules/x64Core/x64AsmLib/IoRead64.asm 1 10/01/10 5:07p Felixp $ +; +; $Revision: 1 $ +; +; $Date: 10/01/10 5:07p $ +;************************************************************************* +; Revision History +; ---------------- +; $Log: /Alaska/SOURCE/Core/Modules/x64Core/x64AsmLib/IoRead64.asm $ +; +; 1 10/01/10 5:07p Felixp +; +; 1 8/24/06 12:57p Felixp +; +;************************************************************************* +;<AMI_FHDR_START> +; +; Name: +; +; Description: +; +;<AMI_FHDR_END> +;************************************************************************* +.code + +;************************************************************************* +;<AMI_PHDR_START> +; +; Name: IoRead64 +; +; Description: +; UINT32 IoRead64(IN UINT16 Port) reads the 64-bit value stored at the I/O +; port defined by Port. +; +; Input: +; IN UINT16 Port +; I/O port to read 64-bits from. +; +; Output: +; UINT64 value stored at I/O Port. +; +; Modified: +; +; Referrals: +; +; Notes: +; +;<AMI_PHDR_END> +;************************************************************************* +IoRead64 proc + mov dx, cx + in rax, dx + ret +IoRead64 endp + +END +;************************************************************************* +;************************************************************************* +;** ** +;** (C)Copyright 1985-2009, American Megatrends, Inc. ** +;** ** +;** All Rights Reserved. ** +;** ** +;** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +;** ** +;** Phone: (770)-246-8600 ** +;** ** +;************************************************************************* diff --git a/Core/CPU/x64/x64AsmLib/IoRead8.asm b/Core/CPU/x64/x64AsmLib/IoRead8.asm new file mode 100644 index 0000000..3dfd1fd --- /dev/null +++ b/Core/CPU/x64/x64AsmLib/IoRead8.asm @@ -0,0 +1,83 @@ +;************************************************************************* +;************************************************************************* +;** ** +;** (C)Copyright 1985-2009, American Megatrends, Inc. ** +;** ** +;** All Rights Reserved. ** +;** ** +;** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +;** ** +;** Phone: (770)-246-8600 ** +;** ** +;************************************************************************* +;************************************************************************* + +;************************************************************************* +; $Header: /Alaska/SOURCE/Core/Modules/x64Core/x64AsmLib/IoRead8.asm 1 10/01/10 5:07p Felixp $ +; +; $Revision: 1 $ +; +; $Date: 10/01/10 5:07p $ +;************************************************************************* +; Revision History +; ---------------- +; $Log: /Alaska/SOURCE/Core/Modules/x64Core/x64AsmLib/IoRead8.asm $ +; +; 1 10/01/10 5:07p Felixp +; +; 1 8/24/06 12:57p Felixp +; +;************************************************************************* +;<AMI_FHDR_START> +; +; Name: +; +; Description: +; +;<AMI_FHDR_END> +;************************************************************************* +.code + +;************************************************************************* +;<AMI_PHDR_START> +; +; Name: IoRead8 +; +; Description: +; UINT8 IoRead8(IN UINT16 Port) reads the 8-bit value stored at the I/O +; port defined by Port. +; +; Input: +; IN UINT16 Port +; I/O port to read 8-bits from. +; +; Output: +; UINT8 value stored at I/O Port. +; +; Modified: +; +; Referrals: +; +; Notes: +; +;<AMI_PHDR_END> +;************************************************************************* +IoRead8 proc + mov dx, cx + in al, dx + ret +IoRead8 endp + +END +;************************************************************************* +;************************************************************************* +;** ** +;** (C)Copyright 1985-2009, American Megatrends, Inc. ** +;** ** +;** All Rights Reserved. ** +;** ** +;** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +;** ** +;** Phone: (770)-246-8600 ** +;** ** +;************************************************************************* diff --git a/Core/CPU/x64/x64AsmLib/IoWrite16.asm b/Core/CPU/x64/x64AsmLib/IoWrite16.asm new file mode 100644 index 0000000..2616d1a --- /dev/null +++ b/Core/CPU/x64/x64AsmLib/IoWrite16.asm @@ -0,0 +1,87 @@ +;************************************************************************* +;************************************************************************* +;** ** +;** (C)Copyright 1985-2009, American Megatrends, Inc. ** +;** ** +;** All Rights Reserved. ** +;** ** +;** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +;** ** +;** Phone: (770)-246-8600 ** +;** ** +;************************************************************************* +;************************************************************************* + +;************************************************************************* +; $Header: /Alaska/SOURCE/Core/Modules/x64Core/x64AsmLib/IoWrite16.asm 1 10/01/10 5:07p Felixp $ +; +; $Revision: 1 $ +; +; $Date: 10/01/10 5:07p $ +;************************************************************************* +; Revision History +; ---------------- +; $Log: /Alaska/SOURCE/Core/Modules/x64Core/x64AsmLib/IoWrite16.asm $ +; +; 1 10/01/10 5:07p Felixp +; +; 1 8/24/06 12:57p Felixp +; +;************************************************************************* +;<AMI_FHDR_START> +; +; Name: +; +; Description: +; +;<AMI_FHDR_END> +;************************************************************************* +.code + +;************************************************************************* +;<AMI_PHDR_START> +; +; Name: IoWrite16 +; +; Description: +; VOID IoWrite16(IN UINT16 Port, IN UINT16 Value) writes the 16-bit Value +; to the I/O port defined by Port. +; +; Input: +; IN UINT16 Port +; I/O port to write 16-bits to. +; +; IN UINT16 Value +; 16-bits to write to the I/O Port. +; +; Output: +; VOID. +; +; Modified: +; +; Referrals: +; +; Notes: +; +;<AMI_PHDR_END> +;************************************************************************* +IoWrite16 proc + mov ax, dx + mov dx, cx + out dx, ax + ret +IoWrite16 endp + +END +;************************************************************************* +;************************************************************************* +;** ** +;** (C)Copyright 1985-2009, American Megatrends, Inc. ** +;** ** +;** All Rights Reserved. ** +;** ** +;** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +;** ** +;** Phone: (770)-246-8600 ** +;** ** +;************************************************************************* diff --git a/Core/CPU/x64/x64AsmLib/IoWrite32.asm b/Core/CPU/x64/x64AsmLib/IoWrite32.asm new file mode 100644 index 0000000..98096d7 --- /dev/null +++ b/Core/CPU/x64/x64AsmLib/IoWrite32.asm @@ -0,0 +1,87 @@ +;************************************************************************* +;************************************************************************* +;** ** +;** (C)Copyright 1985-2009, American Megatrends, Inc. ** +;** ** +;** All Rights Reserved. ** +;** ** +;** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +;** ** +;** Phone: (770)-246-8600 ** +;** ** +;************************************************************************* +;************************************************************************* + +;************************************************************************* +; $Header: /Alaska/SOURCE/Core/Modules/x64Core/x64AsmLib/IoWrite32.asm 1 10/01/10 5:07p Felixp $ +; +; $Revision: 1 $ +; +; $Date: 10/01/10 5:07p $ +;************************************************************************* +; Revision History +; ---------------- +; $Log: /Alaska/SOURCE/Core/Modules/x64Core/x64AsmLib/IoWrite32.asm $ +; +; 1 10/01/10 5:07p Felixp +; +; 1 8/24/06 12:57p Felixp +; +;************************************************************************* +;<AMI_FHDR_START> +; +; Name: +; +; Description: +; +;<AMI_FHDR_END> +;************************************************************************* +.code + +;************************************************************************* +;<AMI_PHDR_START> +; +; Name: IoWrite32 +; +; Description: +; VOID IoWrite32(IN UINT16 Port, IN UINT32 Value) writes the 32-bit Value +; to the I/O port defined by Port. +; +; Input: +; IN UINT16 Port +; I/O port to write 32-bits to. +; +; IN UINT32 Value +; 32-bits to write to the I/O Port. +; +; Output: +; VOID. +; +; Modified: +; +; Referrals: +; +; Notes: +; +;<AMI_PHDR_END> +;************************************************************************* +IoWrite32 proc + mov eax, edx + mov dx, cx + out dx, eax + ret +IoWrite32 endp + +END +;************************************************************************* +;************************************************************************* +;** ** +;** (C)Copyright 1985-2009, American Megatrends, Inc. ** +;** ** +;** All Rights Reserved. ** +;** ** +;** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +;** ** +;** Phone: (770)-246-8600 ** +;** ** +;************************************************************************* diff --git a/Core/CPU/x64/x64AsmLib/IoWrite64.asm b/Core/CPU/x64/x64AsmLib/IoWrite64.asm new file mode 100644 index 0000000..c38c832 --- /dev/null +++ b/Core/CPU/x64/x64AsmLib/IoWrite64.asm @@ -0,0 +1,87 @@ +;************************************************************************* +;************************************************************************* +;** ** +;** (C)Copyright 1985-2009, American Megatrends, Inc. ** +;** ** +;** All Rights Reserved. ** +;** ** +;** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +;** ** +;** Phone: (770)-246-8600 ** +;** ** +;************************************************************************* +;************************************************************************* + +;************************************************************************* +; $Header: /Alaska/SOURCE/Core/Modules/x64Core/x64AsmLib/IoWrite64.asm 1 10/01/10 5:07p Felixp $ +; +; $Revision: 1 $ +; +; $Date: 10/01/10 5:07p $ +;************************************************************************* +; Revision History +; ---------------- +; $Log: /Alaska/SOURCE/Core/Modules/x64Core/x64AsmLib/IoWrite64.asm $ +; +; 1 10/01/10 5:07p Felixp +; +; 1 8/24/06 12:57p Felixp +; +;************************************************************************* +;<AMI_FHDR_START> +; +; Name: +; +; Description: +; +;<AMI_FHDR_END> +;************************************************************************* +.code + +;************************************************************************* +;<AMI_PHDR_START> +; +; Name: IoWrite64 +; +; Description: +; VOID IoWrite64(IN UINT16 Port, IN UINT64 Value) writes the 64-bit Value +; to the I/O port defined by Port. +; +; Input: +; IN UINT16 Port +; I/O port to write 64-bits to. +; +; IN UINT64 Value +; 64-bits to write to the I/O Port. +; +; Output: +; VOID. +; +; Modified: +; +; Referrals: +; +; Notes: +; +;<AMI_PHDR_END> +;************************************************************************* +IoWrite64 proc + mov rax, rdx + mov dx, cx + out dx, rax + ret +IoWrite64 endp + +END +;************************************************************************* +;************************************************************************* +;** ** +;** (C)Copyright 1985-2009, American Megatrends, Inc. ** +;** ** +;** All Rights Reserved. ** +;** ** +;** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +;** ** +;** Phone: (770)-246-8600 ** +;** ** +;************************************************************************* diff --git a/Core/CPU/x64/x64AsmLib/IoWrite8.asm b/Core/CPU/x64/x64AsmLib/IoWrite8.asm new file mode 100644 index 0000000..4bd5119 --- /dev/null +++ b/Core/CPU/x64/x64AsmLib/IoWrite8.asm @@ -0,0 +1,87 @@ +;************************************************************************* +;************************************************************************* +;** ** +;** (C)Copyright 1985-2009, American Megatrends, Inc. ** +;** ** +;** All Rights Reserved. ** +;** ** +;** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +;** ** +;** Phone: (770)-246-8600 ** +;** ** +;************************************************************************* +;************************************************************************* + +;************************************************************************* +; $Header: /Alaska/SOURCE/Core/Modules/x64Core/x64AsmLib/IoWrite8.asm 1 10/01/10 5:07p Felixp $ +; +; $Revision: 1 $ +; +; $Date: 10/01/10 5:07p $ +;************************************************************************* +; Revision History +; ---------------- +; $Log: /Alaska/SOURCE/Core/Modules/x64Core/x64AsmLib/IoWrite8.asm $ +; +; 1 10/01/10 5:07p Felixp +; +; 1 8/24/06 12:57p Felixp +; +;************************************************************************* +;<AMI_FHDR_START> +; +; Name: +; +; Description: +; +;<AMI_FHDR_END> +;************************************************************************* +.code + +;************************************************************************* +;<AMI_PHDR_START> +; +; Name: IoWrite8 +; +; Description: +; VOID IoWrite8(IN UINT16 Port, IN UINT8 Value) writes the 8-bit Value to +; the I/O port defined by Port. +; +; Input: +; IN UINT16 Port +; I/O port to write 8-bits to. +; +; IN UINT8 Value +; 8-bits to write to the I/O Port. +; +; Output: +; VOID. +; +; Modified: +; +; Referrals: +; +; Notes: +; +;<AMI_PHDR_END> +;************************************************************************* +IoWrite8 proc + mov al, dl + mov dx, cx + out dx, al + ret +IoWrite8 endp + +END +;************************************************************************* +;************************************************************************* +;** ** +;** (C)Copyright 1985-2009, American Megatrends, Inc. ** +;** ** +;** All Rights Reserved. ** +;** ** +;** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +;** ** +;** Phone: (770)-246-8600 ** +;** ** +;************************************************************************* diff --git a/Core/CPU/x64/x64AsmLib/MemCpy.asm b/Core/CPU/x64/x64AsmLib/MemCpy.asm new file mode 100644 index 0000000..a671ec8 --- /dev/null +++ b/Core/CPU/x64/x64AsmLib/MemCpy.asm @@ -0,0 +1,178 @@ +;************************************************************************* +;************************************************************************* +;** ** +;** (C)Copyright 1985-2009, American Megatrends, Inc. ** +;** ** +;** All Rights Reserved. ** +;** ** +;** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +;** ** +;** Phone: (770)-246-8600 ** +;** ** +;************************************************************************* +;************************************************************************* + +;************************************************************************* +; $Header: /Alaska/SOURCE/Core/Modules/x64Core/x64AsmLib/MemCpy.asm 2 3/09/11 1:58p Felixp $ +; +; $Revision: 2 $ +; +; $Date: 3/09/11 1:58p $ +;************************************************************************* +; Revision History +; ---------------- +; $Log: /Alaska/SOURCE/Core/Modules/x64Core/x64AsmLib/MemCpy.asm $ +; +; 2 3/09/11 1:58p Felixp +; MemCpy is updated to copy 8 bytes at a time (used to be 4) +; +; 1 10/01/10 5:07p Felixp +; +; 1 8/24/06 12:57p Felixp +; +;************************************************************************* +;<AMI_FHDR_START> +; +; Name: +; +; Description: +; +;<AMI_FHDR_END> +;************************************************************************* +.code + +;************************************************************************* +;<AMI_PHDR_START> +; +; Name: MemCpy +; +; Description: +; VOID MemCpy(OUT VOID *pDestination, IN VOID *pSource, IN UINTN Count) +; copies Count bytes of memory from Source to Destination. +; +; Input: +; OUT VOID *pDestination +; Memory address where data shall be copied. User is responsible for +; allocating the necessary memory resources. +; +; IN VOID *pSource +; Memory address from where data shall be copied. +; +; IN UINTN Count +; Number of bytes to copy from pSource. +; +; Output: +; VOID. +; +; Modified: +; +; Referrals: +; +; Notes: +; This function checks for overlapping of source and destination and +; selects copy direction that prevents memory corruption. +; +;<AMI_PHDR_END> +;************************************************************************* +public memcpy +memcpy: +MemCpy proc + push rdi + push rsi + push rbx + pushf + mov rsi, rdx ; pSource + mov rdi, rcx ; pDestination + mov rcx, r8 ; Count + mov dl, 0 + ; if pSource > pDestination CopyForward + mov rax, rsi + sub rax, rdi ; rax = pSource-pDestination + jnb CopyForward; if pSource-pDestination > 0 CopyForward + ; if pSource+Count < pDestination then CopyForward + lea rbx, [rsi+rcx] ; rbx = pSource + Count + neg rax ; rax = pDestination - pSource + cmp rbx, rdi + jb CopyForward ; if (pSource + Count < pDestination ) CopyForward + ; Copy Backward + mov rsi, rbx; rsi = pSource + Count + lea rdi, [rdi+rcx]; rdi = pDestination + Count + mov dl, 1; Flag to indicate that we are copying backward + std; set direction flag to copy backward +CopyForward: + cmp rcx, 8 ; if (Counter<8) copy byte by byte + jb m8 + cmp rax, 8 ; if (pDestination - pSource < 8) copy byte by byte + jb m8 + ; if pSource and pDestination are not 8 byte aligned + ; Calculate 8-(Buffer%8), which is a number of bytes we have to copy to align the buffer + ; if this number if the same for source and destinations + ; copy several bytes to align them + ; otherwise proceed to QWORD copy + mov rax, rsi + mov rbx, rdi + and rax, 7 + and rbx, 7 + test dl, dl + jz skip1 + dec rsi + dec rdi +skip1: + cmp rax, rbx + jne m64 + test rax, rax + jz m64 + test dl, dl + jnz skip_nz1 + neg rax + add rax, 8 +skip_nz1: + xchg rax, rcx + sub rax, rcx + rep movsb + mov rcx, rax +m64: + test dl, dl + jz skip2 + sub rsi, 7 + sub rdi, 7 +skip2: + mov rax, rcx + shr rcx, 3 + rep movsq + and rax, 7 + jz MemCpuEnd + test dl, dl + jz skip3 + add rsi, 8 + add rdi, 8 +skip3: + mov rcx, rax +m8: + test dl, dl + jz skip4 + dec rsi + dec rdi +skip4: + rep movsb +MemCpuEnd: + popf + pop rbx + pop rsi + pop rdi + ret +MemCpy endp + +END +;************************************************************************* +;************************************************************************* +;** ** +;** (C)Copyright 1985-2009, American Megatrends, Inc. ** +;** ** +;** All Rights Reserved. ** +;** ** +;** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +;** ** +;** Phone: (770)-246-8600 ** +;** ** +;************************************************************************* diff --git a/Core/CPU/x64/x64AsmLib/MemCpy32.asm b/Core/CPU/x64/x64AsmLib/MemCpy32.asm new file mode 100644 index 0000000..a5886b3 --- /dev/null +++ b/Core/CPU/x64/x64AsmLib/MemCpy32.asm @@ -0,0 +1,178 @@ +;************************************************************************* +;************************************************************************* +;** ** +;** (C)Copyright 1985-2009, American Megatrends, Inc. ** +;** ** +;** All Rights Reserved. ** +;** ** +;** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +;** ** +;** Phone: (770)-246-8600 ** +;** ** +;************************************************************************* +;************************************************************************* + +;************************************************************************* +; $Header: /Alaska/SOURCE/Core/Modules/x64Core/x64AsmLib/MemCpy32.asm 1 10/17/11 1:03p Yakovlevs $ +; +; $Revision: 1 $ +; +; $Date: 10/17/11 1:03p $ +;************************************************************************* +; Revision History +; ---------------- +; $Log: /Alaska/SOURCE/Core/Modules/x64Core/x64AsmLib/MemCpy32.asm $ +; +; 1 10/17/11 1:03p Yakovlevs +; [TAG] EIP71694 +; +; 1 10/01/10 5:07p Felixp +; +; 1 8/24/06 12:57p Felixp +; +;************************************************************************* +;<AMI_FHDR_START> +; +; Name: +; +; Description: +; +;<AMI_FHDR_END> +;************************************************************************* +.code + +;************************************************************************* +;<AMI_PHDR_START> +; +; Name: MemCpy32 +; +; Description: +; VOID MemCpy32(OUT VOID *pDestination, IN VOID *pSource, IN UINTN Count) +; copies Count bytes of memory from Source to Destination. +; +; Input: +; OUT VOID *pDestination +; Memory address where data shall be copied. User is responsible for +; allocating the necessary memory resources. +; +; IN VOID *pSource +; Memory address from where data shall be copied. +; +; IN UINTN Count +; Number of bytes to copy from pSource. +; +; Output: +; VOID. +; +; Modified: +; +; Referrals: +; +; Notes: +; This function checks for overlapping of source and destination and +; selects copy direction that prevents memory corruption. +; +;<AMI_PHDR_END> +;************************************************************************* +public memcpy32 +memcpy32: +MemCpy32 proc + push rdi + push rsi + push rbx + pushf + mov rsi, rdx ; pSource + mov rdi, rcx ; pDestination + mov rcx, r8 ; Count + mov dl, 0 + ; if pSource > pDestination CopyForward + mov rax, rsi + sub rax, rdi ; rax = pSource-pDestination + jnb CopyForward; if pSource-pDestination > 0 CopyForward + ; if pSource+Count < pDestination then CopyForward + lea rbx, [rsi+rcx] ; rbx = pSource + Count + neg rax ; rax = pDestination - pSource + cmp rbx, rdi + jb CopyForward ; if (pSource + Count < pDestination ) CopyForward + ; Copy Backward + mov rsi, rbx; rsi = pSource + Count + lea rdi, [rdi+rcx]; rdi = pDestination + Count + mov dl, 1; Flag to indicate that we are copying backward + std; set direction flag to copy backward +CopyForward: + cmp rcx, 4 ; if (Counter<4) copy byte by byte + jb m8 + cmp rax, 4 ; if (pDestination - pSource < 4) copy byte by byte + jb m8 + ; if pSource and pDestination are not 4 byte aligned + ; Calculate 4-(Buffer%4), which is a number of bytes we have to copy to align the buffer + ; if this number if the same for source and destinations + ; copy several bytes to align them + ; otherwise proceed to DWORD copy + mov rax, rsi + mov rbx, rdi + and rax, 3 + and rbx, 3 + test dl, dl + jz skip1 + dec rsi + dec rdi +skip1: + cmp rax, rbx + jne m32 + test rax, rax + jz m32 + test dl, dl + jnz skip_nz1 + neg rax + add rax, 4 +skip_nz1: + xchg rax, rcx + sub rax, rcx + rep movsb + mov rcx, rax +m32: + test dl, dl + jz skip2 + sub rsi, 3 + sub rdi, 3 +skip2: + mov rax, rcx + shr rcx, 2 + rep movsd + and rax, 3 + jz MemCpuEnd + test dl, dl + jz skip3 + add rsi, 4 + add rdi, 4 +skip3: + mov rcx, rax +m8: + test dl, dl + jz skip4 + dec rsi + dec rdi +skip4: + rep movsb +MemCpuEnd: + popf + pop rbx + pop rsi + pop rdi + ret +MemCpy32 endp + +END +;************************************************************************* +;************************************************************************* +;** ** +;** (C)Copyright 1985-2009, American Megatrends, Inc. ** +;** ** +;** All Rights Reserved. ** +;** ** +;** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +;** ** +;** Phone: (770)-246-8600 ** +;** ** +;************************************************************************* diff --git a/Core/CPU/x64/x64AsmLib/MemRead32.asm b/Core/CPU/x64/x64AsmLib/MemRead32.asm new file mode 100644 index 0000000..3f79a06 --- /dev/null +++ b/Core/CPU/x64/x64AsmLib/MemRead32.asm @@ -0,0 +1,82 @@ +;************************************************************************* +;************************************************************************* +;** ** +;** (C)Copyright 1985-2009, American Megatrends, Inc. ** +;** ** +;** All Rights Reserved. ** +;** ** +;** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +;** ** +;** Phone: (770)-246-8600 ** +;** ** +;************************************************************************* +;************************************************************************* + +;************************************************************************* +; $Header: /Alaska/SOURCE/Core/Modules/x64Core/x64AsmLib/MemRead32.asm 1 10/01/10 5:07p Felixp $ +; +; $Revision: 1 $ +; +; $Date: 10/01/10 5:07p $ +;************************************************************************* +; Revision History +; ---------------- +; $Log: /Alaska/SOURCE/Core/Modules/x64Core/x64AsmLib/MemRead32.asm $ +; +; 1 10/01/10 5:07p Felixp +; +; 1 8/24/06 12:57p Felixp +; +;************************************************************************* +;<AMI_FHDR_START> +; +; Name: +; +; Description: +; +;<AMI_FHDR_END> +;************************************************************************* +.code + +;************************************************************************* +;<AMI_PHDR_START> +; +; Name: MemRead32 +; +; Description: +; UINT32 MemRead32(IN UINT32 *Address) reads and returns the 32-bit value +; stored at the user provided address. +; +; Input: +; IN UINT32 *Address +; Address to read 32-bits from. +; +; Output: +; UINT32 value stored at Address. +; +; Modified: +; +; Referrals: +; +; Notes: +; +;<AMI_PHDR_END> +;************************************************************************* +MemRead32 proc + mov eax, [rcx] + ret +MemRead32 endp + +END +;************************************************************************* +;************************************************************************* +;** ** +;** (C)Copyright 1985-2009, American Megatrends, Inc. ** +;** ** +;** All Rights Reserved. ** +;** ** +;** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +;** ** +;** Phone: (770)-246-8600 ** +;** ** +;************************************************************************* diff --git a/Core/CPU/x64/x64AsmLib/MemReadWrite32.asm b/Core/CPU/x64/x64AsmLib/MemReadWrite32.asm new file mode 100644 index 0000000..a9ab5ba --- /dev/null +++ b/Core/CPU/x64/x64AsmLib/MemReadWrite32.asm @@ -0,0 +1,93 @@ +;************************************************************************* +;************************************************************************* +;** ** +;** (C)Copyright 1985-2009, American Megatrends, Inc. ** +;** ** +;** All Rights Reserved. ** +;** ** +;** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +;** ** +;** Phone: (770)-246-8600 ** +;** ** +;************************************************************************* +;************************************************************************* + +;************************************************************************* +; $Header: /Alaska/SOURCE/Core/Modules/x64Core/x64AsmLib/MemReadWrite32.asm 1 10/01/10 5:07p Felixp $ +; +; $Revision: 1 $ +; +; $Date: 10/01/10 5:07p $ +;************************************************************************* +; Revision History +; ---------------- +; $Log: /Alaska/SOURCE/Core/Modules/x64Core/x64AsmLib/MemReadWrite32.asm $ +; +; 1 10/01/10 5:07p Felixp +; +; 1 8/24/06 12:57p Felixp +; +;************************************************************************* +;<AMI_FHDR_START> +; +; Name: +; +; Description: +; +;<AMI_FHDR_END> +;************************************************************************* +.code + +;************************************************************************* +;<AMI_PHDR_START> +; +; Name: MemReadWrite32 +; +; Description: +; VOID MemReadWrite32(IN UINT32 *Address, IN UINT32 Value, IN UINT32 Mask) +; reads the 32-bit value stored at Address, ANDs it with Mask, ORs the result +; with Value, then writes the result back to Address. +; +; Input: +; IN UINT32 *Address +; Address which shall be read from and subsequently written to. +; +; IN UINT32 Value +; Value to be ORed with the value stored at Address after it has been ANDed +; with the provided Mask. +; +; IN UINT32 Mask +; Mask to be ANDed with the original value stored at Address. +; +; Output: +; VOID. +; +; Modified: +; +; Referrals: +; +; Notes: +; +;<AMI_PHDR_END> +;************************************************************************* +MemReadWrite32 proc + mov eax, [rcx] + and eax, r8D ;Mask + or eax, edx ;Value + mov [rcx], eax + ret +MemReadWrite32 endp + +END +;************************************************************************* +;************************************************************************* +;** ** +;** (C)Copyright 1985-2009, American Megatrends, Inc. ** +;** ** +;** All Rights Reserved. ** +;** ** +;** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +;** ** +;** Phone: (770)-246-8600 ** +;** ** +;************************************************************************* diff --git a/Core/CPU/x64/x64AsmLib/MemSet.asm b/Core/CPU/x64/x64AsmLib/MemSet.asm new file mode 100644 index 0000000..246b985 --- /dev/null +++ b/Core/CPU/x64/x64AsmLib/MemSet.asm @@ -0,0 +1,127 @@ +;************************************************************************* +;************************************************************************* +;** ** +;** (C)Copyright 1985-2009, American Megatrends, Inc. ** +;** ** +;** All Rights Reserved. ** +;** ** +;** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +;** ** +;** Phone: (770)-246-8600 ** +;** ** +;************************************************************************* +;************************************************************************* + +;************************************************************************* +; $Header: /Alaska/SOURCE/Core/Modules/x64Core/x64AsmLib/MemSet.asm 1 10/01/10 5:08p Felixp $ +; +; $Revision: 1 $ +; +; $Date: 10/01/10 5:08p $ +;************************************************************************* +; Revision History +; ---------------- +; $Log: /Alaska/SOURCE/Core/Modules/x64Core/x64AsmLib/MemSet.asm $ +; +; 1 10/01/10 5:08p Felixp +; +; 1 8/24/06 12:57p Felixp +; +;************************************************************************* +;<AMI_FHDR_START> +; +; Name: +; +; Description: +; +;<AMI_FHDR_END> +;************************************************************************* +.code + +;************************************************************************* +;<AMI_PHDR_START> +; +; Name: MemSet +; +; Description: +; VOID MemSet(IN VOID *pBuffer, IN UINTN Count, IN UINT8 Value) fills Count +; bytes of memory in pBuffer with Value. +; +; Input: +; IN VOID *pBuffer +; The starting location in memory where to begin filling. +; +; IN UINTN Count +; The number of bytes to fill with Value. +; +; IN UINT8 Value +; The value to fill memory with starting at pBuffer. +; +; Output: +; VOID. +; +; Modified: +; +; Referrals: +; +; Notes: +; +;<AMI_PHDR_END> +;************************************************************************* +MemSet proc + push rdi + push rbx + mov rdi, rcx ; rdi = pBuffer + mov rcx, rdx ; rcx = Count + mov rax, r8 ; al = Value + ; fill EAX with the Value so that we can perform DWORD operatins + mov ah, al + mov bx,ax + shl rax,16 + mov ax,bx + ; if Counter is less then 4, jump to byte copy + cmp rcx, 4 + jb CopyByte + ; check if the Buffer is 4-bytes aligned + mov rdx,rdi + and rdx, 3 + ; if the Buffer is 4-bytes aligned, jump to DWORD copy + jz CopyDword + ; Buffer is not 4-bytes aligned + ; Calculate 4-(Buffer%4), which is a number of bytes we have to copy before + ; Buffer will reach 4-bytes boundary, and perform byte copy + neg rdx + add rdx, 4 + xchg rcx, rdx + sub rdx, rcx + rep stosb + mov rcx, rdx +CopyDword: + ; perform DWORD copy + mov rdx, rcx + shr rcx, 2 + rep stosd + ; copy the remainder + and rdx,3 + mov rcx, rdx +CopyByte: + rep stosb + ;;; + pop rbx + pop rdi + ret +MemSet endp + +END +;************************************************************************* +;************************************************************************* +;** ** +;** (C)Copyright 1985-2009, American Megatrends, Inc. ** +;** ** +;** All Rights Reserved. ** +;** ** +;** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +;** ** +;** Phone: (770)-246-8600 ** +;** ** +;************************************************************************* diff --git a/Core/CPU/x64/x64AsmLib/ReadCr3.asm b/Core/CPU/x64/x64AsmLib/ReadCr3.asm new file mode 100644 index 0000000..ad90c20 --- /dev/null +++ b/Core/CPU/x64/x64AsmLib/ReadCr3.asm @@ -0,0 +1,79 @@ +;************************************************************************* +;************************************************************************* +;** ** +;** (C)Copyright 1985-2009, American Megatrends, Inc. ** +;** ** +;** All Rights Reserved. ** +;** ** +;** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +;** ** +;** Phone: (770)-246-8600 ** +;** ** +;************************************************************************* +;************************************************************************* + +;************************************************************************* +; $Header: /Alaska/SOURCE/Core/Modules/x64Core/x64AsmLib/ReadCr3.asm 1 10/01/10 5:08p Felixp $ +; +; $Revision: 1 $ +; +; $Date: 10/01/10 5:08p $ +;************************************************************************* +; Revision History +; ---------------- +; $Log: /Alaska/SOURCE/Core/Modules/x64Core/x64AsmLib/ReadCr3.asm $ +; +; 1 10/01/10 5:08p Felixp +; +; 1 8/24/06 12:57p Felixp +; +;************************************************************************* +;<AMI_FHDR_START> +; +; Name: +; +; Description: +; +;<AMI_FHDR_END> +;************************************************************************* +.code + +;************************************************************************* +;<AMI_PHDR_START> +; +; Name: ReadCr3 +; +; Description: +; UINTN ReadCr3() reads the register CR3 and returns its value. +; +; Input: +; +; Output: +; UINTN value stored in the CR3 register. +; +; Modified: +; +; Referrals: +; +; Notes: +; +;<AMI_PHDR_END> +;************************************************************************* +ReadCr3 PROC PUBLIC + mov rax, cr3 + ret +ReadCr3 ENDP + +END +;************************************************************************* +;************************************************************************* +;** ** +;** (C)Copyright 1985-2009, American Megatrends, Inc. ** +;** ** +;** All Rights Reserved. ** +;** ** +;** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +;** ** +;** Phone: (770)-246-8600 ** +;** ** +;************************************************************************* diff --git a/Core/CPU/x64/x64AsmLib/ReadMsr.asm b/Core/CPU/x64/x64AsmLib/ReadMsr.asm new file mode 100644 index 0000000..3fbeff6 --- /dev/null +++ b/Core/CPU/x64/x64AsmLib/ReadMsr.asm @@ -0,0 +1,85 @@ +;************************************************************************* +;************************************************************************* +;** ** +;** (C)Copyright 1985-2009, American Megatrends, Inc. ** +;** ** +;** All Rights Reserved. ** +;** ** +;** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +;** ** +;** Phone: (770)-246-8600 ** +;** ** +;************************************************************************* +;************************************************************************* + +;************************************************************************* +; $Header: /Alaska/SOURCE/Core/Modules/x64Core/x64AsmLib/ReadMsr.asm 1 10/01/10 5:08p Felixp $ +; +; $Revision: 1 $ +; +; $Date: 10/01/10 5:08p $ +;************************************************************************* +; Revision History +; ---------------- +; $Log: /Alaska/SOURCE/Core/Modules/x64Core/x64AsmLib/ReadMsr.asm $ +; +; 1 10/01/10 5:08p Felixp +; +; 1 8/24/06 12:57p Felixp +; +;************************************************************************* +;<AMI_FHDR_START> +; +; Name: +; +; Description: +; +;<AMI_FHDR_END> +;************************************************************************* +.code + +;************************************************************************* +;<AMI_PHDR_START> +; +; Name: ReadMsr +; +; Description: +; UINT64 ReadMsr(UINT32 Msr) reads the CPU MSR index defined by Msr and +; returns the value. +; +; Input: +; IN UINT32 Msr +; 32-bit MSR index to be read. +; +; Output: +; UINT64 MSR value at MSR index, Msr. +; +; Modified: +; +; Referrals: +; +; Notes: +; +;<AMI_PHDR_END> +;************************************************************************* +ReadMsr Proc ;(UINT32 Msr) + rdmsr ;rcx = MSR + and rax, 0ffffffffh + shl rdx, 32 + or rax, rdx ;rax = (rdx << 32) | eax + ret +ReadMsr endp + +END +;************************************************************************* +;************************************************************************* +;** ** +;** (C)Copyright 1985-2009, American Megatrends, Inc. ** +;** ** +;** All Rights Reserved. ** +;** ** +;** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +;** ** +;** Phone: (770)-246-8600 ** +;** ** +;************************************************************************* diff --git a/Core/CPU/x64/x64AsmLib/ReadRtdsc.asm b/Core/CPU/x64/x64AsmLib/ReadRtdsc.asm new file mode 100644 index 0000000..078964c --- /dev/null +++ b/Core/CPU/x64/x64AsmLib/ReadRtdsc.asm @@ -0,0 +1,82 @@ +;************************************************************************* +;************************************************************************* +;** ** +;** (C)Copyright 1985-2009, American Megatrends, Inc. ** +;** ** +;** All Rights Reserved. ** +;** ** +;** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +;** ** +;** Phone: (770)-246-8600 ** +;** ** +;************************************************************************* +;************************************************************************* + +;************************************************************************* +; $Header: /Alaska/SOURCE/Core/Modules/x64Core/x64AsmLib/ReadRtdsc.asm 1 10/01/10 5:08p Felixp $ +; +; $Revision: 1 $ +; +; $Date: 10/01/10 5:08p $ +;************************************************************************* +; Revision History +; ---------------- +; $Log: /Alaska/SOURCE/Core/Modules/x64Core/x64AsmLib/ReadRtdsc.asm $ +; +; 1 10/01/10 5:08p Felixp +; +; 1 8/24/06 12:57p Felixp +; +;************************************************************************* +;<AMI_FHDR_START> +; +; Name: +; +; Description: +; +;<AMI_FHDR_END> +;************************************************************************* +.code + +;************************************************************************* +;<AMI_PHDR_START> +; +; Name: ReadRtdsc +; +; Description: +; UINT64 ReadRtdsc() retrieves the time stamp counter. +; +; Input: +; VOID. +; +; Output: +; UINT64 value of the time stamp counter. +; +; Modified: +; +; Referrals: +; +; Notes: +; +;<AMI_PHDR_END> +;************************************************************************* +ReadRtdsc Proc + rdtsc + shl rdx,32 + or rax, rdx + ret +ReadRtdsc endp + +END +;************************************************************************* +;************************************************************************* +;** ** +;** (C)Copyright 1985-2009, American Megatrends, Inc. ** +;** ** +;** All Rights Reserved. ** +;** ** +;** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +;** ** +;** Phone: (770)-246-8600 ** +;** ** +;************************************************************************* diff --git a/Core/CPU/x64/x64AsmLib/WaitForSemaphore.asm b/Core/CPU/x64/x64AsmLib/WaitForSemaphore.asm new file mode 100644 index 0000000..a5efa82 --- /dev/null +++ b/Core/CPU/x64/x64AsmLib/WaitForSemaphore.asm @@ -0,0 +1,88 @@ +;************************************************************************* +;************************************************************************* +;** ** +;** (C)Copyright 1985-2009, American Megatrends, Inc. ** +;** ** +;** All Rights Reserved. ** +;** ** +;** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +;** ** +;** Phone: (770)-246-8600 ** +;** ** +;************************************************************************* +;************************************************************************* + +;************************************************************************* +; $Header: /Alaska/SOURCE/Core/Modules/x64Core/x64AsmLib/WaitForSemaphore.asm 1 10/01/10 5:08p Felixp $ +; +; $Revision: 1 $ +; +; $Date: 10/01/10 5:08p $ +;************************************************************************* +; Revision History +; ---------------- +; $Log: /Alaska/SOURCE/Core/Modules/x64Core/x64AsmLib/WaitForSemaphore.asm $ +; +; 1 10/01/10 5:08p Felixp +; +; 1 8/24/06 12:57p Felixp +; +;************************************************************************* +;<AMI_FHDR_START> +; +; Name: +; +; Description: +; +;<AMI_FHDR_END> +;************************************************************************* +.code + +;************************************************************************* +;<AMI_PHDR_START> +; +; Name: WaitForSemaphore +; +; Description: +; VOID WaitForSemaphore(IN volatile UINT8 *Semaphore) waits for the +; semaphore to become available; once available, it claims the semaphore and +; returns. +; +; Input: +; IN volatile UINT8 *Semaphore +; Pointer to the desired semaphore. +; +; Output: +; VOID. +; +; Modified: +; +; Referrals: +; +; Notes: +; +;<AMI_PHDR_END> +;************************************************************************* +WaitForSemaphore Proc + mov al, 1 +@@: + xchg al, [rcx] + or al, al + pause + jnz @b + ret +WaitForSemaphore endp + +END +;************************************************************************* +;************************************************************************* +;** ** +;** (C)Copyright 1985-2009, American Megatrends, Inc. ** +;** ** +;** All Rights Reserved. ** +;** ** +;** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +;** ** +;** Phone: (770)-246-8600 ** +;** ** +;************************************************************************* diff --git a/Core/CPU/x64/x64AsmLib/WaitForever.asm b/Core/CPU/x64/x64AsmLib/WaitForever.asm new file mode 100644 index 0000000..c010643 --- /dev/null +++ b/Core/CPU/x64/x64AsmLib/WaitForever.asm @@ -0,0 +1,82 @@ +;************************************************************************* +;************************************************************************* +;** ** +;** (C)Copyright 1985-2009, American Megatrends, Inc. ** +;** ** +;** All Rights Reserved. ** +;** ** +;** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +;** ** +;** Phone: (770)-246-8600 ** +;** ** +;************************************************************************* +;************************************************************************* + +;************************************************************************* +; $Header: /Alaska/SOURCE/Core/Modules/x64Core/x64AsmLib/WaitForever.asm 1 10/01/10 5:08p Felixp $ +; +; $Revision: 1 $ +; +; $Date: 10/01/10 5:08p $ +;************************************************************************* +; Revision History +; ---------------- +; $Log: /Alaska/SOURCE/Core/Modules/x64Core/x64AsmLib/WaitForever.asm $ +; +; 1 10/01/10 5:08p Felixp +; +; 1 8/24/06 12:57p Felixp +; +;************************************************************************* +;<AMI_FHDR_START> +; +; Name: +; +; Description: +; +;<AMI_FHDR_END> +;************************************************************************* +.code + +;************************************************************************* +;<AMI_PHDR_START> +; +; Name: WaitForever +; +; Description: +; VOID WaitForever() performs an infinite loop which does nothing. +; +; Input: +; VOID. +; +; Output: +; VOID. +; +; Modified: +; +; Referrals: +; +; Notes: +; +;<AMI_PHDR_END> +;************************************************************************* +WaitForever Proc +@@: + Pause + jmp @b + ret +WaitForever endp + +END +;************************************************************************* +;************************************************************************* +;** ** +;** (C)Copyright 1985-2009, American Megatrends, Inc. ** +;** ** +;** All Rights Reserved. ** +;** ** +;** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +;** ** +;** Phone: (770)-246-8600 ** +;** ** +;************************************************************************* diff --git a/Core/CPU/x64/x64AsmLib/WaitUntilZero32.asm b/Core/CPU/x64/x64AsmLib/WaitUntilZero32.asm new file mode 100644 index 0000000..cdda323 --- /dev/null +++ b/Core/CPU/x64/x64AsmLib/WaitUntilZero32.asm @@ -0,0 +1,86 @@ +;************************************************************************* +;************************************************************************* +;** ** +;** (C)Copyright 1985-2009, American Megatrends, Inc. ** +;** ** +;** All Rights Reserved. ** +;** ** +;** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +;** ** +;** Phone: (770)-246-8600 ** +;** ** +;************************************************************************* +;************************************************************************* + +;************************************************************************* +; $Header: /Alaska/SOURCE/Core/Modules/x64Core/x64AsmLib/WaitUntilZero32.asm 1 10/01/10 5:08p Felixp $ +; +; $Revision: 1 $ +; +; $Date: 10/01/10 5:08p $ +;************************************************************************* +; Revision History +; ---------------- +; $Log: /Alaska/SOURCE/Core/Modules/x64Core/x64AsmLib/WaitUntilZero32.asm $ +; +; 1 10/01/10 5:08p Felixp +; +; 1 8/24/06 12:57p Felixp +; +;************************************************************************* +;<AMI_FHDR_START> +; +; Name: +; +; Description: +; +;<AMI_FHDR_END> +;************************************************************************* +.code + +;************************************************************************* +;<AMI_PHDR_START> +; +; Name: WaitUntilZero32 +; +; Description: +; VOID WaitUntilZero32(IN volatile UINT32 *Value) waits until the UINT32 +; value stored at the Value address becomes 0, then continues. +; +; Input: +; IN volatile UINT32 *Value +; Address of the UINT32 value to be monitored. +; +; Output: +; VOID. +; +; Modified: +; +; Referrals: +; +; Notes: +; +;<AMI_PHDR_END> +;************************************************************************* +WaitUntilZero32 Proc +@@: + mov eax, [rcx] + or eax, eax + pause + jnz @b + ret +WaitUntilZero32 endp + +END +;************************************************************************* +;************************************************************************* +;** ** +;** (C)Copyright 1985-2009, American Megatrends, Inc. ** +;** ** +;** All Rights Reserved. ** +;** ** +;** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +;** ** +;** Phone: (770)-246-8600 ** +;** ** +;************************************************************************* diff --git a/Core/CPU/x64/x64AsmLib/WaitUntilZero8.asm b/Core/CPU/x64/x64AsmLib/WaitUntilZero8.asm new file mode 100644 index 0000000..b2c5f4d --- /dev/null +++ b/Core/CPU/x64/x64AsmLib/WaitUntilZero8.asm @@ -0,0 +1,86 @@ +;************************************************************************* +;************************************************************************* +;** ** +;** (C)Copyright 1985-2009, American Megatrends, Inc. ** +;** ** +;** All Rights Reserved. ** +;** ** +;** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +;** ** +;** Phone: (770)-246-8600 ** +;** ** +;************************************************************************* +;************************************************************************* + +;************************************************************************* +; $Header: /Alaska/SOURCE/Core/Modules/x64Core/x64AsmLib/WaitUntilZero8.asm 1 10/01/10 5:08p Felixp $ +; +; $Revision: 1 $ +; +; $Date: 10/01/10 5:08p $ +;************************************************************************* +; Revision History +; ---------------- +; $Log: /Alaska/SOURCE/Core/Modules/x64Core/x64AsmLib/WaitUntilZero8.asm $ +; +; 1 10/01/10 5:08p Felixp +; +; 1 8/24/06 12:57p Felixp +; +;************************************************************************* +;<AMI_FHDR_START> +; +; Name: +; +; Description: +; +;<AMI_FHDR_END> +;************************************************************************* +.code + +;************************************************************************* +;<AMI_PHDR_START> +; +; Name: WaitUntilZero8 +; +; Description: +; VOID WaitUntilZero8(IN volatile UINT8 *Value) waits until the byte stored +; at Value becomes 0, then continues. +; +; Input: +; IN volatile UINT8 *Value +; Address of the byte value to be monitored. +; +; Output: +; VOID. +; +; Modified: +; +; Referrals: +; +; Notes: +; +;<AMI_PHDR_END> +;************************************************************************* +WaitUntilZero8 Proc +@@: + mov al, [rcx] + or al, al + pause + jnz @b + ret +WaitUntilZero8 endp + +END +;************************************************************************* +;************************************************************************* +;** ** +;** (C)Copyright 1985-2009, American Megatrends, Inc. ** +;** ** +;** All Rights Reserved. ** +;** ** +;** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +;** ** +;** Phone: (770)-246-8600 ** +;** ** +;************************************************************************* diff --git a/Core/CPU/x64/x64AsmLib/WriteCr3.asm b/Core/CPU/x64/x64AsmLib/WriteCr3.asm new file mode 100644 index 0000000..d028b07 --- /dev/null +++ b/Core/CPU/x64/x64AsmLib/WriteCr3.asm @@ -0,0 +1,81 @@ +;************************************************************************* +;************************************************************************* +;** ** +;** (C)Copyright 1985-2009, American Megatrends, Inc. ** +;** ** +;** All Rights Reserved. ** +;** ** +;** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +;** ** +;** Phone: (770)-246-8600 ** +;** ** +;************************************************************************* +;************************************************************************* + +;************************************************************************* +; $Header: /Alaska/SOURCE/Core/Modules/x64Core/x64AsmLib/WriteCr3.asm 1 10/01/10 5:08p Felixp $ +; +; $Revision: 1 $ +; +; $Date: 10/01/10 5:08p $ +;************************************************************************* +; Revision History +; ---------------- +; $Log: /Alaska/SOURCE/Core/Modules/x64Core/x64AsmLib/WriteCr3.asm $ +; +; 1 10/01/10 5:08p Felixp +; +; 1 8/24/06 12:57p Felixp +; +;************************************************************************* +;<AMI_FHDR_START> +; +; Name: +; +; Description: +; +;<AMI_FHDR_END> +;************************************************************************* +.code + +;************************************************************************* +;<AMI_PHDR_START> +; +; Name: WriteCr3 +; +; Description: +; VOID WriteCr3(IN UINTN CR3) writes the provided value to the CR3 register. +; +; Input: +; IN UINTN CR3 +; Value to be written to the CR3 register. +; +; Output: +; VOID. +; +; Modified: +; +; Referrals: +; +; Notes: +; +;<AMI_PHDR_END> +;************************************************************************* +WriteCr3 PROC PUBLIC + mov cr3, rcx + ret +WriteCr3 ENDP + +END +;************************************************************************* +;************************************************************************* +;** ** +;** (C)Copyright 1985-2009, American Megatrends, Inc. ** +;** ** +;** All Rights Reserved. ** +;** ** +;** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +;** ** +;** Phone: (770)-246-8600 ** +;** ** +;************************************************************************* diff --git a/Core/CPU/x64/x64AsmLib/WriteMsr.asm b/Core/CPU/x64/x64AsmLib/WriteMsr.asm new file mode 100644 index 0000000..b181a5b --- /dev/null +++ b/Core/CPU/x64/x64AsmLib/WriteMsr.asm @@ -0,0 +1,89 @@ +;************************************************************************* +;************************************************************************* +;** ** +;** (C)Copyright 1985-2009, American Megatrends, Inc. ** +;** ** +;** All Rights Reserved. ** +;** ** +;** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +;** ** +;** Phone: (770)-246-8600 ** +;** ** +;************************************************************************* +;************************************************************************* + +;************************************************************************* +; $Header: /Alaska/SOURCE/Core/Modules/x64Core/x64AsmLib/WriteMsr.asm 1 10/01/10 5:08p Felixp $ +; +; $Revision: 1 $ +; +; $Date: 10/01/10 5:08p $ +;************************************************************************* +; Revision History +; ---------------- +; $Log: /Alaska/SOURCE/Core/Modules/x64Core/x64AsmLib/WriteMsr.asm $ +; +; 1 10/01/10 5:08p Felixp +; +; 1 8/24/06 12:57p Felixp +; +;************************************************************************* +;<AMI_FHDR_START> +; +; Name: +; +; Description: +; +;<AMI_FHDR_END> +;************************************************************************* +.code + +;************************************************************************* +;<AMI_PHDR_START> +; +; Name: WriteMsr +; +; Description: +; VOID WriteMsr(IN UINT32 Msr, IN UINT64 Value) writes the Value to the +; supplied MSR index, Msr. +; +; Input: +; IN UINT32 Msr +; 32-bit MSR index to be written to. +; +; IN UINT64 Value +; Value to be written to MSR index. +; +; Output: +; VOID. +; +; Modified: +; +; Referrals: +; +; Notes: +; +;<AMI_PHDR_END> +;************************************************************************* +WriteMsr proc + ;rcx = MSR + mov rax, rdx ;rax = rdx = Value + and rax, 0ffffffffh ;Lower 32 bit MSR Value + shr rdx, 32 ;Upper 32 bit MSR Value + wrmsr + ret +WriteMsr endp + +END +;************************************************************************* +;************************************************************************* +;** ** +;** (C)Copyright 1985-2009, American Megatrends, Inc. ** +;** ** +;** All Rights Reserved. ** +;** ** +;** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +;** ** +;** Phone: (770)-246-8600 ** +;** ** +;************************************************************************* diff --git a/Core/CPU/x64/x64AsmLib/checkpoint.asm b/Core/CPU/x64/x64AsmLib/checkpoint.asm new file mode 100644 index 0000000..38edb52 --- /dev/null +++ b/Core/CPU/x64/x64AsmLib/checkpoint.asm @@ -0,0 +1,84 @@ +;************************************************************************* +;************************************************************************* +;** ** +;** (C)Copyright 1985-2009, American Megatrends, Inc. ** +;** ** +;** All Rights Reserved. ** +;** ** +;** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +;** ** +;** Phone: (770)-246-8600 ** +;** ** +;************************************************************************* +;************************************************************************* + +;************************************************************************* +; $Header: /Alaska/SOURCE/Core/Modules/x64Core/x64AsmLib/checkpoint.asm 1 10/01/10 5:07p Felixp $ +; +; $Revision: 1 $ +; +; $Date: 10/01/10 5:07p $ +;************************************************************************* +; Revision History +; ---------------- +; $Log: /Alaska/SOURCE/Core/Modules/x64Core/x64AsmLib/checkpoint.asm $ +; +; 1 10/01/10 5:07p Felixp +; +; 1 8/24/06 12:57p Felixp +; +;************************************************************************* +;<AMI_FHDR_START> +; +; Name: +; +; Description: +; +;<AMI_FHDR_END> +;************************************************************************* +.code + +;************************************************************************* +;<AMI_PHDR_START> +; +; Name: checkpoint +; +; Description: +; VOID checkpoint(IN UINT8 c) writes the value c to port 0x80. +; +; Input: +; IN UINT8 c +; The value/checkpoint to write to 0x80. +; +; Output: +; VOID. +; +; Modified: +; +; Referrals: +; +; Notes: +; This routine should only be used if the PROGRESS_CODE or +; PEI_PROGRESS_CODE macros are unavailable. +; +;<AMI_PHDR_END> +;************************************************************************* +checkpoint proc + mov al, cl + out 80h,al + ret +checkpoint endp + +END +;************************************************************************* +;************************************************************************* +;** ** +;** (C)Copyright 1985-2009, American Megatrends, Inc. ** +;** ** +;** All Rights Reserved. ** +;** ** +;** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +;** ** +;** Phone: (770)-246-8600 ** +;** ** +;************************************************************************* |