PciIovPlatformPolicy.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /** @file
  2. @copyright
  3. Copyright 2014 - 2021 Intel Corporation. <BR>
  4. SPDX-License-Identifier: BSD-2-Clause-Patent
  5. **/
  6. #include <PiDxe.h>
  7. #include "PciPlatform.h"
  8. #include <Guid/SetupVariable.h>
  9. #ifdef EFI_PCI_IOV_SUPPORT
  10. /**
  11. The GetSystemLowestPageSize() function retrieves the system lowest page size.
  12. @param This - Pointer to the EFI_PCI_IOV_PLATFORM_PROTOCOL instance.
  13. @param SystemLowestPageSize - The system lowest page size. (This system supports a
  14. page size of 2^(n+12) if bit n is set.)
  15. @retval EFI_SUCCESS - The function completed successfully.
  16. @retval EFI_INVALID_PARAMETER - SystemLowestPageSize is NULL.
  17. **/
  18. EFI_STATUS
  19. EFIAPI
  20. GetSystemLowestPageSize (
  21. IN EFI_PCI_IOV_PLATFORM_PROTOCOL *This,
  22. OUT UINT32 *SystemLowestPageSize
  23. )
  24. {
  25. UINT8 SystemPageSizeOption;
  26. CopyMem (&SystemPageSizeOption, (((UINT8*) PcdGetPtr (PcdSetup)) + OFFSET_OF (SYSTEM_CONFIGURATION, SystemPageSize)), sizeof (UINT8));
  27. if (SystemLowestPageSize != NULL) {
  28. //
  29. // Convert page size option to page size
  30. // Option is n in 2^n
  31. // Page size is number of 4KiB pages
  32. //
  33. *SystemLowestPageSize = (UINT32) (1 << SystemPageSizeOption);
  34. }
  35. return EFI_SUCCESS;
  36. }
  37. /**
  38. The GetIovPlatformPolicy() function retrieves the platform policy regarding PCI IOV.
  39. @param This - Pointer to the EFI_PCI_IOV_PLATFORM_PROTOCOL instance.
  40. @param PciIovPolicy - The platform policy for PCI IOV configuration.
  41. @retval EFI_SUCCESS - The function completed successfully.
  42. @retval EFI_INVALID_PARAMETER - PciPolicy is NULL.
  43. **/
  44. EFI_STATUS
  45. EFIAPI
  46. GetIovPlatformPolicy (
  47. IN EFI_PCI_IOV_PLATFORM_PROTOCOL *This,
  48. OUT EFI_PCI_IOV_PLATFORM_POLICY *PciIovPolicy
  49. )
  50. {
  51. UINT8 PolicyEnable;
  52. UINT8 ARIEnable;
  53. UINT8 SRIOVEnable;
  54. UINT8 MRIOVEnable;
  55. PolicyEnable = 0;
  56. CopyMem (&ARIEnable, (((UINT8*) PcdGetPtr (PcdSetup)) + OFFSET_OF (SYSTEM_CONFIGURATION, ARIEnable)), sizeof (UINT8));
  57. CopyMem (&SRIOVEnable, (((UINT8*) PcdGetPtr (PcdSetup)) + OFFSET_OF (SYSTEM_CONFIGURATION, SRIOVEnable)), sizeof (UINT8));
  58. CopyMem (&MRIOVEnable, (((UINT8*) PcdGetPtr (PcdSetup)) + OFFSET_OF (SYSTEM_CONFIGURATION, MRIOVEnable)), sizeof (UINT8));
  59. if (ARIEnable == TRUE) {
  60. PolicyEnable = PolicyEnable | EFI_PCI_IOV_POLICY_ARI;
  61. }
  62. if (SRIOVEnable == TRUE) {
  63. PolicyEnable = PolicyEnable | EFI_PCI_IOV_POLICY_SRIOV;
  64. }
  65. if (MRIOVEnable == TRUE) {
  66. PolicyEnable = PolicyEnable | EFI_PCI_IOV_POLICY_MRIOV;
  67. }
  68. if (PciIovPolicy != NULL) {
  69. //*PciIovPolicy = EFI_PCI_IOV_POLICY_ARI | EFI_PCI_IOV_POLICY_SRIOV;
  70. *PciIovPolicy = PolicyEnable;
  71. }
  72. return EFI_SUCCESS;
  73. }
  74. #endif