1.9.4 SCADI interface access

This section describes the CAInterface::ObtainInterface() method and how to use it.

About SCADI interface access

You can obtain the SCADI interface from the same CAInterface pointers that provide 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 pass 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 access the SCADI interface of the LISA component itself, use the getSCADI() function. This returns the SCADI interface of the LISA component itself.

To access the SCADI interfaces of other components in the system, use the getGlobalInterface() function. This returns a CAInterface pointer to a simulation-wide Component Registry.

You then have to use this registry pointer with the obtainComponentInterfacePointer() function to obtain the SystemTraceInterface. This interface provides a list of all components in the system that provide trace data. You can use this list to access the SCADI interfaces of all the components.

Access to SCADI from within SystemC

To access the SCADI interfaces from within SystemC, use the scx_get_global_interface() function. This returns a CAInterface pointer to a simulation-wide Component Registry.

You then have to use this registry pointer with the obtainComponentInterfacePointer() function to obtain the SystemTraceInterface. This interface provides a list of all components in the system that provide trace data. You can use this list to access the SCADI interfaces of all the components.

Access to SCADI from MTI plug-ins

MTI plug-ins 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 SystemC or LISA use cases.

Example code for retrieving a SCADI interface pointer of a component

This code demonstrates how to use getGlobalInterface() to retrieve a SCADI interface pointer of a specific component.

From within LISA, use getGlobalInterface(). From within SystemC, it is assumed that you have a pointer to the Fast Models platform called platform. From within an MTI plug-in, you do not have to call getGlobalInterface(), and you can use the CAInterface pointer passed to RegisterSimulation().

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 SystemC peripheral
  // - 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 = scx::scx_get_global_interface();
  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));
}
Non-ConfidentialPDF file icon PDF version100964_1180_00_en
Copyright © 2014–2019 Arm Limited or its affiliates. All rights reserved.