diff --git a/guest/kext/Makefile b/guest/kext/Makefile index d44fee59f..6dd44becb 100644 --- a/guest/kext/Makefile +++ b/guest/kext/Makefile @@ -50,8 +50,9 @@ endif ARCH = -arch $(ARCH_NAME) -isysroot $(SDK) -mmacosx-version-min=$(MIN_OS) # Graft's consumer rules, and the declaration and Info.plist they stage this kext from: one of # each per architecture. An arm64 kernel collection has neither AppleGraphicsDeviceControl nor -# IOAcceleratorFamily2, so the arm64e kext (src/graft-arm64e.json, src/Info-arm64e.plist) takes -# both of its parents from IOGraphicsFamily and has no device control. +# IOAcceleratorFamily2, and its WindowServer drives an IOMobileFramebuffer, so the arm64e kext +# (src/graft-arm64e.json, src/Info-arm64e.plist) takes its display's parent from +# IOMobileGraphicsFamily, its accelerator's from IOGraphicsFamily, and has no device control. GRAFT_SDK ?= ../graft/sdk ifeq ($(ARCH_NAME),arm64e) GRAFT_DECL = src/graft-arm64e.json @@ -75,7 +76,7 @@ HEADERS = $(wildcard src/*.hpp) # control (RgfxDeviceControl), all one kext: the objects both architectures build, with # each architecture's own (OBJECTS_x86_64, OBJECTS_arm64e) third in the link. OBJECTS_x86_64 = $(BUILD)/obj/RgfxDeviceControl.o -OBJECTS_arm64e = +OBJECTS_arm64e = $(BUILD)/obj/ReimsGraphicsMobile.o OBJECTS = $(BUILD)/obj/ReimsGraphics.o \ $(BUILD)/obj/RgfxAccelerator.o \ $(OBJECTS_$(ARCH_NAME)) \ diff --git a/guest/kext/src/IOMobileFramebufferLegacy.hpp b/guest/kext/src/IOMobileFramebufferLegacy.hpp new file mode 100644 index 000000000..80e292341 --- /dev/null +++ b/guest/kext/src/IOMobileFramebufferLegacy.hpp @@ -0,0 +1,101 @@ +/* + * IOMobileFramebufferLegacy: a declaration of IOMobileGraphicsFamily's class of that name for the + * arm64e ReimsGraphics, which no SDK declares. It holds only what ReimsGraphics overrides or + * calls: the class's own pure methods, the methods ReimsGraphics overrides and forwards to it, and + * start, stop and free, each with the signature its symbol in the arm64 kernel collections of + * macOS 13.6 to 27.0.1 names. The types are named for the manglings and declared no further. + * + * No symbol carries a return type. Where nothing says what a method returns, it returns + * RgfxIOMFBWord, a 64-bit word: a forward hands whatever the class returned (an IOReturn, a bool + * or a pointer) back unchanged, and ReimsGraphics' own answers are 0, or 1 for a yes. + * + * Graft builds the vtable of the class's subclass from the live class at bind time and places each + * override by its selector (Graft's notes/arm64-display.md), so this declaration's vtable order is + * not the live one. Its fields are a reserve, field_reserve, inside which the live class's own + * fields lie; Graft refuses to bind where the live class is bigger than IOService and the reserve. + */ + +#ifndef RGFX_IOMOBILEFRAMEBUFFERLEGACY_HPP_ +#define RGFX_IOMOBILEFRAMEBUFFERLEGACY_HPP_ + +#include + +class IOSurface; +struct IOMFBGammaTable; +struct IOMFBNotifyRequest; +struct IOMFBSwapIORequest; +struct IOMFBColorFixedMatrix; +struct SwapInfoBlob; +namespace IOMFB { +namespace AP { +struct DisplayedData; +} +} +enum IOMFB_NotificationType : uint32_t; +enum DisplayColorRemapMode : uint32_t; +enum IOMFBColorMatrixFunction : uint32_t; +enum IOMFBParameterName : uint32_t; + +typedef uint64_t RgfxIOMFBWord; + +// The reserve holds the live IOMobileFramebufferLegacy's own fields, which its inherited methods +// reach at their real offsets, so ReimsGraphics' own fields follow it rather than overlapping +// them. The live class is at most 0x1dd8 bytes across macOS 13 to 27 (Ambrosia's per-release +// measurement), and this stand-in's IOService base is 0x88, so the reserve covers 0x1dd8 - 0x88 +// with a little room; Graft refuses the bind where a release's live class is bigger still. +// +// The live chain is IOMobileFramebufferLegacy : IOMobileFramebufferService : IOMobileFramebuffer : +// IOService. The intermediate IOMobileFramebufferService changes neither Legacy's method manglings +// nor, since Graft sizes the subclass to the live Legacy, its layout, so the stand-in leaves it +// out. +constexpr size_t kRgfxIOMFBLegacyReserve = 0x2000; + +class IOMobileFramebuffer : public IOService { + OSDeclareAbstractStructors(IOMobileFramebuffer); +}; + +class IOMobileFramebufferLegacy : public IOMobileFramebuffer { + OSDeclareAbstractStructors(IOMobileFramebufferLegacy); + +public: + struct SwapInfoBlob; + + bool start(IOService *provider) override; + void stop(IOService *provider) override; + void free() override; + + // The class's own pure methods: each subclass implements them. + virtual RgfxIOMFBWord set_notify_tag_mask_gated(IOMFB_NotificationType type, + IOMFBNotifyRequest *request, uint32_t mask) = 0; + // macOS 14 and later; macOS 13's takes no fourth argument (Graft takes either). + virtual RgfxIOMFBWord supported_frame_info(uint32_t index, uint32_t *count, char (*names)[64], + uint32_t *field_3) = 0; + virtual RgfxIOMFBWord factory_portal(void *field_0, task *owner) = 0; + virtual RgfxIOMFBWord executeFactoryConfigurations_gated() = 0; + virtual RgfxIOMFBWord set_frame_info_notification_state_gated(IOMFBNotifyRequest *request, + bool on) = 0; + virtual RgfxIOMFBWord do_swap_info_notify_gated(IOMFBNotifyRequest *request, + const SwapInfoBlob *blob) = 0; + virtual RgfxIOMFBWord notify_swap_done_gated(uint32_t field_0, ::SwapInfoBlob *blob, + uint32_t *field_2, uint32_t field_3) = 0; + virtual RgfxIOMFBWord notify_crc_ready_gated(uint32_t field_0) = 0; + virtual bool are_timings_enabled() const = 0; + + // What the class implements, which ReimsGraphics overrides and forwards to it. + virtual RgfxIOMFBWord start_hardware(); + virtual RgfxIOMFBWord stop_hardware_gated(); + virtual RgfxIOMFBWord swap_begin_gated(); + virtual RgfxIOMFBWord verify_swap(IOMFBSwapIORequest *request); + virtual RgfxIOMFBWord swap_layer_map(IOMFBSwapIORequest *request, uint32_t layer); + virtual RgfxIOMFBWord surface_layer_map(IOMFB::AP::DisplayedData *data, uint32_t layer, + IOSurface *surface); + virtual RgfxIOMFBWord surface_layer_unmap(IOMFB::AP::DisplayedData *data, uint32_t layer); + + // What ReimsGraphics calls: a refresh of the display. + void note_vbl_ISR(uint32_t field_0); + +private: + UInt8 field_reserve[kRgfxIOMFBLegacyReserve]; +}; + +#endif // RGFX_IOMOBILEFRAMEBUFFERLEGACY_HPP_ diff --git a/guest/kext/src/Info-arm64e.plist b/guest/kext/src/Info-arm64e.plist index f124b1ed6..33a6ceedf 100644 --- a/guest/kext/src/Info-arm64e.plist +++ b/guest/kext/src/Info-arm64e.plist @@ -82,11 +82,13 @@ LSMinimumSystemVersion - 26.0 + 13.0 OSBundleLibraries com.apple.iokit.IOGraphicsFamily 1.0.0b1 + com.apple.iokit.IOMobileGraphicsFamily + 1.0.0 com.apple.iokit.IOPCIFamily 2.9 com.apple.iokit.IOSurface diff --git a/guest/kext/src/ReimsGraphics.cpp b/guest/kext/src/ReimsGraphics.cpp index ff25ea4a6..e54681d25 100644 --- a/guest/kext/src/ReimsGraphics.cpp +++ b/guest/kext/src/ReimsGraphics.cpp @@ -21,8 +21,13 @@ #include "RgfxTrace.hpp" +#if defined(__x86_64__) #define super IOFramebuffer OSDefineMetaClassAndStructors(ReimsGraphics, IOFramebuffer); +#else +#define super IOMobileFramebufferLegacy +OSDefineMetaClassAndStructors(ReimsGraphics, IOMobileFramebufferLegacy); +#endif namespace { @@ -39,10 +44,12 @@ constexpr UInt32 kMsgAlign = 8; static_assert(kRgfxIOReturnError == static_cast(kIOReturnError) && kRgfxIOReturnUnsupportedMode == static_cast(kIOReturnUnsupportedMode), "RgfxDisplayModes.hpp's statuses are IOReturn's"); +#if defined(__x86_64__) IOReturn noSuchMode(RgfxModeCall call) { return static_cast(rgfxNoSuchModeStatus(call)); } +#endif // The ring header's fields, by their offset in it (each in a 64-byte line). constexpr UInt32 kRingProducer = __builtin_offsetof(RgfxRingHeader, producer); @@ -146,8 +153,10 @@ void traceAttribute(const char *kind, IOIndex connect, IOSelect attribute, uintp } #else #define FBTRACE(...) do {} while (0) +#if defined(__x86_64__) inline void traceAttribute(const char *, IOIndex, IOSelect, uintptr_t, IOReturn) {} #endif +#endif } // namespace @@ -1023,6 +1032,7 @@ RgfxAccelerator *ReimsGraphics::copyAccelerator() return accelerator; } +#if defined(__x86_64__) IOReturn ReimsGraphics::newUserClient(task_t owningTask, void *securityID, UInt32 type, IOUserClient **clientH) { @@ -1079,6 +1089,7 @@ IOReturn ReimsGraphics::newUserClient(task_t owningTask, void *securityID, UInt3 caller.name, caller.pid, r); return r; } +#endif // IOAcceleratorFamily2's IOAccelMemoryMap::getAssignedGPUVirtualAddressLength() const, // referenced weakly and never called (assignedLengthExported). A binder that cannot resolve it @@ -1266,6 +1277,7 @@ bool ReimsGraphics::start(IOService *provider) } setProperty("IOAccelIndex", 0ull, 32); +#if defined(__x86_64__) // The framebuffer is its own controller's one dependent (index 0), named by its own registry // ID. IOFramebuffer finishes a framebuffer's open (postOpen, in IOGraphics' open source) only // for one with a dependent ID: there it publishes kIOFBNeedsRefreshKey, initialises the @@ -1334,6 +1346,10 @@ bool ReimsGraphics::start(IOService *provider) // accelerated, transactional display model (kIOWindowServerActiveAttribute) off for a name in // which it finds none, as it does for "ReimsGraphics". setProperty("IOClassNameOverride", "ReimsGraphicsAMD"); +#else + if (!startMobile()) + goto fail; +#endif if (super::start(provider)) return true; @@ -1345,6 +1361,9 @@ fail: void ReimsGraphics::stop(IOService *provider) { +#if defined(__arm64e__) + stopMobile(); +#endif quiesce(); super::stop(provider); teardown(); @@ -1455,6 +1474,7 @@ void ReimsGraphics::free() super::free(); } +#if defined(__x86_64__) // MARK: - IOFramebuffer: the device and its modes IOReturn ReimsGraphics::enableController() @@ -2239,6 +2259,7 @@ IOReturn ReimsGraphics::setInterruptState(void *interruptRef, UInt32 state) kickWorkLoop(); return kIOReturnSuccess; } +#endif // MARK: - The display pipe @@ -2424,7 +2445,7 @@ void ReimsGraphics::setPipeVblankEnabled(OSObject *client, bool enabled) kickWorkLoop(); } -#if RGFX_FB_TRACE +#if RGFX_FB_TRACE && defined(__x86_64__) // MARK: - The trace build's forwarding overrides IOReturn ReimsGraphics::open() diff --git a/guest/kext/src/ReimsGraphics.hpp b/guest/kext/src/ReimsGraphics.hpp index 179e2041c..4f800f2f8 100644 --- a/guest/kext/src/ReimsGraphics.hpp +++ b/guest/kext/src/ReimsGraphics.hpp @@ -31,6 +31,9 @@ #include #include #include +#if defined(__arm64e__) +#include "IOMobileFramebufferLegacy.hpp" +#endif #include "RgfxBootConsole.hpp" #include "RgfxDeferredAnswers.hpp" @@ -43,7 +46,15 @@ class RgfxAccelerator; +// The display front end each architecture's WindowServer drives: an IOFramebuffer on x86-64, and +// on arm64, where WindowServer opens no IOFramebuffer, an IOMobileFramebuffer, the subclass of +// IOMobileFramebufferLegacy that Apple's own paravirtual display is (docs/graphics-kext/design.md, +// Decided 13). The device, its rings and its pipe clients are one for both. +#if defined(__x86_64__) class ReimsGraphics : public IOFramebuffer { +#else +class ReimsGraphics : public IOMobileFramebufferLegacy { +#endif OSDeclareDefaultStructors(ReimsGraphics); public: @@ -52,6 +63,7 @@ public: void stop(IOService *provider) override; void free() override; +#if defined(__x86_64__) // IOFramebuffer: the device and its modes IOReturn enableController() override; IODeviceMemory *getApertureRange(IOPixelAperture aperture) override; @@ -140,6 +152,33 @@ public: OSObject *copyProperty(const OSString *aKey) const override; OSObject *copyProperty(const char *aKey) const override; #endif +#else + // IOMobileFramebufferLegacy (ReimsGraphicsMobile.cpp): the class's own pure methods. + RgfxIOMFBWord set_notify_tag_mask_gated(IOMFB_NotificationType type, IOMFBNotifyRequest *request, + uint32_t mask) override; + RgfxIOMFBWord supported_frame_info(uint32_t index, uint32_t *count, char (*names)[64], + uint32_t *field_3) override; + RgfxIOMFBWord factory_portal(void *field_0, task *owner) override; + RgfxIOMFBWord executeFactoryConfigurations_gated() override; + RgfxIOMFBWord set_frame_info_notification_state_gated(IOMFBNotifyRequest *request, + bool on) override; + RgfxIOMFBWord do_swap_info_notify_gated(IOMFBNotifyRequest *request, + const IOMobileFramebufferLegacy::SwapInfoBlob *blob) override; + RgfxIOMFBWord notify_swap_done_gated(uint32_t field_0, ::SwapInfoBlob *blob, uint32_t *field_2, + uint32_t field_3) override; + RgfxIOMFBWord notify_crc_ready_gated(uint32_t field_0) override; + bool are_timings_enabled() const override; + // And what the class implements, which each of these logs and forwards to it: the hardware's + // start and stop, and a swap's steps; a layer's surface map also presents it. + RgfxIOMFBWord start_hardware() override; + RgfxIOMFBWord stop_hardware_gated() override; + RgfxIOMFBWord swap_begin_gated() override; + RgfxIOMFBWord verify_swap(IOMFBSwapIORequest *request) override; + RgfxIOMFBWord swap_layer_map(IOMFBSwapIORequest *request, uint32_t layer) override; + RgfxIOMFBWord surface_layer_map(IOMFB::AP::DisplayedData *data, uint32_t layer, + IOSurface *surface) override; + RgfxIOMFBWord surface_layer_unmap(IOMFB::AP::DisplayedData *data, uint32_t layer) override; +#endif // The display pipe (RgfxDisplayPipeUserClient, on the accelerator) presents through the // framebuffer, which owns the control ring. postPresent puts PRESENT_SURFACE for the @@ -486,6 +525,19 @@ private: UInt64 bootScreenSeqno; bool bootScreenCleared; +#if defined(__arm64e__) + // The arm64e front end's (ReimsGraphicsMobile.cpp): set up in start before the class's own + // start, which it is the pipe client of, and let go in stop. The present of the latest swap's + // surface waits for its answer; the transactions it posts are numbered from 1. + bool startMobile(); + void stopMobile(); + static void mobileVblank(OSObject *client, UInt64 count, UInt64 time, UInt64 next); + static void mobilePresented(OSObject *client, UInt64 seqno, UInt32 status, UInt64 time); + bool mobilePipe; + UInt64 mobilePresentSeqno; + UInt32 mobileTransaction; +#endif + bool ready; // start's and stop's alone: whether start reset the device to take it. Only a device taken is // reset when the kext lets it go; one refused before stays as the firmware left it. diff --git a/guest/kext/src/ReimsGraphicsMobile.cpp b/guest/kext/src/ReimsGraphicsMobile.cpp new file mode 100644 index 000000000..0f363c102 --- /dev/null +++ b/guest/kext/src/ReimsGraphicsMobile.cpp @@ -0,0 +1,252 @@ +/* + * ReimsGraphics' arm64e front end: the IOMobileFramebufferLegacy subclass an arm64 WindowServer + * drives (ReimsGraphics.hpp). The device, its rings, its display and its pipe clients are + * ReimsGraphics.cpp's, as on x86-64; this file is what the class asks of a subclass. + * + * This first cut learns the class's calls: each override logs its calls (the first ones and then + * one in kLogEvery) and forwards to the class where it implements the method. A layer's surface + * map presents the layer-0 surface on the device, and the device's refreshes reach the class as + * its vblank note. The class's own pure methods answer what a display with no frame info, no + * factory configuration and no CRC answers. + */ + +#include "ReimsGraphics.hpp" + +#include + +#if defined(__arm64e__) + +#define super IOMobileFramebufferLegacy + +// An IOReturn as a word: its 32 bits, which a caller of a method returning IOReturn reads. +static constexpr RgfxIOMFBWord word(IOReturn r) +{ + return static_cast(r); +} + +// IOSurface's global ID (IOSurface.kext's exported member, as RgfxIOSurfaceKPI.hpp declares the +// others): the ID PRESENT_SURFACE names a surface by. +extern "C" uint32_t rgfxIOSurfaceSurfaceID(const OSObject *surface) + __asm__("__ZNK9IOSurface12getSurfaceIDEv"); + +namespace { + +// The methods whose calls are logged, each counted apart. +enum MobileCall : unsigned { + kSetNotifyTagMask, + kSupportedFrameInfo, + kFactoryPortal, + kExecuteFactoryConfigurations, + kSetFrameInfoNotificationState, + kDoSwapInfoNotify, + kNotifySwapDone, + kNotifyCrcReady, + kAreTimingsEnabled, + kStartHardware, + kStopHardware, + kSwapBegin, + kVerifySwap, + kSwapLayerMap, + kSurfaceLayerMap, + kSurfaceLayerUnmap, + kVblank, + kPresented, + kMobileCalls, +}; + +constexpr UInt32 kLogFirst = 16; +constexpr UInt32 kLogEvery = 1024; +UInt32 callCounts[kMobileCalls]; + +// Whether this call of `call` is one to log: the first kLogFirst, then one in kLogEvery. +bool logged(MobileCall call) +{ + const UInt32 n = __atomic_fetch_add(&callCounts[call], 1, __ATOMIC_RELAXED); + return n < kLogFirst || n % kLogEvery == 0; +} + +} // namespace + +bool ReimsGraphics::startMobile() +{ + mobilePresentSeqno = 0; + mobileTransaction = 0; + mobilePipe = addPipe(this, mobileVblank, mobilePresented); + if (!mobilePipe) { + IOLog("ReimsGraphics: no pipe for the mobile framebuffer\n"); + return false; + } + setPipeVblankEnabled(this, true); + IOLog("ReimsGraphics: mobile framebuffer, display %u\n", displayId); + return true; +} + +void ReimsGraphics::stopMobile() +{ + if (mobilePipe) + removePipe(this); + mobilePipe = false; +} + +void ReimsGraphics::mobileVblank(OSObject *client, UInt64 count, UInt64 time, UInt64 next) +{ + ReimsGraphics *self = static_cast(client); + if (logged(kVblank)) + IOLog("ReimsGraphics: vblank %llu at %llu, next %llu\n", count, time, next); + self->note_vbl_ISR(static_cast(count)); +} + +void ReimsGraphics::mobilePresented(OSObject *client, UInt64 seqno, UInt32 status, UInt64 time) +{ + ReimsGraphics *self = static_cast(client); + if (seqno != __atomic_load_n(&self->mobilePresentSeqno, __ATOMIC_ACQUIRE)) + return; + if (logged(kPresented)) + IOLog("ReimsGraphics: present %llu shown, status %u at %llu\n", seqno, status, time); +} + +// MARK: - The class's own pure methods + +RgfxIOMFBWord ReimsGraphics::set_notify_tag_mask_gated(IOMFB_NotificationType type, + IOMFBNotifyRequest *request, uint32_t mask) +{ + if (logged(kSetNotifyTagMask)) + IOLog("ReimsGraphics: set_notify_tag_mask_gated(%u, %p, 0x%x)\n", + static_cast(type), request, mask); + return word(kIOReturnSuccess); +} + +RgfxIOMFBWord ReimsGraphics::supported_frame_info(uint32_t index, uint32_t *count, char (*names)[64], + uint32_t *field_3) +{ + if (logged(kSupportedFrameInfo)) + IOLog("ReimsGraphics: supported_frame_info(%u, %p, %p, %p)\n", index, count, names, + field_3); + return word(kIOReturnUnsupported); +} + +RgfxIOMFBWord ReimsGraphics::factory_portal(void *field_0, task *owner) +{ + if (logged(kFactoryPortal)) + IOLog("ReimsGraphics: factory_portal(%p, %p)\n", field_0, owner); + return word(kIOReturnUnsupported); +} + +RgfxIOMFBWord ReimsGraphics::executeFactoryConfigurations_gated() +{ + if (logged(kExecuteFactoryConfigurations)) + IOLog("ReimsGraphics: executeFactoryConfigurations_gated()\n"); + return word(kIOReturnSuccess); +} + +RgfxIOMFBWord ReimsGraphics::set_frame_info_notification_state_gated(IOMFBNotifyRequest *request, + bool on) +{ + if (logged(kSetFrameInfoNotificationState)) + IOLog("ReimsGraphics: set_frame_info_notification_state_gated(%p, %d)\n", request, on); + return word(kIOReturnSuccess); +} + +RgfxIOMFBWord ReimsGraphics::do_swap_info_notify_gated(IOMFBNotifyRequest *request, + const IOMobileFramebufferLegacy::SwapInfoBlob *blob) +{ + if (logged(kDoSwapInfoNotify)) + IOLog("ReimsGraphics: do_swap_info_notify_gated(%p, %p)\n", request, blob); + return word(kIOReturnSuccess); +} + +RgfxIOMFBWord ReimsGraphics::notify_swap_done_gated(uint32_t field_0, ::SwapInfoBlob *blob, + uint32_t *field_2, uint32_t field_3) +{ + if (logged(kNotifySwapDone)) + IOLog("ReimsGraphics: notify_swap_done_gated(%u, %p, %p, %u)\n", field_0, blob, field_2, + field_3); + return word(kIOReturnSuccess); +} + +RgfxIOMFBWord ReimsGraphics::notify_crc_ready_gated(uint32_t field_0) +{ + if (logged(kNotifyCrcReady)) + IOLog("ReimsGraphics: notify_crc_ready_gated(%u)\n", field_0); + return word(kIOReturnSuccess); +} + +bool ReimsGraphics::are_timings_enabled() const +{ + if (logged(kAreTimingsEnabled)) + IOLog("ReimsGraphics: are_timings_enabled()\n"); + return true; +} + +// MARK: - What the class implements, logged and forwarded + +RgfxIOMFBWord ReimsGraphics::start_hardware() +{ + const RgfxIOMFBWord r = super::start_hardware(); + if (logged(kStartHardware)) + IOLog("ReimsGraphics: start_hardware() = 0x%llx\n", r); + return r; +} + +RgfxIOMFBWord ReimsGraphics::stop_hardware_gated() +{ + const RgfxIOMFBWord r = super::stop_hardware_gated(); + if (logged(kStopHardware)) + IOLog("ReimsGraphics: stop_hardware_gated() = 0x%llx\n", r); + return r; +} + +RgfxIOMFBWord ReimsGraphics::swap_begin_gated() +{ + const RgfxIOMFBWord r = super::swap_begin_gated(); + if (logged(kSwapBegin)) + IOLog("ReimsGraphics: swap_begin_gated() = 0x%llx\n", r); + return r; +} + +RgfxIOMFBWord ReimsGraphics::verify_swap(IOMFBSwapIORequest *request) +{ + const RgfxIOMFBWord r = super::verify_swap(request); + if (logged(kVerifySwap)) + IOLog("ReimsGraphics: verify_swap(%p) = 0x%llx\n", request, r); + return r; +} + +RgfxIOMFBWord ReimsGraphics::swap_layer_map(IOMFBSwapIORequest *request, uint32_t layer) +{ + const RgfxIOMFBWord r = super::swap_layer_map(request, layer); + if (logged(kSwapLayerMap)) + IOLog("ReimsGraphics: swap_layer_map(%p, %u) = 0x%llx\n", request, layer, r); + return r; +} + +RgfxIOMFBWord ReimsGraphics::surface_layer_map(IOMFB::AP::DisplayedData *data, uint32_t layer, + IOSurface *surface) +{ + const RgfxIOMFBWord r = super::surface_layer_map(data, layer, surface); + const uint32_t id = + surface ? rgfxIOSurfaceSurfaceID(reinterpret_cast(surface)) : 0; + IOReturn presented = kIOReturnNotReady; + UInt64 seqno = 0; + if (layer == 0 && id) { + const UInt32 transaction = ++mobileTransaction; + presented = postPresent(id, transaction, 0, &seqno); + if (presented == kIOReturnSuccess) + __atomic_store_n(&mobilePresentSeqno, seqno, __ATOMIC_RELEASE); + } + if (logged(kSurfaceLayerMap)) + IOLog("ReimsGraphics: surface_layer_map(%p, %u, %p: surface %u) = 0x%llx, present 0x%x " + "seqno %llu\n", + data, layer, surface, id, r, presented, seqno); + return r; +} + +RgfxIOMFBWord ReimsGraphics::surface_layer_unmap(IOMFB::AP::DisplayedData *data, uint32_t layer) +{ + const RgfxIOMFBWord r = super::surface_layer_unmap(data, layer); + if (logged(kSurfaceLayerUnmap)) + IOLog("ReimsGraphics: surface_layer_unmap(%p, %u) = 0x%llx\n", data, layer, r); + return r; +} + +#endif // __arm64e__ diff --git a/guest/kext/src/graft-arm64e.json b/guest/kext/src/graft-arm64e.json index 92f83910b..cc4529a28 100644 --- a/guest/kext/src/graft-arm64e.json +++ b/guest/kext/src/graft-arm64e.json @@ -2,13 +2,16 @@ "libraries": [ { "id": "com.apple.iokit.IOGraphicsFamily" + }, + { + "id": "com.apple.iokit.IOMobileGraphicsFamily" } ], "classes": [ { - "name": "IOFramebuffer", - "header": "IOKit/graphics/IOFramebuffer.h", - "library": 0 + "name": "IOMobileFramebufferLegacy", + "header": "IOMobileFramebufferLegacy.hpp", + "library": 1 }, { "name": "IOAccelerator", diff --git a/guest/prebuilt-arm64e/ReimsGraphics.kext/Contents/Info.plist b/guest/prebuilt-arm64e/ReimsGraphics.kext/Contents/Info.plist index 95a7b3dfc..17c32b4f3 100644 --- a/guest/prebuilt-arm64e/ReimsGraphics.kext/Contents/Info.plist +++ b/guest/prebuilt-arm64e/ReimsGraphics.kext/Contents/Info.plist @@ -92,7 +92,7 @@ LSMinimumSystemVersion - 26.0 + 13.0 OSBundleLibraries com.apple.iokit.IOPCIFamily diff --git a/guest/prebuilt-arm64e/ReimsGraphics.kext/Contents/MacOS/ReimsGraphics b/guest/prebuilt-arm64e/ReimsGraphics.kext/Contents/MacOS/ReimsGraphics index 1b0108d45..89a09652e 100755 Binary files a/guest/prebuilt-arm64e/ReimsGraphics.kext/Contents/MacOS/ReimsGraphics and b/guest/prebuilt-arm64e/ReimsGraphics.kext/Contents/MacOS/ReimsGraphics differ diff --git a/guest/prebuilt-arm64e/set.toml b/guest/prebuilt-arm64e/set.toml index 665e5de60..219f5294a 100644 --- a/guest/prebuilt-arm64e/set.toml +++ b/guest/prebuilt-arm64e/set.toml @@ -14,7 +14,7 @@ Arch = "arm64e" MinKernel = "22.0.0" MaxKernel = "" Comment = "The reims-graphics display and accelerator" -sha256 = "5d2420dea52a69b54323bde47f015934b5243c03f53576ae6056918009c40077" +sha256 = "0b34379dc1aa8eaf252752da4c498e92deea9a16a59022636eb4c48bf8fd0c01" [[kext]] BundlePath = "RgfxGate.kext" diff --git a/guest/prebuilt-arm64e/sources.toml b/guest/prebuilt-arm64e/sources.toml index fdfd28481..9d6820f43 100644 --- a/guest/prebuilt-arm64e/sources.toml +++ b/guest/prebuilt-arm64e/sources.toml @@ -160,12 +160,14 @@ clang = "Apple clang version 21.0.0 (clang-2100.4.1.1)" "guest/graft/sdk/include/graft/Graft.h" = "a248d23e0b169fb602d5a1ceb9b66cc3f586feb65cb7d053364e8a4c43370072" "guest/graft/sdk/prelink.py" = "ee7970ffdee693dddfa565188cbed157f5095a5225461e98d6a722409b0e4ec8" "guest/graft/source.toml" = "d29abe6f2655616832f3f3221f37ff47e8c6d0202931141d5b0ab19129cd2324" -"guest/kext/Makefile" = "7041fd4c8d9f1504acc75190206abfbb826c856fde5b247f449f8a319d65b174" +"guest/kext/Makefile" = "4fafe79fd6944a7157e954724711318d6c4a2b5c2bc907deedc0e0a70781482d" "guest/kext/src/AppleGraphicsDeviceControl.hpp" = "2662c190f4d129534ad179fab8484265e0ff9eb46ea80826d0b03a9feb92b6a0" -"guest/kext/src/Info-arm64e.plist" = "3fdb2268d1b93f5e1c1e6628b9f9bf41b6bcd27df525b47ae242b69ba8c00b34" +"guest/kext/src/IOMobileFramebufferLegacy.hpp" = "1b3918ac1cf74de81aa91354f386c87a47dffd099085470d8d9a3becd2853a84" +"guest/kext/src/Info-arm64e.plist" = "29f80ff246dfd625f284c613486917fb1032cb146b1efd8ceaba0e75b1c006ab" "guest/kext/src/Info.plist" = "d8ef8f0e864142760e434a4864acaa485e8bd54b690b702f4a758239acba73f6" -"guest/kext/src/ReimsGraphics.cpp" = "ea1bed711f9e987177f5582d31a80d7532f782cfea1cb3595cc03217b01d6c07" -"guest/kext/src/ReimsGraphics.hpp" = "5bd647a93d5497dfc92082dac6182327f1df980189d26403e6102c052aabbfc8" +"guest/kext/src/ReimsGraphics.cpp" = "e6b6ef9a480325e83310d93b9b796c56722a8911284a414182ca76872c2a3e6a" +"guest/kext/src/ReimsGraphics.hpp" = "e3bae863e7dd6622996e86b75644d9025d9590c893a21f13ab304f9b5122728a" +"guest/kext/src/ReimsGraphicsMobile.cpp" = "ed472c3e77d3f0904492ab391b6fd9ecdcfbdb583ddf3bba5cec72f1b830de1a" "guest/kext/src/RgfxAccelTypes.hpp" = "bcd9e26ccd43e01ec765f91ce4096ba505bfc8848c75d515b923bc31324abf61" "guest/kext/src/RgfxAccelerator.cpp" = "78b4d44dfd82adfc4bc4166b8312c229d2ef84d0eb99b087c4d9a4f984dc9d58" "guest/kext/src/RgfxAccelerator.hpp" = "928cd8f56ae1f7882b0c1055b9b7812ac06f0d5e5f1387f90bcad250d70a3282" @@ -227,7 +229,7 @@ clang = "Apple clang version 21.0.0 (clang-2100.4.1.1)" "guest/kext/src/RgfxVblankClock.hpp" = "9ce05fe76a6a8f303d8ac65fcd706d0769ccb7317be5beb8ad512243c5942ef9" "guest/kext/src/RgfxVideoCodecs.hpp" = "cf0a0c0de325b9219b1e5b4a4e5365b6ba1c56fd910ed0be0d66a1ade3d0976f" "guest/kext/src/RgfxWindowSpans.hpp" = "503f4f483e4ac21a2ba3e4dd37c4a66e292e2edef84464374928dd1c30f81081" -"guest/kext/src/graft-arm64e.json" = "c051f4b0153431fc22939db20855e2b788df7e7e2d7475394865b06ac8ea56b3" +"guest/kext/src/graft-arm64e.json" = "85e1520c7952418a5a6d73c87829fc0ffef4a312d6d1f90a48f122f02394720b" "guest/kext/src/graft.json" = "a8109824e7f8c0783fdae98ecfcf203dcc984df2a6ee67b507f0269745040201" "guest/kext/src/kmod_info.c" = "38903062e4069fc7e15b9378f5d5fe66bb514d78a833dc298f20274bdeb2fb9e" "guest/rgfxgate/Info.plist" = "79b9fc0db6807b826ff852b59183eccd4ad85187366d878d196ee4395a0e51b8" @@ -248,8 +250,8 @@ clang = "Apple clang version 21.0.0 (clang-2100.4.1.1)" "guest/tools/prebuilt.py" = "cbb3272d7c953a626c484675abcef11727ad33aa728654b0dc46c39f8e5eac75" [outputs] -"ReimsGraphics.kext/Contents/Info.plist" = "164fb78088ea6608528e77d4e19913e3006befd242ad650e74abaadf07605b0a" -"ReimsGraphics.kext/Contents/MacOS/ReimsGraphics" = "5d2420dea52a69b54323bde47f015934b5243c03f53576ae6056918009c40077" +"ReimsGraphics.kext/Contents/Info.plist" = "c2305135457c93649b4e279fcf36b52435876108f891b9babc2b815e211cb409" +"ReimsGraphics.kext/Contents/MacOS/ReimsGraphics" = "0b34379dc1aa8eaf252752da4c498e92deea9a16a59022636eb4c48bf8fd0c01" "RgfxGate.kext/Contents/Info.plist" = "53be328f3be21a97f034d01a0a1c284d3c7ddcf56375f34e06aad26072f18ef4" "RgfxGate.kext/Contents/MacOS/RgfxGate" = "f34d5a2d2d42ec72cafa35739fe9e9c87d1e36c92128ca31590d5132b1c3f700" -"set.toml" = "44c961cd4d4e7ea9f86a824fccbac66030437c963b73d8b9656d2e8e1bb22689" +"set.toml" = "05da379c6ce36b227028e3db8fbe70063230682851802f82fdcb83c85e829721" diff --git a/guest/prebuilt/sources.toml b/guest/prebuilt/sources.toml index a1a276664..a1026cefe 100644 --- a/guest/prebuilt/sources.toml +++ b/guest/prebuilt/sources.toml @@ -160,12 +160,14 @@ clang = "Apple clang version 21.0.0 (clang-2100.4.1.1)" "guest/graft/sdk/include/graft/Graft.h" = "a248d23e0b169fb602d5a1ceb9b66cc3f586feb65cb7d053364e8a4c43370072" "guest/graft/sdk/prelink.py" = "ee7970ffdee693dddfa565188cbed157f5095a5225461e98d6a722409b0e4ec8" "guest/graft/source.toml" = "d29abe6f2655616832f3f3221f37ff47e8c6d0202931141d5b0ab19129cd2324" -"guest/kext/Makefile" = "7041fd4c8d9f1504acc75190206abfbb826c856fde5b247f449f8a319d65b174" +"guest/kext/Makefile" = "4fafe79fd6944a7157e954724711318d6c4a2b5c2bc907deedc0e0a70781482d" "guest/kext/src/AppleGraphicsDeviceControl.hpp" = "2662c190f4d129534ad179fab8484265e0ff9eb46ea80826d0b03a9feb92b6a0" -"guest/kext/src/Info-arm64e.plist" = "3fdb2268d1b93f5e1c1e6628b9f9bf41b6bcd27df525b47ae242b69ba8c00b34" +"guest/kext/src/IOMobileFramebufferLegacy.hpp" = "1b3918ac1cf74de81aa91354f386c87a47dffd099085470d8d9a3becd2853a84" +"guest/kext/src/Info-arm64e.plist" = "29f80ff246dfd625f284c613486917fb1032cb146b1efd8ceaba0e75b1c006ab" "guest/kext/src/Info.plist" = "d8ef8f0e864142760e434a4864acaa485e8bd54b690b702f4a758239acba73f6" -"guest/kext/src/ReimsGraphics.cpp" = "ea1bed711f9e987177f5582d31a80d7532f782cfea1cb3595cc03217b01d6c07" -"guest/kext/src/ReimsGraphics.hpp" = "5bd647a93d5497dfc92082dac6182327f1df980189d26403e6102c052aabbfc8" +"guest/kext/src/ReimsGraphics.cpp" = "e6b6ef9a480325e83310d93b9b796c56722a8911284a414182ca76872c2a3e6a" +"guest/kext/src/ReimsGraphics.hpp" = "e3bae863e7dd6622996e86b75644d9025d9590c893a21f13ab304f9b5122728a" +"guest/kext/src/ReimsGraphicsMobile.cpp" = "ed472c3e77d3f0904492ab391b6fd9ecdcfbdb583ddf3bba5cec72f1b830de1a" "guest/kext/src/RgfxAccelTypes.hpp" = "bcd9e26ccd43e01ec765f91ce4096ba505bfc8848c75d515b923bc31324abf61" "guest/kext/src/RgfxAccelerator.cpp" = "78b4d44dfd82adfc4bc4166b8312c229d2ef84d0eb99b087c4d9a4f984dc9d58" "guest/kext/src/RgfxAccelerator.hpp" = "928cd8f56ae1f7882b0c1055b9b7812ac06f0d5e5f1387f90bcad250d70a3282" @@ -227,7 +229,7 @@ clang = "Apple clang version 21.0.0 (clang-2100.4.1.1)" "guest/kext/src/RgfxVblankClock.hpp" = "9ce05fe76a6a8f303d8ac65fcd706d0769ccb7317be5beb8ad512243c5942ef9" "guest/kext/src/RgfxVideoCodecs.hpp" = "cf0a0c0de325b9219b1e5b4a4e5365b6ba1c56fd910ed0be0d66a1ade3d0976f" "guest/kext/src/RgfxWindowSpans.hpp" = "503f4f483e4ac21a2ba3e4dd37c4a66e292e2edef84464374928dd1c30f81081" -"guest/kext/src/graft-arm64e.json" = "c051f4b0153431fc22939db20855e2b788df7e7e2d7475394865b06ac8ea56b3" +"guest/kext/src/graft-arm64e.json" = "85e1520c7952418a5a6d73c87829fc0ffef4a312d6d1f90a48f122f02394720b" "guest/kext/src/graft.json" = "a8109824e7f8c0783fdae98ecfcf203dcc984df2a6ee67b507f0269745040201" "guest/kext/src/kmod_info.c" = "38903062e4069fc7e15b9378f5d5fe66bb514d78a833dc298f20274bdeb2fb9e" "guest/rgfxgate/Info.plist" = "79b9fc0db6807b826ff852b59183eccd4ad85187366d878d196ee4395a0e51b8"