1 /*++
2 
3 Copyright (c) 2004 - 2006, Intel Corporation. All rights reserved.<BR>
4 This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution.  The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
8 
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11 
12 Module Name:
13 
14   EfiCpuVersion.c
15 
16 Abstract:
17 
18   Provide cpu version extract considering extended family & model ID.
19 --*/
20 
21 #include "CpuIA32.h"
22 
23 VOID
24 EFIAPI
EfiCpuVersion(IN OUT UINT16 * FamilyId,OPTIONAL IN OUT UINT8 * Model,OPTIONAL IN OUT UINT8 * SteppingId,OPTIONAL IN OUT UINT8 * Processor OPTIONAL)25 EfiCpuVersion (
26   IN  OUT UINT16  *FamilyId,    OPTIONAL
27   IN  OUT UINT8   *Model,       OPTIONAL
28   IN  OUT UINT8   *SteppingId,  OPTIONAL
29   IN  OUT UINT8   *Processor    OPTIONAL
30   )
31 /*++
32 
33 Routine Description:
34   Extract CPU detail version infomation
35 
36 Arguments:
37   FamilyId   - FamilyId, including ExtendedFamilyId
38   Model      - Model, including ExtendedModel
39   SteppingId - SteppingId
40   Processor  - Processor
41 
42 --*/
43 {
44   EFI_CPUID_REGISTER Register;
45   UINT8              TempFamilyId;
46 
47   EfiCpuid (EFI_CPUID_VERSION_INFO, &Register);
48 
49   if (SteppingId != NULL) {
50     *SteppingId = (UINT8) (Register.RegEax & 0xF);
51   }
52 
53   if (Processor != NULL) {
54     *Processor = (UINT8) ((Register.RegEax >> 12) & 0x3);
55   }
56 
57   if (Model != NULL || FamilyId != NULL) {
58     TempFamilyId = (UINT8) ((Register.RegEax >> 8) & 0xF);
59 
60     if (Model != NULL) {
61       *Model = (UINT8) ((Register.RegEax >> 4) & 0xF);
62       if (TempFamilyId == 0x6 || TempFamilyId == 0xF) {
63         *Model = (UINT8) (*Model  | ((Register.RegEax >> 12) & 0xF0));
64       }
65     }
66 
67     if (FamilyId != NULL) {
68       *FamilyId = TempFamilyId;
69       if (TempFamilyId == 0xF) {
70         *FamilyId = (UINT8 ) (*FamilyId + (UINT16) ((Register.RegEax >> 20) & 0xFF));
71       }
72     }
73   }
74 }
75