From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:34616) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TmnXe-0000DE-OO for qemu-devel@nongnu.org; Sun, 23 Dec 2012 10:32:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TmnXW-0007TI-O2 for qemu-devel@nongnu.org; Sun, 23 Dec 2012 10:32:42 -0500 Received: from smtp1-g21.free.fr ([2a01:e0c:1:1599::10]:43846) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TmnXW-0007T3-6E for qemu-devel@nongnu.org; Sun, 23 Dec 2012 10:32:34 -0500 From: =?UTF-8?q?Herv=C3=A9=20Poussineau?= Date: Sun, 23 Dec 2012 16:32:47 +0100 Message-Id: <1356276769-7357-8-git-send-email-hpoussin@reactos.org> In-Reply-To: <1356276769-7357-1-git-send-email-hpoussin@reactos.org> References: <1356276769-7357-1-git-send-email-hpoussin@reactos.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [RFC 7/8] ioport: remove now useless portio_list_* functions List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Andreas=20F=C3=A4rber?= , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Gerd Hoffmann Signed-off-by: Herv=C3=A9 Poussineau --- ioport.c | 121 --------------------------------------------------------= ------ ioport.h | 19 ---------- 2 files changed, 140 deletions(-) diff --git a/ioport.c b/ioport.c index 6e4ca0d..05f8026 100644 --- a/ioport.c +++ b/ioport.c @@ -329,124 +329,3 @@ uint32_t cpu_inl(pio_addr_t addr) LOG_IOPORT("inl : %04"FMT_pioaddr" %08"PRIx32"\n", addr, val); return val; } - -void portio_list_init(PortioList *piolist, - const MemoryRegionPortio *callbacks, - void *opaque, const char *name) -{ - unsigned n =3D 0; - - while (callbacks[n].size) { - ++n; - } - - piolist->ports =3D callbacks; - piolist->nr =3D 0; - piolist->regions =3D g_new0(MemoryRegion *, n); - piolist->aliases =3D g_new0(MemoryRegion *, n); - piolist->address_space =3D NULL; - piolist->opaque =3D opaque; - piolist->name =3D name; -} - -void portio_list_destroy(PortioList *piolist) -{ - g_free(piolist->regions); - g_free(piolist->aliases); -} - -static void portio_list_add_1(PortioList *piolist, - const MemoryRegionPortio *pio_init, - unsigned count, unsigned start, - unsigned off_low, unsigned off_high) -{ - MemoryRegionPortio *pio; - MemoryRegionOps *ops; - MemoryRegion *region, *alias; - unsigned i; - - /* Copy the sub-list and null-terminate it. */ - pio =3D g_new(MemoryRegionPortio, count + 1); - memcpy(pio, pio_init, sizeof(MemoryRegionPortio) * count); - memset(pio + count, 0, sizeof(MemoryRegionPortio)); - - /* Adjust the offsets to all be zero-based for the region. */ - for (i =3D 0; i < count; ++i) { - pio[i].offset -=3D off_low; - } - - ops =3D g_new0(MemoryRegionOps, 1); - ops->old_portio =3D pio; - - region =3D g_new(MemoryRegion, 1); - alias =3D g_new(MemoryRegion, 1); - /* - * Use an alias so that the callback is called with an absolute addr= ess, - * rather than an offset relative to to start + off_low. - */ - memory_region_init_io(region, ops, piolist->opaque, piolist->name, - INT64_MAX); - memory_region_init_alias(alias, piolist->name, - region, start + off_low, off_high - off_low= ); - memory_region_add_subregion(piolist->address_space, - start + off_low, alias); - piolist->regions[piolist->nr] =3D region; - piolist->aliases[piolist->nr] =3D alias; - ++piolist->nr; -} - -void portio_list_add(PortioList *piolist, - MemoryRegion *address_space, - uint32_t start) -{ - const MemoryRegionPortio *pio, *pio_start =3D piolist->ports; - unsigned int off_low, off_high, off_last, count; - - piolist->address_space =3D address_space; - - /* Handle the first entry specially. */ - off_last =3D off_low =3D pio_start->offset; - off_high =3D off_low + pio_start->len; - count =3D 1; - - for (pio =3D pio_start + 1; pio->size !=3D 0; pio++, count++) { - /* All entries must be sorted by offset. */ - assert(pio->offset >=3D off_last); - off_last =3D pio->offset; - - /* If we see a hole, break the region. */ - if (off_last > off_high) { - portio_list_add_1(piolist, pio_start, count, start, off_low, - off_high); - /* ... and start collecting anew. */ - pio_start =3D pio; - off_low =3D off_last; - off_high =3D off_low + pio->len; - count =3D 0; - } else if (off_last + pio->len > off_high) { - off_high =3D off_last + pio->len; - } - } - - /* There will always be an open sub-list. */ - portio_list_add_1(piolist, pio_start, count, start, off_low, off_hig= h); -} - -void portio_list_del(PortioList *piolist) -{ - MemoryRegion *mr, *alias; - unsigned i; - - for (i =3D 0; i < piolist->nr; ++i) { - mr =3D piolist->regions[i]; - alias =3D piolist->aliases[i]; - memory_region_del_subregion(piolist->address_space, alias); - memory_region_destroy(alias); - memory_region_destroy(mr); - g_free((MemoryRegionOps *)mr->ops); - g_free(mr); - g_free(alias); - piolist->regions[i] =3D NULL; - piolist->aliases[i] =3D NULL; - } -} diff --git a/ioport.h b/ioport.h index 23441cb..cb06bff 100644 --- a/ioport.h +++ b/ioport.h @@ -56,23 +56,4 @@ uint32_t cpu_inl(pio_addr_t addr); struct MemoryRegion; struct MemoryRegionPortio; =20 -typedef struct PortioList { - const struct MemoryRegionPortio *ports; - struct MemoryRegion *address_space; - unsigned nr; - struct MemoryRegion **regions; - struct MemoryRegion **aliases; - void *opaque; - const char *name; -} PortioList; - -void portio_list_init(PortioList *piolist, - const struct MemoryRegionPortio *callbacks, - void *opaque, const char *name); -void portio_list_destroy(PortioList *piolist); -void portio_list_add(PortioList *piolist, - struct MemoryRegion *address_space, - uint32_t addr); -void portio_list_del(PortioList *piolist); - #endif /* IOPORT_H */ --=20 1.7.10.4