MCPcopy Create free account
hub / github.com/CloverHackyColor/CloverBootloader / getDDRPartNum

Function getDDRPartNum

rEFIt_UEFI/Platform/spd.cpp:559–586  ·  view source on GitHub ↗

Get DDR2 or DDR3 or DDR4 Part Number, always return a valid ptr */

Source from the content-addressed store, hash-verified

557
558/** Get DDR2 or DDR3 or DDR4 Part Number, always return a valid ptr */
559CHAR8* getDDRPartNum(UINT8* spd, UINT32 base, UINT8 slot)
560{
561 UINT16 i, start=0, index = 0;
562 CHAR8 c;
563 CHAR8* asciiPartNo = (__typeof__(asciiPartNo))AllocatePool(32); //[32];
564
565 if (spd[SPD_MEMORY_TYPE] == SPD_MEMORY_TYPE_SDRAM_DDR4) {
566 start = 329;
567 } else if (spd[SPD_MEMORY_TYPE] == SPD_MEMORY_TYPE_SDRAM_DDR3) {
568 start = 128;
569 } else if (spd[SPD_MEMORY_TYPE] == SPD_MEMORY_TYPE_SDRAM_DDR2 ||
570 spd[SPD_MEMORY_TYPE] == SPD_MEMORY_TYPE_SDRAM_DDR) {
571 start = 73;
572 }
573
574 // Check that the spd part name is zero terminated and that it is ascii:
575 ZeroMem(asciiPartNo, 32); //sizeof(asciiPartNo));
576 for (i = start; i < start + 20; i++) {
577 READ_SPD(spd, base, slot, (UINT16)i); // only read once the corresponding model part (ddr3 or ddr2)
578 c = spd[i];
579 if (IS_ALFA(c) || IS_DIGIT(c) || IS_PUNCT(c)) // It seems that System Profiler likes only letters and digits...
580 asciiPartNo[index++] = c;
581 else if (c < 0x20)
582 break;
583 }
584
585 return asciiPartNo;
586}
587
588//INTN mapping []= {0,2,1,3,4,6,5,7,8,10,9,11};
589#define PCI_COMMAND_OFFSET 0x04

Callers 1

read_smbFunction · 0.85

Calls 2

AllocatePoolFunction · 0.50
ZeroMemFunction · 0.50

Tested by

no test coverage detected