Import some basic libraries instances for Mde Packages.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2704 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
vanjeff
2007-06-22 03:21:45 +00:00
parent e053747a04
commit e1f414b6a7
506 changed files with 45626 additions and 0 deletions

View File

@@ -0,0 +1,46 @@
//
// Include common header file for this module.
//
#include "CommonHeader.h"
#------------------------------------------------------------------------------
#
# Copyright (c) 2006, Intel Corporation
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
# Module Name:
#
# ARShiftU64.asm
#
# Abstract:
#
# 64-bit arithmetic right shift function for IA-32
#
#------------------------------------------------------------------------------
.globl ASM_PFX(InternalMathARShiftU64)
#------------------------------------------------------------------------------
# UINT64
# EFIAPI
# InternalMathARShiftU64 (
# IN UINT64 Operand,
# IN UINTN Count
# );
#------------------------------------------------------------------------------
ASM_PFX(InternalMathARShiftU64):
movb 12(%esp), %cl
movl 8(%esp), %eax
cltd
testb $32, %cl
cmovz %eax, %edx
cmovz 4(%esp), %eax
shrdl %cl, %edx, %eax
sar %cl, %edx
ret

View File

@@ -0,0 +1,46 @@
;------------------------------------------------------------------------------
;
; Copyright (c) 2006, Intel Corporation
; All rights reserved. This program and the accompanying materials
; are licensed and made available under the terms and conditions of the BSD License
; which accompanies this distribution. The full text of the license may be found at
; http://opensource.org/licenses/bsd-license.php
;
; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
;
; Module Name:
;
; ARShiftU64.asm
;
; Abstract:
;
; 64-bit arithmetic right shift function for IA-32
;
;------------------------------------------------------------------------------
.686
.model flat,C
.code
;------------------------------------------------------------------------------
; UINT64
; EFIAPI
; InternalMathARShiftU64 (
; IN UINT64 Operand,
; IN UINTN Count
; );
;------------------------------------------------------------------------------
InternalMathARShiftU64 PROC
mov cl, [esp + 12]
mov eax, [esp + 8]
cdq
test cl, 32
cmovz edx, eax
cmovz eax, [esp + 4]
shrd eax, edx, cl
sar edx, cl
ret
InternalMathARShiftU64 ENDP
END

View File

