Skip to content

Commit

Permalink
pci: Fix aliasing warning on Clang
Browse files Browse the repository at this point in the history
  • Loading branch information
marv7000 committed Jan 10, 2025
1 parent fdc0109 commit 7fea593
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion include/menix/system/pci/pci.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ struct ATTR(packed) PciConfigSpace
u8 cache_line_size, latency_timer, header_type, bist;

// Fields depending on the header type.
union
union ATTR(packed)
{
struct ATTR(packed)
{
Expand Down
5 changes: 2 additions & 3 deletions kernel/system/bus/pci/device.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,15 @@ void pci_scan_devices()

PhysAddr pci_get_bar(PciDevice* device, usize idx)
{
volatile u32* bars = device->config_space->generic.bar;
PhysAddr bar = bars[idx];
PhysAddr bar = device->config_space->generic.bar[idx];

// Memory Space BAR
if ((bar & 1) == 0)
{
const usize type = (bar & 0b110) >> 1;
// If a 64-bit BAR, add the upper bits to the address.
if (type == 0x2)
bar |= (PhysAddr)bars[idx + 1] << 32;
bar |= (PhysAddr)device->config_space->generic.bar[idx + 1] << 32;
bar = ALIGN_DOWN(bar, 16);
}
// IO Space BAR
Expand Down

0 comments on commit 7fea593

Please sign in to comment.