From patchwork Tue Dec 29 17:59:08 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Programmingkid X-Patchwork-Id: 561597 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 18A58140C25 for ; Wed, 30 Dec 2015 04:59:43 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=jw5SxDyZ; dkim-atps=neutral Received: from localhost ([::1]:49595 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aDyYe-0002oX-QP for incoming@patchwork.ozlabs.org; Tue, 29 Dec 2015 12:59:40 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59055) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aDyYJ-0002MF-Us for qemu-devel@nongnu.org; Tue, 29 Dec 2015 12:59:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aDyYG-0000tM-Ob for qemu-devel@nongnu.org; Tue, 29 Dec 2015 12:59:19 -0500 Received: from mail-ig0-x22e.google.com ([2607:f8b0:4001:c05::22e]:36043) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aDyYG-0000tG-KO for qemu-devel@nongnu.org; Tue, 29 Dec 2015 12:59:16 -0500 Received: by mail-ig0-x22e.google.com with SMTP id ph11so167098069igc.1 for ; Tue, 29 Dec 2015 09:59:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:content-type:content-transfer-encoding:subject:date:message-id :to:mime-version; bh=fjBcrRuH344fZQdWIm3kcbeXPiGzA0dhGbMdhWa235k=; b=jw5SxDyZTPigIDmWacsVEpBP/rAcGvcWJvkd6jn+gpzjwQmdlG9PL7sTO8riIq7QmH sxCBII7IROTHZmgzRXD9N4FjX0v3dThZrMY5fstFbMdghhEb2JcetG+AvFz+OYx7NdMB TMbM9CkHVwLuPlPvbza+9gnPtHn9oZyR23kiIdSrIcxKKaMqv8xM3LM2rEhfc8aFg0z+ C1y5jwDop0bnfam4b8tGupL28k44KmezTAh3if26n2TPJUGelnPViwuAAsUIzQF/ZbsJ I/hwh0RuXJcz+7gD96+soVwAs3BOtA1/p966ZuwwlWhx2rlSzAryB2oFRkyflnWRihRc X9pg== X-Received: by 10.50.50.143 with SMTP id c15mr58959212igo.83.1451411956101; Tue, 29 Dec 2015 09:59:16 -0800 (PST) Received: from [192.168.0.3] (d199-74-164-53.col.wideopenwest.com. [74.199.53.164]) by smtp.gmail.com with ESMTPSA id or1sm21648164igb.4.2015.12.29.09.59.14 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 29 Dec 2015 09:59:15 -0800 (PST) From: Programmingkid Date: Tue, 29 Dec 2015 12:59:08 -0500 Message-Id: To: qemu-devel qemu-devel , jasowang@redhat.com Mime-Version: 1.0 (Apple Message framework v1084) X-Mailer: Apple Mail (2.1084) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:4001:c05::22e Subject: [Qemu-devel] [PATCH] Make rtl8139 network interface card compatible with Mac OS 10.4 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org This patch solves the few problems that needed to be solved in order for a Mac OS 10.4 guest to use the rtl8139 nic. The pci_dma_read() function would only return zero when a MemoryRegion object was not enabled. Enabling the object makes the pci_dma_read() function work correctly. The Linux rtl8139 driver needs base address register zero set to PIO. This conflicts with Mac OS 10.4's driver needing base address register zero set to MMIO. So a macro has been added that allows the user to decide which operating system this network interface card will be compatible with. Note: Windows XP's driver works regardless of the macro setting. Signed-off-by: John Arbuckle --- hw/net/rtl8139.c | 15 ++++++++++++++- include/hw/pci/pci.h | 1 + 2 files changed, 15 insertions(+), 1 deletions(-) diff --git a/hw/net/rtl8139.c b/hw/net/rtl8139.c index 90ef72b..e17a471 100644 --- a/hw/net/rtl8139.c +++ b/hw/net/rtl8139.c @@ -64,6 +64,14 @@ /* debug RTL8139 card */ //#define DEBUG_RTL8139 1 +/* + * The driver that ships with Mac OS 10.4 has to have its base address register + * 0 set to MMIO space. This directly conflicts with the Linux driver that + * needs the PIO set to base address register 0. Mac OS 10.5 or higher does not + * need this macro set. + */ +/* #define MAC_OS_10_4_DRIVER_COMPATIBILITY 1 */ + #define PCI_PERIOD 30 /* 30 ns period = 33.333333 Mhz frequency */ #define SET_MASKED(input, mask, curr) \ @@ -3444,9 +3452,14 @@ static void pci_rtl8139_realize(PCIDevice *dev, Error **errp) "rtl8139", 0x100); memory_region_init_io(&s->bar_mem, OBJECT(s), &rtl8139_mmio_ops, s, "rtl8139", 0x100); + +#ifdef MAC_OS_10_4_DRIVER_COMPATIBILITY + pci_register_bar(dev, 0, PCI_BASE_ADDRESS_SPACE_MEMORY, &s->bar_mem); + pci_register_bar(dev, 1, PCI_BASE_ADDRESS_SPACE_IO, &s->bar_io); +#else pci_register_bar(dev, 0, PCI_BASE_ADDRESS_SPACE_IO, &s->bar_io); pci_register_bar(dev, 1, PCI_BASE_ADDRESS_SPACE_MEMORY, &s->bar_mem); - +#endif qemu_macaddr_default_if_unset(&s->conf.macaddr); /* prepare eeprom */ diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h index 379b6e1..8e95c75 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -699,6 +699,7 @@ static inline int pci_dma_rw(PCIDevice *dev, dma_addr_t addr, static inline int pci_dma_read(PCIDevice *dev, dma_addr_t addr, void *buf, dma_addr_t len) { + memory_region_set_enabled(&dev->bus_master_enable_region, true); return pci_dma_rw(dev, addr, buf, len, DMA_DIRECTION_TO_DEVICE); }