|
Packit |
db01ca |
/* -*- linux-c -*-
|
|
Packit |
db01ca |
*
|
|
Packit |
db01ca |
* (C) Copyright IBM Corp. 2004-2006
|
|
Packit |
db01ca |
* (C) Copyright Pigeon Point Systems. 2010
|
|
Packit |
db01ca |
*
|
|
Packit |
db01ca |
* This program is distributed in the hope that it will be useful,
|
|
Packit |
db01ca |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
db01ca |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. This
|
|
Packit |
db01ca |
* file and program are licensed under a BSD style license. See
|
|
Packit |
db01ca |
* the Copying file included with the OpenHPI distribution for
|
|
Packit |
db01ca |
* full licensing terms.
|
|
Packit |
db01ca |
*
|
|
Packit |
db01ca |
* Author(s):
|
|
Packit |
db01ca |
* Sean Dague <sdague@users.sf.net>
|
|
Packit |
db01ca |
* Renier Morales <renier@openhpi.org>
|
|
Packit |
db01ca |
* Anton Pak <anton.pak@pigeonpoint.com>
|
|
Packit |
db01ca |
*
|
|
Packit |
db01ca |
*/
|
|
Packit |
db01ca |
|
|
Packit |
db01ca |
#ifndef __EVENT_UTILS_H
|
|
Packit |
db01ca |
#define __EVENT_UTILS_H
|
|
Packit |
db01ca |
|
|
Packit |
db01ca |
#ifndef __OH_UTILS_H
|
|
Packit |
db01ca |
#warning *** Include oh_utils.h instead of individual utility header files ***
|
|
Packit |
db01ca |
#endif
|
|
Packit |
db01ca |
|
|
Packit |
db01ca |
#include <SaHpi.h>
|
|
Packit |
db01ca |
#include <glib.h>
|
|
Packit |
db01ca |
|
|
Packit |
db01ca |
#ifdef __cplusplus
|
|
Packit |
db01ca |
extern "C" {
|
|
Packit |
db01ca |
#endif
|
|
Packit |
db01ca |
|
|
Packit |
db01ca |
/***
|
|
Packit |
db01ca |
* Instructions for using oh_event
|
|
Packit |
db01ca |
*********************************
|
|
Packit |
db01ca |
* oh_event is primarily used by the plugins to report HPI events.
|
|
Packit |
db01ca |
*
|
|
Packit |
db01ca |
* Required Fields:
|
|
Packit |
db01ca |
* .hid, .event
|
|
Packit |
db01ca |
*
|
|
Packit |
db01ca |
* Optional Fields:
|
|
Packit |
db01ca |
* .resource, .rdrs
|
|
Packit |
db01ca |
*
|
|
Packit |
db01ca |
*
|
|
Packit |
db01ca |
* Any Resource oh_events:
|
|
Packit |
db01ca |
* Use RESOURCE_UPDATED event for updating RPT entry.
|
|
Packit |
db01ca |
*
|
|
Packit |
db01ca |
* FRU Resource oh_events:
|
|
Packit |
db01ca |
* If reporting a resource, the plugin sets the appropiate event in .event.
|
|
Packit |
db01ca |
* For example, if reporting a new FRU resource, then the event should be
|
|
Packit |
db01ca |
* a hotswap type showing the correct hotswap state (any except NOT_PRESENT)
|
|
Packit |
db01ca |
* indicating the library that it should add it to the RPT.
|
|
Packit |
db01ca |
* If the plugin needs to report an extracted FRU, then the hotswap
|
|
Packit |
db01ca |
* event has to show the NOT_PRESENT current state, indicating to the library
|
|
Packit |
db01ca |
* that it should remove it from the RPT.
|
|
Packit |
db01ca |
* Hotswap events must have their accompaining resource set its capability bit
|
|
Packit |
db01ca |
* for FRU to 1 or it will be dropped by the infrastructure.
|
|
Packit |
db01ca |
* The .resource.ResourceCapabilities field can be zero.
|
|
Packit |
db01ca |
* If so, the RPT will not be updated, but the SaHpiEventT will be passed
|
|
Packit |
db01ca |
* on to the session queues and domain event log normally.
|
|
Packit |
db01ca |
*
|
|
Packit |
db01ca |
* Non-FRU Resource oh_events:
|
|
Packit |
db01ca |
* For adding or updating Non-FRU resources, the .event should be a resource
|
|
Packit |
db01ca |
* type HPI event and the ResourceEventType should be RESOURCE_ADDED or
|
|
Packit |
db01ca |
* RESOURCE_RESTORED. The resource itself should have its capability bit for
|
|
Packit |
db01ca |
* FRU set to zero or the event will be dropped by the infrastructure.
|
|
Packit |
db01ca |
* Use RESOURCE_REMOVED for removing Non-FRU resource from the RPT.
|
|
Packit |
db01ca |
* If a resource is failed, then the oh_event should
|
|
Packit |
db01ca |
* have a resource event type with the resource state as RESOURCE_FAILED.
|
|
Packit |
db01ca |
* The .resource field should have the RPT entry for resource in question.
|
|
Packit |
db01ca |
* This is used by the infrastructure to update the RPT and mark the resource
|
|
Packit |
db01ca |
* as failed (ResourceFailed == True).
|
|
Packit |
db01ca |
* The .resource.ResourceCapabilities field can be zero. If so,
|
|
Packit |
db01ca |
* the RPT will not be updated, but the SaHpiEventT will be passed on to the
|
|
Packit |
db01ca |
* session queues and domain event log normally.
|
|
Packit |
db01ca |
*
|
|
Packit |
db01ca |
* RDRs:
|
|
Packit |
db01ca |
* If the event is for a resource, be it FRU or Non-FRU, and the resource did
|
|
Packit |
db01ca |
* not previously exist in the RPT for the domain, then the .rdrs field is
|
|
Packit |
db01ca |
* scanned for valid SaHpiRdrTs (RdrType != SAHPI_NO_RECORD) objects and each
|
|
Packit |
db01ca |
* one is added as an rdr for the resource to the RPT. If the resource is
|
|
Packit |
db01ca |
* already in the RPT, then the rdrs field will be ignored for all
|
|
Packit |
db01ca |
* event except RESOURCE_UPDATED.
|
|
Packit |
db01ca |
* In addition to updating RPT entry, the RESOURCE_UPDATED event
|
|
Packit |
db01ca |
* can be used for adding, updating or removing RDRs.
|
|
Packit |
db01ca |
*
|
|
Packit |
db01ca |
* Other event types:
|
|
Packit |
db01ca |
* If the event is of type SENSOR, SENSOR_ENABLE_CHANGE, WATCHDOG, or OEM, then
|
|
Packit |
db01ca |
* The .resource field is scanned for a valid resource to use as reference for
|
|
Packit |
db01ca |
* the domain event log. Also, the .rdrs field is scanned for exactly one
|
|
Packit |
db01ca |
* SaHpiRdrT to be used as reference for the domain event log and session event
|
|
Packit |
db01ca |
* queue. If multiple rdrs are passed for these event types, only the first one
|
|
Packit |
db01ca |
* will be used.
|
|
Packit |
db01ca |
**/
|
|
Packit |
db01ca |
|
|
Packit |
db01ca |
struct oh_event {
|
|
Packit |
db01ca |
unsigned int hid; /* handler id for the event */
|
|
Packit |
db01ca |
SaHpiEventT event;
|
|
Packit |
db01ca |
/* If no resource, ResourceCapabilities must be 0 */
|
|
Packit |
db01ca |
SaHpiRptEntryT resource;
|
|
Packit |
db01ca |
GSList *rdrs;
|
|
Packit |
db01ca |
GSList *rdrs_to_remove;
|
|
Packit |
db01ca |
};
|
|
Packit |
db01ca |
|
|
Packit |
db01ca |
typedef GAsyncQueue oh_evt_queue;
|
|
Packit |
db01ca |
|
|
Packit |
db01ca |
#define oh_new_event() g_new0(struct oh_event, 1)
|
|
Packit |
db01ca |
void oh_event_free(struct oh_event *e, int only_rdrs);
|
|
Packit |
db01ca |
struct oh_event *oh_dup_event(struct oh_event *old_event);
|
|
Packit |
db01ca |
void oh_evt_queue_push(oh_evt_queue *equeue, gpointer data);
|
|
Packit |
db01ca |
|
|
Packit |
db01ca |
#ifdef __cplusplus
|
|
Packit |
db01ca |
}
|
|
Packit |
db01ca |
#endif
|
|
Packit |
db01ca |
|
|
Packit |
db01ca |
#endif /* __EVENT_UTILS_H */
|
|
Packit |
db01ca |
|