xref: /qemu/include/hw/ppc/spapr_ovec.h (revision 21f3f8db)
1b20b7b7aSMichael Roth /*
2b20b7b7aSMichael Roth  * QEMU SPAPR Option/Architecture Vector Definitions
3b20b7b7aSMichael Roth  *
4b20b7b7aSMichael Roth  * Each architecture option is organized/documented by the following
5b20b7b7aSMichael Roth  * in LoPAPR 1.1, Table 244:
6b20b7b7aSMichael Roth  *
7b20b7b7aSMichael Roth  *   <vector number>: the bit-vector in which the option is located
8b20b7b7aSMichael Roth  *   <vector byte>: the byte offset of the vector entry
9b20b7b7aSMichael Roth  *   <vector bit>: the bit offset within the vector entry
10b20b7b7aSMichael Roth  *
11b20b7b7aSMichael Roth  * where each vector entry can be one or more bytes.
12b20b7b7aSMichael Roth  *
13b20b7b7aSMichael Roth  * Firmware expects a somewhat literal encoding of this bit-vector
14b20b7b7aSMichael Roth  * structure, where each entry is stored in little-endian so that the
15b20b7b7aSMichael Roth  * byte ordering reflects that of the documentation, but where each bit
16b20b7b7aSMichael Roth  * offset is from "left-to-right" in the traditional representation of
17b20b7b7aSMichael Roth  * a byte value where the MSB is the left-most bit. Thus, each
18b20b7b7aSMichael Roth  * individual byte encodes the option bits in reverse order of the
19b20b7b7aSMichael Roth  * documented bit.
20b20b7b7aSMichael Roth  *
21b20b7b7aSMichael Roth  * These definitions/helpers attempt to abstract away this internal
22b20b7b7aSMichael Roth  * representation so that we can define/set/test for individual option
23b20b7b7aSMichael Roth  * bits using only the documented values. This is done mainly by relying
24b20b7b7aSMichael Roth  * on a bitmap to approximate the documented "bit-vector" structure and
25b20b7b7aSMichael Roth  * handling conversations to-from the internal representation under the
26b20b7b7aSMichael Roth  * covers.
27b20b7b7aSMichael Roth  *
28b20b7b7aSMichael Roth  * Copyright IBM Corp. 2016
29b20b7b7aSMichael Roth  *
30b20b7b7aSMichael Roth  * Authors:
31b20b7b7aSMichael Roth  *  Michael Roth      <mdroth@linux.vnet.ibm.com>
32b20b7b7aSMichael Roth  *
33b20b7b7aSMichael Roth  * This work is licensed under the terms of the GNU GPL, version 2 or later.
34b20b7b7aSMichael Roth  * See the COPYING file in the top-level directory.
35b20b7b7aSMichael Roth  */
36b20b7b7aSMichael Roth #ifndef _SPAPR_OVEC_H
37b20b7b7aSMichael Roth #define _SPAPR_OVEC_H
38b20b7b7aSMichael Roth 
39b20b7b7aSMichael Roth #include "cpu.h"
4062ef3760SMichael Roth #include "migration/vmstate.h"
41b20b7b7aSMichael Roth 
42b20b7b7aSMichael Roth typedef struct sPAPROptionVector sPAPROptionVector;
43b20b7b7aSMichael Roth 
44b20b7b7aSMichael Roth #define OV_BIT(byte, bit) ((byte - 1) * BITS_PER_BYTE + bit)
45b20b7b7aSMichael Roth 
46e957f6a9SSam Bobroff /* option vector 1 */
47e957f6a9SSam Bobroff #define OV1_PPC_3_00            OV_BIT(3, 0) /* guest supports PowerPC 3.00? */
48e957f6a9SSam Bobroff 
49facdb8b6SMichael Roth /* option vector 5 */
50facdb8b6SMichael Roth #define OV5_DRCONF_MEMORY       OV_BIT(2, 2)
51417ece33SMichael Roth #define OV5_FORM1_AFFINITY      OV_BIT(5, 0)
52ffbb1705SMichael Roth #define OV5_HP_EVT              OV_BIT(6, 5)
532772cf6bSDavid Gibson #define OV5_HPT_RESIZE          OV_BIT(6, 7)
54*21f3f8dbSCédric Le Goater #define OV5_XIVE_BOTH           OV_BIT(23, 0)
55*21f3f8dbSCédric Le Goater #define OV5_XIVE_EXPLOIT        OV_BIT(23, 1) /* 1=exploitation 0=legacy */
56facdb8b6SMichael Roth 
579fb4541fSSam Bobroff /* ISA 3.00 MMU features: */
589fb4541fSSam Bobroff #define OV5_MMU_BOTH            OV_BIT(24, 0) /* Radix and hash */
599fb4541fSSam Bobroff #define OV5_MMU_RADIX_300       OV_BIT(24, 1) /* 1=Radix only, 0=Hash only */
609fb4541fSSam Bobroff #define OV5_MMU_RADIX_GTSE      OV_BIT(26, 1) /* Radix GTSE */
619fb4541fSSam Bobroff 
62b20b7b7aSMichael Roth /* interfaces */
63b20b7b7aSMichael Roth sPAPROptionVector *spapr_ovec_new(void);
64b20b7b7aSMichael Roth sPAPROptionVector *spapr_ovec_clone(sPAPROptionVector *ov_orig);
65b20b7b7aSMichael Roth void spapr_ovec_intersect(sPAPROptionVector *ov,
66b20b7b7aSMichael Roth                           sPAPROptionVector *ov1,
67b20b7b7aSMichael Roth                           sPAPROptionVector *ov2);
68b20b7b7aSMichael Roth bool spapr_ovec_diff(sPAPROptionVector *ov,
69b20b7b7aSMichael Roth                      sPAPROptionVector *ov_old,
70b20b7b7aSMichael Roth                      sPAPROptionVector *ov_new);
71b20b7b7aSMichael Roth void spapr_ovec_cleanup(sPAPROptionVector *ov);
72b20b7b7aSMichael Roth void spapr_ovec_set(sPAPROptionVector *ov, long bitnr);
73b20b7b7aSMichael Roth void spapr_ovec_clear(sPAPROptionVector *ov, long bitnr);
74b20b7b7aSMichael Roth bool spapr_ovec_test(sPAPROptionVector *ov, long bitnr);
75b20b7b7aSMichael Roth sPAPROptionVector *spapr_ovec_parse_vector(target_ulong table_addr, int vector);
76b20b7b7aSMichael Roth int spapr_ovec_populate_dt(void *fdt, int fdt_offset,
77b20b7b7aSMichael Roth                            sPAPROptionVector *ov, const char *name);
78b20b7b7aSMichael Roth 
7962ef3760SMichael Roth /* migration */
8062ef3760SMichael Roth extern const VMStateDescription vmstate_spapr_ovec;
8162ef3760SMichael Roth 
82b20b7b7aSMichael Roth #endif /* !defined (_SPAPR_OVEC_H) */
83