summaryrefslogtreecommitdiffstats
path: root/recipes-extended/openhpi/files/openhpi_openclovis.patch
diff options
context:
space:
mode:
Diffstat (limited to 'recipes-extended/openhpi/files/openhpi_openclovis.patch')
-rw-r--r--recipes-extended/openhpi/files/openhpi_openclovis.patch237
1 files changed, 237 insertions, 0 deletions
diff --git a/recipes-extended/openhpi/files/openhpi_openclovis.patch b/recipes-extended/openhpi/files/openhpi_openclovis.patch
new file mode 100644
index 0000000..5e51bb4
--- /dev/null
+++ b/recipes-extended/openhpi/files/openhpi_openclovis.patch
@@ -0,0 +1,237 @@
1diff -Naur openhpi-3.0.0/plugins/dynamic_simulator/new_sim_file_util.cpp openhpi-3.0.0.oc/plugins/dynamic_simulator/new_sim_file_util.cpp
2--- openhpi-3.0.0/plugins/dynamic_simulator/new_sim_file_util.cpp 2011-10-17 13:57:23.000000000 -0200
3+++ openhpi-3.0.0.oc/plugins/dynamic_simulator/new_sim_file_util.cpp 2012-01-10 14:16:29.000000000 -0200
4@@ -118,7 +118,7 @@
5 } else if (cur_token == G_TOKEN_STRING) {
6 datafield = g_strdup(m_scanner->value.v_string);
7 } else {
8- err("Processing parse textbuffer: unknow value type %u", cur_token);
9+ err("Processing parse textbuffer: unknown value type %u", cur_token);
10 success = false;
11 break;
12 }
13@@ -129,7 +129,7 @@
14 tmp.Language = ( SaHpiLanguageT ) val;
15 } else if (!strcmp( "DataLength", field )) {
16 tmp.DataLength = val;
17- } else if (!strcmp( "Data", field )) {
18+ } else if ((!strcmp( "Data", field ))&&datafield) {
19 strncpy ((char *) tmp.Data, datafield, SAHPI_MAX_TEXT_BUFFER_LENGTH);
20 } else {
21 err("Processing parse textbuffer: unknown field %s", field);
22diff -Naur openhpi-3.0.0/plugins/dynamic_simulator/new_sim_sensor_threshold.cpp openhpi-3.0.0.oc/plugins/dynamic_simulator/new_sim_sensor_threshold.cpp
23--- openhpi-3.0.0/plugins/dynamic_simulator/new_sim_sensor_threshold.cpp 2011-10-17 13:57:23.000000000 -0200
24+++ openhpi-3.0.0.oc/plugins/dynamic_simulator/new_sim_sensor_threshold.cpp 2012-01-10 14:16:25.000000000 -0200
25@@ -478,7 +478,10 @@
26 rv = checkOrdering( tmp );
27 if ( rv != SA_OK )
28 return rv;
29-
30+
31+ // Now check if the threshold changes caused an event
32+ CheckThresholdsAndPublishEvents(&tmp);
33+
34 // Ok, it seems everything is fine - take the new values
35 memcpy( &m_thres, &tmp, sizeof(SaHpiSensorThresholdsT));
36
37@@ -486,6 +489,183 @@
38 }
39
40
41+void NewSimulatorSensorThreshold::CreateThresholdEvent(SaHpiEventStateT theActualEvent, SaHpiBoolT asserted)
42+{
43+ NewSimulatorResource *res = Resource();
44+ if( !res )
45+ {
46+ stdlog << "CreateEnableChangeEvent: No resource !\n";
47+ return;
48+ }
49+
50+ oh_event *e = (oh_event *)g_malloc0( sizeof( struct oh_event ) );
51+
52+ e->event.EventType = SAHPI_ET_SENSOR_ENABLE_CHANGE;
53+
54+ SaHpiRptEntryT *rptentry = oh_get_resource_by_id( res->Domain()->GetHandler()->rptcache, res->ResourceId() );
55+ SaHpiRdrT *rdrentry = oh_get_rdr_by_id( res->Domain()->GetHandler()->rptcache, res->ResourceId(), m_record_id );
56+
57+ if ( rptentry )
58+ e->resource = *rptentry;
59+ else
60+ e->resource.ResourceCapabilities = 0;
61+
62+ if ( rdrentry )
63+ e->rdrs = g_slist_append(e->rdrs, g_memdup(rdrentry, sizeof(SaHpiRdrT)));
64+ else
65+ e->rdrs = NULL;
66+
67+ // Fill the event data
68+ e->event.Source = res->ResourceId();
69+ e->event.EventType = SAHPI_ET_SENSOR;
70+
71+ if ((theActualEvent & SAHPI_ES_LOWER_MINOR) || (theActualEvent & SAHPI_ES_UPPER_MINOR))
72+ e->event.Severity = SAHPI_MINOR;
73+ if ((theActualEvent & SAHPI_ES_LOWER_MAJOR) || (theActualEvent & SAHPI_ES_UPPER_MAJOR))
74+ e->event.Severity = SAHPI_MAJOR;
75+ if ((theActualEvent & SAHPI_ES_LOWER_CRIT) || (theActualEvent & SAHPI_ES_UPPER_CRIT))
76+ e->event.Severity = SAHPI_CRITICAL;
77+
78+ oh_gettimeofday(&e->event.Timestamp);
79+
80+ // sensor enable event
81+ SaHpiSensorEventT *se = &e->event.EventDataUnion.SensorEvent;
82+ se->SensorNum = m_sensor_record.Num;
83+ se->SensorType = Type();
84+ se->EventCategory = SAHPI_EC_THRESHOLD;
85+ se->Assertion = asserted; // True if the condition is being raised, False if cleared
86+
87+ se->EventState = theActualEvent;
88+ se->OptionalDataPresent = 0;
89+
90+ // Issue the event
91+ stdlog << "NewSimulatorSensorThreshold::CreateThresholdEvent OH_ET_HPI Event threshold resource " << res-> ResourceId() << "\n";
92+ res->Domain()->AddHpiEvent( e );
93+
94+}
95+
96+
97+SaErrorT NewSimulatorSensorThreshold::CheckThresholdsAndPublishEvents(const SaHpiSensorThresholdsT* thres)
98+{
99+ // Only generate if the threshold is supported.
100+ if (thres->UpMinor.IsSupported) {
101+ // Crossing the threshold in both directions (from deasserted to asserted,
102+ // and from asserted to deasserted) needs to be handled.
103+
104+ if (m_event_data & SAHPI_ES_UPPER_MINOR) {
105+ // See if the threshold is no longer exceeded
106+ if (lt(m_read_data,thres->UpMinor)) {
107+ CreateThresholdEvent(SAHPI_ES_UPPER_MINOR,SAHPI_FALSE);
108+ m_event_data &= ~SAHPI_ES_UPPER_MINOR;
109+ }
110+
111+ }
112+ else {
113+ // See if the threshold is exceeded
114+ if (gt(m_read_data,thres->UpMinor)) {
115+ CreateThresholdEvent(SAHPI_ES_UPPER_MINOR,SAHPI_TRUE);
116+ m_event_data |= SAHPI_ES_UPPER_MINOR;
117+ }
118+ }
119+ }
120+
121+ if (thres->UpMajor.IsSupported) {
122+ if (m_event_data & SAHPI_ES_UPPER_MAJOR) {
123+ // See if the threshold is no longer exceeded
124+ if (lt(m_read_data,thres->UpMajor)) {
125+ CreateThresholdEvent(SAHPI_ES_UPPER_MAJOR,SAHPI_FALSE);
126+ m_event_data &= ~SAHPI_ES_UPPER_MAJOR;
127+ }
128+
129+ }
130+ else {
131+ // See if the threshold is exceeded
132+ if (gt(m_read_data,thres->UpMajor)) {
133+ CreateThresholdEvent(SAHPI_ES_UPPER_MAJOR,SAHPI_TRUE);
134+ m_event_data |= SAHPI_ES_UPPER_MAJOR;
135+ }
136+ }
137+ }
138+
139+ if (thres->UpCritical.IsSupported) {
140+ if (m_event_data & SAHPI_ES_UPPER_CRIT) {
141+ // See if the threshold is no longer exceeded
142+ if (lt(m_read_data,thres->UpCritical)) {
143+ CreateThresholdEvent(SAHPI_ES_UPPER_CRIT,SAHPI_FALSE);
144+ m_event_data &= ~SAHPI_ES_UPPER_CRIT;
145+ }
146+ }
147+ else {
148+ // See if the threshold is exceeded
149+ if (gt(m_read_data,thres->UpCritical)) {
150+ CreateThresholdEvent(SAHPI_ES_UPPER_CRIT,SAHPI_TRUE);
151+ m_event_data |= SAHPI_ES_UPPER_CRIT;
152+ }
153+ }
154+ }
155+
156+
157+
158+ if (thres->LowMinor.IsSupported) {
159+ // Crossing the threshold in both directions (from deasserted to asserted,
160+ // and from asserted to deasserted) needs to be handled.
161+
162+ if (m_event_data & SAHPI_ES_LOWER_MINOR) {
163+ // See if the threshold is no longer exceeded
164+ if (lt(m_read_data,thres->LowMinor)) {
165+ CreateThresholdEvent(SAHPI_ES_LOWER_MINOR,SAHPI_FALSE);
166+ m_event_data &= ~SAHPI_ES_LOWER_MINOR;
167+ }
168+
169+ }
170+ else {
171+ // See if the threshold is exceeded
172+ if (gt(m_read_data,thres->LowMinor)) {
173+ CreateThresholdEvent(SAHPI_ES_LOWER_MINOR,SAHPI_TRUE);
174+ m_event_data |= SAHPI_ES_LOWER_MINOR;
175+ }
176+ }
177+ }
178+
179+ if (thres->LowMajor.IsSupported) {
180+ if (m_event_data & SAHPI_ES_LOWER_MAJOR) {
181+ // See if the threshold is no longer exceeded
182+ if (lt(m_read_data,thres->LowMajor)) {
183+ CreateThresholdEvent(SAHPI_ES_LOWER_MAJOR,SAHPI_FALSE);
184+ m_event_data &= ~SAHPI_ES_LOWER_MAJOR;
185+ }
186+
187+ }
188+ else {
189+ // See if the threshold is exceeded
190+ if (gt(m_read_data,thres->LowMajor)) {
191+ CreateThresholdEvent(SAHPI_ES_LOWER_MAJOR,SAHPI_TRUE);
192+ m_event_data |= SAHPI_ES_LOWER_MAJOR;
193+ }
194+ }
195+ }
196+
197+ if (thres->LowCritical.IsSupported) {
198+ if (m_event_data & SAHPI_ES_LOWER_CRIT) {
199+ // See if the threshold is no longer exceeded
200+ if (lt(m_read_data,thres->LowCritical)) {
201+ CreateThresholdEvent(SAHPI_ES_LOWER_CRIT,SAHPI_FALSE);
202+ m_event_data &= ~SAHPI_ES_LOWER_CRIT;
203+ }
204+ }
205+ else {
206+ // See if the threshold is exceeded
207+ if (gt(m_read_data,thres->LowCritical)) {
208+ CreateThresholdEvent(SAHPI_ES_LOWER_CRIT,SAHPI_TRUE);
209+ m_event_data |= SAHPI_ES_LOWER_CRIT;
210+ }
211+ }
212+ }
213+
214+
215+ return SA_OK;
216+}
217+
218 /**
219 * Check whether the setting of one threshold value is allowed
220 *
221diff -Naur openhpi-3.0.0/plugins/dynamic_simulator/new_sim_sensor_threshold.h openhpi-3.0.0.oc/plugins/dynamic_simulator/new_sim_sensor_threshold.h
222--- openhpi-3.0.0/plugins/dynamic_simulator/new_sim_sensor_threshold.h 2011-10-17 13:57:23.000000000 -0200
223+++ openhpi-3.0.0.oc/plugins/dynamic_simulator/new_sim_sensor_threshold.h 2012-01-10 14:17:33.000000000 -0200
224@@ -73,6 +73,13 @@
225 // create an RDR sensor record
226 virtual bool CreateRdr( SaHpiRptEntryT &resource, SaHpiRdrT &rdr );
227
228+ // Check to see if changing the thresholds to the passed values
229+ // would result in an error. If so, raise the appropriate event.
230+ SaErrorT CheckThresholdsAndPublishEvents(const SaHpiSensorThresholdsT* newThres);
231+
232+ // Create a threshold event
233+ void CreateThresholdEvent(SaHpiEventStateT theActualEvent, SaHpiBoolT asserted);
234+
235 // official hpi functions
236
237 // get sensor data