34 #include <linux/export.h>
35 #include <linux/string.h>
42 case 1:
return *(
u8 *) (structure + offset);
69 for (i = 0; i < desc_len; ++
i) {
70 if (desc[i].size_bits <= 32) {
77 if (desc[i].struct_size_bytes)
78 val = value_read(desc[i].struct_offset_bytes,
79 desc[i].struct_size_bytes,
84 mask =
cpu_to_be32(((1ull << desc[i].size_bits) - 1) << shift);
85 addr = (
__be32 *) buf + desc[i].offset_words;
87 }
else if (desc[i].size_bits <= 64) {
94 if (desc[i].struct_size_bytes)
95 val = value_read(desc[i].struct_offset_bytes,
96 desc[i].struct_size_bytes,
101 mask =
cpu_to_be64((~0ull >> (64 - desc[i].size_bits)) << shift);
105 if (desc[i].offset_bits % 8 ||
106 desc[i].size_bits % 8) {
108 "bits is not byte-aligned\n",
109 desc[i].field_name, desc[i].size_bits);
112 if (desc[i].struct_size_bytes)
113 memcpy(buf + desc[i].offset_words * 4 +
114 desc[i].offset_bits / 8,
115 structure + desc[i].struct_offset_bytes,
116 desc[i].size_bits / 8);
118 memset(buf + desc[i].offset_words * 4 +
119 desc[i].offset_bits / 8,
121 desc[i].size_bits / 8);
127 static void value_write(
int offset,
int size,
u64 val,
void *structure)
130 case 8: *(
u8 *) (structure + offset) =
val;
break;
156 for (i = 0; i < desc_len; ++
i) {
157 if (!desc[i].struct_size_bytes)
160 if (desc[i].size_bits <= 32) {
167 mask = ((1ull << desc[
i].
size_bits) - 1) << shift;
168 addr = (
__be32 *) buf + desc[i].offset_words;
170 value_write(desc[i].struct_offset_bytes,
171 desc[i].struct_size_bytes,
174 }
else if (desc[i].size_bits <= 64) {
181 mask = (~0ull >> (64 - desc[
i].
size_bits)) << shift;
182 addr = (
__be64 *) buf + desc[i].offset_words;
184 value_write(desc[i].struct_offset_bytes,
185 desc[i].struct_size_bytes,
189 if (desc[i].offset_bits % 8 ||
190 desc[i].size_bits % 8) {
192 "bits is not byte-aligned\n",
193 desc[i].field_name, desc[i].size_bits);
196 memcpy(structure + desc[i].struct_offset_bytes,
197 buf + desc[i].offset_words * 4 +
198 desc[i].offset_bits / 8,
199 desc[i].size_bits / 8);