File: new_sim_event_log.cpp

package info (click to toggle)
openhpi 3.8.0-2.3
  • links: PTS
  • area: main
  • in suites: sid, trixie
  • size: 31,888 kB
  • sloc: ansic: 225,326; cpp: 63,687; java: 16,472; cs: 15,161; python: 11,884; sh: 11,508; makefile: 4,945; perl: 1,529; xml: 36; asm: 13
file content (245 lines) | stat: -rw-r--r-- 6,796 bytes parent folder | download | duplicates (4)
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
238
239
240
241
242
243
244
245
/** 
 * @file    new_sim_event_log.cpp
 *
 * The file includes the implementation of a class for an event log wrapper:
 * NewSimulatorEventLog
 * 
 * @author  Lars Wetzel <larswetzel@users.sourceforge.net>
 * @version 0.1
 * @date    2010
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  This
 * file and program are licensed under a BSD style license.  See
 * the Copying file included with the OpenHPI distribution for
 * full licensing terms.
 *  
 * This EventLog class is adapted from the simulator plugin.
 * Thanks to 
 *      W. David Ashley <dashley@us.ibm.com>
 *      Suntrupth S Yadav <suntrupth@in.ibm.com>
 */

#include "new_sim_event_log.h"
#include "new_sim_log.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <glib.h>

/**
 * Constructor
 **/
NewSimulatorEventLog::NewSimulatorEventLog() {
	
   capability = SAHPI_EVTLOG_CAPABILITY_ENTRY_ADD |
                SAHPI_EVTLOG_CAPABILITY_CLEAR |
                SAHPI_EVTLOG_CAPABILITY_TIME_SET |
                SAHPI_EVTLOG_CAPABILITY_STATE_SET;
}

                      
/**
 * Destructor
 **/
NewSimulatorEventLog::~NewSimulatorEventLog() {
}

// Official HPI functions
/**
 * HPI function saHpiEventLogInfoGet()
 * 
 * See also the description of the function inside the specification or header file.
 * 
 * @param hstate pointer on the handler state struct
 * @param info pointer to the returned Event Log information
 * 
 * @return HPI return code
 **/
SaErrorT NewSimulatorEventLog::IfELGetInfo(oh_handler_state *hstate, 
                                           SaHpiEventLogInfoT *info) {
   if (info == NULL)
      return SA_ERR_HPI_INVALID_PARAMS;
   
   return oh_el_info(hstate->elcache, info);
}


/**
 * HPI function saHpiEventLogStateSet()
 * 
 * See also the description of the function inside the specification or header file.
 * 
 * @param hstate pointer on the handler state struct
 * @param state event Log state to be set
 * 
 * @return HPI return code
 **/
SaErrorT NewSimulatorEventLog::IfELSetState(oh_handler_state *hstate, 
                                            SaHpiBoolT state) {
                                            	
   return oh_el_enableset(hstate->elcache, state);
}


/**
 * HPI function saHpiEventLogStateGet()
 * 
 * See also the description of the function inside the specification or header file.
 * 
 * @param hstate pointer on the handler state struct
 * @param state pointer to the current event log enable state
 * 
 * @return HPI return code
 **/
SaErrorT NewSimulatorEventLog::IfELGetState(oh_handler_state *hstate, 
                                            SaHpiBoolT *state) {
   SaHpiEventLogInfoT elinfo;
   SaErrorT rv;
   	
   rv = oh_el_info(hstate->elcache, &elinfo);
   *state = elinfo.Enabled;
	
   return rv;
}


/**
 * HPI function saHpiEventLogTimeSet()
 * 
 * See also the description of the function inside the specification or header file.
 * 
 * @param hstate pointer on the handler state struct
 * @param time  time to which the Event Log clock should be set
 * 
 * @return HPI return code
 **/
