Conversation
This change updates pci_set_bar() to accept a single `layout` bitmask instead of separate boolean flags, simplifying BAR configuration. The new `layout` argument encodes I/O vs. memory space, 32-/64-bit decoding, and prefetchable settings via standard PCI_BASE_ADDRESS_* macros. Existing callers can now pass any combination of: - PCI_BASE_ADDRESS_SPACE_IO or PCI_BASE_ADDRESS_SPACE_MEMORY - PCI_BASE_ADDRESS_MEM_TYPE_32 or PCI_BASE_ADDRESS_MEM_TYPE_64 - PCI_BASE_ADDRESS_MEM_PREFETCH The function writes the full layout to the BAR, derives `bar_is_io_space` from bit[0], and initializes the region with the provided callback. Docstrings updated with Doxygen examples illustrating MMIO and port I/O. BREAKING CHANGE: pci_set_bar() signature changed; call sites must be updated to pass the new `layout` parameter rather than separate flags.
This replaces bar_is_io_space[6] with bar_layout[6] so the full PCI_BASE_ADDRESS_* bitmask written by pci_set_bar() survives a guest BAR write. Previously only bit 0 (space) was retained; MEM_TYPE and PREFETCH bits were silently dropped on the first config-space probe, which meant pci_set_bar()'s new `layout` parameter was a partial lie. pci_config_bar() now restores all non-address bits via (bar_layout[bar] & ~mask) and assigns space_dev[bar].base to the masked address only, fixing a latent I/O BAR routing bug where the SPACE_IO bit in 'base' made bus_find_dev() miss the first port. Header parameter renamed is_io_space -> layout to match the implementation, and the magic 0x1U mask in pci_set_bar() now uses the standard PCI_BASE_ADDRESS_SPACE_IO constant. 64-bit BARs still need a paired adjacent slot for the upper dword; that limitation is now documented in pci_set_bar(). Co-authored-by: Jim Huang <jserv@ccns.ncku.edu.tw>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary by cubic
Keep the full PCI BAR layout (space, mem type, prefetch) intact across guest sizing and fix I/O BAR routing. Also switch pci_set_bar to a single layout bitmask for simpler, accurate BAR setup.
Bug Fixes
Migration
Written for commit 833b3d0. Summary will update on new commits. Review in cubic