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

Function getDDRspeedMhz

rEFIt_UEFI/Platform/spd.cpp:394–534  ·  view source on GitHub ↗

Get Default Memory Module Speed (no overclocking handled) */

Source from the content-addressed store, hash-verified

392
393/** Get Default Memory Module Speed (no overclocking handled) */
394UINT16 getDDRspeedMhz(UINT8 * spd)
395{
396 UINT16 frequency = 0; // default freq for unknown types //shit! DDR1 = 533
397 UINT16 xmpFrequency1 = 0, xmpFrequency2 = 0;
398 UINT8 xmpVersion = 0;
399 UINT8 xmpProfiles = 0;
400
401 if (spd[SPD_MEMORY_TYPE] == SPD_MEMORY_TYPE_SDRAM_DDR4) {
402 UINT16 mincycle = spd[18];
403 INT8 fineadjust = spd[125];
404 frequency = (UINT16)(2000000 / (mincycle * 125 + fineadjust));
405
406 // Check if module supports XMP
407 if ((spd[SPD_XMP20_SIG1] == SPD_XMP_SIG1_VALUE) &&
408 (spd[SPD_XMP20_SIG2] == SPD_XMP_SIG2_VALUE)) {
409 xmpVersion = spd[SPD_XMP20_VERSION];
410 xmpProfiles = spd[SPD_XMP20_PROFILES] & 3;
411
412 if ((xmpProfiles & 1) == 1) {
413 // Check the first profile
414 mincycle = spd[SPD_XMP20_PROF1_MINCYCLE];
415 fineadjust = spd[SPD_XMP20_PROF1_FINEADJUST];
416 xmpFrequency1 = (UINT16)(2000000 / (mincycle * 125 + fineadjust));
417 DBG("XMP Profile1: %d*125 %d ns\n", mincycle, fineadjust);
418 }
419 if ((xmpProfiles & 2) == 2) {
420 // Check the second profile
421 mincycle = spd[SPD_XMP20_PROF2_MINCYCLE];
422 fineadjust = spd[SPD_XMP20_PROF2_FINEADJUST];
423 xmpFrequency2 = (UINT16)(2000000 / (mincycle * 125 + fineadjust));
424 DBG("XMP Profile2: %d*125 %d ns\n", mincycle, fineadjust);
425 }
426 }
427 } else if (spd[SPD_MEMORY_TYPE] == SPD_MEMORY_TYPE_SDRAM_DDR3) {
428 // This should be multiples of MTB converted to MHz- apianti
429 UINT16 divisor = spd[10];
430 UINT16 dividend = spd[11];
431 UINT16 ratio = spd[12];
432 frequency = (((dividend != 0) && (divisor != 0) && (ratio != 0)) ?
433 ((2000 * dividend) / (divisor * ratio)) : 0);
434
435 // Check if module supports XMP
436 if ((spd[SPD_XMP_SIG1] == SPD_XMP_SIG1_VALUE) &&
437 (spd[SPD_XMP_SIG2] == SPD_XMP_SIG2_VALUE)) {
438 xmpVersion = spd[SPD_XMP_VERSION];
439 xmpProfiles = spd[SPD_XMP_PROFILES] & 3;
440
441 if ((xmpProfiles & 1) == 1) {
442 // Check the first profile
443 divisor = spd[SPD_XMP_PROF1_DIVISOR];
444 dividend = spd[SPD_XMP_PROF1_DIVIDEND];
445 ratio = spd[SPD_XMP_PROF1_RATIO];
446 xmpFrequency1 = (((dividend != 0) && (divisor != 0) && (ratio != 0)) ?
447 ((2000 * dividend) / (divisor * ratio)) : 0);
448 DBG("XMP Profile1: %d*%d/%dns\n", ratio, divisor, dividend);
449 }
450 if ((xmpProfiles & 2) == 2) {
451 // Check the second profile

Callers 1

read_smbFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected