5.9.3. Obtaining the SCADI interface

You can obtain the SCADI interface from the same CAInterface pointers that are used to obtain the CADI and the MTI interfaces. This is done using the CAInterface::ObtainInterface() method. The interface names for the normal CADI and MTI interfaces are CADI::IFNAME() and ComponentTraceInterface::IFNAME() respectively.

The interface name for the SCADI interface to be passed into ObtainInterface() is “eslapi.SCADI2”, the interface revision is 0. There are no IFNAME() and IFREVISION() static functions defined for SCADI, and a plain string constant and integer constant (0) has to be used instead.

The pointer returned by CAInterface::ObtainInterface("eslapi.SCADI2") must be cast into an eslapi::CADI class pointer, that is, the same class as for eslapi.CADI2, the normal CADI interface class.

Access to SCADI from within LISA components

To get access to the SCADI interface of the LISA component itself you can use the getSCADI() function. This returns the SCADI interface of the LISA component itself. To get access to the SCADI interfaces of other components in the system, you can use the getGlobalInterface() function. This returns a CAInteraface pointer. You then have to use the ObtainInterface() function on that pointer to obtain the SystemTraceInterface. This interface provides a list of all components in the system which provide trace data. This list can also be used to gain access to the SCADI interfaces of all these components. See Example code.

Access to SCADI from within System C

Access to the SCADI interfaces from within a System C system work similar to the LISA components: The generated System C platform (the generated System C wrapper around the Fast Model subsystem) provides a getGlobalInterface() function which returns a CAInterface pointer. This can be used to retrieve the SCADI interfaces in the same way as in the LISA case. See Example code.

Access to SCADI from MTI plugins

MTI plugins can gain access to SCADI interfaces by using the CAInterface pointer, which is passed as a parameter to the RegisterSimulation() function. This pointer has the same semantics as the CAInterface pointer returned by the getGlobalInterface() functions in the System C or LISA use cases.

Example code

This example code demonstrates how to use getGlobalInterface() to retrieve a SCADI interface pointer of a specific component. From LISA it is getGlobalInterface(), from within System C it is assumed that you have a pointer to the Fast Models platform called platform. From within a MTI plug-in you do not have to call getGlobalInterface(), and you can use the CAInterface pointer passed to RegisterSimulation().

Example 5.1. Retrieving a SCADI interface pointer of a specific component

#include "sg/SGComponentRegistry.h"
eslapi::CADI *Peripheral::get_SCADI_interface(const char *instanceName)
{
  // get access to MTI interface (SystemTraceInterface)
  // - this code is for a System C peripheral which has access to the generated Fast
  //   Models 'platform'
  // - for LISA this would be just 'getGlobalInterface()'
  // - for MTI plugins this would be just using the CAInterface *caif pointer passed
  //   into RegisterSimulation()
  eslapi::CAInterface *globalInterface = platform->getGlobalInterface();
  const char *errorMessage = "(no error)";

  MTI::SystemTraceInterface *mti = 0;
  if (globalInterface)
     mti = sg::obtainComponentInterfacePointer<MTI::SystemTraceInterface>
                                        (globalInterface, 
                                        "mtiRegistry", 
                                        &errorMessage);
  if (mti == 0)
  {
     printf("ERROR:MTI interface not found! (%s)\n", errorMessage);
     return 0;
  }

  // find component with instanceName
  eslapi::CAInterface *compif = 0;
  for (MTI::SystemTraceInterface::TraceComponentIndex i = 0; 
      i < mti->GetNumOfTraceComponents(); 
      i++)
  {
      const char *name = mti->GetComponentTracePath(i);
      if (verbose)
         printf("TEST MTI component '%s'\n", name);
      if (strcmp(name, instanceName) == 0)
         compif = mti->GetComponentTrace(i);
  }
  if (!compif)
  {
      printf("ERROR:instance '%s' not found while trying to get SCADI! \n",
              instanceName);
      return 0;
  }

  // get and return SCADI interface
  return static_cast<eslapi::CADI *>(compif->ObtainInterface("eslapi.SCADI2", 0, 0));
}

Copyright © 2008-2013 ARM. All rights reserved.ARM DUI 0423O
Non-ConfidentialID060613