@@ -0,0 +1,38 @@
/** @file
64-bit arithmetic right shift function for IA-32.
Copyright (c) 2006 - 2007, Intel Corporation<BR>
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
//
// Include common header file for this module.
//
#include "CommonHeader.h"
UINT64
EFIAPI
InternalMathARShiftU64 (
IN UINT64 Operand,
IN UINTN Count
)
{
_asm {
mov cl, byte ptr [Count]
mov eax, dword ptr [Operand + 4]
cdq
test cl, 32
cmovz edx, eax
cmovz eax, dword ptr [Operand + 0]
shrd eax, edx, cl
sar edx, cl
}
}

View File

@@ -0,0 +1,39 @@
//
// Include common header file for this module.
//
#include "CommonHeader.h"
#------------------------------------------------------------------------------ ;
# Copyright (c) 2006, Intel Corporation
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
# Module Name:
#
# CpuBreakpoint.s
#
# Abstract:
#
# CpuBreakpoint function
#
# Notes:
#
#------------------------------------------------------------------------------
.globl ASM_PFX(CpuBreakpoint)
#------------------------------------------------------------------------------
# VOID
# EFIAPI
# CpuBreakpoint (
# VOID
# );
#------------------------------------------------------------------------------
ASM_PFX(CpuBreakpoint):
int $3
ret

View File

@@ -0,0 +1,40 @@
;------------------------------------------------------------------------------ ;
; Copyright (c) 2006, Intel Corporation
; All rights reserved. This program and the accompanying materials
; are licensed and made available under the terms and conditions of the BSD License
; which accompanies this distribution. The full text of the license may be found at
; http://opensource.org/licenses/bsd-license.php
;
; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
;
; Module Name:
;
; CpuBreakpoint.Asm
;
; Abstract:
;
; CpuBreakpoint function
;
; Notes:
;
;------------------------------------------------------------------------------
.686
.model flat
.xmm
.code
;------------------------------------------------------------------------------
; VOID
; EFIAPI
; CpuBreakpoint (
; VOID
; );
;------------------------------------------------------------------------------
_CpuBreakpoint PROC
int 3
ret
_CpuBreakpoint ENDP
END

View File

@@ -0,0 +1,35 @@
/** @file
CpuBreakpoint function.
Copyright (c) 2006 - 2007, Intel Corporation<BR>
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
//
// Include common header file for this module.
//
#include "CommonHeader.h"
//
// Microsoft Visual Studio 7.1 Function Prototypes for I/O Intrinsics
//
void __debugbreak ();
#pragma intrinsic(__debugbreak)
VOID
EFIAPI
CpuBreakpoint (
VOID
)
{
__debugbreak ();
}

View File

@@ -0,0 +1,40 @@
//
// Include common header file for this module.
//
#include "CommonHeader.h"
#------------------------------------------------------------------------------ ;
# Copyright (c) 2006, Intel Corporation
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
# Module Name:
#
# CpuFlushTlb.Asm
#
# Abstract:
#
# CpuFlushTlb function
#
# Notes:
#
#------------------------------------------------------------------------------
.globl ASM_PFX(CpuFlushTlb)
#------------------------------------------------------------------------------
# VOID
# EFIAPI
# CpuFlushTlb (
# VOID
# );
#------------------------------------------------------------------------------
ASM_PFX(CpuFlushTlb):
movl %cr3, %eax
movl %eax, %cr3
ret

View File

@@ -0,0 +1,40 @@
;------------------------------------------------------------------------------ ;
; Copyright (c) 2006, Intel Corporation
; All rights reserved. This program and the accompanying materials
; are licensed and made available under the terms and conditions of the BSD License
; which accompanies this distribution. The full text of the license may be found at
; http://opensource.org/licenses/bsd-license.php
;
; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
;
; Module Name:
;
; CpuFlushTlb.Asm
;
; Abstract:
;
; CpuFlushTlb function
;
; Notes:
;
;------------------------------------------------------------------------------
.386p
.model flat,C
.code
;------------------------------------------------------------------------------
; VOID
; EFIAPI
; CpuFlushTlb (
; VOID
; );
;------------------------------------------------------------------------------
CpuFlushTlb PROC
mov eax, cr3
mov cr3, eax ; moving to CR3 flushes TLB
ret
CpuFlushTlb ENDP
END

View File

@@ -0,0 +1,31 @@
/** @file
CpuFlushTlb function.
Copyright (c) 2006 - 2007, Intel Corporation<BR>
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
//
// Include common header file for this module.
//
#include "CommonHeader.h"
VOID
EFIAPI
CpuFlushTlb (
VOID
)
{
_asm {
mov eax, cr3
mov cr3, eax
}
}

View File

@@ -0,0 +1,68 @@
//
// Include common header file for this module.
//
#include "CommonHeader.h"
#------------------------------------------------------------------------------
#
# Copyright (c) 2006, Intel Corporation
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
# Module Name:
#
# CpuId.Asm
#
# Abstract:
#
# AsmCpuid function
#
# Notes:
#
#------------------------------------------------------------------------------
.globl ASM_PFX(AsmCpuid)
#------------------------------------------------------------------------------
# VOID
# EFIAPI
# AsmCpuid (
# IN UINT32 RegisterInEax,
# OUT UINT32 *RegisterOutEax OPTIONAL,
# OUT UINT32 *RegisterOutEbx OPTIONAL,
# OUT UINT32 *RegisterOutEcx OPTIONAL,
# OUT UINT32 *RegisterOutEdx OPTIONAL
# )
#------------------------------------------------------------------------------
ASM_PFX(AsmCpuid):
push %ebx
push %ebp
movl %esp, %ebp
movl 12(%ebp), %eax
cpuid
push %ecx
movl 16(%ebp), %ecx
jecxz L1
movl %eax, (%ecx)
L1:
movl 20(%ebp), %ecx
jecxz L2
movl %ebx, (%ecx)
L2:
movl 24(%ebp), %ecx
jecxz L3
popl (%ecx)
L3:
movl 28(%ebp), %ecx
jecxz L4
movl %edx, (%ecx)
L4:
movl 12(%ebp), %eax
leave
pop %ebx
ret

View File

@@ -0,0 +1,66 @@
;------------------------------------------------------------------------------
;
; Copyright (c) 2006, Intel Corporation
; All rights reserved. This program and the accompanying materials
; are licensed and made available under the terms and conditions of the BSD License
; which accompanies this distribution. The full text of the license may be found at
; http://opensource.org/licenses/bsd-license.php
;
; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
;
; Module Name:
;
; CpuId.Asm
;
; Abstract:
;
; AsmCpuid function
;
; Notes:
;
;------------------------------------------------------------------------------
.586P
.model flat,C
.code
;------------------------------------------------------------------------------
; VOID
; EFIAPI
; AsmCpuid (
; IN UINT32 RegisterInEax,
; OUT UINT32 *RegisterOutEax OPTIONAL,
; OUT UINT32 *RegisterOutEbx OPTIONAL,
; OUT UINT32 *RegisterOutEcx OPTIONAL,
; OUT UINT32 *RegisterOutEdx OPTIONAL
; );
;------------------------------------------------------------------------------
AsmCpuid PROC USES ebx
push ebp
mov ebp, esp
mov eax, [ebp + 12]
cpuid
push ecx
mov ecx, [ebp + 16]
jecxz @F
mov [ecx], eax
@@:
mov ecx, [ebp + 20]
jecxz @F
mov [ecx], ebx
@@:
mov ecx, [ebp + 24]
jecxz @F
pop [ecx]
@@:
mov ecx, [ebp + 28]
jecxz @F
mov [ecx], edx
@@:
mov eax, [ebp + 12]
leave
ret
AsmCpuid ENDP
END

View File

@@ -0,0 +1,54 @@
/** @file
AsmCpuid function.
Copyright (c) 2006 - 2007, Intel Corporation<BR>
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
//
// Include common header file for this module.
//
#include "CommonHeader.h"
UINT32
EFIAPI
AsmCpuid (
IN UINT32 Index,
OUT UINT32 *RegisterEax, OPTIONAL
OUT UINT32 *RegisterEbx, OPTIONAL
OUT UINT32 *RegisterEcx, OPTIONAL
OUT UINT32 *RegisterEdx OPTIONAL
)
{
_asm {
mov eax, Index
cpuid
push ecx
mov ecx, RegisterEax
jecxz SkipEax
mov [ecx], eax
SkipEax:
mov ecx, RegisterEbx
jecxz SkipEbx
mov [ecx], ebx
SkipEbx:
pop eax
mov ecx, RegisterEcx
jecxz SkipEcx
mov [ecx], eax
SkipEcx:
mov ecx, RegisterEdx
jecxz SkipEdx
mov [ecx], edx
SkipEdx:
mov eax, Index
}
}

View File

@@ -0,0 +1,72 @@
//
// Include common header file for this module.
//
#include "CommonHeader.h"
#------------------------------------------------------------------------------
#
# Copyright (c) 2006, Intel Corporation
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
# Module Name:
#
# CpuIdEx.Asm
#
# Abstract:
#
# AsmCpuidEx function
#
# Notes:
#
#------------------------------------------------------------------------------
.686:
.code:
#------------------------------------------------------------------------------
# UINT32
# EFIAPI
# AsmCpuidEx (
# IN UINT32 RegisterInEax,
# IN UINT32 RegisterInEcx,
# OUT UINT32 *RegisterOutEax OPTIONAL,
# OUT UINT32 *RegisterOutEbx OPTIONAL,
# OUT UINT32 *RegisterOutEcx OPTIONAL,
# OUT UINT32 *RegisterOutEdx OPTIONAL
# )
#------------------------------------------------------------------------------
.globl ASM_PFX(AsmCpuidEx)
ASM_PFX(AsmCpuidEx):
push %ebx
push %ebp
movl %esp, %ebp
movl 12(%ebp), %eax
movl 16(%ebp), %ecx
cpuid
push %ecx
movl 20(%ebp), %ecx
jecxz L1
movl %eax, (%ecx)
L1:
movl 24(%ebp), %ecx
jecxz L2
movl %ebx, (%ecx)
L2:
movl 28(%ebp), %ecx
jecxz L3
popl (%ecx)
L3:
movl 32(%ebp), %edx
jecxz L4
movl %edx, (%ecx)
L4:
movl 12(%ebp), %eax
leave
pop %ebx
ret

View File

@@ -0,0 +1,68 @@
;------------------------------------------------------------------------------
;
; Copyright (c) 2006, Intel Corporation
; All rights reserved. This program and the accompanying materials
; are licensed and made available under the terms and conditions of the BSD License
; which accompanies this distribution. The full text of the license may be found at
; http://opensource.org/licenses/bsd-license.php
;
; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
;
; Module Name:
;
; CpuIdEx.Asm
;
; Abstract:
;
; AsmCpuidEx function
;
; Notes:
;
;------------------------------------------------------------------------------
.686
.model flat,C
.code
;------------------------------------------------------------------------------
; UINT32
; EFIAPI
; AsmCpuidEx (
; IN UINT32 RegisterInEax,
; IN UINT32 RegisterInEcx,
; OUT UINT32 *RegisterOutEax OPTIONAL,
; OUT UINT32 *RegisterOutEbx OPTIONAL,
; OUT UINT32 *RegisterOutEcx OPTIONAL,
; OUT UINT32 *RegisterOutEdx OPTIONAL
; )
;------------------------------------------------------------------------------
AsmCpuidEx PROC USES ebx
push ebp
mov ebp, esp
mov eax, [ebp + 12]
mov ecx, [ebp + 16]
cpuid
push ecx
mov ecx, [ebp + 20]
jecxz @F
mov [ecx], eax
@@:
mov ecx, [ebp + 24]
jecxz @F
mov [ecx], ebx
@@:
mov ecx, [ebp + 28]
jecxz @F
pop [ecx]
@@:
mov edx, [ebp + 32]
jecxz @F
mov [ecx], edx
@@:
mov eax, [ebp + 12]
leave
ret
AsmCpuidEx ENDP
END

View File

@@ -0,0 +1,55 @@
/** @file
AsmCpuidEx function.
Copyright (c) 2006 - 2007, Intel Corporation<BR>
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
//
// Include common header file for this module.
//
#include "CommonHeader.h"
UINT32
EFIAPI
AsmCpuidEx (
IN UINT32 Index,
IN UINT32 SubIndex,
OUT UINT32 *RegisterEax, OPTIONAL
OUT UINT32 *RegisterEbx, OPTIONAL
OUT UINT32 *RegisterEcx, OPTIONAL
OUT UINT32 *RegisterEdx OPTIONAL
)
{
_asm {
mov eax, Index
mov ecx, SubIndex
cpuid
push ecx
mov ecx, RegisterEax
jecxz SkipEax
mov [ecx], eax
SkipEax:
mov ecx, RegisterEbx
jecxz SkipEbx
mov [ecx], ebx
SkipEbx:
pop eax
mov ecx, RegisterEcx
jecxz SkipEcx
mov [ecx], eax
SkipEcx:
mov ecx, RegisterEdx
jecxz SkipEdx
mov [ecx], edx
SkipEdx:
mov eax, Index
}
}

View File

@@ -0,0 +1,39 @@
//
// Include common header file for this module.
//
#include "CommonHeader.h"
#------------------------------------------------------------------------------ ;
# Copyright (c) 2006, Intel Corporation
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
# Module Name:
#
# CpuPause.Asm
#
# Abstract:
#
# CpuPause function
#
# Notes:
#
#------------------------------------------------------------------------------
.globl ASM_PFX(CpuPause)
#------------------------------------------------------------------------------
# VOID
# EFIAPI
# CpuPause (
# VOID
# );
#------------------------------------------------------------------------------
ASM_PFX(CpuPause):
pause
ret

View File

@@ -0,0 +1,40 @@
;------------------------------------------------------------------------------ ;
; Copyright (c) 2006, Intel Corporation
; All rights reserved. This program and the accompanying materials
; are licensed and made available under the terms and conditions of the BSD License
; which accompanies this distribution. The full text of the license may be found at
; http://opensource.org/licenses/bsd-license.php
;
; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
;
; Module Name:
;
; CpuPause.Asm
;
; Abstract:
;
; CpuPause function
;
; Notes:
;
;------------------------------------------------------------------------------
.686
.model flat,C
.xmm
.code
;------------------------------------------------------------------------------
; VOID
; EFIAPI
; CpuPause (
; VOID
; );
;------------------------------------------------------------------------------
CpuPause PROC
pause
ret
CpuPause ENDP
END

View File

@@ -0,0 +1,30 @@
/** @file
CpuPause function.
Copyright (c) 2006 - 2007, Intel Corporation<BR>
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
//
// Include common header file for this module.
//
#include "CommonHeader.h"
VOID
EFIAPI
CpuPause (
VOID
)
{
_asm {
pause
}
}

View File

@@ -0,0 +1,39 @@
//
// Include common header file for this module.
//
#include "CommonHeader.h"
#------------------------------------------------------------------------------ ;
# Copyright (c) 2006, Intel Corporation
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
# Module Name:
#
# CpuSleep.Asm
#
# Abstract:
#
# CpuSleep function
#
# Notes:
#
#------------------------------------------------------------------------------
.globl ASM_PFX(CpuSleep)
#------------------------------------------------------------------------------
# VOID
# EFIAPI
# CpuSleep (
# VOID
# );
#------------------------------------------------------------------------------
ASM_PFX(CpuSleep):
hlt
ret

View File

@@ -0,0 +1,39 @@
;------------------------------------------------------------------------------ ;
; Copyright (c) 2006, Intel Corporation
; All rights reserved. This program and the accompanying materials
; are licensed and made available under the terms and conditions of the BSD License
; which accompanies this distribution. The full text of the license may be found at
; http://opensource.org/licenses/bsd-license.php
;
; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
;
; Module Name:
;
; CpuSleep.Asm
;
; Abstract:
;
; CpuSleep function
;
; Notes:
;
;------------------------------------------------------------------------------
.386
.model flat,C
.code
;------------------------------------------------------------------------------
; VOID
; EFIAPI
; CpuSleep (
; VOID
; );
;------------------------------------------------------------------------------
CpuSleep PROC
hlt
ret
CpuSleep ENDP
END

View File

@@ -0,0 +1,30 @@
/** @file
CpuSleep function.
Copyright (c) 2006 - 2007, Intel Corporation<BR>
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
//
// Include common header file for this module.
//
#include "CommonHeader.h"
VOID
EFIAPI
CpuSleep (
VOID
)
{
_asm {
hlt
}
}

View File

@@ -0,0 +1,40 @@
//
// Include common header file for this module.
//
#include "CommonHeader.h"
#------------------------------------------------------------------------------
#
# Copyright (c) 2006, Intel Corporation
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
# Module Name:
#
# DisableInterrupts.Asm
#
# Abstract:
#
# DisableInterrupts function
#
# Notes:
#
#------------------------------------------------------------------------------
.globl ASM_PFX(DisableInterrupts)
#------------------------------------------------------------------------------
# VOID
# EFIAPI
# DisableInterrupts (
# VOID
# );
#------------------------------------------------------------------------------
ASM_PFX(DisableInterrupts):
cli
ret

View File

@@ -0,0 +1,40 @@
;------------------------------------------------------------------------------
;
; Copyright (c) 2006, Intel Corporation
; All rights reserved. This program and the accompanying materials
; are licensed and made available under the terms and conditions of the BSD License
; which accompanies this distribution. The full text of the license may be found at
; http://opensource.org/licenses/bsd-license.php
;
; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
;
; Module Name:
;
; DisableInterrupts.Asm
;
; Abstract:
;
; DisableInterrupts function
;
; Notes:
;
;------------------------------------------------------------------------------
.386p
.model flat,C
.code
;------------------------------------------------------------------------------
; VOID
; EFIAPI
; DisableInterrupts (
; VOID
; );
;------------------------------------------------------------------------------
DisableInterrupts PROC
cli
ret
DisableInterrupts ENDP
END

View File

@@ -0,0 +1,30 @@
/** @file
DisableInterrupts function.
Copyright (c) 2006 - 2007, Intel Corporation<BR>
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
//
// Include common header file for this module.
//
#include "CommonHeader.h"
VOID
EFIAPI
DisableInterrupts (
VOID
)
{
_asm {
cli
}
}

View File

@@ -0,0 +1,57 @@
//
// Include common header file for this module.
//
#include "CommonHeader.h"
#------------------------------------------------------------------------------
#
# Copyright (c) 2006, Intel Corporation
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
# Module Name:
#
# DisablePaging32.Asm
#
# Abstract:
#
# InternalX86DisablePaging32 function
#
# Notes:
#
#------------------------------------------------------------------------------
.globl ASM_PFX(InternalX86DisablePaging32)
#------------------------------------------------------------------------------
# VOID
# EFIAPI
# InternalX86DisablePaging32 (
# IN SWITCH_STACK_ENTRY_POINT EntryPoint,
# IN VOID *Context1, OPTIONAL
# IN VOID *Context2, OPTIONAL
# IN VOID *NewStack
# );
#------------------------------------------------------------------------------
ASM_PFX(InternalX86DisablePaging32):
movl 4(%esp), %ebx
movl 8(%esp), %ecx
movl 12(%esp), %edx
pushfl
pop %edi
cli
movl %cr0, %eax
btrl $31, %eax
movl 16(%esp), %esp
movl %eax, %cr0
push %edi
popfl
push %edx
push %ecx
call *%ebx
jmp .

View File

@@ -0,0 +1,57 @@
;------------------------------------------------------------------------------
;
; Copyright (c) 2006, Intel Corporation
; All rights reserved. This program and the accompanying materials
; are licensed and made available under the terms and conditions of the BSD License
; which accompanies this distribution. The full text of the license may be found at
; http://opensource.org/licenses/bsd-license.php
;
; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
;
; Module Name:
;
; DisablePaging32.Asm
;
; Abstract:
;
; AsmDisablePaging32 function
;
; Notes:
;
;------------------------------------------------------------------------------
.386
.model flat,C
.code
;------------------------------------------------------------------------------
; VOID
; EFIAPI
; InternalX86DisablePaging32 (
; IN SWITCH_STACK_ENTRY_POINT EntryPoint,
; IN VOID *Context1, OPTIONAL
; IN VOID *Context2, OPTIONAL
; IN VOID *NewStack
; );
;------------------------------------------------------------------------------
InternalX86DisablePaging32 PROC
mov ebx, [esp + 4]
mov ecx, [esp + 8]
mov edx, [esp + 12]
pushfd
pop edi ; save EFLAGS to edi
cli
mov eax, cr0
btr eax, 31
mov esp, [esp + 16]
mov cr0, eax
push edi
popfd ; restore EFLAGS from edi
push edx
push ecx
call ebx
jmp $ ; EntryPoint() should not return
InternalX86DisablePaging32 ENDP
END

View File

@@ -0,0 +1,51 @@
/** @file
AsmDisablePaging32 function.
Copyright (c) 2006 - 2007, Intel Corporation<BR>
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
//
// Include common header file for this module.
//
#include "CommonHeader.h"
__declspec (naked)
VOID
EFIAPI
InternalX86DisablePaging32 (
IN SWITCH_STACK_ENTRY_POINT EntryPoint,
IN VOID *Context1, OPTIONAL
IN VOID *Context2, OPTIONAL
IN VOID *NewStack
)
{
_asm {
push ebp
mov ebp, esp
mov ebx, EntryPoint
mov ecx, Context1
mov edx, Context2
pushfd
pop edi // save EFLAGS to edi
cli
mov eax, cr0
btr eax, 31
mov esp, NewStack
mov cr0, eax
push edi
popfd // restore EFLAGS from edi
push edx
push ecx
call ebx
jmp $ // EntryPoint() should not return
}
}

View File

@@ -0,0 +1,59 @@
/** @file
Integer division worker functions for Ia32.
Copyright (c) 2006, Intel Corporation<BR>
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name: DivS64x64Remainder.c
**/
//
// Include common header file for this module.
//
#include "CommonHeader.h"
#include "../BaseLibInternals.h"
/**
Worker function that Divides a 64-bit signed integer by a 64-bit signed integer and
generates a 64-bit signed result and a optional 64-bit signed remainder.
This function divides the 64-bit unsigned value Dividend by the 64-bit
unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
is not NULL, then the 64-bit unsigned remainder is returned in Remainder.
This function returns the 64-bit unsigned quotient.
@param Dividend A 64-bit signed value.
@param Divisor A 64-bit signed value.
@param Remainder A pointer to a 64-bit signed value. This parameter is
optional and may be NULL.
@return Dividend / Divisor
**/
INT64
InternalMathDivRemS64x64 (
IN INT64 Dividend,
IN INT64 Divisor,
OUT INT64 *Remainder OPTIONAL
)
{
INT64 Quot;
Quot = InternalMathDivRemU64x64 (
Dividend >= 0 ? Dividend : -Dividend,
Divisor >= 0 ? Divisor : -Divisor,
(UINT64 *) Remainder
);
if (Remainder != NULL && Dividend < 0) {
*Remainder = -*Remainder;
}
return (Dividend ^ Divisor) >= 0 ? Quot : -Quot;
}

