| 1991 | } |
| 1992 | |
| 1993 | EFI_STATUS PrepatchSmbios() |
| 1994 | { |
| 1995 | EFI_STATUS Status = EFI_SUCCESS; |
| 1996 | UINTN BufferLen; |
| 1997 | EFI_PHYSICAL_ADDRESS BufferPtr; |
| 1998 | // UINTN Index; |
| 1999 | DbgHeader("Get Smbios"); |
| 2000 | |
| 2001 | // Get SMBIOS Tables |
| 2002 | Smbios = FindOemSMBIOSPtr(); |
| 2003 | // DBG("OEM SMBIOS EPS=%p\n", Smbios); |
| 2004 | // DBG("OEM Tables = %X\n", ((SMBIOS_TABLE_ENTRY_POINT*)Smbios)->TableAddress); |
| 2005 | if (!Smbios) { |
| 2006 | // DBG("Original SMBIOS System Table not found! Getting from Hob...\n"); |
| 2007 | Smbios = GetSmbiosTablesFromHob(); |
| 2008 | // DBG("HOB SMBIOS EPS=%p\n", Smbios); |
| 2009 | if (!Smbios) { |
| 2010 | // DBG("And here SMBIOS System Table not found! Trying System table ...\n"); |
| 2011 | // this should work on any UEFI |
| 2012 | Smbios = GetSmbiosTablesFromConfigTables(); |
| 2013 | // DBG("ConfigTables SMBIOS EPS=%p\n", Smbios); |
| 2014 | if (!Smbios) { |
| 2015 | // DBG("And here SMBIOS System Table not found! Exiting...\n"); |
| 2016 | return EFI_NOT_FOUND; |
| 2017 | } |
| 2018 | } |
| 2019 | } |
| 2020 | |
| 2021 | //original EPS and tables |
| 2022 | EntryPoint = (SMBIOS_TABLE_ENTRY_POINT*)Smbios; //yes, it is old SmbiosEPS |
| 2023 | // Smbios = (VOID*)(UINT32)EntryPoint->TableAddress; // here is flat Smbios database. Work with it |
| 2024 | //how many we need to add for tables 128, 130, 131, 132 and for strings? |
| 2025 | BufferLen = 0x20 + EntryPoint->TableLength + 64 * 10; |
| 2026 | //new place for EPS and tables. Allocated once for both |
| 2027 | BufferPtr = EFI_SYSTEM_TABLE_MAX_ADDRESS; |
| 2028 | Status = gBS->AllocatePages (AllocateMaxAddress, EfiACPIMemoryNVS, /*EfiACPIReclaimMemory, */ |
| 2029 | EFI_SIZE_TO_PAGES(BufferLen), &BufferPtr); |
| 2030 | if (EFI_ERROR(Status)) { |
| 2031 | // DBG("There is error allocating pages in EfiACPIMemoryNVS!\n"); |
| 2032 | Status = gBS->AllocatePages (AllocateMaxAddress, /*EfiACPIMemoryNVS, */EfiACPIReclaimMemory, |
| 2033 | ROUND_PAGE(BufferLen)/EFI_PAGE_SIZE, &BufferPtr); |
| 2034 | if (EFI_ERROR(Status)) { |
| 2035 | // DBG("There is error allocating pages in EfiACPIReclaimMemory!\n"); |
| 2036 | } |
| 2037 | } |
| 2038 | // DBG("Buffer @ %p\n", BufferPtr); |
| 2039 | if (BufferPtr) { |
| 2040 | SmbiosEpsNew = (SMBIOS_TABLE_ENTRY_POINT *)(UINTN)BufferPtr; //this is new EPS |
| 2041 | } else { |
| 2042 | SmbiosEpsNew = EntryPoint; //is it possible?! |
| 2043 | } |
| 2044 | ZeroMem(SmbiosEpsNew, BufferLen); |
| 2045 | // DBG("New EntryPoint = %p\n", SmbiosEpsNew); |
| 2046 | NumberOfRecords = 0; |
| 2047 | MaxStructureSize = 0; |
| 2048 | //preliminary fill EntryPoint with some data |
| 2049 | CopyMem((VOID *)SmbiosEpsNew, (VOID *)EntryPoint, sizeof(SMBIOS_TABLE_ENTRY_POINT)); |
| 2050 |
no test coverage detected