From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:55589) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TirEi-0005es-L1 for qemu-devel@nongnu.org; Wed, 12 Dec 2012 13:41:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TirEb-0001uF-00 for qemu-devel@nongnu.org; Wed, 12 Dec 2012 13:40:52 -0500 Date: Wed, 12 Dec 2012 12:40:25 -0600 From: Scott Wood References: <1355321398-23393-1-git-send-email-agraf@suse.de> <1355321398-23393-4-git-send-email-agraf@suse.de> In-Reply-To: <1355321398-23393-4-git-send-email-agraf@suse.de> (from agraf@suse.de on Wed Dec 12 08:09:56 2012) Message-ID: <1355337625.28445.2@snotra> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; delsp=Yes; format=Flowed Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [Qemu-ppc] [PATCH 3/5] PPC: E500: Generate dt pci irq map dynamically List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alexander Graf Cc: "qemu-ppc@nongnu.org List" , qemu-devel qemu-devel On 12/12/2012 08:09:56 AM, Alexander Graf wrote: > Today we're hardcoding the PCI interrupt map in the e500 machine file. > Instead, let's write it dynamically so that different machine types > can have different slot properties. >=20 > Signed-off-by: Alexander Graf > --- > hw/ppc/e500.c | 51 =20 > +++++++++++++++++++++++++++++++-------------------- > 1 files changed, 31 insertions(+), 20 deletions(-) >=20 > diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c > index 1034f93..ebb6d96 100644 > --- a/hw/ppc/e500.c > +++ b/hw/ppc/e500.c > @@ -66,25 +66,33 @@ struct boot_info > uint32_t entry; > }; >=20 > -static void pci_map_create(void *fdt, uint32_t *pci_map, uint32_t =20 > mpic) > +static uint32_t *pci_map_create(void *fdt, uint32_t mpic, int =20 > first_slot, > + int nr_slots, int *len) > { > - int i; > - const uint32_t tmp[] =3D { > - /* IDSEL 0x11 J17 Slot 1 */ > - 0x8800, 0x0, 0x0, 0x1, mpic, 0x2, 0x1, > - 0x8800, 0x0, 0x0, 0x2, mpic, 0x3, 0x1, > - 0x8800, 0x0, 0x0, 0x3, mpic, 0x4, 0x1, > - 0x8800, 0x0, 0x0, 0x4, mpic, 0x1, 0x1, > - > - /* IDSEL 0x12 J16 Slot 2 */ > - 0x9000, 0x0, 0x0, 0x1, mpic, 0x3, 0x1, > - 0x9000, 0x0, 0x0, 0x2, mpic, 0x4, 0x1, > - 0x9000, 0x0, 0x0, 0x3, mpic, 0x2, 0x1, > - 0x9000, 0x0, 0x0, 0x4, mpic, 0x1, 0x1, > - }; > - for (i =3D 0; i < (7 * 8); i++) { > - pci_map[i] =3D cpu_to_be32(tmp[i]); > + int i =3D 0; > + int slot; > + int pci_irq; > + int last_slot =3D first_slot + nr_slots; > + uint32_t *pci_map; > + > + *len =3D nr_slots * 4 * 7 * sizeof(uint32_t); > + pci_map =3D g_malloc(*len); > + > + for (slot =3D first_slot; slot < last_slot; slot++) { > + for (pci_irq =3D 0; pci_irq < 4; pci_irq++) { > + pci_map[i++] =3D cpu_to_be32(slot << 11); > + pci_map[i++] =3D cpu_to_be32(0x0); > + pci_map[i++] =3D cpu_to_be32(0x0); > + pci_map[i++] =3D cpu_to_be32(pci_irq + 1); > + pci_map[i++] =3D cpu_to_be32(mpic); > + pci_map[i++] =3D cpu_to_be32(((pci_irq + slot) % 4) + 1); > + pci_map[i++] =3D cpu_to_be32(0x1); > + } > } It would be nice if the slot-to-IRQ calculation were done in only one =20 place rather than duplicated here. -Scott=