Skip to content

Replace BAR flags with unified layout parameter#41

Closed
otischung wants to merge 2 commits intosysprog21:masterfrom
otischung:fix/pci-bar-unified-layout-param
Closed

Replace BAR flags with unified layout parameter#41
otischung wants to merge 2 commits intosysprog21:masterfrom
otischung:fix/pci-bar-unified-layout-param

Conversation

@otischung
Copy link
Copy Markdown
Contributor

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 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.
Comment thread src/pci.h Outdated
Comment thread src/virtio-pci.c
- Remove verbose Doxygen-style documentation for pci_set_bar() to match
  the existing concise comment style used throughout the codebase
- Update PCI_BASE_ADDRESS_MEM_PREFETCH comment to clarify it's an
  optional flag that users can uncomment if prefetchable memory is needed,
  rather than implying it's technically not supported

The original verbose comment was inconsistent with the project's comment
style, which favors brief, direct explanations. The prefetch flag comment
now better explains that it's a user choice rather than a limitation.
@otischung
Copy link
Copy Markdown
Contributor Author

I've completed the requested changes to simplify the PCI-related comments and make them more consistent with the existing codebase style. Please review and approve when ready.

@otischung otischung requested a review from jserv July 30, 2025 05:55
@jserv
Copy link
Copy Markdown
Contributor

jserv commented Apr 29, 2026

Close in favor of #48

@jserv jserv closed this Apr 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants