smbios.c (16e9ec4406c8bf4e06d72e97ebd47bc8dd6c0319) smbios.c (c5e433b99ed3ddef0eb4fa937f38c34d4a3c4ae0)
1/*-
2 * Copyright (c) 2005-2009 Jung-uk Kim <jkim@FreeBSD.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 82 unchanged lines hidden (view full) ---

91 */
92#define SMBIOS_START 0xf0000
93#define SMBIOS_LENGTH 0x10000
94#define SMBIOS_STEP 0x10
95#define SMBIOS_SIG "_SM_"
96#define SMBIOS3_SIG "_SM3_"
97#define SMBIOS_DMI_SIG "_DMI_"
98
1/*-
2 * Copyright (c) 2005-2009 Jung-uk Kim <jkim@FreeBSD.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 82 unchanged lines hidden (view full) ---

91 */
92#define SMBIOS_START 0xf0000
93#define SMBIOS_LENGTH 0x10000
94#define SMBIOS_STEP 0x10
95#define SMBIOS_SIG "_SM_"
96#define SMBIOS3_SIG "_SM3_"
97#define SMBIOS_DMI_SIG "_DMI_"
98
99#define SMBIOS_GET8(base, off) (*(uint8_t *)((base) + (off)))
100#define SMBIOS_GET16(base, off) (*(uint16_t *)((base) + (off)))
101#define SMBIOS_GET32(base, off) (*(uint32_t *)((base) + (off)))
102#define SMBIOS_GET64(base, off) (*(uint64_t *)((base) + (off)))
99/*
100 * 5.1 General
101 *...
102 * NOTE The Entry Point Structure and all SMBIOS structures assume a
103 * little-endian ordering convention...
104 * ...
105 *
106 * We use memcpy to avoid unaligned access to memory. To normal memory, this is
107 * fine, but the memory we are using might be mmap'd /dev/mem which under Linux
108 * on aarch64 doesn't allow unaligned access. leXdec and friends can't be used
109 * because those can optimize to an unaligned load (which often is fine, but not
110 * for mmap'd /dev/mem which has special memory attributes).
111 */
112static inline uint8_t SMBIOS_GET8(const caddr_t base, int off) { return (base[off]); }
103
113
114static inline uint16_t
115SMBIOS_GET16(const caddr_t base, int off)
116{
117 uint16_t v;
118
119 memcpy(&v, base + off, sizeof(v));
120 return (le16toh(v));
121}
122
123static inline uint32_t
124SMBIOS_GET32(const caddr_t base, int off)
125{
126 uint32_t v;
127
128 memcpy(&v, base + off, sizeof(v));
129 return (le32toh(v));
130}
131
132static inline uint64_t
133SMBIOS_GET64(const caddr_t base, int off)
134{
135 uint64_t v;
136
137 memcpy(&v, base + off, sizeof(v));
138 return (le64toh(v));
139}
140
104#define SMBIOS_GETLEN(base) SMBIOS_GET8(base, 0x01)
105#define SMBIOS_GETSTR(base) ((base) + SMBIOS_GETLEN(base))
106
107struct smbios_attr {
108 int probed;
109 caddr_t addr;
110 size_t length;
111 size_t count;

--- 78 unchanged lines hidden (view full) ---

190}
191
192#ifdef SMBIOS_SERIAL_NUMBERS
193
194#define UUID_SIZE 16
195#define UUID_TYPE uint32_t
196#define UUID_STEP sizeof(UUID_TYPE)
197#define UUID_ALL_BITS (UUID_SIZE / UUID_STEP)
141#define SMBIOS_GETLEN(base) SMBIOS_GET8(base, 0x01)
142#define SMBIOS_GETSTR(base) ((base) + SMBIOS_GETLEN(base))
143
144struct smbios_attr {
145 int probed;
146 caddr_t addr;
147 size_t length;
148 size_t count;

--- 78 unchanged lines hidden (view full) ---

227}
228
229#ifdef SMBIOS_SERIAL_NUMBERS
230
231#define UUID_SIZE 16
232#define UUID_TYPE uint32_t
233#define UUID_STEP sizeof(UUID_TYPE)
234#define UUID_ALL_BITS (UUID_SIZE / UUID_STEP)
198#define UUID_GET(base, off) (*(UUID_TYPE *)((base) + (off)))
235#define UUID_GET(base, off) SMBIOS_GET32(base, off)
199
200static void
201smbios_setuuid(const char *name, const caddr_t addr, const int ver __unused)
202{
203 char uuid[37];
204 int byteorder, i, ones, zeros;
205 UUID_TYPE n;
206 uint32_t f1;

--- 408 unchanged lines hidden ---
236
237static void
238smbios_setuuid(const char *name, const caddr_t addr, const int ver __unused)
239{
240 char uuid[37];
241 int byteorder, i, ones, zeros;
242 UUID_TYPE n;
243 uint32_t f1;

--- 408 unchanged lines hidden ---