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