RPT Utilities

Name

RPT Utilities -- Resource Presence Table Utility Functions

Synopsis


#include <SaHpi.h>
#include <glib.h>


#define     FREE_RPT_DATA
#define     KEEP_RPT_DATA
void        oh_flush_rpt                    (RPTable *table);
void        rpt_diff                               (RPTable *cur_rpt,
                                                RPTable *new_rpt,
                                                GSList **res_new,
                                                GSList **rdr_new,
                                                GSList **res_gone,
                                                GSList **rdr_gone);
int         oh_add_resource               (RPTable *table,
                                                SaHpiRptEntryT *entry,
                                                void *data,
                                                int owndata);
int         oh_remove_resource        (RPTable *table,
                                                SaHpiResourceIdT rid);
void*       oh_get_resource_data    (RPTable *table,
                                                SaHpiResourceIdT rid);
SaHpiRptEntryT* oh_get_resource_by_id       (RPTable *table,
                                                        SaHpiResourceIdT rid);
SaHpiRptEntryT* oh_get_resource_by_ep      (RPTable *table,
                                                        SaHpiEntityPathT *ep);
SaHpiRptEntryT* oh_get_resource_next        (RPTable *table,
                                                        SaHpiResourceIdT rid_prev);
int         oh_add_rdr                       (RPTable *table,
                                                SaHpiResourceIdT rid,
                                                SaHpiRdrT *rdr,
                                                void *data,
                                                int owndata);
int         oh_remove_rdr                  (RPTable *table,
                                                SaHpiResourceIdT rid,
                                                SaHpiEntryIdT rdrid);
void*       oh_get_rdr_data              (RPTable *table,
                                                SaHpiResourceIdT rid,
                                                SaHpiEntryIdT rdrid);
SaHpiRdrT*  oh_get_rdr_by_id            (RPTable *table,
                                                SaHpiResourceIdT rid,
                                                SaHpiEntryIdT rdrid);
SaHpiRdrT*  oh_get_rdr_by_type        (RPTable *table,
                                                SaHpiResourceIdT rid,
                                                SaHpiRdrTypeT type,
                                                SaHpiUint8T num);
SaHpiRdrT*  oh_get_rdr_next              (RPTable *table,
                                                SaHpiResourceIdT rid,
                                                SaHpiEntryIdT rdrid_prev);
SaHpiUint32T get_rdr_uid                       (SaHpiRdrTypeT type,
                                                SaHpiUint32T num);

Description

This interface was created to interact with a Resource Presence Table (RPT). By using the interface you may add resources and rdrs to a table, remove them, and fetch them.

Details

FREE_RPT_DATA

#define                FREE_RPT_DATA   SAHPI_FALSE

Used in the oh_add_resource() and oh_add_rdr() calls to tell the interface if it should free the data when the resource/rdr is removed.

KEEP_RPT_DATA

#define        KEEP_RPT_DATA   SAHPI_TRUE

Used in the oh_add_resource() and oh_add_rdr() calls to tell the interface if it should leave the data pointer alone when the resource/rdr is removed.

oh_flush_rpt ()

void           oh_flush_rpt    (RPTable *table);

Cleans RPT from all entries and RDRs and frees the memory associated with them.

table :

Pointer to the RPT to flush.

rpt_diff ()

void           rpt_diff        (RPTable *cur_rpt,
                                 RPTable *new_rpt,
                                 GSList **res_new,
                                 GSList **rdr_new,
                                 GSList **res_gone,
                                 GSList **rdr_gone);

Extracts from current the resources and rdrs that are not found in new and puts them in res_gone and rdr_gone. Also, puts in res_new and rdr_new the resources and rdrs that are not already in current Or that are not identical to the ones in current.

cur_rpt :

IN. Pointer to RPTable that represents the current state of resources and rdrs.

new_rpt :

IN. Pointer to RPTable that contains rpt entries and rdrs just recently discovered.

res_new :

OUT. List of new or changed rpt entries

rdr_new :

OUT. List of new or changed rdrs

res_gone :

OUT. List of old and not present resources.

rdr_gone :

OUT. List of old and not present rdrs.

oh_add_resource ()

int    oh_add_resource         (RPTable *table,
                                 SaHpiRptEntryT *entry,
                                 void *data,
                                 int owndata);

Add a RPT entry to the RPT along with some private data. If an RPT entry with the same resource id exists int the RPT, it will be overlayed with the new RPT entry. Also, this function will assign the resource id as its entry id since it is expected to be unique for the table.

table :

Pointer to the RPT to which the RPT entry will be added.

