Skip to content

Commit

Permalink
Merge pull request #47 from HuO50/master
Browse files Browse the repository at this point in the history
Solve issue 33 and pymap.xml missing chunk.
  • Loading branch information
licliu authored Nov 17, 2022
2 parents e6ab5bc + 9456ca9 commit bee24bc
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/dmidecode.c
Original file line number Diff line number Diff line change
Expand Up @@ -5378,7 +5378,7 @@ xmlNode *dmi_decode(xmlNode *prnt_n, dmi_codes_major *dmiMajor, struct dmi_heade
dmi_memory_device_width(sect_n, "TotalWidth", WORD(data + 0x08));
dmi_memory_device_width(sect_n, "DataWidth", WORD(data + 0x0A));
if (h->length >= 0x20 && WORD(data + 0x0C) == 0x7FFF) {
dmi_memory_device_extended_size(sect_n, WORD(data + 0x1C));
dmi_memory_device_extended_size(sect_n, DWORD(data + 0x1C));
} else {
dmi_memory_device_size(sect_n, WORD(data + 0x0C));
}
Expand Down
1 change: 1 addition & 0 deletions src/pymap.xml
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@
<Map keytype="constant" key="SlotId" valuetype="string" value="SlotID/@id"/>
<Map keytype="constant" key="Type:SlotBusWidth" valuetype="string" value="SlotWidth"/>
<Map keytype="constant" key="Type:SlotType" valuetype="string" value="SlotType"/>
<Map keytype="constant" key="Bus Address" valuetype="string" value="BusAddress"/>
</Map>
</Map>
</TypeMap>
Expand Down
24 changes: 11 additions & 13 deletions src/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ typedef struct {
} u64;
#endif

#ifdef ALIGNMENT_WORKAROUND
#if defined(ALIGNMENT_WORKAROUND) || defined(BIGENDIAN)
static inline u64 U64(u32 low, u32 high)
{
u64 self;
Expand All @@ -69,20 +69,18 @@ static inline u64 U64(u32 low, u32 high)
}
#endif

#ifdef ALIGNMENT_WORKAROUND
# ifdef BIGENDIAN
# define WORD(x) (u16)((x)[1]+((x)[0]<<8))
# define DWORD(x) (u32)((x)[3]+((x)[2]<<8)+((x)[1]<<16)+((x)[0]<<24))
# define QWORD(x) (U64(DWORD(x+4), DWORD(x)))
# else /* BIGENDIAN */
# define WORD(x) (u16)((x)[0]+((x)[1]<<8))
# define DWORD(x) (u32)((x)[0]+((x)[1]<<8)+((x)[2]<<16)+((x)[3]<<24))
# define QWORD(x) (U64(DWORD(x), DWORD(x+4)))
# endif /* BIGENDIAN */
#else /* ALIGNMENT_WORKAROUND */
/*
* Per SMBIOS v2.8.0 and later, all structures assume a little-endian
* ordering convention.
*/
#if defined(ALIGNMENT_WORKAROUND) || defined(BIGENDIAN)
#define WORD(x) (u16)((x)[0] + ((x)[1] << 8))
#define DWORD(x) (u32)((x)[0] + ((x)[1] << 8) + ((x)[2] << 16) + ((x)[3] << 24))
#define QWORD(x) (U64(DWORD(x), DWORD(x + 4)))
#else /* ALIGNMENT_WORKAROUND || BIGENDIAN */
#define WORD(x) (u16)(*(const u16 *)(x))
#define DWORD(x) (u32)(*(const u32 *)(x))
#define QWORD(x) (*(const u64 *)(x))
#endif /* ALIGNMENT_WORKAROUND */
#endif /* ALIGNMENT_WORKAROUND || BIGENDIAN */

#endif

0 comments on commit bee24bc

Please sign in to comment.