qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v2 5/8] hw/display/apple-gfx: Replaces magic number with queried


From: Phil Dennis-Jordan
Subject: [PATCH v2 5/8] hw/display/apple-gfx: Replaces magic number with queried MMIO length
Date: Wed, 17 Jul 2024 13:03:23 +0200

Rather than specifying the length of the device's MMIO range as an
unnamed literal constant (which is at least documented as a comment in
the framework headers), we query the PVG framework's API for the
recommended value. This also avoids problems in future, in case the
currently documented value for the default changes.

Signed-off-by: Phil Dennis-Jordan <phil@philjordan.eu>
---
 hw/display/apple-gfx.m  | 16 +++++++++++++++-
 hw/display/trace-events |  1 +
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/hw/display/apple-gfx.m b/hw/display/apple-gfx.m
index 3756a9e3ff..6f374455f9 100644
--- a/hw/display/apple-gfx.m
+++ b/hw/display/apple-gfx.m
@@ -283,12 +283,26 @@ static void create_fb(AppleGFXState *s)
     s->cursor_show = true;
 }
 
+static size_t apple_gfx_get_default_mmio_range_size(void)
+{
+    size_t mmio_range_size;
+    @autoreleasepool {
+        PGDeviceDescriptor *desc = [PGDeviceDescriptor new];
+        mmio_range_size = desc.mmioLength;
+        [desc release];
+    }
+    return mmio_range_size;
+}
+
 void apple_gfx_common_init(Object *obj, AppleGFXState *s, const char* obj_name)
 {
     Error *local_err = NULL;
     int r;
+    size_t mmio_range_size = apple_gfx_get_default_mmio_range_size();
 
-    memory_region_init_io(&s->iomem_gfx, obj, &apple_gfx_ops, s, obj_name, 
0x4000);
+    trace_apple_gfx_common_init(obj_name, mmio_range_size);
+    memory_region_init_io(&s->iomem_gfx, obj, &apple_gfx_ops, s, obj_name,
+                          mmio_range_size);
 
     /* TODO: PVG framework supports serialising device state: integrate it! */
     if (apple_gfx_mig_blocker == NULL) {
diff --git a/hw/display/trace-events b/hw/display/trace-events
index e35582d659..1809a358e3 100644
--- a/hw/display/trace-events
+++ b/hw/display/trace-events
@@ -208,6 +208,7 @@ apple_gfx_mode_change(uint64_t x, uint64_t y) "x=%"PRId64" 
y=%"PRId64
 apple_gfx_cursor_set(uint32_t bpp, uint64_t width, uint64_t height) "bpp=%d 
width=%"PRId64" height=0x%"PRId64
 apple_gfx_cursor_show(uint32_t show) "show=%d"
 apple_gfx_cursor_move(void) ""
+apple_gfx_common_init(const char *device_name, size_t mmio_size) "device: %s; 
MMIO size: %zu bytes"
 
 # apple-gfx-vmapple.m
 apple_iosfc_read(uint64_t offset, uint64_t res) "offset=0x%"PRIx64" 
res=0x%"PRIx64
-- 
2.39.3 (Apple Git-146)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]