blob: b8cc0aaecaea81bf8737b2743bceb21f897828c5 [file] [log] [blame]
vishwabmcba0bd5f2015-09-30 16:50:23 +05301#include "apphandler.h"
2#include "ipmid-api.h"
Chris Austen6caf28b2015-10-13 12:40:40 -05003#include "ipmid.H"
vishwabmcba0bd5f2015-09-30 16:50:23 +05304#include <stdio.h>
5#include <string.h>
Chris Austen6caf28b2015-10-13 12:40:40 -05006#include <stdint.h>
Adriana Kobylak3a552e12015-10-19 16:11:00 -05007#include <systemd/sd-bus.h>
8
9extern sd_bus *bus;
vishwabmcba0bd5f2015-09-30 16:50:23 +053010
Chris Austen6caf28b2015-10-13 12:40:40 -050011void register_netfn_app_functions() __attribute__((constructor));
vishwabmcba0bd5f2015-09-30 16:50:23 +053012
Chris Austen7303bdc2016-04-17 11:50:54 -050013#define DEVICE_FW1 2
14#define DEVICE_FW2 3
15#define DEVICE_AUX 11
16
vishwa36993272015-11-20 12:43:49 -060017//---------------------------------------------------------------------
18// Called by Host on seeing a SMS_ATN bit set. Return a hardcoded
19// value of 0x2 indicating we need Host read some data.
20//-------------------------------------------------------------------
21ipmi_ret_t ipmi_app_get_msg_flags(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
22 ipmi_request_t request, ipmi_response_t response,
23 ipmi_data_len_t data_len, ipmi_context_t context)
24{
25 // Generic return from IPMI commands.
26 ipmi_ret_t rc = IPMI_CC_OK;
Chris Austen6caf28b2015-10-13 12:40:40 -050027
vishwa36993272015-11-20 12:43:49 -060028 printf("IPMI APP GET MSG FLAGS returning with [bit:2] set\n");
29
30 // From IPMI spec V2.0 for Get Message Flags Command :
31 // bit:[1] from LSB : 1b = Event Message Buffer Full.
32 // Return as 0 if Event Message Buffer is not supported,
33 // or when the Event Message buffer is disabled.
34 // TODO. For now. assume its not disabled and send "0x2" anyway:
35
36 uint8_t set_event_msg_buffer_full = 0x2;
37 *data_len = sizeof(set_event_msg_buffer_full);
38
39 // Pack the actual response
40 memcpy(response, &set_event_msg_buffer_full, *data_len);
41
42 return rc;
43}
44
45//-------------------------------------------------------------------
46// Called by Host post response from Get_Message_Flags
47//-------------------------------------------------------------------
Adriana Kobylak3a552e12015-10-19 16:11:00 -050048ipmi_ret_t ipmi_app_read_event(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
49 ipmi_request_t request, ipmi_response_t response,
Chris Austen6caf28b2015-10-13 12:40:40 -050050 ipmi_data_len_t data_len, ipmi_context_t context)
51{
52 ipmi_ret_t rc = IPMI_CC_OK;
vishwa36993272015-11-20 12:43:49 -060053 printf("IPMI APP READ EVENT command received\n");
Chris Austen6caf28b2015-10-13 12:40:40 -050054
vishwa36993272015-11-20 12:43:49 -060055 // TODO : For now, this is catering only to the Soft Power Off via OEM SEL
56 // mechanism. If we need to make this generically used for some
57 // other conditions, then we can take advantage of context pointer.
58
59 struct oem_sel_timestamped soft_off = {0};
60 *data_len = sizeof(struct oem_sel_timestamped);
61
62 // either id[0] -or- id[1] can be filled in. We will use id[0]
63 soft_off.id[0] = SEL_OEM_ID_0;
64 soft_off.id[1] = SEL_OEM_ID_0;
65 soft_off.type = SEL_RECORD_TYPE_OEM;
66
67 // Following 3 bytes are from IANA Manufactre_Id field. See below
68 soft_off.manuf_id[0]= 0x41;
69 soft_off.manuf_id[1]= 0xA7;
70 soft_off.manuf_id[2]= 0x00;
71
72 // per IPMI spec NetFuntion for OEM
73 soft_off.netfun = 0x3A;
74
75 // Mechanism to kick start soft shutdown.
76 soft_off.cmd = CMD_POWER;
77 soft_off.data[0] = SOFT_OFF;
78
79 // All '0xFF' since unused.
80 memset(&soft_off.data[1], 0xFF, 3);
81
82 // Pack the actual response
83 memcpy(response, &soft_off, *data_len);
Chris Austen6caf28b2015-10-13 12:40:40 -050084 return rc;
Chris Austen6caf28b2015-10-13 12:40:40 -050085}
86
Adriana Kobylak3a552e12015-10-19 16:11:00 -050087ipmi_ret_t ipmi_app_set_acpi_power_state(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
88 ipmi_request_t request, ipmi_response_t response,
Chris Austen6caf28b2015-10-13 12:40:40 -050089 ipmi_data_len_t data_len, ipmi_context_t context)
90{
91 ipmi_ret_t rc = IPMI_CC_OK;
92 *data_len = 0;
93
94 printf("IPMI SET ACPI STATE Ignoring for now\n");
95 return rc;
96}
97
Chris Austen7303bdc2016-04-17 11:50:54 -050098
99typedef struct
100{
101 char major;
102 char minor;
Chris Austen176c9652016-04-30 16:32:17 -0500103 uint16_t d[2];
Chris Austen7303bdc2016-04-17 11:50:54 -0500104} rev_t;
105
106
107/* Currently only supports the vx.x-x-[-x] format Will return -1 if not in */
108/* the format this routine knows how to parse */
109/* version = v0.6-19-gf363f61-dirty */
110/* ^ ^ ^^ ^ */
111/* | | |----------|-- additional details */
112/* | |---------------- Minor */
113/* |------------------ Major */
114/* Additional details : If the option group exists it will force Auxiliary */
115/* Firmware Revision Information 4th byte to 1 indicating the build was */
116/* derived with additional edits */
117int convert_version(const char *p, rev_t *rev)
118{
119 char *s, *token;
120 char hexbyte[5];
121 int l;
Chris Austen176c9652016-04-30 16:32:17 -0500122 uint16_t commits;
Chris Austen7303bdc2016-04-17 11:50:54 -0500123
124 if (*p != 'v')
125 return -1;
126 p++;
127
128 s = strdup(p);
129 token = strtok(s,".-");
130
131 rev->major = (int8_t) atoi(token);
132
133 token = strtok(NULL, ".-");
134 rev->minor = (int8_t) atoi(token);
135
136 // Capture the number of commits on top of the minor tag.
137 // I'm using BE format like the ipmi spec asked for
138 token = strtok(NULL,".-");
Chris Austen7303bdc2016-04-17 11:50:54 -0500139
Chris Austen176c9652016-04-30 16:32:17 -0500140 if (token) {
141 commits = (int16_t) atoi(token);
142 rev->d[0] = (commits>>8) | (commits<<8);
Chris Austen7303bdc2016-04-17 11:50:54 -0500143
Chris Austen176c9652016-04-30 16:32:17 -0500144 // commit number we skip
145 token = strtok(NULL,".-");
Chris Austen7303bdc2016-04-17 11:50:54 -0500146
Chris Austen176c9652016-04-30 16:32:17 -0500147 } else {
148 rev->d[0] = 0;
149 }
Chris Austen7303bdc2016-04-17 11:50:54 -0500150
151 // Any value of the optional parameter forces it to 1
Chris Austen176c9652016-04-30 16:32:17 -0500152 if (token)
153 token = strtok(NULL,".-");
154
155 rev->d[1] = (token != NULL) ? 1 : 0;
Chris Austen7303bdc2016-04-17 11:50:54 -0500156
157 free(s);
158 return 0;
159}
160
Adriana Kobylak3a552e12015-10-19 16:11:00 -0500161ipmi_ret_t ipmi_app_get_device_id(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
162 ipmi_request_t request, ipmi_response_t response,
Chris Austen6caf28b2015-10-13 12:40:40 -0500163 ipmi_data_len_t data_len, ipmi_context_t context)
164{
165 ipmi_ret_t rc = IPMI_CC_OK;
Chris Austen7303bdc2016-04-17 11:50:54 -0500166 const char *busname = "org.openbmc.Inventory";
167 const char *objname = "/org/openbmc/inventory/system/chassis/motherboard/bmc";
168 const char *iface = "org.openbmc.InventoryItem";
169 char *ver = NULL;
170 int r;
171 rev_t rev = {0};
Chris Austen6caf28b2015-10-13 12:40:40 -0500172
Patrick Williams76b51f62015-10-28 12:14:56 -0500173 // TODO:
174 // This value is the IANA number assigned to "IBM Platform Firmware
175 // Division", which is also used by our service processor. We may want
176 // a different number or at least a different version?
Chris Austen7303bdc2016-04-17 11:50:54 -0500177 uint8_t dev_id[] = {0, 0, 0, 0, 2, 0xD, 0x41, 0xA7, 0x00, 0x43, 0x40, 0, 0, 0, 0};
Chris Austen6caf28b2015-10-13 12:40:40 -0500178
179 // Data length
Chris Austen7303bdc2016-04-17 11:50:54 -0500180 *data_len = sizeof(dev_id);
181
182 r = sd_bus_get_property_string(bus,busname,objname,iface,"version", NULL, &ver);
183 if ( r < 0 ) {
184 fprintf(stderr, "Failed to obtain version property: %s\n", strerror(-r));
185 } else {
186 r = convert_version(ver, &rev);
187 if( r >= 0 ) {
188 // bit7 identifies state of SDR repository, hence the mask
189 dev_id[DEVICE_FW1] |= 0x7F & rev.major;
Adriana Kobylak0e912642016-06-22 16:54:39 -0500190
191 rev.minor = (rev.minor > 99 ? 99 : rev.minor);
192 dev_id[DEVICE_FW2] = rev.minor % 10 + (rev.minor / 10) * 16;
Chris Austen7303bdc2016-04-17 11:50:54 -0500193 memcpy(&dev_id[DEVICE_AUX], rev.d, 4);
194 }
195 }
Chris Austen6caf28b2015-10-13 12:40:40 -0500196
197 // Pack the actual response
Chris Austen7303bdc2016-04-17 11:50:54 -0500198 memcpy(response, &dev_id, *data_len);
Chris Austen6caf28b2015-10-13 12:40:40 -0500199 return rc;
200}
201
Adriana Kobylakd100ee52015-10-20 17:02:37 -0500202ipmi_ret_t ipmi_app_get_device_guid(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
203 ipmi_request_t request, ipmi_response_t response,
204 ipmi_data_len_t data_len, ipmi_context_t context)
205{
206 const char *busname = "org.openbmc.control.Chassis";
207 const char *objname = "/org/openbmc/control/chassis0";
Adriana Kobylak31bccae2015-11-05 13:31:06 -0600208 const char *iface = "org.freedesktop.DBus.Properties";
209 const char *chassis_iface = "org.openbmc.control.Chassis";
vishwa1eaea4f2016-02-26 11:57:40 -0600210 sd_bus_message *reply = NULL;
Adriana Kobylakd100ee52015-10-20 17:02:37 -0500211 sd_bus_error error = SD_BUS_ERROR_NULL;
212 int r = 0;
213 char *uuid = NULL;
214
Adriana Kobylakd100ee52015-10-20 17:02:37 -0500215 // UUID is in RFC4122 format. Ex: 61a39523-78f2-11e5-9862-e6402cfc3223
216 // Per IPMI Spec 2.0 need to convert to 16 hex bytes and reverse the byte order
217 // Ex: 0x2332fc2c40e66298e511f2782395a361
218
219 const int resp_size = 16; // Response is 16 hex bytes per IPMI Spec
220 uint8_t resp_uuid[resp_size]; // Array to hold the formatted response
221 int resp_loc = resp_size-1; // Point resp end of array to save in reverse order
222 int i = 0;
223 char *tokptr = NULL;
vishwa1eaea4f2016-02-26 11:57:40 -0600224 char *id_octet = NULL;
225
226 // Status code.
227 ipmi_ret_t rc = IPMI_CC_OK;
228 *data_len = 0;
229
230 printf("IPMI GET DEVICE GUID\n");
231
232 // Call Get properties method with the interface and property name
233 r = sd_bus_call_method(bus,busname,objname,iface,
234 "Get",&error, &reply, "ss",
235 chassis_iface, "uuid");
236 if (r < 0)
237 {
238 fprintf(stderr, "Failed to call Get Method: %s\n", strerror(-r));
239 rc = IPMI_CC_UNSPECIFIED_ERROR;
240 goto finish;
241 }
242
243 r = sd_bus_message_read(reply, "v", "s", &uuid);
244 if (r < 0 || uuid == NULL)
245 {
246 fprintf(stderr, "Failed to get a response: %s", strerror(-r));
247 rc = IPMI_CC_RESPONSE_ERROR;
248 goto finish;
249 }
Adriana Kobylakd100ee52015-10-20 17:02:37 -0500250
251 // Traverse the UUID
vishwa1eaea4f2016-02-26 11:57:40 -0600252 id_octet = strtok_r(uuid, "-", &tokptr); // Get the UUID octects separated by dash
Adriana Kobylakd100ee52015-10-20 17:02:37 -0500253
254 if (id_octet == NULL)
vishwa1eaea4f2016-02-26 11:57:40 -0600255 {
256 // Error
Adriana Kobylakd100ee52015-10-20 17:02:37 -0500257 fprintf(stderr, "Unexpected UUID format: %s", uuid);
vishwa1eaea4f2016-02-26 11:57:40 -0600258 rc = IPMI_CC_RESPONSE_ERROR;
259 goto finish;
Adriana Kobylakd100ee52015-10-20 17:02:37 -0500260 }
261
262 while (id_octet != NULL)
263 {
264 // Calculate the octet string size since it varies
265 // Divide it by 2 for the array size since 1 byte is built from 2 chars
266 int tmp_size = strlen(id_octet)/2;
267
268 for(i = 0; i < tmp_size; i++)
269 {
Joel Stanley38310cd2015-11-25 17:32:08 +1030270 char tmp_array[3] = {0}; // Holder of the 2 chars that will become a byte
Adriana Kobylakd100ee52015-10-20 17:02:37 -0500271 strncpy(tmp_array, id_octet, 2); // 2 chars at a time
272
273 int resp_byte = strtoul(tmp_array, NULL, 16); // Convert to hex byte
274 memcpy((void*)&resp_uuid[resp_loc], &resp_byte, 1); // Copy end to first
275 resp_loc--;
276 id_octet+=2; // Finished with the 2 chars, advance
277 }
278 id_octet=strtok_r(NULL, "-", &tokptr); // Get next octet
279 }
280
281 // Data length
282 *data_len = resp_size;
283
284 // Pack the actual response
285 memcpy(response, &resp_uuid, *data_len);
286
vishwa1eaea4f2016-02-26 11:57:40 -0600287finish:
Adriana Kobylakd100ee52015-10-20 17:02:37 -0500288 sd_bus_error_free(&error);
vishwa1eaea4f2016-02-26 11:57:40 -0600289 reply = sd_bus_message_unref(reply);
Adriana Kobylakd100ee52015-10-20 17:02:37 -0500290
291 return rc;
292}
Chris Austen6caf28b2015-10-13 12:40:40 -0500293
Adriana Kobylak3a552e12015-10-19 16:11:00 -0500294ipmi_ret_t ipmi_app_get_bt_capabilities(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
295 ipmi_request_t request, ipmi_response_t response,
vishwabmcba0bd5f2015-09-30 16:50:23 +0530296 ipmi_data_len_t data_len, ipmi_context_t context)
297{
298 printf("Handling Netfn:[0x%X], Cmd:[0x%X]\n",netfn,cmd);
299
300 // Status code.
301 ipmi_ret_t rc = IPMI_CC_OK;
302
Chris Austen6caf28b2015-10-13 12:40:40 -0500303 uint8_t str[] = {0x01, MAX_IPMI_BUFFER, MAX_IPMI_BUFFER, 0x0A, 0x01};
vishwabmcba0bd5f2015-09-30 16:50:23 +0530304
305 // Data length
306 *data_len = sizeof(str);
307
308 // Pack the actual response
309 memcpy(response, &str, *data_len);
310
311 return rc;
312}
313
Chris Austen6caf28b2015-10-13 12:40:40 -0500314
315struct set_wd_data_t {
316 uint8_t t_use;
317 uint8_t t_action;
318 uint8_t preset;
319 uint8_t flags;
320 uint8_t ls;
321 uint8_t ms;
322} __attribute__ ((packed));
323
324
325
Adriana Kobylak3a552e12015-10-19 16:11:00 -0500326ipmi_ret_t ipmi_app_set_watchdog(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
327 ipmi_request_t request, ipmi_response_t response,
Chris Austen6caf28b2015-10-13 12:40:40 -0500328 ipmi_data_len_t data_len, ipmi_context_t context)
329{
Adriana Kobylak3a552e12015-10-19 16:11:00 -0500330 const char *busname = "org.openbmc.watchdog.Host";
Chris Austen454acfe2015-10-29 23:03:34 -0500331 const char *objname = "/org/openbmc/watchdog/host0";
Adriana Kobylak3a552e12015-10-19 16:11:00 -0500332 const char *iface = "org.openbmc.Watchdog";
vishwa1eaea4f2016-02-26 11:57:40 -0600333 sd_bus_message *reply = NULL;
Adriana Kobylak3a552e12015-10-19 16:11:00 -0500334 sd_bus_error error = SD_BUS_ERROR_NULL;
335 int r = 0;
Chris Austen6caf28b2015-10-13 12:40:40 -0500336
337 set_wd_data_t *reqptr = (set_wd_data_t*) request;
338 uint16_t timer = 0;
Adriana Kobylak3a552e12015-10-19 16:11:00 -0500339 uint32_t timer_ms = 0;
Chris Austen6caf28b2015-10-13 12:40:40 -0500340
341 *data_len = 0;
342
Adriana Kobylak3a552e12015-10-19 16:11:00 -0500343 // Get number of 100ms intervals
Chris Austen6caf28b2015-10-13 12:40:40 -0500344 timer = (((uint16_t)reqptr->ms) << 8) + reqptr->ls;
Adriana Kobylak3a552e12015-10-19 16:11:00 -0500345 // Get timer value in ms
346 timer_ms = timer * 100;
Chris Austen6caf28b2015-10-13 12:40:40 -0500347
348 printf("WATCHDOG SET Timer:[0x%X] 100ms intervals\n",timer);
349
Adriana Kobylak3a552e12015-10-19 16:11:00 -0500350 // Set watchdog timer
vishwa1eaea4f2016-02-26 11:57:40 -0600351 r = sd_bus_call_method(bus, busname, objname, iface,
352 "set", &error, &reply, "i", timer_ms);
353 if(r < 0)
Adriana Kobylak0896be32015-10-22 13:27:23 -0500354 {
vishwa1eaea4f2016-02-26 11:57:40 -0600355 fprintf(stderr, "Failed to call the SET method: %s\n", strerror(-r));
356 goto finish;
Adriana Kobylak0896be32015-10-22 13:27:23 -0500357 }
358
Adriana Kobylak3a552e12015-10-19 16:11:00 -0500359 sd_bus_error_free(&error);
vishwa1eaea4f2016-02-26 11:57:40 -0600360 reply = sd_bus_message_unref(reply);
Chris Austen6caf28b2015-10-13 12:40:40 -0500361
vishwa1eaea4f2016-02-26 11:57:40 -0600362 // Stop the current watchdog if any
363 r = sd_bus_call_method(bus, busname, objname, iface,
364 "stop", &error, &reply, NULL);
365 if(r < 0)
366 {
367 fprintf(stderr, "Failed to call the STOP method: %s\n", strerror(-r));
368 goto finish;
369 }
370
371 if (reqptr->t_use & 0x40)
372 {
373 sd_bus_error_free(&error);
374 reply = sd_bus_message_unref(reply);
375
376 // Start the watchdog if requested
377 r = sd_bus_call_method(bus, busname, objname, iface,
378 "start", &error, &reply, NULL);
379 if(r < 0)
380 {
381 fprintf(stderr, "Failed to call the START method: %s\n", strerror(-r));
382 }
383 }
384
385finish:
386 sd_bus_error_free(&error);
387 reply = sd_bus_message_unref(reply);
388
389 return (r < 0) ? -1 : IPMI_CC_OK;
Chris Austen6caf28b2015-10-13 12:40:40 -0500390}
391
392
Adriana Kobylak3a552e12015-10-19 16:11:00 -0500393ipmi_ret_t ipmi_app_reset_watchdog(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
394 ipmi_request_t request, ipmi_response_t response,
Chris Austen6caf28b2015-10-13 12:40:40 -0500395 ipmi_data_len_t data_len, ipmi_context_t context)
396{
Adriana Kobylak3a552e12015-10-19 16:11:00 -0500397 const char *busname = "org.openbmc.watchdog.Host";
Chris Austen454acfe2015-10-29 23:03:34 -0500398 const char *objname = "/org/openbmc/watchdog/host0";
Adriana Kobylak3a552e12015-10-19 16:11:00 -0500399 const char *iface = "org.openbmc.Watchdog";
vishwa1eaea4f2016-02-26 11:57:40 -0600400 sd_bus_message *reply = NULL;
Adriana Kobylak3a552e12015-10-19 16:11:00 -0500401 sd_bus_error error = SD_BUS_ERROR_NULL;
402 int r = 0;
403
Chris Austen6caf28b2015-10-13 12:40:40 -0500404 // Status code.
405 ipmi_ret_t rc = IPMI_CC_OK;
406 *data_len = 0;
407
408 printf("WATCHDOG RESET\n");
Adriana Kobylak3a552e12015-10-19 16:11:00 -0500409
410 // Refresh watchdog
vishwa1eaea4f2016-02-26 11:57:40 -0600411 r = sd_bus_call_method(bus, busname, objname, iface,
412 "poke", &error, &reply, NULL);
Adriana Kobylak3a552e12015-10-19 16:11:00 -0500413 if (r < 0) {
vishwa1eaea4f2016-02-26 11:57:40 -0600414 fprintf(stderr, "Failed to add reset watchdog: %s\n", strerror(-r));
415 rc = -1;
Adriana Kobylak3a552e12015-10-19 16:11:00 -0500416 }
417
418 sd_bus_error_free(&error);
vishwa1eaea4f2016-02-26 11:57:40 -0600419 reply = sd_bus_message_unref(reply);
Adriana Kobylak3a552e12015-10-19 16:11:00 -0500420
Chris Austen6caf28b2015-10-13 12:40:40 -0500421 return rc;
422}
423
Chris Austenc2cd29d2016-02-05 20:02:29 -0600424// ATTENTION: This ipmi function is very hardcoded on purpose
425// OpenBMC does not fully support IPMI. This command is useful
426// to have around because it enables testing of interfaces with
427// the IPMI tool.
428#define GET_CHANNEL_INFO_CHANNEL_OFFSET 0
429// IPMI Table 6-2
430#define IPMI_CHANNEL_TYPE_IPMB 1
431// IPMI Table 6-3
432#define IPMI_CHANNEL_MEDIUM_TYPE_OTHER 6
433
434ipmi_ret_t ipmi_app_channel_info(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
435 ipmi_request_t request, ipmi_response_t response,
436 ipmi_data_len_t data_len, ipmi_context_t context)
437{
438 ipmi_ret_t rc = IPMI_CC_OK;
439 uint8_t resp[] = {
440 1,
441 IPMI_CHANNEL_MEDIUM_TYPE_OTHER,
442 IPMI_CHANNEL_TYPE_IPMB,
443 1,0x41,0xA7,0x00,0,0};
444 uint8_t *p = (uint8_t*) request;
445
446 printf("IPMI APP GET CHANNEL INFO\n");
447
tomjose7ec0add2016-06-27 07:59:28 -0500448 // The supported channels numbers are 1 and 8.
449 // Channel Number E is used as way to identify the current channel
450 // that the command is being is received from.
tomjose13fb4412016-03-08 14:02:34 -0600451 if (*p == 0xe || *p == 1 || *p == 8) {
Chris Austenc2cd29d2016-02-05 20:02:29 -0600452
453 *data_len = sizeof(resp);
454 memcpy(response, resp, *data_len);
455
456 } else {
457 rc = IPMI_CC_PARM_OUT_OF_RANGE;
458 *data_len = 0;
459 }
460
461 return rc;
462}
463
Adriana Kobylakdfc8d772015-10-20 09:34:48 -0500464ipmi_ret_t ipmi_app_set_bmc_global_enables(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
465 ipmi_request_t request, ipmi_response_t response,
466 ipmi_data_len_t data_len, ipmi_context_t context)
467{
468 ipmi_ret_t rc = IPMI_CC_OK;
469 *data_len = 0;
Chris Austen6caf28b2015-10-13 12:40:40 -0500470
Adriana Kobylakdfc8d772015-10-20 09:34:48 -0500471 // Event and message logging enabled by default so return for now
472 printf("IPMI APP SET BMC GLOBAL ENABLES Ignoring for now\n");
473
474 return rc;
475}
Chris Austen6caf28b2015-10-13 12:40:40 -0500476
477
478
Adriana Kobylak3a552e12015-10-19 16:11:00 -0500479ipmi_ret_t ipmi_app_wildcard_handler(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
480 ipmi_request_t request, ipmi_response_t response,
vishwabmcba0bd5f2015-09-30 16:50:23 +0530481 ipmi_data_len_t data_len, ipmi_context_t context)
482{
483 printf("Handling WILDCARD Netfn:[0x%X], Cmd:[0x%X]\n",netfn, cmd);
484
485 // Status code.
486 ipmi_ret_t rc = IPMI_CC_OK;
487
488 *data_len = strlen("THIS IS WILDCARD");
489
490 // Now pack actual response
491 memcpy(response, "THIS IS WILDCARD", *data_len);
492
493 return rc;
494}
495
Chris Austen6caf28b2015-10-13 12:40:40 -0500496void register_netfn_app_functions()
vishwabmcba0bd5f2015-09-30 16:50:23 +0530497{
498 printf("Registering NetFn:[0x%X], Cmd:[0x%X]\n",NETFUN_APP, IPMI_CMD_GET_CAP_BIT);
Chris Austen6caf28b2015-10-13 12:40:40 -0500499 ipmi_register_callback(NETFUN_APP, IPMI_CMD_GET_CAP_BIT, NULL, ipmi_app_get_bt_capabilities);
500
501 printf("Registering NetFn:[0x%X], Cmd:[0x%X]\n",NETFUN_APP, IPMI_CMD_WILDCARD);
502 ipmi_register_callback(NETFUN_APP, IPMI_CMD_WILDCARD, NULL, ipmi_app_wildcard_handler);
503
504 printf("Registering NetFn:[0x%X], Cmd:[0x%X]\n",NETFUN_APP, IPMI_CMD_RESET_WD);
505 ipmi_register_callback(NETFUN_APP, IPMI_CMD_RESET_WD, NULL, ipmi_app_reset_watchdog);
506
507 printf("Registering NetFn:[0x%X], Cmd:[0x%X]\n",NETFUN_APP, IPMI_CMD_SET_WD);
508 ipmi_register_callback(NETFUN_APP, IPMI_CMD_SET_WD, NULL, ipmi_app_set_watchdog);
509
510 printf("Registering NetFn:[0x%X], Cmd:[0x%X]\n",NETFUN_APP, IPMI_CMD_GET_DEVICE_ID);
511 ipmi_register_callback(NETFUN_APP, IPMI_CMD_GET_DEVICE_ID, NULL, ipmi_app_get_device_id);
512
Adriana Kobylakd100ee52015-10-20 17:02:37 -0500513 printf("Registering NetFn:[0x%X], Cmd:[0x%X]\n",NETFUN_APP, IPMI_CMD_GET_DEVICE_GUID);
514 ipmi_register_callback(NETFUN_APP, IPMI_CMD_GET_DEVICE_GUID, NULL, ipmi_app_get_device_guid);
515
Chris Austen6caf28b2015-10-13 12:40:40 -0500516 printf("Registering NetFn:[0x%X], Cmd:[0x%X]\n",NETFUN_APP, IPMI_CMD_SET_ACPI);
517 ipmi_register_callback(NETFUN_APP, IPMI_CMD_SET_ACPI, NULL, ipmi_app_set_acpi_power_state);
518
519 printf("Registering NetFn:[0x%X], Cmd:[0x%X]\n",NETFUN_APP, IPMI_CMD_READ_EVENT);
520 ipmi_register_callback(NETFUN_APP, IPMI_CMD_READ_EVENT, NULL, ipmi_app_read_event);
Adriana Kobylakdfc8d772015-10-20 09:34:48 -0500521
522 printf("Registering NetFn:[0x%X], Cmd:[0x%X]\n",NETFUN_APP,
523 IPMI_CMD_SET_BMC_GLOBAL_ENABLES);
524 ipmi_register_callback(NETFUN_APP, IPMI_CMD_SET_BMC_GLOBAL_ENABLES, NULL,
525 ipmi_app_set_bmc_global_enables);
526
vishwa36993272015-11-20 12:43:49 -0600527 printf("Registering NetFn:[0x%X], Cmd:[0x%X]\n",NETFUN_APP, IPMI_CMD_GET_MSG_FLAGS);
528 ipmi_register_callback(NETFUN_APP, IPMI_CMD_GET_MSG_FLAGS, NULL, ipmi_app_get_msg_flags);
529
Chris Austenc2cd29d2016-02-05 20:02:29 -0600530
531 printf("Registering NetFn:[0x%X], Cmd:[0x%X]\n",NETFUN_APP, IPMI_CMD_GET_CHAN_INFO);
532 ipmi_register_callback(NETFUN_APP, IPMI_CMD_GET_CHAN_INFO, NULL, ipmi_app_channel_info);
533
534
535
vishwabmcba0bd5f2015-09-30 16:50:23 +0530536 return;
537}
538
Chris Austen6caf28b2015-10-13 12:40:40 -0500539