View File

@@ -0,0 +1,46 @@
//
// Include common header file for this module.
//
#include "CommonHeader.h"
#------------------------------------------------------------------------------
#
# Copyright (c) 2006, Intel Corporation
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
# Module Name:
#
# DivU64x32.asm
#
# Abstract:
#
# Calculate the quotient of a 64-bit integer by a 32-bit integer
#
#------------------------------------------------------------------------------
.globl ASM_PFX(InternalMathDivU64x32)
#------------------------------------------------------------------------------
# UINT64
# EFIAPI
# InternalMathDivU64x32 (
# IN UINT64 Dividend,
# IN UINT32 Divisor
# );
#------------------------------------------------------------------------------
ASM_PFX(InternalMathDivU64x32):
movl 8(%esp), %eax
movl 12(%esp), %ecx
xorl %edx, %edx
divl %ecx
push %eax
movl 8(%esp), %eax
divl %ecx
pop %edx
ret

View File

@@ -0,0 +1,46 @@
;------------------------------------------------------------------------------
;
; Copyright (c) 2006, Intel Corporation
; All rights reserved. This program and the accompanying materials
; are licensed and made available under the terms and conditions of the BSD License
; which accompanies this distribution. The full text of the license may be found at
; http://opensource.org/licenses/bsd-license.php
;
; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
;
; Module Name:
;
; DivU64x32.asm
;
; Abstract:
;
; Calculate the quotient of a 64-bit integer by a 32-bit integer
;
;------------------------------------------------------------------------------
.386
.model flat,C
.code
;------------------------------------------------------------------------------
; UINT64
; EFIAPI
; InternalMathDivU64x32 (
; IN UINT64 Dividend,
; IN UINT32 Divisor
; );
;------------------------------------------------------------------------------
InternalMathDivU64x32 PROC
mov eax, [esp + 8]
mov ecx, [esp + 12]
xor edx, edx
div ecx
push eax ; save quotient on stack
mov eax, [esp + 8]
div ecx
pop edx ; restore high-order dword of the quotient
ret
InternalMathDivU64x32 ENDP
END

View File

