📄 bios32.c
字号:
bus->resource[i]->name = bus->name; } } bus->resource[0]->flags |= pci_bridge_check_io(dev); bus->resource[1]->flags |= IORESOURCE_MEM; if (bus->resource[2] && root->resource[2]) bus->resource[2]->flags = root->resource[2]->flags; } else { /* * Assign root bus resources. */ for (i = 0; i < 3; i++) bus->resource[i] = root->resource[i]; }}/* * pcibios_fixup_bus - Called after each bus is probed, * but before its children are examined. */void __init pcibios_fixup_bus(struct pci_bus *bus){ struct pci_sys_data *root = bus->sysdata; struct list_head *walk; u16 features = PCI_COMMAND_SERR | PCI_COMMAND_PARITY; u16 all_status = -1; pbus_assign_bus_resources(bus, root); /* * Walk the devices on this bus, working out what we can * and can't support. */ for (walk = bus->devices.next; walk != &bus->devices; walk = walk->next) { struct pci_dev *dev = pci_dev_b(walk); u16 status; pdev_fixup_device_resources(root, dev); pci_read_config_word(dev, PCI_STATUS, &status); all_status &= status; if (pdev_bad_for_parity(dev)) features &= ~(PCI_COMMAND_SERR | PCI_COMMAND_PARITY); /* * If this device is an ISA bridge, set the have_isa_bridge * flag. We will then go looking for things like keyboard, * etc */ if (dev->class >> 8 == PCI_CLASS_BRIDGE_ISA || dev->class >> 8 == PCI_CLASS_BRIDGE_EISA) have_isa_bridge = !0; } /* * If any device on this bus does not support fast back to back * transfers, then the bus as a whole is not able to support them. * Having fast back to back transfers on saves us one PCI cycle * per transaction. */ if (all_status & PCI_STATUS_FAST_BACK) features |= PCI_COMMAND_FAST_BACK; /* * Now walk the devices again, this time setting them up. */ for (walk = bus->devices.next; walk != &bus->devices; walk = walk->next) { struct pci_dev *dev = pci_dev_b(walk); u16 cmd; pci_read_config_word(dev, PCI_COMMAND, &cmd); cmd |= features; pci_write_config_word(dev, PCI_COMMAND, cmd); pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, SMP_CACHE_BYTES >> 2); } /* * Report what we did for this bus */ printk(KERN_INFO "PCI: bus%d: Fast back to back transfers %sabled\n", bus->number, (features & PCI_COMMAND_FAST_BACK) ? "en" : "dis");}/* * Convert from Linux-centric to bus-centric addresses for bridge devices. */void __initpcibios_fixup_pbus_ranges(struct pci_bus *bus, struct pbus_set_ranges_data *ranges){ struct pci_sys_data *root = bus->sysdata; ranges->io_start -= root->io_offset; ranges->io_end -= root->io_offset; ranges->mem_start -= root->mem_offset; ranges->mem_end -= root->mem_offset; ranges->prefetch_start -= root->mem_offset; ranges->prefetch_end -= root->mem_offset;}/* * This is the standard PCI-PCI bridge swizzling algorithm: * * Dev: 0 1 2 3 * A A B C D * B B C D A * C C D A B * D D A B C * ^^^^^^^^^^ irq pin on bridge */u8 __devinit pci_std_swizzle(struct pci_dev *dev, u8 *pinp){ int pin = *pinp; if (pin != 0) { pin -= 1; while (dev->bus->self) { pin = (pin + PCI_SLOT(dev->devfn)) & 3; /* * move up the chain of bridges, * swizzling as we go. */ dev = dev->bus->self; } *pinp = pin + 1; } return PCI_SLOT(dev->devfn);}/* * Swizzle the device pin each time we cross a bridge. * This might update pin and returns the slot number. */static u8 __devinit pcibios_swizzle(struct pci_dev *dev, u8 *pin){ struct pci_sys_data *sys = dev->sysdata; int slot = 0, oldpin = *pin; if (sys->swizzle) slot = sys->swizzle(dev, pin); if (debug_pci) printk("PCI: %s swizzling pin %d => pin %d slot %d\n", dev->slot_name, oldpin, *pin, slot); return slot;}/* * Map a slot/pin to an IRQ. */static int pcibios_map_irq(struct pci_dev *dev, u8 slot, u8 pin){ struct pci_sys_data *sys = dev->sysdata; int irq = -1; if (sys->map_irq) irq = sys->map_irq(dev, slot, pin); if (debug_pci) printk("PCI: %s mapping slot %d pin %d => irq %d\n", dev->slot_name, slot, pin, irq); return irq;}static void __init pcibios_init_hw(struct hw_pci *hw){ struct pci_sys_data *sys = NULL; int ret; int nr, busnr; for (nr = busnr = 0; nr < hw->nr_controllers; nr++) { sys = kmalloc(sizeof(struct pci_sys_data), GFP_KERNEL); if (!sys) panic("PCI: unable to allocate sys data!"); memset(sys, 0, sizeof(struct pci_sys_data)); sys->hw = hw; sys->busnr = busnr; sys->swizzle = hw->swizzle; sys->map_irq = hw->map_irq; sys->resource[0] = &ioport_resource; sys->resource[1] = &iomem_resource; ret = hw->setup(nr, sys); if (ret > 0) { sys->bus = hw->scan(nr, sys); if (!sys->bus) panic("PCI: unable to scan bus!"); busnr = sys->bus->subordinate + 1; } else { kfree(sys); if (ret < 0) break; } }}extern struct hw_pci ebsa285_pci;extern struct hw_pci cats_pci;extern struct hw_pci netwinder_pci;extern struct hw_pci personal_server_pci;extern struct hw_pci ftv_pci;extern struct hw_pci shark_pci;extern struct hw_pci integrator_pci;extern struct hw_pci iq80310_pci;void __init pcibios_init(void){ struct hw_pci *hw = NULL; do {#ifdef CONFIG_ARCH_EBSA285 if (machine_is_ebsa285()) { hw = &ebsa285_pci; break; }#endif#ifdef CONFIG_ARCH_SHARK if (machine_is_shark()) { hw = &shark_pci; break; }#endif#ifdef CONFIG_ARCH_CATS if (machine_is_cats()) { hw = &cats_pci; break; }#endif#ifdef CONFIG_ARCH_NETWINDER if (machine_is_netwinder()) { hw = &netwinder_pci; break; }#endif#ifdef CONFIG_ARCH_PERSONAL_SERVER if (machine_is_personal_server()) { hw = &personal_server_pci; break; }#endif#ifdef CONFIG_ARCH_FTVPCI if (machine_is_ftvpci()) { hw = &ftv_pci; break; }#endif#ifdef CONFIG_ARCH_INTEGRATOR if (machine_is_integrator()) { hw = &integrator_pci; break; }#endif#ifdef CONFIG_ARCH_IQ80310 if (machine_is_iq80310()) { hw = &iq80310_pci; break; }#endif } while (0); if (hw == NULL) return; if (hw->preinit) hw->preinit(); pcibios_init_hw(hw); if (hw->postinit) hw->postinit(); /* * Assign any unassigned resources. */ pci_assign_unassigned_resources(); pci_fixup_irqs(pcibios_swizzle, pcibios_map_irq);}char * __init pcibios_setup(char *str){ if (!strcmp(str, "debug")) { debug_pci = 1; return NULL; } return str;}/* * From arch/i386/kernel/pci-i386.c: * * We need to avoid collisions with `mirrored' VGA ports * and other strange ISA hardware, so we always want the * addresses to be allocated in the 0x000-0x0ff region * modulo 0x400. * * Why? Because some silly external IO cards only decode * the low 10 bits of the IO address. The 0x00-0xff region * is reserved for motherboard devices that decode all 16 * bits, so it's ok to allocate at, say, 0x2800-0x28ff, * but we want to try to avoid allocating at 0x2900-0x2bff * which might be mirrored at 0x0100-0x03ff.. */void pcibios_align_resource(void *data, struct resource *res, unsigned long size){ if (res->flags & IORESOURCE_IO) { unsigned long start = res->start; if (start & 0x300) res->start = (start + 0x3ff) & ~0x3ff; }}/** * pcibios_enable_device - Enable I/O and memory. * @dev: PCI device to be enabled */int pcibios_enable_device(struct pci_dev *dev){ u16 cmd, old_cmd; int idx; struct resource *r; pci_read_config_word(dev, PCI_COMMAND, &cmd); old_cmd = cmd; for (idx = 0; idx < 6; idx++) { r = dev->resource + idx; if (!r->start && r->end) { printk(KERN_ERR "PCI: Device %s not available because" " of resource collisions\n", dev->slot_name); return -EINVAL; } if (r->flags & IORESOURCE_IO) cmd |= PCI_COMMAND_IO; if (r->flags & IORESOURCE_MEM) cmd |= PCI_COMMAND_MEMORY; } if (cmd != old_cmd) { printk("PCI: enabling device %s (%04x -> %04x)\n", dev->slot_name, old_cmd, cmd); pci_write_config_word(dev, PCI_COMMAND, cmd); } return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -