/* Get the SystemID from the bios dmi info */ static EFI_CHAR8* getSmbiosUUID() { struct SMBEntryPoint *smbios; SMBByte *p; int i, isZero, isOnes; static EFI_CHAR8 uuid[UUID_LEN]; smbios = getSmbios(SMBIOS_PATCHED); /* checks for _SM_ anchor and table header checksum */ if (smbios==NULL) return 0; // getSmbios() return a non null value if smbios is found p = (SMBByte*) FindFirstDmiTableOfType(1, 0x19); /* Type 1: (3.3.2) System Information */ if (p==NULL) return NULL; verbose("Found SMBIOS System Information Table 1\n"); p += 8; for (i=0, isZero=1, isOnes=1; i<UUID_LEN; i++) { if (p[i] != 0x00) isZero = 0; if (p[i] != 0xff) isOnes = 0; } if (isZero || isOnes) { /* empty or setable means: no uuid present */ verbose("No UUID present in SMBIOS System Information Table\n"); return 0; } memcpy(uuid, p, UUID_LEN); return uuid; }
void dumpAllTablesOfType(int i) { char title[32]; struct DMIHeader * dmihdr; for(dmihdr = FindFirstDmiTableOfType(i, 4); dmihdr; dmihdr = FindNextDmiTableOfType(i, 4)) { sprintf(title,"Table (type %d) :" , i); dumpPhysAddr(title, dmihdr, dmihdr->length+32); } }
void scan_memory(PlatformInfo_t *p) { int i=0; struct DMIHeader * dmihdr = NULL; struct DMIMemoryModuleInfo* memInfo[MAX_RAM_SLOTS]; // 6 struct DMIPhysicalMemoryArray* physMemArray; // 16 struct DMIMemoryDevice* memDev[MAX_RAM_SLOTS]; //17 /* We mainly don't use obsolete tables 5,6 because most of computers don't handle it anymore */ Platform.DMI.MemoryModules = 0; /* Now lets peek info from table 16,17 as for some bios, table 5 & 6 are not used */ physMemArray = (struct DMIPhysicalMemoryArray*) FindFirstDmiTableOfType(16, 4); Platform.DMI.MaxMemorySlots = physMemArray ? physMemArray->numberOfMemoryDevices : 0; i = 0; for(dmihdr = FindFirstDmiTableOfType(17, 4); dmihdr; dmihdr = FindNextDmiTableOfType(17, 4) ) { memDev[i] = (struct DMIMemoryDevice*) dmihdr; if (memDev[i]->size !=0 ) Platform.DMI.MemoryModules++; if (memDev[i]->speed>0) Platform.RAM.DIMM[i].Frequency = memDev[i]->speed; // take it here for now but we'll check spd and dmi table 6 as well i++; } // for table 6, we only have a look at the current speed i = 0; for(dmihdr = FindFirstDmiTableOfType(6, 4); dmihdr; dmihdr = FindNextDmiTableOfType(6, 4) ) { memInfo[i] = (struct DMIMemoryModuleInfo*) dmihdr; if (memInfo[i]->currentSpeed > Platform.RAM.DIMM[i].Frequency) Platform.RAM.DIMM[i].Frequency = memInfo[i]->currentSpeed; // favor real overclocked speed if any i++; } #if 0 dumpAllTablesOfType(17); getc(); #endif }