]> git.proxmox.com Git - mirror_edk2.git/commitdiff
1. Added AsmCpuidEx() to BaseLib
authorbxing <bxing@6f19259b-4bc3-4df7-8a09-765794883524>
Sat, 10 Jun 2006 09:37:12 +0000 (09:37 +0000)
committerbxing <bxing@6f19259b-4bc3-4df7-8a09-765794883524>
Sat, 10 Jun 2006 09:37:12 +0000 (09:37 +0000)
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

MdePkg/Include/Library/BaseLib.h
MdePkg/Library/BaseLib/BaseLib.msa
MdePkg/Library/BaseLib/Ia32/CpuIdEx.asm [new file with mode: 0644]
MdePkg/Library/BaseLib/String.c
MdePkg/Library/BaseLib/X64/CpuIdEx.asm

index e042ccb712641e0809b66793e3bb04b5ed610717..a63bc1bc3e893828505a1e841292dc413cbe0cde 100644 (file)
@@ -638,6 +638,45 @@ AsciiStrnCat (
   IN      UINTN                     Length\r
   );\r
 \r
   IN      UINTN                     Length\r
   );\r
 \r
+/**\r
+  Converts an 8-bit value to an 8-bit BCD value.\r
+\r
+  Converts the 8-bit value specified by Value to BCD. The BCD value is\r
+  returned.\r
+\r
+  If Value >= 100, then ASSERT().\r
+\r
+  @param  Value The 8-bit value to convert to BCD. Range 0..99.\r
+\r
+  @return The BCD value\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+DecimalToBcd8 (\r
+  IN      UINT8                     Value\r
+  );\r
+\r
+/**\r
+  Converts an 8-bit BCD value to an 8-bit value.\r
+\r
+  Converts the 8-bit BCD value specified by Value to an 8-bit value. The 8-bit\r
+  value is returned.\r
+\r
+  If Value >= 0xA0, then ASSERT().\r
+  If (Value & 0x0F) >= 0x0A, then ASSERT().\r
+\r
+  @param  Value The 8-bit BCD value to convert to an 8-bit value.\r
+\r
+  @return The 8-bit value is returned.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+BcdToDecimal8 (\r
+  IN      UINT8                     Value\r
+  );\r
+\r
 //\r
 // LIST_ENTRY definition\r
 //\r
 //\r
 // LIST_ENTRY definition\r
 //\r
@@ -2994,6 +3033,49 @@ AsmCpuid (
   OUT     UINT32                    *Edx   OPTIONAL\r
   );\r
 \r
   OUT     UINT32                    *Edx   OPTIONAL\r
   );\r
 \r
+/**\r
+  Retrieves CPUID information using an extended leaf identifier.\r
+\r
+  Executes the CPUID instruction with EAX set to the value specified by Index\r
+  and ECX set to the value specified by SubIndex. This function always returns\r
+  Index. This function is only available on IA-32 and x64.\r
+\r
+  If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.\r
+  If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.\r
+  If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.\r
+  If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.\r
+\r
+  @param  Index     The 32-bit value to load into EAX prior to invoking the\r
+                    CPUID instruction.\r
+  @param  SubIndex  The 32-bit value to load into ECX prior to invoking the\r
+                    CPUID instruction.\r
+  @param  Eax       Pointer to the 32-bit EAX value returned by the CPUID\r
+                    instruction. This is an optional parameter that may be\r
+                    NULL.\r
+  @param  Ebx       Pointer to the 32-bit EBX value returned by the CPUID\r
+                    instruction. This is an optional parameter that may be\r
+                    NULL.\r
+  @param  Ecx       Pointer to the 32-bit ECX value returned by the CPUID\r
+                    instruction. This is an optional parameter that may be\r
+                    NULL.\r
+  @param  Edx       Pointer to the 32-bit EDX value returned by the CPUID\r
+                    instruction. This is an optional parameter that may be\r
+                    NULL.\r
+\r
+  @return Index\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+AsmCpuidEx (\r
+  IN      UINT32                    Index,\r
+  IN      UINT32                    SubIndex,\r
+  OUT     UINT32                    *Eax,  OPTIONAL\r
+  OUT     UINT32                    *Ebx,  OPTIONAL\r
+  OUT     UINT32                    *Ecx,  OPTIONAL\r
+  OUT     UINT32                    *Edx   OPTIONAL\r
+  );\r
+\r
 /**\r
   Returns the lower 32-bits of a Machine Specific Register(MSR).\r
 \r
 /**\r
   Returns the lower 32-bits of a Machine Specific Register(MSR).\r
 \r
index 5fc8430422a7d8dcbb816e9a282b84365274b206..0d07e79af4f513b09a154cd56baf4556c6589752 100644 (file)
@@ -94,6 +94,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
       <Filename>Ia32/SetJump.asm</Filename>\r
       <Filename>Ia32/LongJump.asm</Filename>\r
       <Filename>Ia32/CpuId.asm</Filename>\r
       <Filename>Ia32/SetJump.asm</Filename>\r
       <Filename>Ia32/LongJump.asm</Filename>\r
       <Filename>Ia32/CpuId.asm</Filename>\r
+      <Filename>Ia32/CpuIdEx.asm</Filename>\r
       <Filename>Ia32/ReadEflags.asm</Filename>\r
       <Filename>Ia32/ReadMsr64.asm</Filename>\r
       <Filename>Ia32/WriteMsr32.asm</Filename>\r
       <Filename>Ia32/ReadEflags.asm</Filename>\r
       <Filename>Ia32/ReadMsr64.asm</Filename>\r
       <Filename>Ia32/WriteMsr32.asm</Filename>\r
diff --git a/MdePkg/Library/BaseLib/Ia32/CpuIdEx.asm b/MdePkg/Library/BaseLib/Ia32/CpuIdEx.asm
new file mode 100644 (file)
index 0000000..cdebec2
--- /dev/null
@@ -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\r
+;
+; Abstract:
+;
+;   AsmCpuidEx function\r
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+    .686\r
+    .model  flat,C\r
+    .code
+
+;------------------------------------------------------------------------------
+;  UINT32
+;  EFIAPI
+;  AsmCpuidEx (\r
+;    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\r
+    push    ebp\r
+    mov     ebp, esp\r
+    mov     eax, [ebp + 12]\r
+    mov     ecx, [ebp + 16]\r
+    cpuid\r
+    push    ecx\r
+    mov     ecx, [ebp + 20]\r
+    jecxz   @F\r
+    mov     [ecx], eax\r
+@@:\r
+    mov     ecx, [ebp + 24]\r
+    jecxz   @F\r
+    mov     [ecx], ebx\r
+@@:\r
+    mov     ecx, [ebp + 28]\r
+    jecxz   @F\r
+    pop     [ecx]\r
+@@:\r
+    mov     edx, [ebp + 32]\r
+    jecxz   @F\r
+    mov     [ecx], edx\r
+@@:\r
+    mov     eax, [ebp + 12]\r
+    leave\r
+    ret\r
+AsmCpuidEx  ENDP\r
+
+    END
index 6ef2c3b2d321688b0a643554dee68b19f1d56754..0483fc712ef41e37502c6aab59f706f6996edfc4 100644 (file)
@@ -796,3 +796,51 @@ AsciiStrnCat (
   ASSERT (AsciiStrSize (Destination) != 0);\r
   return Destination;\r
 }\r
   ASSERT (AsciiStrSize (Destination) != 0);\r
   return Destination;\r
 }\r
+\r
+/**\r
+  Converts an 8-bit value to an 8-bit BCD value.\r
+\r
+  Converts the 8-bit value specified by Value to BCD. The BCD value is\r
+  returned.\r
+\r
+  If Value >= 100, then ASSERT().\r
+\r
+  @param  Value The 8-bit value to convert to BCD. Range 0..99.\r
+\r
+  @return The BCD value\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+DecimalToBcd8 (\r
+  IN      UINT8                     Value\r
+  )\r
+{\r
+  ASSERT (Value < 100);\r
+  return ((Value / 10) << 4) | (Value % 10);\r
+}\r
+\r
+/**\r
+  Converts an 8-bit BCD value to an 8-bit value.\r
+\r
+  Converts the 8-bit BCD value specified by Value to an 8-bit value. The 8-bit\r
+  value is returned.\r
+\r
+  If Value >= 0xA0, then ASSERT().\r
+  If (Value & 0x0F) >= 0x0A, then ASSERT().\r
+\r
+  @param  Value The 8-bit BCD value to convert to an 8-bit value.\r
+\r
+  @return The 8-bit value is returned.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+BcdToDecimal8 (\r
+  IN      UINT8                     Value\r
+  )\r
+{\r
+  ASSERT (Value < 0xa0);\r
+  ASSERT ((Value & 0xf) < 0xa);\r
+  return (Value >> 4) * 10 + (Value & 0xf);\r
+}\r
index ec5729fbaab61a450a9a3472684be04e132975b3..450cf543f70d0c9fe345372309e13fa6d3283af8 100644 (file)
 ;
 ; Module Name:
 ;
 ;
 ; Module Name:
 ;
-;   CpuId.Asm
+;   CpuIdEx.Asm
 ;
 ; Abstract:
 ;
 ;
 ; Abstract:
 ;
-;   AsmCpuid function
+;   AsmCpuidEx function
 ;
 ; Notes:
 ;
 ;
 ; Notes:
 ;
@@ -26,7 +26,7 @@
 ;------------------------------------------------------------------------------
 ;  UINT32
 ;  EFIAPI
 ;------------------------------------------------------------------------------
 ;  UINT32
 ;  EFIAPI
-;  AsmCpuid (
+;  AsmCpuidEx (
 ;    IN   UINT32  RegisterInEax,
 ;    IN   UINT32  RegisterInEcx,
 ;    OUT  UINT32  *RegisterOutEax  OPTIONAL,
 ;    IN   UINT32  RegisterInEax,
 ;    IN   UINT32  RegisterInEcx,
 ;    OUT  UINT32  *RegisterOutEax  OPTIONAL,