On Tue, Aug 19, 2014 at 5:51 AM, Michael Roth <mdr...@linux.vnet.ibm.com> wrote: > From: Nathan Fontenot <nf...@linux.vnet.ibm.com> > > This add entries to the root OF node to advertise our PHBs as being > DR-capable in according with PAPR specification. > > Each PHB is given a name of PHB<bus#>, advertised as a PHB type, > and associated with a power domain of -1 (indicating to guests that > power management is handled automatically by hardware). > > We currently allocate entries for up to 32 DR-capable PHBs, though > this limit can be increased later. > > DrcEntry objects to track the state of the DR-connector associated > with each PHB are stored in a 32-entry array, and each DrcEntry has > in turn have a dynamically-sized number of child DR-connectors, > which we will use later to track the state of DR-connectors > associated with a PHB's physical slots. > > Signed-off-by: Nathan Fontenot <nf...@linux.vnet.ibm.com> > Signed-off-by: Michael Roth <mdr...@linux.vnet.ibm.com> > --- > hw/ppc/spapr.c | 143 > +++++++++++++++++++++++++++++++++++++++++++++++++ > hw/ppc/spapr_pci.c | 1 + > include/hw/ppc/spapr.h | 35 ++++++++++++ > 3 files changed, 179 insertions(+) > > diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c > index 5c92707..d5e46c3 100644 > --- a/hw/ppc/spapr.c > +++ b/hw/ppc/spapr.c > @@ -296,6 +296,143 @@ static hwaddr spapr_node0_size(void) > return ram_size; > } > > +sPAPRDrcEntry *spapr_phb_to_drc_entry(uint64_t buid) > +{ > + int i; > + > + for (i = 0; i < SPAPR_DRC_TABLE_SIZE; i++) { > + if (spapr->drc_table[i].phb_buid == buid) { > + return &spapr->drc_table[i]; > + } > + } > + > + return NULL; > +} > + > +static void spapr_init_drc_table(void) > +{ > + int i; > + > + memset(spapr->drc_table, 0, sizeof(spapr->drc_table)); > + > + /* For now we only care about PHB entries */ > + for (i = 0; i < SPAPR_DRC_TABLE_SIZE; i++) { > + spapr->drc_table[i].drc_index = 0x2000001 + i; > + } > +} > + > +sPAPRDrcEntry *spapr_add_phb_to_drc_table(uint64_t buid, uint32_t state) > +{ > + sPAPRDrcEntry *empty_drc = NULL; > + sPAPRDrcEntry *found_drc = NULL; > + int i, phb_index; > + > + for (i = 0; i < SPAPR_DRC_TABLE_SIZE; i++) { > + if (spapr->drc_table[i].phb_buid == 0) { > + empty_drc = &spapr->drc_table[i]; > + } > + > + if (spapr->drc_table[i].phb_buid == buid) { > + found_drc = &spapr->drc_table[i]; > + break; > + } > + } > + > + if (found_drc) { > + return found_drc; > + } > + > + if (empty_drc) { > + empty_drc->phb_buid = buid; > + empty_drc->state = state;
Shouldn't this be empty_drc->state = state << INDICATOR_ENTITY_SENSE_SHIFT ? Regards, Bharata.