entry :

The RPT entry (resource) to be added to the RPT.

data :

Pointer to private data for storing along with the RPT entry.

owndata :

boolean flag. true (KEEP_RPT_DATA) to tell the interface *not* to free the data when the resource is removed. false (FREE_RPT_DATA) to tell the interface to free the data when the resource is removed.

Returns :

0 - successful addition to the RPT. -1 - table pointer is NULL. -2 - entry is NULL. -3 - entry does not have an id assigned. -4 - entry has an invalid/reserved id assinged. -5 - entity path does not contain root element. -6 - failure and not enough memory could be allocated. for a new position in the RPT.

oh_remove_resource ()

int    oh_remove_resource      (RPTable *table,
                                 SaHpiResourceIdT rid);

Remove a resource from the RPT. If the rid is SAHPI_FIRST_ENTRY, the first RPT entry in the table will be removed. The void data will be freed if owndata was false (FREE_RPT_DATA) when adding the resource, otherwise if owndata was true (KEEP_RPT_DATA) it will not be freed.

table :

Pointer to the RPT from which an RPT entry will be removed.

rid :

Resource id of the RPT entry to be removed.

Returns :

0 - Successful removal from the RPT. -1 - table pointer is NULL. -2 - Failure. No resource found by that id.

oh_get_resource_data ()

void*  oh_get_resource_data    (RPTable *table,
                                 SaHpiResourceIdT rid);

Get the private data for a RPT entry. If the rid is SAHPI_FIRST_ENTRY, the first RPT entry's data in the table will be returned.

table :

Pointer to the RPT for looking up the RPT entry's private data.

rid :

Resource id of the RPT entry that holds the private data.

oh_get_resource_by_id ()

SaHpiRptEntryT*        oh_get_resource_by_id   (RPTable *table,
                                         SaHpiResourceIdT rid);

Get a RPT entry from the RPT by using the resource id. If rid is SAHPI_FIRST_ENTRY, the first RPT entry in the table will be returned.

table :

Pointer to the RPT for looking up the RPT entry.

rid :

Resource id of the RPT entry to be looked up.

Returns :

Pointer to the RPT entry found or NULL if an RPT entry by that id was not found or the table was a NULL pointer.

oh_get_resource_by_ep ()

SaHpiRptEntryT* oh_get_resource_by_ep  (RPTable *table,
                                         SaHpiEntityPathT *ep);

Get a RPT entry from the RPT by using the entity path.

table :

Pointer to the RPT for looking up the RPT entry.

ep :

Entity path of the RPT entry to be looked up.

Returns :

Pointer to the RPT entry found or NULL if an RPT entry by that entity path was not found or the table was a NULL pointer.

oh_get_resource_next ()

SaHpiRptEntryT* oh_get_resource_next   (RPTable *table,
                                         SaHpiResourceIdT rid_prev);

Get the RPT entry next to the specified RPT entry from the RPT. If rid_prev is SAHPI_FIRST_ENTRY, the first RPT entry in the table will be returned.

table :

Pointer to the RPT for looking up the RPT entry.

rid_prev :

Resource id of the RPT entry previous to the one being looked up.

Returns :

Pointer to the RPT entry found or NULL if the previous RPT entry by that id was not found or the table was a NULL pointer.

oh_add_rdr ()

int    oh_add_rdr      (RPTable *table,
                         SaHpiResourceIdT rid,
                         SaHpiRdrT *rdr,
                         void *data,
                         int owndata);

Add an RDR to a RPT entry's RDR repository. If an RDR is found with the same record id as the one being added, the RDR being added will overlay the existing one. Also, a unique record id will be assigned to it based on the RDR type and its type's numeric id. All rdr interface funtions, except oh_add_rdr() will act in the context of the first RPT entry in the table, if rid is SAHPI_FIRST_ENTRY.

table :

Pointer to RPT table containig the RPT entry to which the RDR will belong.

rid :

Id of the RPT entry that will own the RDR to be added.

rdr :

RDR to be added to an RPT entry's RDR repository.

data :

Pointer to private data belonging to the RDR that is being added.

owndata :

boolean flag. true (KEEP_RPT_DATA) to tell the interface *not* to free the data when the rdr is removed. false (FREE_RPT_DATA) to tell the interface to free the data when the rdr is removed.

Returns :

0 - Successful addition of RDR. -1 - table pointer is NULL. -2 - Failure. RDR is NULL. -3 - Failure. RPT entry for that rid was not found. -4 - Failure. RDR entity path is different from parent RPT entry. -5 - Failure. Could not allocate enough memory to position the new RDR in the RDR repository.