@@ -0,0 +1,38 @@
/** @file
Calculate the quotient of a 64-bit integer by a 32-bit integer
Copyright (c) 2006 - 2007, Intel Corporation<BR>
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
//
// Include common header file for this module.
//
#include "CommonHeader.h"
UINT64
EFIAPI
InternalMathDivU64x32 (
IN UINT64 Dividend,
IN UINT32 Divisor
)
{
_asm {
mov eax, dword ptr [Dividend + 4]
mov ecx, Divisor
xor edx, edx
div ecx
push eax ; save quotient on stack
mov eax, dword ptr [Dividend]
div ecx
pop edx ; restore high-order dword of the quotient
}
}

View File

@@ -0,0 +1,51 @@
//
// Include common header file for this module.
//
#include "CommonHeader.h"
#------------------------------------------------------------------------------
#
# Copyright (c) 2006, Intel Corporation
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
# Module Name:
#
# DivError.asm
#
# Abstract:
#
# Set error flag for all division functions
#
#------------------------------------------------------------------------------
.globl ASM_PFX(InternalMathDivRemU64x32)
#------------------------------------------------------------------------------
# UINT64
# EFIAPI
# InternalMathDivRemU64x32 (
# IN UINT64 Dividend,
# IN UINT32 Divisor,
# OUT UINT32 *Remainder
# );
#------------------------------------------------------------------------------
ASM_PFX(InternalMathDivRemU64x32):
movl 12(%esp), %ecx
movl 8(%esp), %eax
xorl %edx, %edx
divl %ecx
push %eax
movl 8(%esp), %eax
divl %ecx
movl 20(%esp), %ecx
jecxz L1
movl %edx, (%ecx)
L1:
pop %edx
ret

View File

@@ -0,0 +1,51 @@
;------------------------------------------------------------------------------
;
; Copyright (c) 2006, Intel Corporation
; All rights reserved. This program and the accompanying materials
; are licensed and made available under the terms and conditions of the BSD License
; which accompanies this distribution. The full text of the license may be found at
; http://opensource.org/licenses/bsd-license.php
;
; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
;
; Module Name:
;
; DivError.asm
;
; Abstract:
;
; Set error flag for all division functions
;
;------------------------------------------------------------------------------
.386
.model flat,C
.code
;------------------------------------------------------------------------------
; UINT64
; EFIAPI
; InternalMathDivRemU64x32 (
; IN UINT64 Dividend,
; IN UINT32 Divisor,
; OUT UINT32 *Remainder
; );
;------------------------------------------------------------------------------
InternalMathDivRemU64x32 PROC
mov ecx, [esp + 12] ; ecx <- divisor
mov eax, [esp + 8] ; eax <- dividend[32..63]
xor edx, edx
div ecx ; eax <- quotient[32..63], edx <- remainder
push eax
mov eax, [esp + 8] ; eax <- dividend[0..31]
div ecx ; eax <- quotient[0..31]
mov ecx, [esp + 20] ; ecx <- Remainder
jecxz @F ; abandon remainder if Remainder == NULL
mov [ecx], edx
@@:
pop edx ; edx <- quotient[32..63]
ret
InternalMathDivRemU64x32 ENDP
END

View File

@@ -0,0 +1,43 @@
/** @file
Set error flag for all division functions
Copyright (c) 2006 - 2007, Intel Corporation<BR>
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
//
// Include common header file for this module.
//
#include "CommonHeader.h"
UINT64
EFIAPI
InternalMathDivRemU64x32 (
IN UINT64 Dividend,
IN UINT32 Divisor,
OUT UINT32 *Remainder
)
{
_asm {
mov ecx, Divisor
mov eax, dword ptr [Dividend + 4]
xor edx, edx
div ecx
push eax
mov eax, dword ptr [Dividend + 0]
div ecx
mov ecx, Remainder
jecxz RemainderNull // abandon remainder if Remainder == NULL
mov [ecx], edx
RemainderNull:
pop edx
}
}

View File

@@ -0,0 +1,94 @@
//
// Include common header file for this module.
//
#include "CommonHeader.h"
#------------------------------------------------------------------------------
#
# Copyright (c) 2006, Intel Corporation
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
# Module Name:
#
# DivU64x64Remainder.asm
#
# Abstract:
#
# Calculate the quotient of a 64-bit integer by a 64-bit integer and returns
# both the quotient and the remainder
#
#------------------------------------------------------------------------------
.globl ASM_PFX(InternalMathDivRemU64x32), ASM_PFX(InternalMathDivRemU64x64)
#------------------------------------------------------------------------------
# UINT64
# EFIAPI
# InternalMathDivRemU64x64 (
# IN UINT64 Dividend,
# IN UINT64 Divisor,
# OUT UINT64 *Remainder OPTIONAL
# );
#------------------------------------------------------------------------------
ASM_PFX(InternalMathDivRemU64x64):
movl 16(%esp), %ecx
testl %ecx, %ecx
jnz Hard
movl 20(%esp), %ecx
jecxz L1
and $0, 4(%ecx)
movl %ecx, 16(%esp)
L1:
jmp ASM_PFX(InternalMathDivRemU64x32)
Hard:
push %ebx
push %esi
push %edi
mov 20(%esp), %edx
mov 16(%esp), %eax
movl %edx, %edi
movl %eax, %esi
mov 24(%esp), %ebx
L2:
shrl %edx
rcrl $1, %eax
shrdl $1, %ecx, %ebx
shrl %ecx
jnz L2
divl %ebx
movl %eax, %ebx
movl 28(%esp), %ecx
mull 24(%esp)
imull %ebx, %ecx
addl %ecx, %edx
mov 32(%esp), %ecx
jc TooLarge
cmpl %edx, %edi
ja Correct
jb TooLarge
cmpl %eax, %esi
jae Correct
TooLarge:
decl %ebx
jecxz Return
sub 24(%esp), %eax
sbb 28(%esp), %edx
Correct:
jecxz Return
subl %eax, %esi
sbbl %edx, %edi
movl %esi, (%ecx)
movl %edi, 4(%ecx)
Return:
movl %ebx, %eax
xorl %edx, %edx
pop %edi
pop %esi
pop %ebx
ret

View File

@@ -0,0 +1,92 @@
;------------------------------------------------------------------------------
;
; Copyright (c) 2006, Intel Corporation
; All rights reserved. This program and the accompanying materials
; are licensed and made available under the terms and conditions of the BSD License
; which accompanies this distribution. The full text of the license may be found at
; http://opensource.org/licenses/bsd-license.php
;
; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
;
; Module Name:
;
; DivU64x64Remainder.asm
;
; Abstract:
;
; Calculate the quotient of a 64-bit integer by a 64-bit integer and returns
; both the quotient and the remainder
;
;------------------------------------------------------------------------------
.386
.model flat,C
.code
EXTERN InternalMathDivRemU64x32:PROC
;------------------------------------------------------------------------------
; UINT64
; EFIAPI
; InternalMathDivRemU64x64 (
; IN UINT64 Dividend,
; IN UINT64 Divisor,
; OUT UINT64 *Remainder OPTIONAL
; );
;------------------------------------------------------------------------------
InternalMathDivRemU64x64 PROC
mov ecx, [esp + 16] ; ecx <- divisor[32..63]
test ecx, ecx
jnz _@DivRemU64x64 ; call _@DivRemU64x64 if Divisor > 2^32
mov ecx, [esp + 20]
jecxz @F
and dword ptr [ecx + 4], 0 ; zero high dword of remainder
mov [esp + 16], ecx ; set up stack frame to match DivRemU64x32
@@:
jmp InternalMathDivRemU64x32
InternalMathDivRemU64x64 ENDP
_@DivRemU64x64 PROC USES ebx esi edi
mov edx, dword ptr [esp + 20]
mov eax, dword ptr [esp + 16] ; edx:eax <- dividend
mov edi, edx
mov esi, eax ; edi:esi <- dividend
mov ebx, dword ptr [esp + 24] ; ecx:ebx <- divisor
@@:
shr edx, 1
rcr eax, 1
shrd ebx, ecx, 1
shr ecx, 1
jnz @B
div ebx
mov ebx, eax ; ebx <- quotient
mov ecx, [esp + 28] ; ecx <- high dword of divisor
mul dword ptr [esp + 24] ; edx:eax <- quotient * divisor[0..31]
imul ecx, ebx ; ecx <- quotient * divisor[32..63]
add edx, ecx ; edx <- (quotient * divisor)[32..63]
mov ecx, dword ptr [esp + 32] ; ecx <- addr for Remainder
jc @TooLarge ; product > 2^64
cmp edi, edx ; compare high 32 bits
ja @Correct
jb @TooLarge ; product > dividend
cmp esi, eax
jae @Correct ; product <= dividend
@TooLarge:
dec ebx ; adjust quotient by -1
jecxz @Return ; return if Remainder == NULL
sub eax, dword ptr [esp + 24]
sbb edx, dword ptr [esp + 28] ; edx:eax <- (quotient - 1) * divisor
@Correct:
jecxz @Return
sub esi, eax
sbb edi, edx ; edi:esi <- remainder
mov [ecx], esi
mov [ecx + 4], edi
@Return:
mov eax, ebx ; eax <- quotient
xor edx, edx ; quotient is 32 bits long
ret
_@DivRemU64x64 ENDP
END

View File

@@ -0,0 +1,71 @@
/** @file
Calculate the quotient of a 64-bit integer by a 64-bit integer and returns
both the quotient and the remainderSet error flag for all division functions
Copyright (c) 2006 - 2007, Intel Corporation<BR>
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
//
// Include common header file for this module.
//
#include "CommonHeader.h"
UINT64
EFIAPI
InternalMathDivRemU64x64 (
IN UINT64 Dividend,
IN UINT64 Divisor,
OUT UINT64 *Remainder OPTIONAL
)
{
_asm {
mov edx, dword ptr [Dividend + 4]
mov eax, dword ptr [Dividend + 0] // edx:eax <- dividend
mov edi, edx
mov esi, eax // edi:esi <- dividend
mov ecx, dword ptr [Divisor + 4]
mov ebx, dword ptr [Divisor + 0] // ecx:ebx <- divisor
BitLoop:
shr edx, 1
rcr eax, 1
shrd ebx, ecx, 1
shr ecx, 1
jnz BitLoop
div ebx
mov ebx, eax // ebx <- quotient
mov ecx, dword ptr [Divisor + 4]
mul dword ptr [Divisor]
imul ecx, ebx
add edx, ecx
mov ecx, Remainder
jc TooLarge // product > 2^64
cmp edi, edx // compare high 32 bits
ja Correct
jb TooLarge // product > dividend
cmp esi, eax
jae Correct // product <= dividend
TooLarge:
dec ebx // adjust quotient by -1
jecxz Return // return if Remainder == NULL
sub eax, dword ptr [Divisor + 0]
sbb edx, dword ptr [Divisor + 4]
Correct:
jecxz Return
sub esi, eax
sbb edi, edx // edi:esi <- remainder
mov [ecx], esi
mov [ecx + 4], edi
Return:
mov eax, ebx // eax <- quotient
xor edx, edx
}
}

View File

@@ -0,0 +1,41 @@
//
// Include common header file for this module.
//
#include "CommonHeader.h"
#------------------------------------------------------------------------------
#
# Copyright (c) 2006, Intel Corporation
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
# Module Name:
#
# EnableDisableInterrupts.Asm
#
# Abstract:
#
# EnableDisableInterrupts function
#
# Notes:
#
#------------------------------------------------------------------------------
.globl ASM_PFX(EnableDisableInterrupts)
#------------------------------------------------------------------------------
# VOID
# EFIAPI
# EnableDisableInterrupts (
# VOID
# );
#------------------------------------------------------------------------------
ASM_PFX(EnableDisableInterrupts):
sti
cli
ret

View File

@@ -0,0 +1,41 @@
;------------------------------------------------------------------------------
;
; Copyright (c) 2006, Intel Corporation
; All rights reserved. This program and the accompanying materials
; are licensed and made available under the terms and conditions of the BSD License
; which accompanies this distribution. The full text of the license may be found at
; http://opensource.org/licenses/bsd-license.php
;
; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
;
; Module Name:
;
; EnableDisableInterrupts.Asm
;
; Abstract:
;
; EnableDisableInterrupts function
;
; Notes:
;
;------------------------------------------------------------------------------
.386p
.model flat
.code
;------------------------------------------------------------------------------
; VOID
; EFIAPI
; EnableDisableInterrupts (
; VOID
; );
;------------------------------------------------------------------------------
_EnableDisableInterrupts PROC
sti
cli
ret
_EnableDisableInterrupts ENDP
END

View File

@@ -0,0 +1,33 @@
/** @file
EnableDisableInterrupts function
Copyright (c) 2006 - 2007, Intel Corporation<BR>
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
//
// Include common header file for this module.
//
#include "CommonHeader.h"
VOID
EFIAPI
EnableDisableInterrupts (
VOID
)
{
_asm {
sti
nop
nop
cli
}
}

View File

@@ -0,0 +1,40 @@
//
// Include common header file for this module.
//
#include "CommonHeader.h"
#------------------------------------------------------------------------------
#
# Copyright (c) 2006, Intel Corporation
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
# Module Name:
#
# EnableInterrupts.Asm
#
# Abstract:
#
# EnableInterrupts function
#
# Notes:
#
#------------------------------------------------------------------------------
.globl ASM_PFX(EnableInterrupts)
#------------------------------------------------------------------------------
# VOID
# EFIAPI
# EnableInterrupts (
# VOID
# );
#------------------------------------------------------------------------------
ASM_PFX(EnableInterrupts):
sti
ret

View File

@@ -0,0 +1,40 @@
;------------------------------------------------------------------------------
;
; Copyright (c) 2006, Intel Corporation
; All rights reserved. This program and the accompanying materials
; are licensed and made available under the terms and conditions of the BSD License
; which accompanies this distribution. The full text of the license may be found at
; http://opensource.org/licenses/bsd-license.php
;
; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
;
; Module Name:
;
; EnableInterrupts.Asm
;
; Abstract:
;
; EnableInterrupts function
;
; Notes:
;
;------------------------------------------------------------------------------
.386p
.model flat
.code
;------------------------------------------------------------------------------
; VOID
; EFIAPI
; EnableInterrupts (
; VOID
; );
;------------------------------------------------------------------------------
_EnableInterrupts PROC
sti
ret
_EnableInterrupts ENDP
END

View File

@@ -0,0 +1,30 @@
/** @file
EnableInterrupts function
Copyright (c) 2006 - 2007, Intel Corporation<BR>
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
//
// Include common header file for this module.
//
#include "CommonHeader.h"
VOID
EFIAPI
EnableInterrupts (
VOID
)
{
_asm {
sti
}
}

View File

@@ -0,0 +1,57 @@
//
// Include common header file for this module.
//
#include "CommonHeader.h"
#------------------------------------------------------------------------------
#
# Copyright (c) 2006, Intel Corporation
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
# Module Name:
#
# EnablePaging32.Asm
#
# Abstract:
#
# InternalX86EnablePaging32 function
#
# Notes:
#
#------------------------------------------------------------------------------
.globl ASM_PFX(InternalX86EnablePaging32)
#------------------------------------------------------------------------------
# VOID
# EFIAPI
# InternalX86EnablePaging32 (
# IN SWITCH_STACK_ENTRY_POINT EntryPoint,
# IN VOID *Context1, OPTIONAL
# IN VOID *Context2, OPTIONAL
# IN VOID *NewStack
# );
#------------------------------------------------------------------------------
ASM_PFX(InternalX86EnablePaging32):
movl 4(%esp), %ebx
movl 8(%esp), %ecx
movl 12(%esp), %edx
pushfl
pop %edi
cli
movl %cr0, %eax
btsl $31, %eax
movl 16(%esp), %esp
movl %eax, %cr0
push %edi
popfl
push %edx
push %ecx
call *%ebx
jmp .

View File

@@ -0,0 +1,57 @@
;------------------------------------------------------------------------------
;
; Copyright (c) 2006, Intel Corporation
; All rights reserved. This program and the accompanying materials
; are licensed and made available under the terms and conditions of the BSD License
; which accompanies this distribution. The full text of the license may be found at
; http://opensource.org/licenses/bsd-license.php
;
; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
;
; Module Name:
;
; EnablePaging32.Asm
;
; Abstract:
;
; AsmEnablePaging32 function
;
; Notes:
;
;------------------------------------------------------------------------------
.386
.model flat,C
.code
;------------------------------------------------------------------------------
; VOID
; EFIAPI
; InternalX86EnablePaging32 (
; IN SWITCH_STACK_ENTRY_POINT EntryPoint,
; IN VOID *Context1, OPTIONAL
; IN VOID *Context2, OPTIONAL
; IN VOID *NewStack
; );
;------------------------------------------------------------------------------
InternalX86EnablePaging32 PROC
mov ebx, [esp + 4]
mov ecx, [esp + 8]
mov edx, [esp + 12]
pushfd
pop edi ; save flags in edi
cli
mov eax, cr0
bts eax, 31
mov esp, [esp + 16]
mov cr0, eax
push edi
popfd ; restore flags
push edx
push ecx
call ebx
jmp $
InternalX86EnablePaging32 ENDP
END

View File

@@ -0,0 +1,51 @@
/** @file
AsmEnablePaging32 function
Copyright (c) 2006 - 2007, Intel Corporation<BR>
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
//
// Include common header file for this module.
//
#include "CommonHeader.h"
__declspec (naked)
VOID
EFIAPI
InternalX86EnablePaging32 (
IN SWITCH_STACK_ENTRY_POINT EntryPoint,
IN VOID *Context1, OPTIONAL
IN VOID *Context2, OPTIONAL
IN VOID *NewStack
)
{
_asm {
push ebp
mov ebp, esp
mov ebx, EntryPoint
mov ecx, Context1
mov edx, Context2
pushfd
pop edi
cli
mov eax, cr0
bts eax, 31
mov esp, NewStack
mov cr0, eax
push edi
popfd
push edx
push ecx
call ebx
jmp $
}
}

View File

@@ -0,0 +1,68 @@
//
// Include common header file for this module.
//
#include "CommonHeader.h"
#------------------------------------------------------------------------------
#
# Copyright (c) 2006, Intel Corporation
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
# Module Name:
#
# EnablePaging64.Asm
#
# Abstract:
#
# InternalX86EnablePaging64 function
#
# Notes:
#
#------------------------------------------------------------------------------
.globl ASM_PFX(InternalX86EnablePaging64)
#------------------------------------------------------------------------------
# VOID
# EFIAPI
# InternalX86EnablePaging64 (
# IN UINT16 CodeSelector,
# IN UINT64 EntryPoint,
# IN UINT64 Context1, OPTIONAL
# IN UINT64 Context2, OPTIONAL
# IN UINT64 NewStack
# );
#------------------------------------------------------------------------------
ASM_PFX(InternalX86EnablePaging64):
cli
movl $LongStart, (%esp)
movl %cr4, %eax
orb $0x20, %al
movl %eax, %cr4 # enable PAE
movl $0xc0000080, %ecx
rdmsr
orb $1, %ah # set LME
wrmsr
movl %cr0, %eax
btsl $31, %eax
movl %eax, %cr0 # enable paging
lret
LongStart: # long mode starts here
.byte 0x67, 0x48
movl (%esp), %ebx # mov rbx, [esp]
.byte 0x67, 0x48
movl 8(%esp), %ecx # mov rcx, [esp + 8]
.byte 0x67, 0x48
movl 0x10(%esp), %edx # mov rdx, [esp + 10h]
.byte 0x67, 0x48
movl 0x18(%esp), %esp # mov rsp, [esp + 18h]
.byte 0x48
addl $0x-20, %esp # add rsp, -20h
call *%ebx # call rbx
jmp .

View File

@@ -0,0 +1,73 @@
//
// Include common header file for this module.
//
#include "CommonHeader.h"
;------------------------------------------------------------------------------
;
; Copyright (c) 2006, Intel Corporation
; All rights reserved. This program and the accompanying materials
; are licensed and made available under the terms and conditions of the BSD License
; which accompanies this distribution. The full text of the license may be found at
; http://opensource.org/licenses/bsd-license.php
;
; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
;
; Module Name:
;
; EnablePaging64.Asm
;
; Abstract:
;
; AsmEnablePaging64 function
;
; Notes:
;
;------------------------------------------------------------------------------
.686p
.model flat,C
.code
;------------------------------------------------------------------------------
; VOID
; EFIAPI
; InternalX86EnablePaging64 (
; IN UINT16 Cs,
; IN UINT64 EntryPoint,
; IN UINT64 Context1, OPTIONAL
; IN UINT64 Context2, OPTIONAL
; IN UINT64 NewStack
; );
;------------------------------------------------------------------------------
InternalX86EnablePaging64 PROC
cli
mov [esp], @F ; offset for far retf, seg is the 1st arg
mov eax, cr4
or al, (1 SHL 5)
mov cr4, eax ; enable PAE
mov ecx, 0c0000080h
rdmsr
or ah, 1 ; set LME
wrmsr
mov eax, cr0
bts eax, 31 ; set PG
mov cr0, eax ; enable paging
retf ; topmost 2 dwords hold the address
@@: ; long mode starts here
DB 67h, 48h ; 32-bit address size, 64-bit operand size
mov ebx, [esp] ; mov rbx, [esp]
DB 67h, 48h
mov ecx, [esp + 8] ; mov rcx, [esp + 8]
DB 67h, 48h
mov edx, [esp + 10h] ; mov rdx, [esp + 10h]
DB 67h, 48h
mov esp, [esp + 18h] ; mov rsp, [esp + 18h]
DB 48h
add esp, -20h ; add rsp, -20h
call ebx ; call rbx
hlt ; no one should get here
InternalX86EnablePaging64 ENDP
END

View File

@@ -0,0 +1,41 @@
//
// Include common header file for this module.
//
#include "CommonHeader.h"
#------------------------------------------------------------------------------
#
# Copyright (c) 2006, Intel Corporation
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
# Module Name:
#
# FlushCacheLine.Asm
#
# Abstract:
#
# AsmFlushCacheLine function
#
# Notes:
#
#------------------------------------------------------------------------------
.globl ASM_PFX(AsmFlushCacheLine)
#------------------------------------------------------------------------------
# VOID
# EFIAPI
# AsmFlushCacheLine (
# IN VOID *LinearAddress
# );
#------------------------------------------------------------------------------
ASM_PFX(AsmFlushCacheLine):
movl 4(%esp), %eax
clflush (%eax)
ret

View File

@@ -0,0 +1,42 @@
;------------------------------------------------------------------------------
;
; Copyright (c) 2006, Intel Corporation
; All rights reserved. This program and the accompanying materials
; are licensed and made available under the terms and conditions of the BSD License
; which accompanies this distribution. The full text of the license may be found at
; http://opensource.org/licenses/bsd-license.php
;
; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
;
; Module Name:
;
; FlushCacheLine.Asm
;
; Abstract:
;
; AsmFlushCacheLine function
;
; Notes:
;
;------------------------------------------------------------------------------
.586P
.model flat,C
.xmm
.code
;------------------------------------------------------------------------------
; VOID *
; EFIAPI
; AsmFlushCacheLine (
; IN VOID *LinearAddress
; );
;------------------------------------------------------------------------------
AsmFlushCacheLine PROC
mov eax, [esp + 4]
clflush [eax]
ret
AsmFlushCacheLine ENDP
END

View File

@@ -0,0 +1,31 @@
/** @file
AsmFlushCacheLine function
Copyright (c) 2006 - 2007, Intel Corporation<BR>
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
//
// Include common header file for this module.
//
#include "CommonHeader.h"
VOID *
EFIAPI
AsmFlushCacheLine (
IN VOID *LinearAddress
)
{
_asm {
mov eax, LinearAddress
clflush [eax]
}
}

View File

@@ -0,0 +1,41 @@
//
// Include common header file for this module.
//
#include "CommonHeader.h"
#------------------------------------------------------------------------------
#
# Copyright (c) 2006, Intel Corporation
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
# Module Name:
#
# FxRestore.Asm
#
# Abstract:
#
# InternalX86FxRestore function
#
# Notes:
#
#------------------------------------------------------------------------------
.globl ASM_PFX(InternalX86FxRestore)
#------------------------------------------------------------------------------
# VOID
# EFIAPI
# InternalX86FxRestore (
# IN CONST IA32_FX_BUFFER *Buffer
# );
#------------------------------------------------------------------------------
ASM_PFX(InternalX86FxRestore):
movl 4(%esp), %eax
fxrstor (%eax)
ret

View File

@@ -0,0 +1,42 @@
;------------------------------------------------------------------------------
;
; Copyright (c) 2006, Intel Corporation
; All rights reserved. This program and the accompanying materials
; are licensed and made available under the terms and conditions of the BSD License
; which accompanies this distribution. The full text of the license may be found at
; http://opensource.org/licenses/bsd-license.php
;
; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
;
; Module Name:
;
; FxRestore.Asm
;
; Abstract:
;
; AsmFxRestore function
;
; Notes:
;
;------------------------------------------------------------------------------
.586
.model flat,C
.xmm
.code
;------------------------------------------------------------------------------
; VOID
; EFIAPI
; InternalX86FxRestore (
; IN CONST IA32_FX_BUFFER *Buffer
; );
;------------------------------------------------------------------------------
InternalX86FxRestore PROC
mov eax, [esp + 4] ; Buffer must be 16-byte aligned
fxrstor [eax]
ret
InternalX86FxRestore ENDP
END

View File

@@ -0,0 +1,31 @@
/** @file
AsmFxRestore function
Copyright (c) 2006 - 2007, Intel Corporation<BR>
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
//
// Include common header file for this module.
//
#include "CommonHeader.h"
VOID
EFIAPI
InternalX86FxRestore (
IN CONST IA32_FX_BUFFER *Buffer
)
{
_asm {
mov eax, Buffer
fxrstor [eax]
}
}

View File

@@ -0,0 +1,41 @@
//
// Include common header file for this module.
//
#include "CommonHeader.h"
#------------------------------------------------------------------------------
#
# Copyright (c) 2006, Intel Corporation
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
# Module Name:
#
# FxSave.Asm
#
# Abstract:
#
# InternalX86FxSave function
#
# Notes:
#
#------------------------------------------------------------------------------
.globl ASM_PFX(InternalX86FxSave)
#------------------------------------------------------------------------------
# VOID
# EFIAPI
# InternalX86FxSave (
# OUT IA32_FX_BUFFER *Buffer
# );
#------------------------------------------------------------------------------
ASM_PFX(InternalX86FxSave):
movl 4(%esp), %eax
fxsave (%eax)
ret

View File

@@ -0,0 +1,42 @@
;------------------------------------------------------------------------------
;
; Copyright (c) 2006, Intel Corporation
; All rights reserved. This program and the accompanying materials
; are licensed and made available under the terms and conditions of the BSD License
; which accompanies this distribution. The full text of the license may be found at
; http://opensource.org/licenses/bsd-license.php
;
; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
;
; Module Name:
;
; FxSave.Asm
;
; Abstract:
;
; AsmFxSave function
;
; Notes:
;
;------------------------------------------------------------------------------
.586
.model flat,C
.xmm
.code
;------------------------------------------------------------------------------
; VOID
; EFIAPI
; InternalX86FxSave (
; OUT IA32_FX_BUFFER *Buffer
; );
;------------------------------------------------------------------------------
InternalX86FxSave PROC
mov eax, [esp + 4] ; Buffer must be 16-byte aligned
fxsave [eax]
ret
InternalX86FxSave ENDP
END

View File

@@ -0,0 +1,31 @@
/** @file
AsmFxSave function
Copyright (c) 2006 - 2007, Intel Corporation<BR>
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
//
// Include common header file for this module.
//
#include "CommonHeader.h"
VOID
EFIAPI
InternalX86FxSave (
OUT IA32_FX_BUFFER *Buffer
)
{
_asm {
mov eax, Buffer
fxsave [eax]
}
}

View File

@@ -0,0 +1,46 @@
//
// Include common header file for this module.
//
#include "CommonHeader.h"
#------------------------------------------------------------------------------
#
# Copyright (c) 2006, Intel Corporation
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
# Module Name:
#
# InterlockedCompareExchange32.Asm
#
# Abstract:
#
# InternalSyncCompareExchange32 function
#
# Notes:
#
#------------------------------------------------------------------------------
.globl ASM_PFX(InternalSyncCompareExchange32)
#------------------------------------------------------------------------------
# UINT32
# EFIAPI
# InternalSyncCompareExchange32 (
# IN UINT32 *Value,
# IN UINT32 CompareValue,
# IN UINT32 ExchangeValue
# );
#------------------------------------------------------------------------------
ASM_PFX(InternalSyncCompareExchange32):
movl 4(%esp), %ecx
movl 8(%esp), %eax
movl 12(%esp), %edx
lock
cmpxchgl %edx, (%ecx)
ret

View File

@@ -0,0 +1,45 @@
;------------------------------------------------------------------------------
;
; Copyright (c) 2006, Intel Corporation
; All rights reserved. This program and the accompanying materials
; are licensed and made available under the terms and conditions of the BSD License
; which accompanies this distribution. The full text of the license may be found at
; http://opensource.org/licenses/bsd-license.php
;
; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
;
; Module Name:
;
; InterlockedCompareExchange32.Asm
;
; Abstract:
;
; InterlockedCompareExchange32 function
;
; Notes:
;
;------------------------------------------------------------------------------
.486
.model flat,C
.code
;------------------------------------------------------------------------------
; UINT32
; EFIAPI
; InternalSyncCompareExchange32 (
; IN UINT32 *Value,
; IN UINT32 CompareValue,
; IN UINT32 ExchangeValue
; );
;------------------------------------------------------------------------------
InternalSyncCompareExchange32 PROC
mov ecx, [esp + 4]
mov eax, [esp + 8]
mov edx, [esp + 12]
lock cmpxchg [ecx], edx
ret
InternalSyncCompareExchange32 ENDP
END

View File

@@ -0,0 +1,35 @@
/** @file
InterlockedCompareExchange32 function
Copyright (c) 2006 - 2007, Intel Corporation<BR>
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
//
// Include common header file for this module.
//
#include "CommonHeader.h"
UINT32
EFIAPI
InternalSyncCompareExchange32 (
IN UINT32 *Value,
IN UINT32 CompareValue,
IN UINT32 ExchangeValue
)
{
_asm {
mov ecx, Value
mov eax, CompareValue
mov edx, ExchangeValue
lock cmpxchg [ecx], edx
}
}

View File

@@ -0,0 +1,52 @@
//
// Include common header file for this module.
//
#include "CommonHeader.h"
#------------------------------------------------------------------------------
#
# Copyright (c) 2006, Intel Corporation
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
# Module Name:
#
# InterlockedCompareExchange64.Asm
#
# Abstract:
#
# InternalSyncCompareExchange64 function
#
# Notes:
#
#------------------------------------------------------------------------------
.globl ASM_PFX(InternalSyncCompareExchange64)
#------------------------------------------------------------------------------
# UINT64
# EFIAPI
# InternalSyncCompareExchange64 (
# IN UINT64 *Value,
# IN UINT64 CompareValue,
# IN UINT64 ExchangeValue
# );
#------------------------------------------------------------------------------
ASM_PFX(InternalSyncCompareExchange64):
push %esi
push %ebx
movl 12(%esp), %esi
movl 16(%esp), %eax
movl 20(%esp), %edx
movl 24(%esp), %ebx
movl 28(%esp), %ecx
lock
cmpxchg8b (%esi)
pop %ebx
pop %esi
ret

View File

@@ -0,0 +1,47 @@
;------------------------------------------------------------------------------
;
; Copyright (c) 2006, Intel Corporation
; All rights reserved. This program and the accompanying materials
; are licensed and made available under the terms and conditions of the BSD License
; which accompanies this distribution. The full text of the license may be found at
; http://opensource.org/licenses/bsd-license.php
;
; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
;
; Module Name:
;
; InterlockedCompareExchange64.Asm
;
; Abstract:
;
; InterlockedCompareExchange64 function
;
; Notes:
;
;------------------------------------------------------------------------------
.586P
.model flat,C
.code
;------------------------------------------------------------------------------
; UINT64
; EFIAPI
; InternalSyncCompareExchange64 (
; IN UINT64 *Value,
; IN UINT64 CompareValue,
; IN UINT64 ExchangeValue
; );
;------------------------------------------------------------------------------
InternalSyncCompareExchange64 PROC USES esi ebx
mov esi, [esp + 12]
mov eax, [esp + 16]
mov edx, [esp + 20]
mov ebx, [esp + 24]
mov ecx, [esp + 28]
lock cmpxchg8b qword ptr [esi]
ret
InternalSyncCompareExchange64 ENDP
END

View File

@@ -0,0 +1,36 @@
/** @file
InterlockedCompareExchange64 function
Copyright (c) 2006 - 2007, Intel Corporation<BR>
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
//
// Include common header file for this module.
//
#include "CommonHeader.h"
UINT64
EFIAPI
InternalSyncCompareExchange64 (
IN UINT64 *Value,
IN UINT64 CompareValue,
IN UINT64 ExchangeValue
)
{
_asm {
mov esi, Value
mov eax, dword ptr [CompareValue + 0]
mov edx, dword ptr [CompareValue + 4]
mov ebx, dword ptr [ExchangeValue + 0]
mov ecx, dword ptr [ExchangeValue + 4]
lock cmpxchg8b qword ptr [esi]
}
}

View File

@@ -0,0 +1,43 @@
//
// Include common header file for this module.
//
#include "CommonHeader.h"
#------------------------------------------------------------------------------
#
# Copyright (c) 2006, Intel Corporation
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
# Module Name:
#
# InterlockedDecrement.Asm
#
# Abstract:
#
# InternalSyncDecrement function
#
# Notes:
#
#------------------------------------------------------------------------------
.globl ASM_PFX(InternalSyncDecrement)
#------------------------------------------------------------------------------
# UINT32
# EFIAPI
# InternalSyncDecrement (
# IN UINT32 *Value
# );
#------------------------------------------------------------------------------
ASM_PFX(InternalSyncDecrement):
movl 4(%esp), %eax
lock
decl (%eax)
movl (%eax), %eax
ret

View File

@@ -0,0 +1,42 @@
;------------------------------------------------------------------------------
;
; Copyright (c) 2006, Intel Corporation
; All rights reserved. This program and the accompanying materials
; are licensed and made available under the terms and conditions of the BSD License
; which accompanies this distribution. The full text of the license may be found at
; http://opensource.org/licenses/bsd-license.php
;
; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
;
; Module Name:
;
; InterlockedDecrement.Asm
;
; Abstract:
;
; InterlockedDecrement function
;
; Notes:
;
;------------------------------------------------------------------------------
.386
.model flat,C
.code
;------------------------------------------------------------------------------
; UINT32
; EFIAPI
; InternalSyncDecrement (
; IN UINT32 *Value
; );
;------------------------------------------------------------------------------
InternalSyncDecrement PROC
mov eax, [esp + 4]
lock dec dword ptr [eax]
mov eax, [eax]
ret
InternalSyncDecrement ENDP
END

View File

@@ -0,0 +1,31 @@
/** @file
InterlockedDecrement function
Copyright (c) 2006 - 2007, Intel Corporation<BR>
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
//
// Include common header file for this module.
//
#include "CommonHeader.h"
UINT32
EFIAPI
InternalSyncDecrement (
IN UINT32 *Value
)
{
_asm {
mov eax, Value
lock dec dword ptr [eax]
mov eax, [eax]
}
}

View File

@@ -0,0 +1,43 @@
//
// Include common header file for this module.
//
#include "CommonHeader.h"
#------------------------------------------------------------------------------
#
# Copyright (c) 2006, Intel Corporation
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
# Module Name:
#
# InterlockedIncrement.Asm
#
# Abstract:
#
# InternalSyncIncrement function
#
# Notes:
#
#------------------------------------------------------------------------------
.globl ASM_PFX(InternalSyncIncrement)
#------------------------------------------------------------------------------
# UINT32
# EFIAPI
# InternalSyncIncrement (
# IN UINT32 *Value
# );
#------------------------------------------------------------------------------
ASM_PFX(InternalSyncIncrement):
movl 4(%esp), %eax
lock
incl (%eax)
movl (%eax), %eax
ret

View File

@@ -0,0 +1,42 @@
;------------------------------------------------------------------------------
;
; Copyright (c) 2006, Intel Corporation
; All rights reserved. This program and the accompanying materials
; are licensed and made available under the terms and conditions of the BSD License
; which accompanies this distribution. The full text of the license may be found at
; http://opensource.org/licenses/bsd-license.php
;
; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
;
; Module Name:
;
; InterlockedIncrement.Asm
;
; Abstract:
;
; InterlockedIncrement function
;
; Notes:
;
;------------------------------------------------------------------------------
.386
.model flat,C
.code
;------------------------------------------------------------------------------
; UINT32
; EFIAPI
; InternalSyncIncrement (
; IN UINT32 *Value
; );
;------------------------------------------------------------------------------
InternalSyncIncrement PROC
mov eax, [esp + 4]
lock inc dword ptr [eax]
mov eax, [eax]
ret
InternalSyncIncrement ENDP
END

View File

@@ -0,0 +1,32 @@
/** @file
InterLockedIncrement function
Copyright (c) 2006 - 2007, Intel Corporation<BR>
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
//
// Include common header file for this module.
//
#include "CommonHeader.h"
UINT32
EFIAPI
InternalSyncIncrement (
IN UINT32 *Value
)
{
_asm {
mov eax, Value
lock inc dword ptr [eax]
mov eax, [eax]
}
}

View File

@@ -0,0 +1,70 @@
/** @file
SwitchStack() function for IA-32.
Copyright (c) 2006 - 2007, Intel Corporation<BR>
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name: InternalSwitchStack.c
**/
//
// Include common header file for this module.
//
#include "CommonHeader.h"
/**
Transfers control to a function starting with a new stack.
Transfers control to the function specified by EntryPoint using the
new stack specified by NewStack and passing in the parameters specified
by Context1 and Context2. Context1 and Context2 are optional and may
be NULL. The function EntryPoint must never return.
Marker will be ignored on IA-32, x64, and EBC.
IPF CPUs expect one additional parameter of type VOID * that specifies
the new backing store pointer.
If EntryPoint is NULL, then ASSERT().
If NewStack is NULL, then ASSERT().
@param EntryPoint A pointer to function to call with the new stack.
@param Context1 A pointer to the context to pass into the EntryPoint
function.
@param Context2 A pointer to the context to pass into the EntryPoint
function.
@param NewStack A pointer to the new stack to use for the EntryPoint
function.
@param Marker VA_LIST marker for the variable argument list.
**/
VOID
EFIAPI
InternalSwitchStack (
IN SWITCH_STACK_ENTRY_POINT EntryPoint,
IN VOID *Context1, OPTIONAL
IN VOID *Context2, OPTIONAL
IN VOID *NewStack,
IN VA_LIST Marker
)
{
BASE_LIBRARY_JUMP_BUFFER JumpBuffer;
//
// Stack should be aligned with CPU_STACK_ALIGNMENT
//
ASSERT (((UINTN)NewStack & (CPU_STACK_ALIGNMENT - 1)) == 0);
JumpBuffer.Eip = (UINTN)EntryPoint;
JumpBuffer.Esp = (UINTN)NewStack - sizeof (VOID*);
JumpBuffer.Esp -= sizeof (Context1) + sizeof (Context2);
((VOID**)JumpBuffer.Esp)[1] = Context1;
((VOID**)JumpBuffer.Esp)[2] = Context2;
LongJump (&JumpBuffer, (UINTN)-1);
}

