1. Added AsmCpuidEx() to BaseLib

2. Added DecimalToBcd8() and BcdToDecimal8() to String.c

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@465 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
bxing
2006-06-10 09:37:12 +00:00
parent 4cbd217532
commit dee4740abe
5 changed files with 202 additions and 3 deletions

View File

@@ -94,6 +94,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
<Filename>Ia32/SetJump.asm</Filename>
<Filename>Ia32/LongJump.asm</Filename>
<Filename>Ia32/CpuId.asm</Filename>
<Filename>Ia32/CpuIdEx.asm</Filename>
<Filename>Ia32/ReadEflags.asm</Filename>
<Filename>Ia32/ReadMsr64.asm</Filename>
<Filename>Ia32/WriteMsr32.asm</Filename>

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

@@ -796,3 +796,51 @@ AsciiStrnCat (
ASSERT (AsciiStrSize (Destination) != 0);
return Destination;
}
/**
Converts an 8-bit value to an 8-bit BCD value.
Converts the 8-bit value specified by Value to BCD. The BCD value is
returned.
If Value >= 100, then ASSERT().
@param Value The 8-bit value to convert to BCD. Range 0..99.
@return The BCD value
**/
UINT8
EFIAPI
DecimalToBcd8 (
IN UINT8 Value
)
{
ASSERT (Value < 100);
return ((Value / 10) << 4) | (Value % 10);
}
/**
Converts an 8-bit BCD value to an 8-bit value.
Converts the 8-bit BCD value specified by Value to an 8-bit value. The 8-bit
value is returned.
If Value >= 0xA0, then ASSERT().
If (Value & 0x0F) >= 0x0A, then ASSERT().
@param Value The 8-bit BCD value to convert to an 8-bit value.
@return The 8-bit value is returned.
**/
UINT8
EFIAPI
BcdToDecimal8 (
IN UINT8 Value
)
{
ASSERT (Value < 0xa0);
ASSERT ((Value & 0xf) < 0xa);
return (Value >> 4) * 10 + (Value & 0xf);
}

View File

@@ -11,11 +11,11 @@
;
; Module Name:
;
; CpuId.Asm
; CpuIdEx.Asm
;
; Abstract:
;
; AsmCpuid function
; AsmCpuidEx function
;
; Notes:
;
@@ -26,7 +26,7 @@
;------------------------------------------------------------------------------
; UINT32
; EFIAPI
; AsmCpuid (
; AsmCpuidEx (
; IN UINT32 RegisterInEax,
; IN UINT32 RegisterInEcx,
; OUT UINT32 *RegisterOutEax OPTIONAL,