static void finish_write_pci_config(sPAPREnvironment *spapr, uint64_t buid,

                                    uint32_t addr, uint32_t size,

                                    uint32_t val, target_ulong rets)

{

    PCIDevice *pci_dev;



    if ((size != 1) && (size != 2) && (size != 4)) {

        /* access must be 1, 2 or 4 bytes */

        rtas_st(rets, 0, RTAS_OUT_HW_ERROR);

        return;

    }



    pci_dev = find_dev(spapr, buid, addr);

    addr = rtas_pci_cfgaddr(addr);



    if (!pci_dev || (addr % size) || (addr >= pci_config_size(pci_dev))) {

        /* Access must be to a valid device, within bounds and

         * naturally aligned */

        rtas_st(rets, 0, RTAS_OUT_HW_ERROR);

        return;

    }



    pci_host_config_write_common(pci_dev, addr, pci_config_size(pci_dev),

                                 val, size);



    rtas_st(rets, 0, RTAS_OUT_SUCCESS);

}

static void finish_write_pci_config(sPAPREnvironment *spapr, uint64_t buid,

                                    uint32_t addr, uint32_t size,

                                    uint32_t val, target_ulong rets)

{

    PCIDevice *pci_dev;



    if ((size != 1) && (size != 2) && (size != 4)) {

        

        rtas_st(rets, 0, RTAS_OUT_HW_ERROR);

        return;

    }



    pci_dev = find_dev(spapr, buid, addr);

    addr = rtas_pci_cfgaddr(addr);



    if (!pci_dev || (addr % size) || (addr >= pci_config_size(pci_dev))) {

        



        rtas_st(rets, 0, RTAS_OUT_HW_ERROR);

        return;

    }



    pci_host_config_write_common(pci_dev, addr, pci_config_size(pci_dev),

                                 val, size);



    rtas_st(rets, 0, RTAS_OUT_SUCCESS);

}

static void FUNC_0(sPAPREnvironment *VAR_0, uint64_t VAR_1,

                                    uint32_t VAR_2, uint32_t VAR_3,

                                    uint32_t VAR_4, target_ulong VAR_5)

{

    PCIDevice *pci_dev;



    if ((VAR_3 != 1) && (VAR_3 != 2) && (VAR_3 != 4)) {

        

        rtas_st(VAR_5, 0, RTAS_OUT_HW_ERROR);

        return;

    }



    pci_dev = find_dev(VAR_0, VAR_1, VAR_2);

    VAR_2 = rtas_pci_cfgaddr(VAR_2);



    if (!pci_dev || (VAR_2 % VAR_3) || (VAR_2 >= pci_config_size(pci_dev))) {

        



        rtas_st(VAR_5, 0, RTAS_OUT_HW_ERROR);

        return;

    }



    pci_host_config_write_common(pci_dev, VAR_2, pci_config_size(pci_dev),

                                 VAR_4, VAR_3);



    rtas_st(VAR_5, 0, RTAS_OUT_SUCCESS);

}

static void FUNC_0(sPAPREnvironment *VAR_0, uint64_t VAR_1,
uint32_t VAR_2, uint32_t VAR_3,
uint32_t VAR_4, target_ulong VAR_5)
{ PCIDevice *pci_dev; if ((VAR_3 != 1) && (VAR_3 != 2) && (VAR_3 != 4)) { rtas_st(VAR_5, 0, RTAS_OUT_HW_ERROR); return; } pci_dev = find_dev(VAR_0, VAR_1, VAR_2); VAR_2 = rtas_pci_cfgaddr(VAR_2); if (!pci_dev || (VAR_2 % VAR_3) || (VAR_2 >= pci_config_size(pci_dev))) { rtas_st(VAR_5, 0, RTAS_OUT_HW_ERROR); return; } pci_host_config_write_common(pci_dev, VAR_2, pci_config_size(pci_dev),
VAR_4, VAR_3); rtas_st(VAR_5, 0, RTAS_OUT_SUCCESS); }