Listening for Notifications

In additional to the normal timed and stacked events, it is possible to add modules that listen to special notifications. Such notifications include for example bus traffic notifications (which can be used to tap some of the bus models), and trap taken and return from trap notifications. Normally, notifications are disabled, but they can be enabled using certain programming interfaces.

Notification listening can be handle in plug-ins (plug-ins do not need to register any models) or they can be added in your own program that drives the emulator (see [using-temu-in-a-simulator]). As an example, in order to handle traps and rett instructions (return from trap), you can register to receive two notifications as follows:

void
trapEntry(void *arg, void *source, void *notinfo)
{
  temu_TrapEventInfo *info = (temu_TrapEventInfo *)notinfo;
  temu_logInfo(source, "trap taken %x", info->TrapId);
}
void
trapExit(void *arg, void *source, void *notinfo)
{
  temu_logInfo(source, "rett executed");
}

Note that the actual type for the notinfo pointer should be documented in the respective manuals and it differ depending on the type of notification. The actual registration for subscription can be done as follows:

  void *cpu0 = temu_objectForName("cpu0");
  temu_CpuIface *iface = temu_getInterface(cpu0, "CpuIface", 0);
  iface->enableTrapEvents(cpu0);
  temu_subscribeNotification("temu.cpuTrapEntry", cpu0, NULL, trapEntry);
  temu_subscribeNotification("temu.cpuTrapExit", cpu0, NULL, trapExit);

There is a command to list all published notifications and possible source objects. Type "notification-list" in the command line to see these.

Note that notifications are in a global namespace (unlike timed events, which are associated with an object). This allows you to for example listen to all notifications with a certain event, without specifying the source object.