diff --git a/SPDAccessor/SPDAccessor.cpp b/SPDAccessor/SPDAccessor.cpp index 1c5b302d4..91b40fbcb 100644 --- a/SPDAccessor/SPDAccessor.cpp +++ b/SPDAccessor/SPDAccessor.cpp @@ -66,7 +66,8 @@ const char *spd_memory_type_name[] = "LPDDR4", "LPDDR4X", "DDR5", - "LPDDR5" + "LPDDR5", + "Unknown" }; SPDAccessor::SPDAccessor(i2c_smbus_interface *bus, uint8_t spd_addr) @@ -161,7 +162,16 @@ DDR4Accessor::~DDR4Accessor() SPDMemoryType DDR4Accessor::memory_type() { - return((SPDMemoryType)(this->at(BASIC_MEMORY_TYPE_ADDR))); + SPDMemoryType type = (SPDMemoryType)(this->at(BASIC_MEMORY_TYPE_ADDR)); + + if(type <= SPD_UNKNOWN) + { + return(type); + } + else + { + return(SPD_UNKNOWN); + } } uint16_t DDR4Accessor::jedec_id() @@ -195,7 +205,16 @@ DDR5Accessor::~DDR5Accessor() SPDMemoryType DDR5Accessor::memory_type() { - return((SPDMemoryType)(this->at(BASIC_MEMORY_TYPE_ADDR))); + SPDMemoryType type = (SPDMemoryType)(this->at(BASIC_MEMORY_TYPE_ADDR)); + + if(type <= SPD_UNKNOWN) + { + return(type); + } + else + { + return(SPD_UNKNOWN); + } } uint16_t DDR5Accessor::jedec_id() diff --git a/SPDAccessor/SPDCommon.h b/SPDAccessor/SPDCommon.h index 12538fdab..b7111c482 100644 --- a/SPDAccessor/SPDCommon.h +++ b/SPDAccessor/SPDCommon.h @@ -48,7 +48,8 @@ typedef enum SPD_LPDDR4_SDRAM = 16, SPD_LPDDR4X_SDRAM = 17, SPD_DDR5_SDRAM = 18, - SPD_LPDDR5_SDRAM = 19 + SPD_LPDDR5_SDRAM = 19, + SPD_UNKNOWN = 20, } SPDMemoryType; #define SPD_IO_DELAY 1ms diff --git a/SPDAccessor/SPDDetector.cpp b/SPDAccessor/SPDDetector.cpp index 29bb60b71..fcb7b2e0e 100644 --- a/SPDAccessor/SPDDetector.cpp +++ b/SPDAccessor/SPDDetector.cpp @@ -30,7 +30,14 @@ bool SPDDetector::is_valid() const SPDMemoryType SPDDetector::memory_type() const { - return(mem_type); + if(mem_type <= SPD_UNKNOWN) + { + return(mem_type); + } + else + { + return(SPD_UNKNOWN); + } } void SPDDetector::detect_memory_type() diff --git a/SPDAccessor/SPDWrapper.cpp b/SPDAccessor/SPDWrapper.cpp index 5c4e321a5..32ecd2d8f 100644 --- a/SPDAccessor/SPDWrapper.cpp +++ b/SPDAccessor/SPDWrapper.cpp @@ -65,7 +65,14 @@ SPDWrapper::~SPDWrapper() SPDMemoryType SPDWrapper::memory_type() { - return mem_type; + if(mem_type <= SPD_UNKNOWN) + { + return(mem_type); + } + else + { + return(SPD_UNKNOWN); + } } uint8_t SPDWrapper::address()