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" 40b20b7b7aSMichael Roth 41b20b7b7aSMichael Roth typedef struct sPAPROptionVector sPAPROptionVector; 42b20b7b7aSMichael Roth 43b20b7b7aSMichael Roth #define OV_BIT(byte, bit) ((byte - 1) * BITS_PER_BYTE + bit) 44b20b7b7aSMichael Roth 45facdb8b6SMichael Roth /* option vector 5 */ 46facdb8b6SMichael Roth #define OV5_DRCONF_MEMORY OV_BIT(2, 2) 47*417ece33SMichael Roth #define OV5_FORM1_AFFINITY OV_BIT(5, 0) 48facdb8b6SMichael Roth 49b20b7b7aSMichael Roth /* interfaces */ 50b20b7b7aSMichael Roth sPAPROptionVector *spapr_ovec_new(void); 51b20b7b7aSMichael Roth sPAPROptionVector *spapr_ovec_clone(sPAPROptionVector *ov_orig); 52b20b7b7aSMichael Roth void spapr_ovec_intersect(sPAPROptionVector *ov, 53b20b7b7aSMichael Roth sPAPROptionVector *ov1, 54b20b7b7aSMichael Roth sPAPROptionVector *ov2); 55b20b7b7aSMichael Roth bool spapr_ovec_diff(sPAPROptionVector *ov, 56b20b7b7aSMichael Roth sPAPROptionVector *ov_old, 57b20b7b7aSMichael Roth sPAPROptionVector *ov_new); 58b20b7b7aSMichael Roth void spapr_ovec_cleanup(sPAPROptionVector *ov); 59b20b7b7aSMichael Roth void spapr_ovec_set(sPAPROptionVector *ov, long bitnr); 60b20b7b7aSMichael Roth void spapr_ovec_clear(sPAPROptionVector *ov, long bitnr); 61b20b7b7aSMichael Roth bool spapr_ovec_test(sPAPROptionVector *ov, long bitnr); 62b20b7b7aSMichael Roth sPAPROptionVector *spapr_ovec_parse_vector(target_ulong table_addr, int vector); 63b20b7b7aSMichael Roth int spapr_ovec_populate_dt(void *fdt, int fdt_offset, 64b20b7b7aSMichael Roth sPAPROptionVector *ov, const char *name); 65b20b7b7aSMichael Roth 66b20b7b7aSMichael Roth #endif /* !defined (_SPAPR_OVEC_H) */ 67