summaryrefslogtreecommitdiff
path: root/sys/src/9/pc/pcipc.c
AgeCommit message (Collapse)Author
2021-11-26kernel: support large 64-bit pci membars, increase pc64 VMAPSIZE to 1TBcinap_lenrek
This makes vmap()/vunmap() take a vlong size argument, and change the type of Pci.mem[].size to vlong as well. Even if vmap() wont support large mappings, it is nice to get the original unruncated value for error checking. pc64 needs a bigger VMAP window, as system76 pangolin puts the framebuffer at a physical address > 512GB.
2021-03-01devpccard, pci: fix pccard support and handle pci expansion romscinap_lenrek
let pci.c deal with the special cardbus controller bar0 and expansion roms. handle apic interrupt routing for devices behind a cardbus slot. do not free the pcidev on card removal, as the drivers most certanly are not prepared to handle this yet. instead, we provide a pcidevfree() function that just unlinks the device from pcilist and the parent bridge.
2021-01-10pc, pc64: revert addition of pcireset() call to pcicfginit()cinap_lenrek
Revert the change, as it causes system lockups on bootup on some systems with USB OHCI controllers, suspected to be caused by BIOS/SMM accessing the device as BIOS handover has not been executed yet. We might bring that back when the problem has is better understood.
2020-11-21pc, pc64: disable all pci devices in pcicfginit()cinap_lenrek
Make sure all pci busmaster activity is disabled, including MSI/MSI-X interrupts. Drivers will later reenable once taking control of a device.
2020-11-03pc, pc64: allocate i/o port space for unassigned pci bars, move ioalloc() to ↵cinap_lenrek
port/iomap.c With some newer UEFI firmware, not all pci bars get programmed and we have to assign them ourselfs. This was already done for memory bars. This change adds the same for i/o port space, by providing a ioreservewin() function which can be used to allocate port space within the parent pci-pci bridge window. Also, the pci code now allocates the pci config space i/o ports 0xCF8/0xCFC so userspace needs to use devpnp to access pci config space now. (see latest realemu change). Also, this moves the ioalloc()/iofree() code out of devarch into port/iomap.c as it can be shared with the ppc mtx kernel.
2020-10-18pc, pc64: remove mystery "type" bits in pcicfgrw*raw() (fixes qemu, thanks ↵cinap_lenrek
mischief) the access functions for pci config space in config mode #1 used to set bit 0 in the register offset if the access was to a device on any bus different from 0. it is completely unclear why this was done and i can't find any documentation on this. but for sure, this breaks all pci config spacess access to pci devices behind a bridge on qemu. with -trace pci* it was discovered that all config space register offsets on devies behind pci brige where off by one. on real hardware, setting bit 0 in the offset doesnt appear to be an issue. thanks mischief for reporting and providing a qemu demo configuration to reproduce the problem.
2020-09-13kernel: massive pci code rewritecinap_lenrek
The new pci code is moved to port/pci.[hc] and shared by all ports. Each port has its own PCI controller implementation, providing the pcicfgrw*() functions for low level pci config space access. The locking for pcicfgrw*() is now done by the caller (only port/pci.c). Device drivers now need to include "../port/pci.h" in addition to "io.h". The new code now checks bridge windows and membars, while enumerating the bus, giving the pc driver a chance to re-assign them. This is needed because some UEFI implementations fail to assign the bars for some devices, so we need to do it outselfs. (See pcireservemem()). While working on this, it was discovered that the pci code assimed the smallest I/O bar size is 16 (pcibarsize()), which is wrong. I/O bars can be as small as 4 bytes. Bit 1 in an I/O bar is also reserved and should be masked off, making the port mask: port = bar & ~3;