View File

@@ -0,0 +1,40 @@
//
// Include common header file for this module.
//
#include "CommonHeader.h"
#------------------------------------------------------------------------------
#
# Copyright (c) 2006, Intel Corporation
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
# Module Name:
#
# Invd.Asm
#
# Abstract:
#
# AsmInvd function
#
# Notes:
#
#------------------------------------------------------------------------------
.globl ASM_PFX(AsmInvd)
#------------------------------------------------------------------------------
# VOID
# EFIAPI
# AsmInvd (
# VOID
# );
#------------------------------------------------------------------------------
ASM_PFX(AsmInvd):
invd
ret

View File

@@ -0,0 +1,40 @@
;------------------------------------------------------------------------------
;
; Copyright (c) 2006, Intel Corporation
; All rights reserved. This program and the accompanying materials
; are licensed and made available under the terms and conditions of the BSD License
; which accompanies this distribution. The full text of the license may be found at
; http://opensource.org/licenses/bsd-license.php
;
; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
;
; Module Name:
;
; Invd.Asm
;
; Abstract:
;
; AsmInvd function
;
; Notes:
;
;------------------------------------------------------------------------------
.486p
.model flat
.code
;------------------------------------------------------------------------------
; VOID
; EFIAPI
; AsmInvd (
; VOID
; );
;------------------------------------------------------------------------------
_AsmInvd PROC
invd
ret
_AsmInvd ENDP
END

View File

@@ -0,0 +1,30 @@
/** @file
AsmInvd function
Copyright (c) 2006 - 2007, Intel Corporation<BR>
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
//
// Include common header file for this module.
//
#include "CommonHeader.h"
VOID
EFIAPI
AsmInvd (
VOID
)
{
_asm {
invd
}
}

View File

@@ -0,0 +1,51 @@
//
// Include common header file for this module.
//
#include "CommonHeader.h"
#------------------------------------------------------------------------------
#
# Copyright (c) 2006, Intel Corporation
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
# Module Name:
#
# LRotU64.asm
#
# Abstract:
#
# 64-bit left rotation for Ia32
#
#------------------------------------------------------------------------------
.globl ASM_PFX(InternalMathLRotU64)
#------------------------------------------------------------------------------
# UINT64
# EFIAPI
# InternalMathLRotU64 (
# IN UINT64 Operand,
# IN UINTN Count
# );
#------------------------------------------------------------------------------
ASM_PFX(InternalMathLRotU64):
push %ebx
movb 16(%esp), %cl
movl 12(%esp), %edx
movl 8(%esp), %eax
shldl %cl, %edx, %ebx
shldl %cl, %eax, %edx
rorl %cl, %ebx
shldl %cl, %ebx, %eax
testb $32, %cl
cmovnz %eax, %ecx
cmovnz %edx, %eax
cmovnz %ecx, %edx
pop %ebx
ret

View File

@@ -0,0 +1,49 @@
;------------------------------------------------------------------------------
;
; Copyright (c) 2006, Intel Corporation
; All rights reserved. This program and the accompanying materials
; are licensed and made available under the terms and conditions of the BSD License
; which accompanies this distribution. The full text of the license may be found at
; http://opensource.org/licenses/bsd-license.php
;
; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
;
; Module Name:
;
; LRotU64.asm
;
; Abstract:
;
; 64-bit left rotation for Ia32
;
;------------------------------------------------------------------------------
.686
.model flat,C
.code
;------------------------------------------------------------------------------
; UINT64
; EFIAPI
; InternalMathLRotU64 (
; IN UINT64 Operand,
; IN UINTN Count
; );
;------------------------------------------------------------------------------
InternalMathLRotU64 PROC USES ebx
mov cl, [esp + 16]
mov edx, [esp + 12]
mov eax, [esp + 8]
shld ebx, edx, cl
shld edx, eax, cl
ror ebx, cl
shld eax, ebx, cl
test cl, 32 ; Count >= 32?
cmovnz ecx, eax
cmovnz eax, edx
cmovnz edx, ecx
ret
InternalMathLRotU64 ENDP
END

View File

@@ -0,0 +1,41 @@
/** @file
64-bit left rotation for Ia32
Copyright (c) 2006 - 2007, Intel Corporation<BR>
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
//
// Include common header file for this module.
//
#include "CommonHeader.h"
UINT64
EFIAPI
InternalMathLRotU64 (
IN UINT64 Operand,
IN UINTN Count
)
{
_asm {
mov cl, byte ptr [Count]
mov edx, dword ptr [Operand + 4]
mov eax, dword ptr [Operand + 0]
shld ebx, edx, cl
shld edx, eax, cl
ror ebx, cl
shld eax, ebx, cl
test cl, 32 ; Count >= 32?
cmovnz ecx, eax
cmovnz eax, edx
cmovnz edx, ecx
}
}

View File

@@ -0,0 +1,46 @@
//
// Include common header file for this module.
//
#include "CommonHeader.h"
#------------------------------------------------------------------------------
#
# Copyright (c) 2006, Intel Corporation
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
# Module Name:
#
# LShiftU64.asm
#
# Abstract:
#
# 64-bit left shift function for IA-32
#
#------------------------------------------------------------------------------
.globl ASM_PFX(InternalMathLShiftU64)
#------------------------------------------------------------------------------
# UINT64
# EFIAPI
# InternalMathLShiftU64 (
# IN UINT64 Operand,
# IN UINTN Count
# );
#------------------------------------------------------------------------------
ASM_PFX(InternalMathLShiftU64):
movb 12(%esp), %cl
xorl %eax, %eax
movl 4(%esp), %edx
testb $32, %cl
cmovz %edx, %eax
cmovz 0x8(%esp), %edx
shld %cl, %eax, %edx
shl %cl, %eax
ret

View File

@@ -0,0 +1,46 @@
;------------------------------------------------------------------------------
;
; Copyright (c) 2006, Intel Corporation
; All rights reserved. This program and the accompanying materials
; are licensed and made available under the terms and conditions of the BSD License
; which accompanies this distribution. The full text of the license may be found at
; http://opensource.org/licenses/bsd-license.php
;
; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
;
; Module Name:
;
; LShiftU64.asm
;
; Abstract:
;
; 64-bit left shift function for IA-32
;
;------------------------------------------------------------------------------
.686
.model flat,C
.code
;------------------------------------------------------------------------------
; UINT64
; EFIAPI
; InternalMathLShiftU64 (
; IN UINT64 Operand,
; IN UINTN Count
; );
;------------------------------------------------------------------------------
InternalMathLShiftU64 PROC
mov cl, [esp + 12]
xor eax, eax
mov edx, [esp + 4]
test cl, 32 ; Count >= 32?
cmovz eax, edx
cmovz edx, [esp + 8]
shld edx, eax, cl
shl eax, cl
ret
InternalMathLShiftU64 ENDP
END

View File

@@ -0,0 +1,38 @@
/** @file
64-bit left shift function for IA-32.
Copyright (c) 2006 - 2007, Intel Corporation<BR>
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
//
// Include common header file for this module.
//
#include "CommonHeader.h"
UINT64
EFIAPI
InternalMathLShiftU64 (
IN UINT64 Operand,
IN UINTN Count
)
{
_asm {
mov cl, byte ptr [Count]
xor eax, eax
mov edx, dword ptr [Operand + 0]
test cl, 32 // Count >= 32?
cmovz eax, edx
cmovz edx, dword ptr [Operand + 4]
shld edx, eax, cl
shl eax, cl
}
}

View File

@@ -0,0 +1,46 @@
//
// Include common header file for this module.
//
#include "CommonHeader.h"
#------------------------------------------------------------------------------
#
# Copyright (c) 2006, Intel Corporation
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
# Module Name:
#
# LongJump.Asm
#
# Abstract:
#
# Implementation of _LongJump() on IA-32.
#
#------------------------------------------------------------------------------
.globl ASM_PFX(InternalLongJump)
#------------------------------------------------------------------------------
# VOID
# EFIAPI
# InternalLongJump (
# IN BASE_LIBRARY_JUMP_BUFFER *JumpBuffer,
# IN UINTN Value
# );
#------------------------------------------------------------------------------
ASM_PFX(InternalLongJump):
pop %eax
pop %edx
pop %eax
movl (%edx), %ebx
movl 4(%edx), %esi
movl 8(%edx), %edi
movl 12(%edx), %ebp
movl 16(%edx), %esp
jmp *20(%edx)

View File

@@ -0,0 +1,46 @@
;------------------------------------------------------------------------------
;
; Copyright (c) 2006, Intel Corporation
; All rights reserved. This program and the accompanying materials
; are licensed and made available under the terms and conditions of the BSD License
; which accompanies this distribution. The full text of the license may be found at
; http://opensource.org/licenses/bsd-license.php
;
; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
;
; Module Name:
;
; LongJump.Asm
;
; Abstract:
;
; Implementation of _LongJump() on IA-32.
;
;------------------------------------------------------------------------------
.386
.model flat,C
.code
;------------------------------------------------------------------------------
; VOID
; EFIAPI
; InternalLongJump (
; IN BASE_LIBRARY_JUMP_BUFFER *JumpBuffer,
; IN UINTN Value
; );
;------------------------------------------------------------------------------
InternalLongJump PROC
pop eax ; skip return address
pop edx ; edx <- JumpBuffer
pop eax ; eax <- Value
mov ebx, [edx]
mov esi, [edx + 4]
mov edi, [edx + 8]
mov ebp, [edx + 12]
mov esp, [edx + 16]
jmp dword ptr [edx + 20] ; restore "eip"
InternalLongJump ENDP
END

View File

@@ -0,0 +1,40 @@
/** @file
Implementation of _LongJump() on IA-32.
Copyright (c) 2006 - 2007, Intel Corporation<BR>
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
//
// Include common header file for this module.
//
#include "CommonHeader.h"
__declspec (naked)
VOID
EFIAPI
InternalLongJump (
IN BASE_LIBRARY_JUMP_BUFFER *JumpBuffer,
IN UINTN Value
)
{
_asm {
pop eax ; skip return address
pop edx ; edx <- JumpBuffer
pop eax ; eax <- Value
mov ebx, [edx]
mov esi, [edx + 4]
mov edi, [edx + 8]
mov ebp, [edx + 12]
mov esp, [edx + 16]
jmp dword ptr [edx + 20]
}
}

View File

@@ -0,0 +1,45 @@
//
// Include common header file for this module.
//
#include "CommonHeader.h"
#------------------------------------------------------------------------------
#
# Copyright (c) 2006, Intel Corporation
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
# Module Name:
#
# DivU64x32.S
#
# Abstract:
#
# Calculate the remainder of a 64-bit integer by a 32-bit integer
#
#------------------------------------------------------------------------------
.globl ASM_PFX(InternalMathModU64x32)
#------------------------------------------------------------------------------
# UINT32
# EFIAPI
# InternalMathModU64x32 (
# IN UINT64 Dividend,
# IN UINT32 Divisor
# );
#------------------------------------------------------------------------------
ASM_PFX(InternalMathModU64x32):
movl 8(%esp), %eax
movl 12(%esp), %ecx
xorl %edx, %edx
divl %ecx
movl 4(%esp), %eax
divl %ecx
movl %edx, %eax
ret

View File

@@ -0,0 +1,45 @@
;------------------------------------------------------------------------------
;
; Copyright (c) 2006, Intel Corporation
; All rights reserved. This program and the accompanying materials
; are licensed and made available under the terms and conditions of the BSD License
; which accompanies this distribution. The full text of the license may be found at
; http://opensource.org/licenses/bsd-license.php
;
; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
;
; Module Name:
;
; DivU64x32.asm
;
; Abstract:
;
; Calculate the remainder of a 64-bit integer by a 32-bit integer
;
;------------------------------------------------------------------------------
.386
.model flat,C
.code
;------------------------------------------------------------------------------
; UINT32
; EFIAPI
; InternalMathModU64x32 (
; IN UINT64 Dividend,
; IN UINT32 Divisor
; );
;------------------------------------------------------------------------------
InternalMathModU64x32 PROC
mov eax, [esp + 8]
mov ecx, [esp + 12]
xor edx, edx
div ecx
mov eax, [esp + 4]
div ecx
mov eax, edx
ret
InternalMathModU64x32 ENDP
END

View File

@@ -0,0 +1,36 @@
/** @file
Calculate the remainder of a 64-bit integer by a 32-bit integer
Copyright (c) 2006 - 2007, Intel Corporation<BR>
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
//
// Include common header file for this module.
//
#include "CommonHeader.h"
UINT32
EFIAPI
InternalMathModU64x32 (
IN UINT64 Dividend,
IN UINT32 Divisor
)
{
_asm {
mov eax, dword ptr [Dividend + 4]
mov ecx, Divisor
xor edx, edx
div ecx
mov eax, dword ptr [Dividend + 0]
div ecx
mov eax, edx
}
}

View File

@@ -0,0 +1,45 @@
//
// Include common header file for this module.
//
#include "CommonHeader.h"
#------------------------------------------------------------------------------
#
# Copyright (c) 2006, Intel Corporation
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
# Module Name:
#
# Monitor.Asm
#
# Abstract:
#
# AsmMonitor function
#
# Notes:
#
#------------------------------------------------------------------------------
.globl ASM_PFX(AsmMonitor)
#------------------------------------------------------------------------------
# UINT64
# EFIAPI
# AsmMonitor (
# IN UINTN Eax,
# IN UINTN Ecx,
# IN UINTN Edx
# );
#------------------------------------------------------------------------------
ASM_PFX(AsmMonitor):
movl 4(%esp), %eax
movl 8(%esp), %ecx
movl 12(%esp), %edx
monitor %eax, %ecx, %edx
ret

View File

@@ -0,0 +1,45 @@
;------------------------------------------------------------------------------
;
; Copyright (c) 2006, Intel Corporation
; All rights reserved. This program and the accompanying materials
; are licensed and made available under the terms and conditions of the BSD License
; which accompanies this distribution. The full text of the license may be found at
; http://opensource.org/licenses/bsd-license.php
;
; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
;
; Module Name:
;
; Monitor.Asm
;
; Abstract:
;
; AsmMonitor function
;
; Notes:
;
;------------------------------------------------------------------------------
.686
.model flat,C
.code
;------------------------------------------------------------------------------
; UINTN
; EFIAPI
; AsmMonitor (
; IN UINTN Eax,
; IN UINTN Ecx,
; IN UINTN Edx
; );
;------------------------------------------------------------------------------
AsmMonitor PROC
mov eax, [esp + 4]
mov ecx, [esp + 8]
mov edx, [esp + 12]
DB 0fh, 1, 0c8h ; monitor
ret
AsmMonitor ENDP
END

View File

@@ -0,0 +1,37 @@
/** @file
AsmMonitor function
Copyright (c) 2006 - 2007, Intel Corporation<BR>
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
//
// Include common header file for this module.
//
#include "CommonHeader.h"
UINTN
EFIAPI
AsmMonitor (
IN UINTN RegisterEax,
IN UINTN RegisterEcx,
IN UINTN RegisterEdx
)
{
_asm {
mov eax, RegisterEax
mov ecx, RegisterEcx
mov edx, RegisterEdx
_emit 0x0f // monitor
_emit 0x01
_emit 0xc8
}
}

View File

@@ -0,0 +1,46 @@
//
// Include common header file for this module.
//
#include "CommonHeader.h"
#------------------------------------------------------------------------------
#
# Copyright (c) 2006, Intel Corporation
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
# Module Name:
#
# MultU64x32.asm
#
# Abstract:
#
# Calculate the product of a 64-bit integer and a 32-bit integer
#
#------------------------------------------------------------------------------
.386:
.code:
.globl ASM_PFX(InternalMathMultU64x32)
#------------------------------------------------------------------------------
# UINT64
# EFIAPI
# InternalMathMultU64x32 (
# IN UINT64 Multiplicand,
# IN UINT32 Multiplier
# );
#------------------------------------------------------------------------------
ASM_PFX(InternalMathMultU64x32):
movl 12(%esp), %ecx
movl %ecx, %eax
imull 8(%esp), %ecx
mull 0x4(%esp)
addl %ecx, %edx
ret

View File

@@ -0,0 +1,43 @@
;------------------------------------------------------------------------------
;
; Copyright (c) 2006, Intel Corporation
; All rights reserved. This program and the accompanying materials
; are licensed and made available under the terms and conditions of the BSD License
; which accompanies this distribution. The full text of the license may be found at
; http://opensource.org/licenses/bsd-license.php
;
; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
;
; Module Name:
;
; MultU64x32.asm
;
; Abstract:
;
; Calculate the product of a 64-bit integer and a 32-bit integer
;
;------------------------------------------------------------------------------
.386
.model flat,C
.code
;------------------------------------------------------------------------------
; UINT64
; EFIAPI
; InternalMathMultU64x32 (
; IN UINT64 Multiplicand,
; IN UINT32 Multiplier
; );
;------------------------------------------------------------------------------
InternalMathMultU64x32 PROC
mov ecx, [esp + 12]
mov eax, ecx
imul ecx, [esp + 8] ; overflow not detectable
mul dword ptr [esp + 4]
add edx, ecx
ret
InternalMathMultU64x32 ENDP
END

View File

@@ -0,0 +1,35 @@
/** @file
Calculate the product of a 64-bit integer and a 32-bit integer
Copyright (c) 2006 - 2007, Intel Corporation<BR>
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
//
// Include common header file for this module.
//
#include "CommonHeader.h"
UINT64
EFIAPI
InternalMathMultU64x32 (
IN UINT64 Multiplicand,
IN UINT32 Multiplier
)
{
_asm {
mov ecx, Multiplier
mov eax, ecx
imul ecx, dword ptr [Multiplicand + 4] // overflow not detectable
mul dword ptr [Multiplicand + 0]
add edx, ecx
}
}

View File

@@ -0,0 +1,49 @@
//
// Include common header file for this module.
//
#include "CommonHeader.h"
#------------------------------------------------------------------------------
#
# Copyright (c) 2006, Intel Corporation
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
# Module Name:
#
# MultU64x64.asm
#
# Abstract:
#
# Calculate the product of a 64-bit integer and another 64-bit integer
#
#------------------------------------------------------------------------------
.globl ASM_PFX(InternalMathMultU64x64)
#------------------------------------------------------------------------------
# UINT64
# EFIAPI
# InternalMathMultU64x64 (
# IN UINT64 Multiplicand,
# IN UINT64 Multiplier
# );
#------------------------------------------------------------------------------
ASM_PFX(InternalMathMultU64x64):
push %ebx
movl 8(%esp), %ebx
movl 16(%esp), %edx
movl %ebx, %ecx
movl %edx, %eax
imull 20(%esp), %ebx
imull 12(%esp), %edx
addl %edx, %ebx
mull %ecx
addl %ebx, %edx
pop %ebx
ret

View File

@@ -0,0 +1,47 @@
;------------------------------------------------------------------------------
;
; Copyright (c) 2006, Intel Corporation
; All rights reserved. This program and the accompanying materials
; are licensed and made available under the terms and conditions of the BSD License
; which accompanies this distribution. The full text of the license may be found at
; http://opensource.org/licenses/bsd-license.php
;
; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
;
; Module Name:
;
; MultU64x64.asm
;
; Abstract:
;
; Calculate the product of a 64-bit integer and another 64-bit integer
;
;------------------------------------------------------------------------------
.386
.model flat,C
.code
;------------------------------------------------------------------------------
; UINT64
; EFIAPI
; InternalMathMultU64x64 (
; IN UINT64 Multiplicand,
; IN UINT64 Multiplier
; );
;------------------------------------------------------------------------------
InternalMathMultU64x64 PROC USES ebx
mov ebx, [esp + 8] ; ebx <- M1[0..31]
mov edx, [esp + 16] ; edx <- M2[0..31]
mov ecx, ebx
mov eax, edx
imul ebx, [esp + 20] ; ebx <- M1[0..31] * M2[32..63]
imul edx, [esp + 12] ; edx <- M1[32..63] * M2[0..31]
add ebx, edx ; carries are abandoned
mul ecx ; edx:eax <- M1[0..31] * M2[0..31]
add edx, ebx ; carries are abandoned
ret
InternalMathMultU64x64 ENDP
END

View File

@@ -0,0 +1,39 @@
/** @file
Calculate the product of a 64-bit integer and another 64-bit integer
Copyright (c) 2006 - 2007, Intel Corporation<BR>
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
//
// Include common header file for this module.
//
#include "CommonHeader.h"
UINT64
EFIAPI
InternalMathMultU64x64 (
IN UINT64 Multiplicand,
IN UINT64 Multiplier
)
{
_asm {
mov ebx, dword ptr [Multiplicand + 0]
mov edx, dword ptr [Multiplier + 0]
mov ecx, ebx
mov eax, edx
imul ebx, dword ptr [Multiplier + 4]
imul edx, dword ptr [Multiplicand + 4]
add ebx, edx
mul ecx
add edx, ebx
}
}

View File

@@ -0,0 +1,43 @@
//
// Include common header file for this module.
//
#include "CommonHeader.h"
#------------------------------------------------------------------------------
#
# Copyright (c) 2006, Intel Corporation
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
# Module Name:
#
# Mwait.Asm
#
# Abstract:
#
# AsmMwait function
#
# Notes:
#
#------------------------------------------------------------------------------
.globl ASM_PFX(AsmMwait)
#------------------------------------------------------------------------------
# UINT64
# EFIAPI
# AsmMwait (
# IN UINTN Eax,
# IN UINTN Ecx
# );
#------------------------------------------------------------------------------
ASM_PFX(AsmMwait):
movl 4(%esp), %eax
movl 8(%esp), %ecx
mwait %eax, %ecx
ret

View File

@@ -0,0 +1,43 @@
;------------------------------------------------------------------------------
;
; Copyright (c) 2006, Intel Corporation
; All rights reserved. This program and the accompanying materials
; are licensed and made available under the terms and conditions of the BSD License
; which accompanies this distribution. The full text of the license may be found at
; http://opensource.org/licenses/bsd-license.php
;
; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
;
; Module Name:
;
; Mwait.Asm
;
; Abstract:
;
; AsmMwait function
;
; Notes:
;
;------------------------------------------------------------------------------
.686
.model flat,C
.code
;------------------------------------------------------------------------------
; UINTN
; EFIAPI
; AsmMwait (
; IN UINTN Eax,
; IN UINTN Ecx
; );
;------------------------------------------------------------------------------
AsmMwait PROC
mov eax, [esp + 4]
mov ecx, [esp + 8]
DB 0fh, 1, 0c9h ; mwait
ret
AsmMwait ENDP
END

View File

@@ -0,0 +1,35 @@
/** @file
AsmMwait function
Copyright (c) 2006 - 2007, Intel Corporation<BR>
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
//
// Include common header file for this module.
//
#include "CommonHeader.h"
UINTN
EFIAPI
AsmMwait (
IN UINTN RegisterEax,
IN UINTN RegisterEcx
)
{
_asm {
mov eax, RegisterEax
mov ecx, RegisterEcx
_emit 0x0f // mwait
_emit 0x01
_emit 0xC9
}
}

View File

@@ -0,0 +1,65 @@
/** @file
Non-existing BaseLib functions on Ia32
Copyright (c) 2006, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name: Non-existing.c
**/
//
// Include common header file for this module.
//
#include "CommonHeader.h"
#include "../BaseLibInternals.h"
/**
Disables the 64-bit paging mode on the CPU.
Disables the 64-bit paging mode on the CPU and returns to 32-bit protected
mode. This function assumes the current execution mode is 64-paging mode.
This function is only available on X64. After the 64-bit paging mode is
disabled, control is transferred to the function specified by EntryPoint
using the new stack specified by NewStack and passing in the parameters
specified by Context1 and Context2. Context1 and Context2 are optional and
may be 0. The function EntryPoint must never return.
@param Cs The 16-bit selector to load in the CS before EntryPoint
is called. The descriptor in the GDT that this selector
references must be setup for 32-bit protected mode.
@param EntryPoint The 64-bit virtual address of the function to call with
the new stack after paging is disabled.
@param Context1 The 64-bit virtual address of the context to pass into
the EntryPoint function as the first parameter after
paging is disabled.
@param Context2 The 64-bit virtual address of the context to pass into
the EntryPoint function as the second parameter after
paging is disabled.
@param NewStack The 64-bit virtual address of the new stack to use for
the EntryPoint function after paging is disabled.
**/
VOID
EFIAPI
InternalX86DisablePaging64 (
IN UINT16 CodeSelector,
IN UINT32 EntryPoint,
IN UINT32 Context1, OPTIONAL
IN UINT32 Context2, OPTIONAL
IN UINT32 NewStack
)
{
//
// This function cannot work on IA32 platform
//
ASSERT (FALSE);
}

