Please consider a donation to the Higher Intellect project. See https://preterhuman.net/donate.php or the Donate to Higher Intellect page for more info.

Mixed Mode Manager

From Higher Intellect Vintage Wiki
Jump to navigation Jump to search

The Mixed Mode Manager is essentially a “black box” interface that allows routines with different calling conventions to exchange parameter information. The routines may reflect different architectures, different hardware, or both, but the basic treatment is the same.

In addition to routine parameter information, the Mixed Mode Manager requires the following information to make a mode switch:

  • the calling conventions of the routine making the call
  • a translation key that tells the Mixed Mode Manager how to manipulate the parameters to meet the calling conventions of the routine being called

Currently the Mixed Mode Manager handles calls between CFM-based architecture code and classic 68K architecture code.

The Mixed Mode Manager has two rules for the code that it handles:

  1. The older classic 68K code does not need to be aware of the Mixed Mode Manager and no modification is required for mode switching.
  2. The newer CFM-based code must be aware of the Mixed Mode Manager and take the steps necessary to invoke it if there is the possibility of a mode switch. Typically a mode switch can occur when a routine calls code not stored directly in the application or software (for example when loading and executing code stored in a resource).

Given these assumptions, if there is the possibility of a mode switch, there are four different types of calls that can be made:

  • A CFM-based routine calls a classic 68K routine.
  • A CFM-based routine calls a CFM-based routine.
  • A classic 68K routine calls a CFM-based routine.
  • A classic 68K routine calls a classic 68K routine.

How the call is handled depends on the type of code that originates the call:

1. A CFM-based routine originates the call.

Rule 2 requires the calling CFM-based routine to invoke the Mixed Mode Manager if there is a possibility of a mode switch.

If the Mixed Mode Manager discovers that the called routine is classic 68K, a mode switch is required. The Mixed Mode Manager should make the switch and then execute the call. Any return values are passed back to the calling routine.

If the Mixed Mode Manager discovers that the called routine is CFM-based, no mode switch is necessary. The Mixed Mode Manager should allow the call to be made normally.

Note that you need to call the Mixed Mode Manager only if the calling conventions of the called routine are unknown. If you know that both the calling routine and the called routine are CFM-based (when making routine calls within an application, for example), you do not have to call the Mixed Mode Manager.

2. A classic 68K routine originates the call.

Rule 1 requires that a classic 68K routine need no knowledge of the Mixed Mode Manager.

If the called routine is CFM-based, the supplier of the CFM-based routine must make sure the Mixed Mode Manager is invoked. The Mixed Mode Manager can then make the mode switch, execute the call, and pass back any return values.

If the called routine is a classic 68K routine, neither the calling routine or the called routine invokes the Mixed Mode Manager. The call proceeds normally.

IMPORTANT: The Mixed Mode Manager knows the size of the parameters it translates but not their type, so it cannot handle floating point parameters. If you need to pass floating-point values in a possible Mixed Mode call, you should pass pointers to the values instead.

See Also