If the device is marked as bus master capable (currently disabled) and we are running on an Apple PPC platform, enable bus mastering for this card. This is currently tied to this particular card although it is likely that in future this check could be loosened to other bus master capable cards on Apple PPC.
This is because it seems that Apple's OF implementation enables bus mastering on some cards by default and so some drivers forget to explicitly enable bus mastering, even though the driver requires it. The rtl8139 driver is one such buggy driver and this has been reported as necessary for both OS X and MorphOS.
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@ilande.co.uk --- openbios-devel/drivers/pci.c | 15 +++++++++++++++ openbios-devel/drivers/pci_database.c | 2 +- openbios-devel/drivers/pci_database.h | 1 + 3 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/openbios-devel/drivers/pci.c b/openbios-devel/drivers/pci.c index 0108a0d..04cc230 100644 --- a/openbios-devel/drivers/pci.c +++ b/openbios-devel/drivers/pci.c @@ -550,6 +550,21 @@ int eth_config_cb (const pci_config_t *config) return 0; }
+int rtl8139_config_cb(const pci_config_t *config) +{ +#ifdef CONFIG_PPC + /* Apple's OF seemingly enables bus mastering on some cards by + * default, which means that some buggy drivers forget to + * explicitly set it (OS X, MorphOS). Mimic this behaviour so + * that these buggy drivers work under emulation. */ + if (is_apple() && ob_pci_is_bus_master_capable(config)) { + ob_pci_enable_bus_master(config); + } +#endif + + return eth_config_cb(config); +} + static inline void pci_decode_pci_addr(pci_addr addr, int *flags, int *space_code, uint32_t *mask) { diff --git a/openbios-devel/drivers/pci_database.c b/openbios-devel/drivers/pci_database.c index 9104c0b..67767c8 100644 --- a/openbios-devel/drivers/pci_database.c +++ b/openbios-devel/drivers/pci_database.c @@ -132,7 +132,7 @@ static const pci_dev_t eth_devices[] = { PCI_VENDOR_ID_REALTEK, PCI_DEVICE_ID_REALTEK_RTL8139, NULL, "RTL8139", "RTL8139 PCI", NULL, 0, 0, 0, - NULL, "ethernet", + rtl8139_config_cb, "ethernet", }, { /* Virtio-network controller */ diff --git a/openbios-devel/drivers/pci_database.h b/openbios-devel/drivers/pci_database.h index 92234fc..e96b3b1 100644 --- a/openbios-devel/drivers/pci_database.h +++ b/openbios-devel/drivers/pci_database.h @@ -39,6 +39,7 @@ extern int bridge_config_cb(const pci_config_t *config); extern int ebus_config_cb(const pci_config_t *config); extern int i82378_config_cb(const pci_config_t *config); extern int usb_ohci_config_cb(const pci_config_t *config); +extern int rtl8139_config_cb(const pci_config_t *config);
static inline int pci_compat_len(const pci_dev_t *dev) {