next up previous contents
Next: 4.1.5.6 Event table navigation Up: 4.1.5 Event allocation Previous: 4.1.5.4 Event Table navigation

4.1.5.5 Event Table inspection

We need get_url and nameof for both trap and interrupt tables.

<Other public methods of off_TrapTbl. >+= (<-U) [<-D]
// Get the trap table URL.
const char *get_url(void);
// Returns the trap table name. 
const char *nameof(void);

<Other public methods of off_IntTbl. >+= (<-U) [<-D]
// Get the interrupt table URL.
const char *get_url(void);
// Returns the interrupt table name. 
const char *nameof(void);

The URL for a trap (interrupt) table is that of its node with trap.html (or int.html) appended. We use a new member, a character array initialized the very first time it is needed.

<Other private members of off_TrapTbl. >= (<-U) [D->]
static char *t_url;             // URL for this trap table.

<Other private members of off_IntTbl. >+= (<-U) [<-D->]
static char *i_url;             // URL for this interrupt table.

Initially it is empty.

<Off event table static members. >= (U->)
char *off_TrapTbl::t_url=NULL;    // URL for trap tables.
char *off_IntTbl::i_url=NULL;    // URL for interrupt tables.

<off_TrapTbl::get_url implementation. >= (U->)
// Get the trap table URL.
const char *off_TrapTbl::get_url(void)
{
  assert(valid());
  if (!t_url){
    t_url=new char[strlen(nd.get_url())+strlen(OFF_TRAPTBL_URL)+1];//+1 for \0
    if (t_url)
      sprintf(t_url,"%s%s",nd.get_url(),OFF_TRAPTBL_URL);
  }
  return t_url;
}

<off_IntTbl::get_url implementation. >= (U->)
// Get the interrupt table URL.
const char *off_IntTbl::get_url(void)
{
  assert(valid());
  if (!i_url){
    i_url=new char[strlen(nd.get_url())+strlen(OFF_INTTBL_URL)+1];//+1 for \0
    if (i_url)
      sprintf(i_url,"%s%s",nd.get_url(),OFF_INTTBL_URL);
  }
  return i_url;
}

Where he have to define the relative URLs for event tables.

<Off source code urls. >= [D->]
const char OFF_TRAPTBL_URL[]="/trap.html";
const char OFF_INTTBL_URL[]="/irq.html";

<Off event table dependencies. >+= (U->) [<-D]
#include <klib/url.h>           // for OFF_TRAPTBL_URL et al.

<Off event table implementation dependencies. >= (U->)
#include <stdio.h>              // for sprintf et al
#include <node/Node.h>          // for nd

The name for an event table is that of its node complemented with a little suffix. The implementation is almost the same of get_url, however, the name is not shared in the same node (i.e. it is not static).

<Other private members of off_TrapTbl. >+= (<-U) [<-D->]
char *t_name;             // name for this trap table.

<Other private members of off_IntTbl. >+= (<-U) [<-D]
char *i_name;             // name for this interrupt table.

<Initialize other aggregate members of off_TrapTbl. >= (<-U) [D->]
t_name(NULL),

<Initialize other aggregate members of off_IntTbl. >+= (<-U) [<-D]
i_name(NULL)

<off_TrapTbl::nameof implementation. >= (U->)
// Returns the trap table name. 
const char *off_TrapTbl::nameof(void)
{
  assert(valid());
  if (!t_name){
    t_name = new char[strlen(nd.nameof())+strlen("/trap")+9]; // for N...N\0
    if (t_name)
      sprintf(t_name,"%s/trap%08x",nd.nameof(),(natural_t)get_id());
  }
  return t_name;
}

<off_IntTbl::nameof implementation. >= (U->)
// Returns the interrupt table name. 
const char *off_IntTbl::nameof(void)
{
  assert(valid());
  if (!i_name){
    i_name = new char[strlen(nd.nameof())+strlen("/int")+9]; // for N...N\0
    if (i_name)
      sprintf(i_name,"%s/int%08x",nd.nameof(),(natural_t)get_id());
  }
  return i_name;
}

\subsubsection{Event inspection}

We need get_rurl and get_url_holder for both trap and interrupts to support ResUnit::get_url.

<Other protected methods of off_Trap. >= (<-U) [D->]
// Get the trap URL.
virtual const char *get_rurl(void) const { return OFF_TRAP_URL; }
// Returns the trap name. 
virtual char *&get_url_holder(void);

<Other protected methods of off_Irq. >+= (<-U) [<-D->]
// Get the irq URL.
virtual const char *get_rurl(void) const { return OFF_IRQ_URL; }
// Returns the irq name. 
virtual char *&get_url_holder(void);

Where we must define the relative URL for traps

<Off source code urls. >+= [<-D->]
const char OFF_TRAP_URL[]="#Trap";
Defines OFF_TRAP_URL (links are to index).

<Off event dependencies. >+= (U->) [<-D]
#include <klib/url.h>           // for OFF_TRAP_URL

and interrupts.

<Off source code urls. >+= [<-D]
const char OFF_IRQ_URL[]="#Irq";
Defines OFF_IRQ_URL (links are to index).

URLs are the same for all traps.

<Other private members of off_Trap. >= (<-U)
static char *t_url;             // URL for this trap

<off_Trap::get_url_holder implementation. >= (U->)
char *&off_Trap::get_url_holder(void) {  return t_url; }

Initially it is empty.

<Off trap static members. >= (U->)
char *off_Trap::t_url=NULL;   // URL for trap.

URLs are also the same for all interrupts.

<Other private members of off_Irq. >+= (<-U) [<-D]
static char *i_url;             // URL for this interrupt.

<off_Irq::get_url_holder implementation. >= (U->)
char *&off_Irq::get_url_holder(void) {  return i_url; }

Initially it is empty.

<Off interrupt static members. >= (U->)
char *off_Irq::i_url=NULL;   // URL for interrupt.



Francisco J. Ballesteros
1998-05-25