Clean up SPD type handling with unions

This commit is contained in:
RichardG867
2021-04-17 16:27:38 -03:00
parent 841ac25297
commit 8f92c6d6cc
2 changed files with 16 additions and 14 deletions

View File

@@ -47,16 +47,6 @@
#define SPD_SDR_ATTR_VCC_HI_5 0x20 #define SPD_SDR_ATTR_VCC_HI_5 0x20
typedef struct {
uint8_t slot;
uint16_t size;
uint16_t row1;
uint16_t row2;
uint8_t data[SPD_DATA_SIZE];
void *eeprom;
} spd_t;
typedef struct { typedef struct {
uint8_t bytes_used, spd_size, mem_type, uint8_t bytes_used, spd_size, mem_type,
row_bits, col_bits, banks, row_bits, col_bits, banks,
@@ -99,6 +89,20 @@ typedef struct {
checksum2; checksum2;
} spd_sdram_t; } spd_sdram_t;
typedef struct {
uint8_t slot;
uint16_t size;
uint16_t row1;
uint16_t row2;
union {
uint8_t data[SPD_DATA_SIZE];
spd_edo_t edo_data;
spd_sdram_t sdram_data;
};
void *eeprom;
} spd_t;
extern void spd_register(uint8_t ram_type, uint8_t slot_mask, uint16_t max_module_size); extern void spd_register(uint8_t ram_type, uint8_t slot_mask, uint16_t max_module_size);
extern void spd_write_drbs(uint8_t *regs, uint8_t reg_min, uint8_t reg_max, uint8_t drb_unit); extern void spd_write_drbs(uint8_t *regs, uint8_t reg_min, uint8_t reg_max, uint8_t drb_unit);

View File

@@ -226,8 +226,7 @@ spd_register(uint8_t ram_type, uint8_t slot_mask, uint16_t max_module_size)
switch (ram_type) { switch (ram_type) {
case SPD_TYPE_FPM: case SPD_TYPE_FPM:
case SPD_TYPE_EDO: case SPD_TYPE_EDO:
edo_data = (spd_edo_t *) &spd_modules[slot]->data; edo_data = &spd_modules[slot]->edo_data;
memset(edo_data, 0, sizeof(spd_edo_t));
/* EDO SPD is specified by JEDEC and present in some modules, but /* EDO SPD is specified by JEDEC and present in some modules, but
most utilities cannot interpret it correctly. SIV32 at least gets most utilities cannot interpret it correctly. SIV32 at least gets
@@ -265,8 +264,7 @@ spd_register(uint8_t ram_type, uint8_t slot_mask, uint16_t max_module_size)
break; break;
case SPD_TYPE_SDRAM: case SPD_TYPE_SDRAM:
sdram_data = (spd_sdram_t *) &spd_modules[slot]->data; sdram_data = &spd_modules[slot]->sdram_data;
memset(sdram_data, 0, sizeof(spd_sdram_t));
sdram_data->bytes_used = 0x80; sdram_data->bytes_used = 0x80;
sdram_data->spd_size = 0x08; sdram_data->spd_size = 0x08;