diff --git a/stand/libsa/smbios.c b/stand/libsa/smbios.c --- a/stand/libsa/smbios.c +++ b/stand/libsa/smbios.c @@ -96,10 +96,45 @@ #define SMBIOS3_SIG "_SM3_" #define SMBIOS_DMI_SIG "_DMI_" -#define SMBIOS_GET8(base, off) (*(uint8_t *)((base) + (off))) -#define SMBIOS_GET16(base, off) (*(uint16_t *)((base) + (off))) -#define SMBIOS_GET32(base, off) (*(uint32_t *)((base) + (off))) -#define SMBIOS_GET64(base, off) (*(uint64_t *)((base) + (off))) +/* + * Some arm environments have unalgined accesses mapped to a bus error, + * so we have to use our friend memcpy to get these unaligned values. + */ + +static inline uint8_t +SMBIOS_GET8(const caddr_t base, int off) +{ + uint8_t *bp = (uint8_t *)base + off; + + return (*bp); +} + +static inline uint16_t +SMBIOS_GET16(const caddr_t base, int off) +{ + uint16_t v; + + memcpy(&v, base + off, sizeof(v)); + return (v); +} + +static inline uint32_t +SMBIOS_GET32(const caddr_t base, int off) +{ + uint32_t v; + + memcpy(&v, base + off, sizeof(v)); + return (v); +} + +static inline uint64_t +SMBIOS_GET64(const caddr_t base, int off) +{ + uint64_t v; + + memcpy(&v, base + off, sizeof(v)); + return (v); +} #define SMBIOS_GETLEN(base) SMBIOS_GET8(base, 0x01) #define SMBIOS_GETSTR(base) ((base) + SMBIOS_GETLEN(base)) @@ -195,7 +230,7 @@ #define UUID_TYPE uint32_t #define UUID_STEP sizeof(UUID_TYPE) #define UUID_ALL_BITS (UUID_SIZE / UUID_STEP) -#define UUID_GET(base, off) (*(UUID_TYPE *)((base) + (off))) +#define UUID_GET(base, off) SMBIOS_GET32(base, off) static void smbios_setuuid(const char *name, const caddr_t addr, const int ver __unused)