MiscPhysicalArrayFunction.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /*++
  2. Copyright (c) 2012 - 2014, Intel Corporation. All rights reserved.<BR>
  3. SPDX-License-Identifier: BSD-2-Clause-Patent
  4. Module Name:
  5. MiscPhysicalArrayFunction.c
  6. Abstract:
  7. BIOS system Physical Array boot time changes.
  8. SMBIOS type 16.
  9. --*/
  10. #include "CommonHeader.h"
  11. #include "MiscSubclassDriver.h"
  12. /**
  13. This function makes boot time changes to the contents of the
  14. MiscPhysicalArrayFunction (Type 16).
  15. @param RecordData Pointer to copy of RecordData from the Data Table.
  16. @retval EFI_SUCCESS All parameters were valid.
  17. @retval EFI_UNSUPPORTED Unexpected RecordType value.
  18. @retval EFI_INVALID_PARAMETER Invalid parameter was found.
  19. **/
  20. MISC_SMBIOS_TABLE_FUNCTION(MiscPhysicalMemoryArray)
  21. {
  22. EFI_STATUS Status;
  23. EFI_SMBIOS_HANDLE SmbiosHandle;
  24. SMBIOS_TABLE_TYPE16 *SmbiosRecord;
  25. EFI_MEMORY_ARRAY_LOCATION_DATA *ForType16InputData;
  26. UINT32 TopOfMemory = 8 * 1024 * 1024;
  27. //
  28. // First check for invalid parameters.
  29. //
  30. if (RecordData == NULL) {
  31. return EFI_INVALID_PARAMETER;
  32. }
  33. ForType16InputData = (EFI_MEMORY_ARRAY_LOCATION_DATA *)RecordData;
  34. //
  35. // Two zeros following the last string.
  36. //
  37. SmbiosRecord = AllocatePool(sizeof (SMBIOS_TABLE_TYPE16) + 1);
  38. ZeroMem(SmbiosRecord, sizeof (SMBIOS_TABLE_TYPE16) + 1);
  39. SmbiosRecord->Hdr.Type = EFI_SMBIOS_TYPE_PHYSICAL_MEMORY_ARRAY;
  40. SmbiosRecord->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE16);
  41. //
  42. // Make handle chosen by smbios protocol.add automatically.
  43. //
  44. SmbiosRecord->Hdr.Handle = 0;
  45. //
  46. // ReleaseDate will be the 3rd optional string following the formatted structure.
  47. //
  48. SmbiosRecord->Location = *(UINT8 *) &ForType16InputData ->MemoryArrayLocation;
  49. SmbiosRecord->Use = *(UINT8 *) &ForType16InputData ->MemoryArrayUse;
  50. SmbiosRecord->MemoryErrorCorrection = *(UINT8 *) &ForType16InputData->MemoryErrorCorrection;
  51. //
  52. // System does not provide the error information structure
  53. //
  54. SmbiosRecord->MemoryErrorInformationHandle = 0xFFFE;
  55. //
  56. // Maximum memory capacity
  57. //
  58. SmbiosRecord-> MaximumCapacity = TopOfMemory;
  59. SmbiosRecord-> NumberOfMemoryDevices= 0x02;
  60. //
  61. // Now we have got the full smbios record, call smbios protocol to add this record.
  62. //
  63. SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED;
  64. Status = Smbios-> Add(
  65. Smbios,
  66. NULL,
  67. &SmbiosHandle,
  68. (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord
  69. );
  70. FreePool(SmbiosRecord);
  71. return Status;
  72. }