oh_remove_rdr ()

int    oh_remove_rdr   (RPTable *table,
                         SaHpiResourceIdT rid,
                         SaHpiEntryIdT rdrid);

Remove an RDR from a RPT entry's RDR repository. If rdrid is SAHPI_FIRST_ENTRY, the first RDR in the repository will be removed. If owndata was set to false (FREE_RPT_DATA) on the rdr when it was added, the data will be freed, otherwise if it was set to true (KEEP_RPT_DATA), it will not be freed. All rdr interface funtions, except oh_add_rdr() will act in the context of the first RPT entry in the table, if rid is SAHPI_FIRST_ENTRY.

table :

Pointer to RPT table containig the RPT entry from which the RDR will be removed.

rid :

Id of the RPT entry from which the RDR will be removed.

rdrid :

Record id of the RDR to remove.

Returns :

0 - Successful removal of RDR. -1 - table pointer is NULL. -2 - Failure. RPT entry for that rid was not found. -3 - Failure. No RDR by that rdrid was found.

oh_get_rdr_data ()

void*  oh_get_rdr_data (RPTable *table,
                         SaHpiResourceIdT rid,
                         SaHpiEntryIdT rdrid);

Get the private data associated to an RDR. If rdrid is SAHPI_FIRST_ENTRY, the first RDR's data in the repository will be returned. All rdr interface funtions, except oh_add_rdr() will act in the context of the first RPT entry in the table, if rid is SAHPI_FIRST_ENTRY.

table :

Pointer to RPT table containig the RPT entry from which the RDR's data will be read.

rid :

Id of the RPT entry from which the RDR's data will be read.

rdrid :

Record id of the RDR to read data from.

oh_get_rdr_by_id ()

SaHpiRdrT*     oh_get_rdr_by_id        (RPTable *table,
                                         SaHpiResourceIdT rid,
                                         SaHpiEntryIdT rdrid);

Get a reference to an RDR by its record id. If rdrid is SAHPI_FIRST_ENTRY, the first RDR in the repository will be returned. All rdr interface funtions, except oh_add_rdr() will act in the context of the first RPT entry in the table, if rid is SAHPI_FIRST_ENTRY.

table :

Pointer to RPT table containig the RPT entry tha has the RDR being looked up.

rid :

Id of the RPT entry containing the RDR being looked up.

rdrid :

Record id of the RDR being looked up.

Returns :

Reference to the RDR looked up or NULL if no RDR was found.

oh_get_rdr_by_type ()

SaHpiRdrT*     oh_get_rdr_by_type      (RPTable *table,
                                         SaHpiResourceIdT rid,
                                         SaHpiRdrTypeT type,
                                         SaHpiUint8T num);

Get a reference to an RDR by its type and number. All rdr interface funtions, except oh_add_rdr() will act in the context of the first RPT entry in the table, if rid is SAHPI_FIRST_ENTRY.

table :

Pointer to RPT table containig the RPT entry tha has the RDR being looked up.

rid :

Id of the RPT entry containing the RDR being looked up.

type :

RDR Type of the RDR being looked up.

num :

RDR id within the RDR type for the specified RPT entry.

Returns :

Reference to the RDR looked up or NULL if no RDR was found.

oh_get_rdr_next ()

SaHpiRdrT*     oh_get_rdr_next         (RPTable *table,
                                         SaHpiResourceIdT rid,
                                         SaHpiEntryIdT rdrid_prev);

Get the RDR next to the specified RDR in the specified RPT entry's repository. If rdrid_prev is SAHPI_FIRST_ENTRY, the first RDR in the repository will be returned. All rdr interface funtions, except oh_add_rdr() will act in the context of the first RPT entry in the table, if rid is SAHPI_FIRST_ENTRY.

table :

Pointer to the RPT containing the RPT entry to look up the RDR in.

rid :

Id of the RPT entry containing the RDR being looked up.

rdrid_prev :

Record id of the RDR previous to the one being looked up, relative to the specified RPT entry.

Returns :

Pointer to the RDR found or NULL if the previous RDR by that id was not found. If the rdrid_prev was SAHPI_FIRST_ENTRY, the first RDR in the list will be returned.

get_rdr_uid ()

SaHpiUint32T   get_rdr_uid     (SaHpiRdrTypeT type,
                                 SaHpiUint32T num);

Helper function to derive the Record id of an rdr from its type and num

type :

type of rdr

num :

id number of the RDR unique withing the RDR type for that resource

Returns :

a derived Record Id used to identify RDRs within Resources