1 /* 2 * Data structures and functions shared between variants of the macOS 3 * ParavirtualizedGraphics.framework based apple-gfx display adapter. 4 * 5 * SPDX-License-Identifier: GPL-2.0-or-later 6 */ 7 8 #ifndef QEMU_APPLE_GFX_H 9 #define QEMU_APPLE_GFX_H 10 11 #include "qemu/queue.h" 12 #include "exec/memory.h" 13 #include "hw/qdev-properties.h" 14 #include "ui/surface.h" 15 16 #define TYPE_APPLE_GFX_MMIO "apple-gfx-mmio" 17 18 @class PGDeviceDescriptor; 19 @protocol PGDevice; 20 @protocol PGDisplay; 21 @protocol MTLDevice; 22 @protocol MTLTexture; 23 @protocol MTLCommandQueue; 24 25 typedef QTAILQ_HEAD(, PGTask_s) PGTaskList; 26 27 typedef struct AppleGFXState { 28 /* Initialised on init/realize() */ 29 MemoryRegion iomem_gfx; 30 id<PGDevice> pgdev; 31 id<PGDisplay> pgdisp; 32 QemuConsole *con; 33 id<MTLDevice> mtl; 34 id<MTLCommandQueue> mtl_queue; 35 36 /* List `tasks` is protected by task_mutex */ 37 QemuMutex task_mutex; 38 PGTaskList tasks; 39 40 /* Mutable state (BQL protected) */ 41 QEMUCursor *cursor; 42 DisplaySurface *surface; 43 id<MTLTexture> texture; 44 int8_t pending_frames; /* # guest frames in the rendering pipeline */ 45 bool gfx_update_requested; /* QEMU display system wants a new frame */ 46 bool new_frame_ready; /* Guest has rendered a frame, ready to be used */ 47 bool using_managed_texture_storage; 48 uint32_t rendering_frame_width; 49 uint32_t rendering_frame_height; 50 51 /* Mutable state (atomic) */ 52 bool cursor_show; 53 } AppleGFXState; 54 55 void apple_gfx_common_init(Object *obj, AppleGFXState *s, const char* obj_name); 56 bool apple_gfx_common_realize(AppleGFXState *s, DeviceState *dev, 57 PGDeviceDescriptor *desc, Error **errp); 58 void *apple_gfx_host_ptr_for_gpa_range(uint64_t guest_physical, 59 uint64_t length, bool read_only, 60 MemoryRegion **mapping_in_region); 61 62 #endif 63 64