From 5f8b4d4d2e296f0199aff135ced520d6e4a3ade1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Duval?= Date: Sat, 22 Jan 2022 17:12:09 +0100 Subject: [PATCH] framebuffer: handle 64-bit PCI BARs Change-Id: I634f2a75fe80da99063b98a255d14953cd1a361f Reviewed-on: https://review.haiku-os.org/c/haiku/+/4880 Tested-by: Commit checker robot Reviewed-by: waddlesplash --- .../graphics/framebuffer/framebuffer.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/add-ons/kernel/drivers/graphics/framebuffer/framebuffer.cpp b/src/add-ons/kernel/drivers/graphics/framebuffer/framebuffer.cpp index 4c9c5c2cab..43e736e452 100644 --- a/src/add-ons/kernel/drivers/graphics/framebuffer/framebuffer.cpp +++ b/src/add-ons/kernel/drivers/graphics/framebuffer/framebuffer.cpp @@ -38,12 +38,20 @@ find_graphics_card(addr_t frameBuffer, addr_t& base, size_t& size) // check PCI BARs for (uint32 i = 0; i < 6; i++) { - if (info.u.h0.base_registers[i] <= frameBuffer - && info.u.h0.base_registers[i] + info.u.h0.base_register_sizes[i] - > frameBuffer) { + phys_addr_t addr = info.u.h0.base_registers[i]; + uint64 barSize = info.u.h0.base_register_sizes[i]; + if (i < 5 + && (info.u.h0.base_register_flags[i] & PCI_address_type) == PCI_address_type_64) { + addr |= (uint64)info.u.h0.base_registers[i + 1] << 32; + barSize |= (uint64)info.u.h0.base_register_sizes[i + 1] << 32; + i++; + } + if (addr <= frameBuffer && addr + barSize > frameBuffer) { // found it! - base = info.u.h0.base_registers[i]; - size = info.u.h0.base_register_sizes[i]; + base = addr; + size = barSize; + dprintf(DEVICE_NAME " find_graphics_card: found base 0x%lx size %" B_PRIuSIZE "\n", + base, size); put_module(B_PCI_MODULE_NAME); return B_OK; @@ -51,6 +59,7 @@ find_graphics_card(addr_t frameBuffer, addr_t& base, size_t& size) } } + dprintf(DEVICE_NAME " find_graphics_card: no entry found for 0x%lx\n", frameBuffer); put_module(B_PCI_MODULE_NAME); return B_ENTRY_NOT_FOUND; }