]>
Commit | Line | Data |
---|---|---|
5f0a17d8 JF |
1 | /** @file\r |
2 | Internal function to get spin lock alignment.\r | |
3 | \r | |
4 | Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>\r | |
5 | This program and the accompanying materials\r | |
6 | are licensed and made available under the terms and conditions of the BSD License\r | |
7 | which accompanies this distribution. The full text of the license may be found at\r | |
8 | http://opensource.org/licenses/bsd-license.php.\r | |
9 | \r | |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
12 | \r | |
13 | **/\r | |
14 | \r | |
15 | #include "BaseSynchronizationLibInternals.h"\r | |
16 | \r | |
17 | /**\r | |
18 | Internal function to retrieve the architecture specific spin lock alignment\r | |
19 | requirements for optimal spin lock performance.\r | |
20 | \r | |
21 | @return The architecture specific spin lock alignment.\r | |
22 | \r | |
23 | **/\r | |
24 | UINTN\r | |
25 | InternalGetSpinLockProperties (\r | |
26 | VOID\r | |
27 | )\r | |
28 | {\r | |
29 | UINT32 RegEax;\r | |
30 | UINT32 RegEbx;\r | |
31 | UINTN FamilyId;\r | |
32 | UINTN ModelId;\r | |
33 | UINTN CacheLineSize;\r | |
34 | \r | |
35 | //\r | |
36 | // Retrieve CPUID Version Information\r | |
37 | //\r | |
38 | AsmCpuid (0x01, &RegEax, &RegEbx, NULL, NULL);\r | |
39 | //\r | |
40 | // EBX: Bits 15 - 08: CLFLUSH line size (Value * 8 = cache line size)\r | |
41 | //\r | |
42 | CacheLineSize = ((RegEbx >> 8) & 0xff) * 8;\r | |
43 | //\r | |
44 | // Retrieve CPU Family and Model\r | |
45 | //\r | |
46 | FamilyId = (RegEax >> 8) & 0xf;\r | |
47 | ModelId = (RegEax >> 4) & 0xf;\r | |
48 | if (FamilyId == 0x0f) {\r | |
49 | //\r | |
50 | // In processors based on Intel NetBurst microarchitecture, use two cache lines\r | |
51 | // \r | |
52 | ModelId = ModelId | ((RegEax >> 12) & 0xf0);\r | |
53 | if (ModelId <= 0x04 || ModelId == 0x06) {\r | |
54 | CacheLineSize *= 2;\r | |
55 | }\r | |
56 | }\r | |
57 | \r | |
52f5bd26 JF |
58 | if (CacheLineSize < 32) {\r |
59 | CacheLineSize = 32;\r | |
60 | }\r | |
61 | \r | |
5f0a17d8 JF |
62 | return CacheLineSize;\r |
63 | }\r | |
64 | \r |