[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH] usb-ohci: Add address masking.

From: takasi-y
Subject: [Qemu-devel] [PATCH] usb-ohci: Add address masking.
Date: Fri, 5 Dec 2008 22:52:43 +0900 (JST)

About this
> [1] It's actually the offset from the start of the first page of that region. 
> In practice this difference doesn't matter, and makes the implementation a 
> lot simpler.

The patch below adds address mask(0xff) to mmio read/write funcs in usb-ohci.
I know now we are deleting this kind of address mask/subtract things.
But because of the restriction [1] above, we have to add address mask here.

The mmio change potentially breaks PCI device emulations which has mmio region
smaller than page size, like usb-ohci and rtl8139 (both have 256byte), because
PCI memory regions are configured to be aligned to it size, but to page.

usb-ohci is really broken now.
rtl8139 is OK because it already has address mask.
Others are not checked.

I think the most important thing is eliminating dependency to base address,
and small numbers of masks should be acceptable.


This patch adds address mask to mmio read/write function.
Because its memory region is not always aligned to page.

Signed-off-by: Takashi YOSHII <address@hidden>
 hw/usb-ohci.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/hw/usb-ohci.c b/hw/usb-ohci.c
index 585f3a4..bfa7d77 100644
--- a/hw/usb-ohci.c
+++ b/hw/usb-ohci.c
@@ -1366,6 +1366,7 @@ static uint32_t ohci_mem_read(void *ptr, 
target_phys_addr_t addr)
         fprintf(stderr, "usb-ohci: Mis-aligned read\n");
         return 0xffffffff;
+    addr &= 0xff;
     if (addr >= 0x54 && addr < 0x54 + ohci->num_ports * 4) {
         /* HcRhPortStatus */
@@ -1462,6 +1463,7 @@ static void ohci_mem_write(void *ptr, target_phys_addr_t 
addr, uint32_t val)
         fprintf(stderr, "usb-ohci: Mis-aligned write\n");
+    addr &= 0xff;
     if (addr >= 0x54 && addr < 0x54 + ohci->num_ports * 4) {
         /* HcRhPortStatus */

reply via email to

[Prev in Thread] Current Thread [Next in Thread]