CpuCacheInfoLib.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /** @file
  2. Header file for CPU Cache info Library.
  3. Copyright (c) 2020 - 2021, Intel Corporation. All rights reserved.<BR>
  4. SPDX-License-Identifier: BSD-2-Clause-Patent
  5. **/
  6. #ifndef _CPU_CACHE_INFO_LIB_H_
  7. #define _CPU_CACHE_INFO_LIB_H_
  8. typedef struct {
  9. //
  10. // Package number.
  11. //
  12. UINT32 Package;
  13. //
  14. // Core type of logical processor.
  15. // Value = CPUID.1Ah:EAX[31:24]
  16. //
  17. UINT8 CoreType;
  18. //
  19. // Level of the cache that this package's this type of logical processor corresponds to.
  20. // Value = CPUID.04h:EAX[07:05]
  21. //
  22. UINT8 CacheLevel : 3;
  23. //
  24. // Type of the cache that this package's this type of logical processor corresponds to.
  25. // Value = CPUID.04h:EAX[04:00]
  26. //
  27. UINT8 CacheType : 5;
  28. //
  29. // Ways of associativity.
  30. // Value = CPUID.04h:EBX[31:22]
  31. //
  32. UINT16 CacheWays : 10;
  33. //
  34. // Fully associative cache.
  35. // Value = CPUID.04h:EAX[09]
  36. //
  37. UINT16 FullyAssociativeCache : 1;
  38. //
  39. // Direct mapped cache.
  40. // Value = CPUID.04h:EDX[02]
  41. //
  42. UINT16 DirectMappedCache : 1;
  43. UINT16 Reserved : 4;
  44. //
  45. // Size of single cache that this package's this type of logical processor corresponds to.
  46. // Value = (CPUID.04h:EBX[31:22] + 1) * (CPUID.04h:EBX[21:12] + 1) *
  47. // (CPUID.04h:EBX[11:00] + 1) * (CPUID.04h:ECX[31:00] + 1)
  48. //
  49. UINT32 CacheSizeinKB;
  50. //
  51. // Number of the cache that this package's this type of logical processor corresponds to.
  52. // Have subtracted the number of caches that are shared.
  53. //
  54. UINT16 CacheCount;
  55. } CPU_CACHE_INFO;
  56. /**
  57. Get CpuCacheInfo data array. The array is sorted by CPU package ID, core type, cache level and cache type.
  58. @param[in, out] CpuCacheInfo Pointer to the CpuCacheInfo array.
  59. @param[in, out] CpuCacheInfoCount As input, point to the length of response CpuCacheInfo array.
  60. As output, point to the actual length of response CpuCacheInfo array.
  61. @retval EFI_SUCCESS Function completed successfully.
  62. @retval EFI_INVALID_PARAMETER CpuCacheInfoCount is NULL.
  63. @retval EFI_INVALID_PARAMETER CpuCacheInfo is NULL while CpuCacheInfoCount contains the value
  64. greater than zero.
  65. @retval EFI_UNSUPPORTED Processor does not support CPUID_CACHE_PARAMS Leaf.
  66. @retval EFI_OUT_OF_RESOURCES Required resources could not be allocated.
  67. @retval EFI_BUFFER_TOO_SMALL CpuCacheInfoCount is too small to hold the response CpuCacheInfo
  68. array. CpuCacheInfoCount has been updated with the length needed
  69. to complete the request.
  70. **/
  71. EFI_STATUS
  72. EFIAPI
  73. GetCpuCacheInfo (
  74. IN OUT CPU_CACHE_INFO *CpuCacheInfo,
  75. IN OUT UINTN *CpuCacheInfoCount
  76. );
  77. #endif