spapr_ovec: initial implementation of option vector helpers
[qemu/ar7.git] / include / hw / ppc / spapr_ovec.h
blob7ee07770c4682b799c205aca18538e93c8fb3d3e
1 /*
2 * QEMU SPAPR Option/Architecture Vector Definitions
4 * Each architecture option is organized/documented by the following
5 * in LoPAPR 1.1, Table 244:
7 * <vector number>: the bit-vector in which the option is located
8 * <vector byte>: the byte offset of the vector entry
9 * <vector bit>: the bit offset within the vector entry
11 * where each vector entry can be one or more bytes.
13 * Firmware expects a somewhat literal encoding of this bit-vector
14 * structure, where each entry is stored in little-endian so that the
15 * byte ordering reflects that of the documentation, but where each bit
16 * offset is from "left-to-right" in the traditional representation of
17 * a byte value where the MSB is the left-most bit. Thus, each
18 * individual byte encodes the option bits in reverse order of the
19 * documented bit.
21 * These definitions/helpers attempt to abstract away this internal
22 * representation so that we can define/set/test for individual option
23 * bits using only the documented values. This is done mainly by relying
24 * on a bitmap to approximate the documented "bit-vector" structure and
25 * handling conversations to-from the internal representation under the
26 * covers.
28 * Copyright IBM Corp. 2016
30 * Authors:
31 * Michael Roth <mdroth@linux.vnet.ibm.com>
33 * This work is licensed under the terms of the GNU GPL, version 2 or later.
34 * See the COPYING file in the top-level directory.
36 #ifndef _SPAPR_OVEC_H
37 #define _SPAPR_OVEC_H
39 #include "cpu.h"
41 typedef struct sPAPROptionVector sPAPROptionVector;
43 #define OV_BIT(byte, bit) ((byte - 1) * BITS_PER_BYTE + bit)
45 /* interfaces */
46 sPAPROptionVector *spapr_ovec_new(void);
47 sPAPROptionVector *spapr_ovec_clone(sPAPROptionVector *ov_orig);
48 void spapr_ovec_intersect(sPAPROptionVector *ov,
49 sPAPROptionVector *ov1,
50 sPAPROptionVector *ov2);
51 bool spapr_ovec_diff(sPAPROptionVector *ov,
52 sPAPROptionVector *ov_old,
53 sPAPROptionVector *ov_new);
54 void spapr_ovec_cleanup(sPAPROptionVector *ov);
55 void spapr_ovec_set(sPAPROptionVector *ov, long bitnr);
56 void spapr_ovec_clear(sPAPROptionVector *ov, long bitnr);
57 bool spapr_ovec_test(sPAPROptionVector *ov, long bitnr);
58 sPAPROptionVector *spapr_ovec_parse_vector(target_ulong table_addr, int vector);
59 int spapr_ovec_populate_dt(void *fdt, int fdt_offset,
60 sPAPROptionVector *ov, const char *name);
62 #endif /* !defined (_SPAPR_OVEC_H) */