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 */ 36a8b991b5SMarkus Armbruster 37a8b991b5SMarkus Armbruster #ifndef SPAPR_OVEC_H 38a8b991b5SMarkus Armbruster #define SPAPR_OVEC_H 39b20b7b7aSMichael Roth 40b20b7b7aSMichael Roth #include "cpu.h" 41b20b7b7aSMichael Roth 42ce2918cbSDavid Gibson 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) 52*e0eb84d4SDaniel Henrique Barboza #define OV5_FORM2_AFFINITY OV_BIT(5, 2) 53ffbb1705SMichael Roth #define OV5_HP_EVT OV_BIT(6, 5) 542772cf6bSDavid Gibson #define OV5_HPT_RESIZE OV_BIT(6, 7) 55a324d6f1SBharata B Rao #define OV5_DRMEM_V2 OV_BIT(22, 0) 5621f3f8dbSCédric Le Goater #define OV5_XIVE_BOTH OV_BIT(23, 0) 5721f3f8dbSCédric Le Goater #define OV5_XIVE_EXPLOIT OV_BIT(23, 1) /* 1=exploitation 0=legacy */ 58facdb8b6SMichael Roth 599fb4541fSSam Bobroff /* ISA 3.00 MMU features: */ 609fb4541fSSam Bobroff #define OV5_MMU_BOTH OV_BIT(24, 0) /* Radix and hash */ 619fb4541fSSam Bobroff #define OV5_MMU_RADIX_300 OV_BIT(24, 1) /* 1=Radix only, 0=Hash only */ 629fb4541fSSam Bobroff #define OV5_MMU_RADIX_GTSE OV_BIT(26, 1) /* Radix GTSE */ 639fb4541fSSam Bobroff 64b20b7b7aSMichael Roth /* interfaces */ 65ce2918cbSDavid Gibson SpaprOptionVector *spapr_ovec_new(void); 66ce2918cbSDavid Gibson SpaprOptionVector *spapr_ovec_clone(SpaprOptionVector *ov_orig); 67ce2918cbSDavid Gibson void spapr_ovec_intersect(SpaprOptionVector *ov, 68ce2918cbSDavid Gibson SpaprOptionVector *ov1, 69ce2918cbSDavid Gibson SpaprOptionVector *ov2); 70d1d32d62SDavid Gibson bool spapr_ovec_subset(SpaprOptionVector *ov1, SpaprOptionVector *ov2); 71ce2918cbSDavid Gibson void spapr_ovec_cleanup(SpaprOptionVector *ov); 72ce2918cbSDavid Gibson void spapr_ovec_set(SpaprOptionVector *ov, long bitnr); 73ce2918cbSDavid Gibson void spapr_ovec_clear(SpaprOptionVector *ov, long bitnr); 74ce2918cbSDavid Gibson bool spapr_ovec_test(SpaprOptionVector *ov, long bitnr); 7573598c75SGreg Kurz bool spapr_ovec_empty(SpaprOptionVector *ov); 76ce2918cbSDavid Gibson SpaprOptionVector *spapr_ovec_parse_vector(target_ulong table_addr, int vector); 7791335a5eSDavid Gibson int spapr_dt_ovec(void *fdt, int fdt_offset, 78ce2918cbSDavid Gibson SpaprOptionVector *ov, const char *name); 79b20b7b7aSMichael Roth 8062ef3760SMichael Roth /* migration */ 8162ef3760SMichael Roth extern const VMStateDescription vmstate_spapr_ovec; 8262ef3760SMichael Roth 83a8b991b5SMarkus Armbruster #endif /* SPAPR_OVEC_H */ 84