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