SaErrorT NewSimulatorEventLog::IfELSetTime(oh_handler_state *hstate, 
                                           SaHpiTimeT time) {

   return oh_el_timeset(hstate->elcache, time);
}


/**
 * HPI function saHpiEventLogEntryAdd()
 * 
 * See also the description of the function inside the specification or header file.
 * 
 * @param hstate pointer on the handler state struct
 * @param event  pointer to event data to write to the Event Log
 * 
 * @return HPI return code
 **/
SaErrorT NewSimulatorEventLog::IfELAddEntry(oh_handler_state *hstate, 
                                            const SaHpiEventT *event) {
   
   if (!event)
       return SA_ERR_HPI_INVALID_PARAMS;
                             	
   return  oh_el_append(hstate->elcache, event, NULL, NULL);
}


/**
 * HPI function saHpiEventLogEntryGet()
 * 
 * See also the description of the function inside the specification or header file.
 * 
 * @param hstate pointer on the handler state struct
 * @param current  Identifier of event log entry to retrieve
 * @param prev Event Log entry identifier for the previous entry
 * @param next  Event Log entry identifier for the next entry
 * @param entry Pointer to retrieved Event Log entry
 * @param rdr Pointer to structure to receive resource data record
 * @param rptentry Pointer to structure to receive RPT entry
 * 
 * @return HPI return code
 **/
SaErrorT NewSimulatorEventLog::IfELGetEntry(oh_handler_state *hstate, 
                        SaHpiEventLogEntryIdT current,
		                SaHpiEventLogEntryIdT *prev, 
		                SaHpiEventLogEntryIdT *next,
		                SaHpiEventLogEntryT   *entry, 
		                SaHpiRdrT             *rdr, 
		                SaHpiRptEntryT        *rptentry) {
   
   SaErrorT rv;
   oh_el_entry tmpentry, *tmpentryptr;
   tmpentryptr = &tmpentry;
   
   if (!prev || !next || !entry)
      return SA_ERR_HPI_INVALID_PARAMS;

   rv = oh_el_get(hstate->elcache, current, prev, next, &tmpentryptr);
   
   if (rv != SA_OK) 
      return rv;

   memcpy(entry, &(tmpentryptr->event), sizeof(SaHpiEventLogEntryT));
   
   if (rdr)
      memcpy(rdr, &tmpentryptr->rdr, sizeof(SaHpiRdrT));
   
   if (rptentry)
      memcpy(rptentry, &(tmpentryptr->res), sizeof(SaHpiRptEntryT));
   
   return rv;
}


/**
 * HPI function saHpiEventLogClear()
 * 
 * See also the description of the function inside the specification or header file.
 * 
 * @param hstate pointer on the handler state struct
 * 
 * @return HPI return code
 **/
SaErrorT NewSimulatorEventLog::IfELClear(oh_handler_state *hstate) {

   return oh_el_clear(hstate->elcache); 
}


/**
 * HPI function saHpiEventLogOverflowReset()
 * 
 * See also the description of the function inside the specification or header file.
 * 
 * @param hstate pointer on the handler state struct
 * 
 * @return HPI return code
 **/
SaErrorT NewSimulatorEventLog::IfELOverflow(oh_handler_state *hstate) {

   return oh_el_overflowreset(hstate->elcache);
}


/**
 * HPI function saHpiEventLogCapabilitiesGet()
 * 
 * See also the description of the function inside the specification or header file.
 * 
 * @param hstate pointer on the handler state struct
 * @param caps Pointer to store the Event Log Capabilities value
 * 
 * @return HPI return code
 **/
SaErrorT NewSimulatorEventLog::IfELGetCaps(oh_handler_state *hstate, 
                                   SaHpiEventLogCapabilitiesT *caps) {

   *caps = capability;
   
   if (hstate->elcache->info.OverflowResetable) {
      *caps |= SAHPI_EVTLOG_CAPABILITY_OVERFLOW_RESET;
   }
   
   return SA_OK;
}