Works on at least my 2010 iMac. Display autodetection does not work, so you have to reboot the device for it to properly detect connected displays.
This is a tiny (<5KB) EFI executable that pokes at the Apple System Management Controller to enable Target Display Mode. This can be placed on a USB flash drive or on the hard drive and will work regardless of what version of macOS is on the iMac (although since Target Display Mode is an opaque hardware feature, the usual disclaimers apply to computers connected to the iMac)
You need Clang and lld-link, once you have those just type make.
- Don't pin a CPU core while Boot2Target is running
Display auto-detectionkinda, we can now hotplug the display connector but we can't return to EFI- Possibly put the iMac CPU to sleep to minimize heat output (not sure if this is possible, I'd have to experiment in Linux)
- EFI headers from EDK2
- Apple SMC protocol headers from OpenCore
- Target Display reverse engineering based on this blog post from Florian Echtler