qemu/include/hw/ppc/spapr_ovec.h
Michael Roth facdb8b63b spapr_hcall: use spapr_ovec_* interfaces for CAS options
Currently we access individual bytes of an option vector via
ldub_phys() to test for the presence of a particular capability
within that byte. Currently this is only done for the "dynamic
reconfiguration memory" capability bit. If that bit is present,
we pass a boolean value to spapr_h_cas_compose_response()
to generate a modified device tree segment with the additional
properties required to enable this functionality.

As more capability bits are added, will would need to modify the
code to add additional option vector accesses and extend the
param list for spapr_h_cas_compose_response() to include similar
boolean values for these parameters.

Avoid this by switching to spapr_ovec_* helpers so we can do all
the parsing in one shot and then test for these additional bits
within spapr_h_cas_compose_response() directly.

Cc: Bharata B Rao <bharata@linux.vnet.ibm.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Bharata B Rao <bharata@linux.vnet.ibm.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2016-10-28 09:38:26 +11:00

66 lines
2.5 KiB
C

/*
* QEMU SPAPR Option/Architecture Vector Definitions
*
* Each architecture option is organized/documented by the following
* in LoPAPR 1.1, Table 244:
*
* <vector number>: the bit-vector in which the option is located
* <vector byte>: the byte offset of the vector entry
* <vector bit>: the bit offset within the vector entry
*
* where each vector entry can be one or more bytes.
*
* Firmware expects a somewhat literal encoding of this bit-vector
* structure, where each entry is stored in little-endian so that the
* byte ordering reflects that of the documentation, but where each bit
* offset is from "left-to-right" in the traditional representation of
* a byte value where the MSB is the left-most bit. Thus, each
* individual byte encodes the option bits in reverse order of the
* documented bit.
*
* These definitions/helpers attempt to abstract away this internal
* representation so that we can define/set/test for individual option
* bits using only the documented values. This is done mainly by relying
* on a bitmap to approximate the documented "bit-vector" structure and
* handling conversations to-from the internal representation under the
* covers.
*
* Copyright IBM Corp. 2016
*
* Authors:
* Michael Roth <mdroth@linux.vnet.ibm.com>
*
* This work is licensed under the terms of the GNU GPL, version 2 or later.
* See the COPYING file in the top-level directory.
*/
#ifndef _SPAPR_OVEC_H
#define _SPAPR_OVEC_H
#include "cpu.h"
typedef struct sPAPROptionVector sPAPROptionVector;
#define OV_BIT(byte, bit) ((byte - 1) * BITS_PER_BYTE + bit)
/* option vector 5 */
#define OV5_DRCONF_MEMORY OV_BIT(2, 2)
/* interfaces */
sPAPROptionVector *spapr_ovec_new(void);
sPAPROptionVector *spapr_ovec_clone(sPAPROptionVector *ov_orig);
void spapr_ovec_intersect(sPAPROptionVector *ov,
sPAPROptionVector *ov1,
sPAPROptionVector *ov2);
bool spapr_ovec_diff(sPAPROptionVector *ov,
sPAPROptionVector *ov_old,
sPAPROptionVector *ov_new);
void spapr_ovec_cleanup(sPAPROptionVector *ov);
void spapr_ovec_set(sPAPROptionVector *ov, long bitnr);
void spapr_ovec_clear(sPAPROptionVector *ov, long bitnr);
bool spapr_ovec_test(sPAPROptionVector *ov, long bitnr);
sPAPROptionVector *spapr_ovec_parse_vector(target_ulong table_addr, int vector);
int spapr_ovec_populate_dt(void *fdt, int fdt_offset,
sPAPROptionVector *ov, const char *name);
#endif /* !defined (_SPAPR_OVEC_H) */