Non-Confidential | ![]() | ARM 100963_0200_00_en | ||
| ||||
Home > CADI Extension Mechanism > Obtaining a custom interface |
This section describes how to ensure the correct functionality of an acquired interface and to avoid, for example, the utilization of an outdated interface revision.
The procedure of obtaining a custom interface is the same as the one for the standard interfaces:
CAInterface
pointer to the target interface
class is required. The CADI simulation typically returns this pointer.ObtainInterface()
method
must be called to check if the required interface is provided.The returned pointer to CAInterface
,
which might differ from the originally obtained one, must be converted
to a pointer to the requested interface class by using a static_cast()
.
MyExtensions
and MyCADI
classes implementationsCADISimulation* cadiSimulation; uint32_t targetID; CAInterface* ca_interface; MyExtensions* my_extensions_if; . . . // Get the CADISimulation pointer. . . . // Here, gets a pointer of type CAInterface. this pointer can be used to obtain // any interface provided by the target using ObtainInterface(). ca_interface = cadiSimulation->GetTarget(targetID); //obtain the desired interface if_name_t ifName = “MyExtensions”; if_rev_t minRev = 0; if_rev_t actualRev = 0; // ObtainInterface() asks for "MyExtensions" interface. // It returns the corresponding base class pointer. ca_interface = ca_interface->ObtainInterface(ifName, minRev, &actualRev); if (ca_interface == NULL) { // Something went wrong, handle it... } else // MyExtensions interface supported. { my_extensions_if = static_cast<MyExtensions*>(ca_interface); } . . . //go on using the obtained interface extensions