View File

@@ -0,0 +1,51 @@
//
// Include common header file for this module.
//
#include "CommonHeader.h"
#------------------------------------------------------------------------------
#
# Copyright (c) 2006, Intel Corporation
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
# Module Name:
#
# RRotU64.asm
#
# Abstract:
#
# 64-bit right rotation for Ia32
#
#------------------------------------------------------------------------------
.globl ASM_PFX(InternalMathRRotU64)
#------------------------------------------------------------------------------
# UINT64
# EFIAPI
# InternalMathRRotU64 (
# IN UINT64 Operand,
# IN UINTN Count
# );
#------------------------------------------------------------------------------
ASM_PFX(InternalMathRRotU64):
push %ebx
movb 16(%esp), %cl
movl 8(%esp), %eax
movl 12(%esp), %edx
shrdl %cl, %eax, %ebx
shrdl %cl, %edx, %eax
roll %cl, %ebx
shrdl %cl, %ebx, %edx
testb $32, %cl
cmovnz %eax, %ecx
cmovnz %edx, %eax
cmovnz %ecx, %edx
pop %ebx
ret

View File

@@ -0,0 +1,49 @@
;------------------------------------------------------------------------------
;
; Copyright (c) 2006, Intel Corporation
; All rights reserved. This program and the accompanying materials
; are licensed and made available under the terms and conditions of the BSD License
; which accompanies this distribution. The full text of the license may be found at
; http://opensource.org/licenses/bsd-license.php
;
; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
;
; Module Name:
;
; RRotU64.asm
;
; Abstract:
;
; 64-bit right rotation for Ia32
;
;------------------------------------------------------------------------------
.686
.model flat,C
.code
;------------------------------------------------------------------------------
; UINT64
; EFIAPI
; InternalMathRRotU64 (
; IN UINT64 Operand,
; IN UINTN Count
; );
;------------------------------------------------------------------------------
InternalMathRRotU64 PROC USES ebx
mov cl, [esp + 16]
mov eax, [esp + 8]
mov edx, [esp + 12]
shrd ebx, eax, cl
shrd eax, edx, cl
rol ebx, cl
shrd edx, ebx, cl
test cl, 32 ; Count >= 32?
cmovnz ecx, eax ; switch eax & edx if Count >= 32
cmovnz eax, edx
cmovnz edx, ecx
ret
InternalMathRRotU64 ENDP
END

Some files were not shown because too many files have changed in this diff Show More