[CDG5] NanoKernel
Elliot Nunn
elliotnunn at fastmail.com
Mon Oct 21 12:50:18 AWST 2019
ThePluginDispatchTable is a semi-standardised export for several types of
fragment that expect to be called by other fragments. Essentially it is a
struct with a 16-byte header followed by a variable number of function pointers.
The struct is versioned, but the Monster Disk Driver Technote makes clear that
this version does not reliably indicate the contents. So I have coded cfmtool.py
to take a good guess, and write this out to codelocs-disptable.txt
The ATA interface (for ndrv frags with service type 'ata-') is documented in the
Monster TN. Here is the dump of the Kauai ATA parcel (the only extant version):
[
{'section': 'code', 'offset': 0x00754, 'function': 'ATAPluginInit'},
{'section': 'code', 'offset': 0x00f4c, 'function': 'ATAPluginClose'},
{'section': 'code', 'offset': 0x02784, 'function': 'ATAPluginAction'},
{'section': 'code', 'offset': 0x027d4, 'function': 'ATAPluginDeviceLock'},
{'section': 'code', 'offset': 0x0287c, 'function': 'ATAPluginSuspend'},
{'section': 'code', 'offset': 0x02928, 'function': 'ATAPluginResume'},
{'section': 'code', 'offset': 0x04860, 'function': 'ATAPluginPoll'},
{'section': 'code', 'offset': 0x04988, 'function': 'ATAPluginHandleBusEvent'},
]
The PowerMgrPlugin interface is exported by all of the "via" parcels and
imported by the NativePowerMgrLib. Thankfully I was able to guess names for all
but three of the struct members, by cross-referencing with MacsBug symbols left
in later builds of the via drivers. Here is the dump of the via-pmu2000 parcel
in the 10.2.1 ROM:
[
{'section': 'code', 'offset': 0x00560, 'function': 'PMPluginCallPMU'},
{'section': 'code', 'offset': 0x0076c, 'function': 'PMPluginPrimaryInit'},
{'section': 'code', 'offset': 0x01224, 'function': 'PMPluginSecondaryInit'},
{'section': 'code', 'offset': 0x014b4, 'function': 'PMPluginConfigForHardware'},
{'section': 'code', 'offset': 0x014e0, 'function': 'PMPluginDriverReplacement'},
{'section': 'code', 'offset': 0x0150c, 'function': 'PMPluginFinalize'},
{'section': 'code', 'offset': 0x01640, 'function': 'PMPluginPowerOff'},
{'section': 'code', 'offset': 0x019b0, 'function': 'PMPluginRestart'},
{'section': 'code', 'offset': 0x01b48, 'function': 'PMPluginDoze'},
{'section': 'code', 'offset': 0x01bb0, 'function': 'PMPluginWakeFromDoze'},
{'section': 'code', 'offset': 0x01d1c, 'function': 'PMPluginEnterIdle2'},
{'section': 'code', 'offset': 0x01dc0, 'function': 'PMPluginHandleIdle2'},
{'section': 'code', 'offset': 0x01e2c, 'function': 'PMPluginExitIdle2'},
{'section': 'code', 'offset': 0x01fc4, 'function': 'PMPluginEnableWakeUpEvents'},
{'section': 'code', 'offset': 0x023bc, 'function': 'PMPluginSleep'},
{'section': 'code', 'offset': 0x02744, 'function': 'PMPluginWake'},
{'section': 'code', 'offset': 0x02f6c, 'function': 'PMPluginSuspendResumeHW'},
{'section': 'code', 'offset': 0x03050, 'function': 'PMPluginGetStartupTimer'},
{'section': 'code', 'offset': 0x030e0, 'function': 'PMPluginSetStartupTimer'},
{'section': 'code', 'offset': 0x031c0, 'function': 'PMPluginGetWakeTimer'},
{'section': 'code', 'offset': 0x03238, 'function': 'PMPluginSetWakeTimer'},
{'section': 'code', 'offset': 0x032f4, 'function': 'PMPluginGetFirstPowerSource'},
{'section': 'code', 'offset': 0x0332c, 'function': 'PMPluginGetNextPowerSource'},
{'section': 'code', 'offset': 0x03368, 'function': 'PMPluginGetProcessorSpeed'},
{'section': 'code', 'offset': 0x03408, 'function': 'PMPluginSetProcessorSpeed'},
{'section': 'code', 'offset': 0x034dc, 'function': 'PMPluginGetMaxProcessorSpeed'},
{'section': 'code', 'offset': 0x03528, 'function': 'PMPluginGetMinProcessorSpeed'},
{'section': 'code', 'offset': 0x03574, 'function': 'PMPluginSetMaxProcessorSpeed'},
{'section': 'code', 'offset': 0x035c4, 'function': 'PMPluginIsClamshellClosed'},
{'section': 'code', 'offset': 0x037d4, 'function': 'PMPluginOverrideClamshellClosedBehavior'},
{'section': 'code', 'offset': 0x03890, 'function': 'PMPluginDoClamshellClosedChores'},
{'section': 'code', 'offset': 0x03940, 'function': 'PMPluginGetSleepActionBits'},
{'section': 'code', 'offset': 0x03980, 'function': 'PMPluginGetWakeInfo'},
{'section': 'code', 'offset': 0x039d8, 'function': 'PMPluginGetPrimInfoEntry'},
{'section': 'code', 'offset': 0x03ae8, 'function': 'PMPluginRegisterInterruptCallback'},
{'section': 'code', 'offset': 0x03b58, 'function': 'PMPluginEnteredADBHandler'},
{'section': 'code', 'offset': 0x03b88, 'function': 'PMPluginEnablePowerUpEvents'},
{'section': 'code', 'offset': 0x03c1c, 'function': 'PMPluginArePowerUpEventsEnabled'},
{'section': 'code', 'offset': 0x03ccc, 'function': 'PMPluginAreWakeUpEventsEnabled'},
{'section': 'code', 'offset': 0x03d7c, 'function': 'PMPluginSetWakeOnNetActOptions'},
{'section': 'code', 'offset': 0x03db4, 'function': 'PMPluginGetWakeOnNetActOptions'},
{'section': 'code', 'offset': 0x03dec, 'function': 'PMPluginGetIntModemInfo'},
{'section': 'code', 'offset': 0x03e88, 'function': 'PMPluginSetIntModemState'},
{'section': 'code', 'offset': 0x03f0c, 'function': 'PMPluginResetModemLow'},
{'section': 'code', 'offset': 0x03f70, 'function': 'PMPluginResetModemHigh'},
{'section': 'code', 'offset': 0x03fd4, 'function': 'PMPluginPowerOnModem'},
{'section': 'code', 'offset': 0x04034, 'function': 'PMPluginPowerOffModem'},
{'section': 'code', 'offset': 0x04098, 'function': 'PMPluginSystemReady'},
{'section': 'code', 'offset': 0x04664, 'function': 'PMPluginEnableThermalMgt'},
{'section': 'code', 'offset': 0x049d0, 'function': 'PMPluginThermalEvent'},
{'section': 'code', 'offset': 0x04b10, 'function': 'PMPluginGetThermalLevel'},
{'section': 'code', 'offset': 0x04b44, 'function': 'PMPluginNumFans'},
{'section': 'code', 'offset': 0x04b70, 'function': 'PMPluginFanControl'},
{'section': 'code', 'offset': 0x04b9c, 'function': 'PMPluginNumThermostats'},
{'section': 'code', 'offset': 0x04bd0, 'function': 'PMPluginThermostatControl'},
{'section': 'code', 'offset': 0x04c80, 'function': 'PMPluginReadThermostat'},
{'section': 'code', 'offset': 0x04d38, 'function': 'PMPluginGetRangeForLevel'},
{'section': 'code', 'offset': 0x05734, 'function': 'PMPluginActivateClock'},
{'section': 'code', 'offset': 0x06048, 'function': 'PMPluginDeactivateClock'},
{'section': 'code', 'offset': 0x062b0, 'function': 'PMPluginDeactivateCurrentClock'},
{'section': 'code', 'offset': 0x06334, 'function': 'PMPluginGetCurrentClockID'},
{'section': 'code', 'offset': 0x0aac4, 'function': 'PMPluginEnqueueWakeHandler'},
{'section': 'code', 'offset': 0x0abb4, 'function': 'PMPluginDequeueWakeHandler'},
{'section': 'code', 'offset': 0x0d18c, 'function': 'PMPluginCheckForForcedReducedSpeed'},
]
Several other fragment types export such a table, and there are also tables
named TheAppleStorageClassDispatchTable, TheClassDriverPluginDispatchTable and
TheHIDModuleDispatchTable lying around. If anyone figures them out we can add
them to cfmtool.py
> On 3 Dec 2018, at 10:50 am, Daniel B-J <danielbj314 at verizon.net> wrote:
>
>> Well, the Trampoline will replace OF RTAS with the following three libraries: RTCServicesLib, NVRAMServicesLib and PowerMgrPlugin. These are called "RTAS replacement plug-ins." I think these libraries provide the desired HW abstraction as required by the NK
>
> Here are the partial disassemblies of RTCServicesLib and NVRAMServicesLib. It's interesting that they both contain the string "ThePluginDispatchTable", which is exported by a few parcel PEFs. Some undocumented plugin interface?
>
> Just for fun, here is dePEF, my MPW tool to disassemble PEFs. Sadly, it's output is not build-able (it does not place csects yet) and it only disassembles PEFs which are at the start of a data fork. It will likely take a few more months of procrastination before it actually is considered adequate by my standards.
> <NV and RTC.sit><dePEF.sit>_______________________________________________
> cdg5 mailing list
> cdg5 at ucc.asn.au
> https://lists.ucc.gu.uwa.edu.au/mailman/listinfo/cdg5
More information about the cdg5
mailing list