1 #include <asm/byteorder.h>
5 * Convert the associativity domain numbers returned from the hypervisor
6 * to the sequence they would appear in the ibm,associativity property.
8 int vphn_unpack_associativity(const long *packed, __be32 *unpacked)
10 __be64 be_packed[VPHN_REGISTER_COUNT];
11 int i, nr_assoc_doms = 0;
12 const __be16 *field = (const __be16 *) be_packed;
14 #define VPHN_FIELD_UNUSED (0xffff)
15 #define VPHN_FIELD_MSB (0x8000)
16 #define VPHN_FIELD_MASK (~VPHN_FIELD_MSB)
18 /* Let's recreate the original stream. */
19 for (i = 0; i < VPHN_REGISTER_COUNT; i++)
20 be_packed[i] = cpu_to_be64(packed[i]);
22 for (i = 1; i < VPHN_ASSOC_BUFSIZE; i++) {
23 if (be16_to_cpup(field) == VPHN_FIELD_UNUSED) {
24 /* All significant fields processed, and remaining
25 * fields contain the reserved value of all 1's.
28 unpacked[i] = *((__be32 *)field);
30 } else if (be16_to_cpup(field) & VPHN_FIELD_MSB) {
31 /* Data is in the lower 15 bits of this field */
32 unpacked[i] = cpu_to_be32(
33 be16_to_cpup(field) & VPHN_FIELD_MASK);
37 /* Data is in the lower 15 bits of this field
38 * concatenated with the next 16 bit field
40 unpacked[i] = *((__be32 *)field);
46 /* The first cell contains the length of the property */
47 unpacked[0] = cpu_to_be32(nr_assoc_doms);