blob: 71dba6629628dec8fd13357b3c4977628b646db0 [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;
190 dev_id[DEVICE_FW2] = rev.minor;
191 memcpy(&dev_id[DEVICE_AUX], rev.d, 4);
192 }
193 }
Chris Austen6caf28b2015-10-13 12:40:40 -0500194
195 // Pack the actual response
Chris Austen7303bdc2016-04-17 11:50:54 -0500196 memcpy(response, &dev_id, *data_len);
Chris Austen6caf28b2015-10-13 12:40:40 -0500197 return rc;
198}
199
Adriana Kobylakd100ee52015-10-20 17:02:37 -0500200ipmi_ret_t ipmi_app_get_device_guid(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
201 ipmi_request_t request, ipmi_response_t response,
202 ipmi_data_len_t data_len, ipmi_context_t context)
203{
204 const char *busname = "org.openbmc.control.Chassis";
205 const char *objname = "/org/openbmc/control/chassis0";
Adriana Kobylak31bccae2015-11-05 13:31:06 -0600206 const char *iface = "org.freedesktop.DBus.Properties";
207 const char *chassis_iface = "org.openbmc.control.Chassis";
vishwa1eaea4f2016-02-26 11:57:40 -0600208 sd_bus_message *reply = NULL;
Adriana Kobylakd100ee52015-10-20 17:02:37 -0500209 sd_bus_error error = SD_BUS_ERROR_NULL;
210 int r = 0;
211 char *uuid = NULL;
212
Adriana Kobylakd100ee52015-10-20 17:02:37 -0500213 // UUID is in RFC4122 format. Ex: 61a39523-78f2-11e5-9862-e6402cfc3223
214 // Per IPMI Spec 2.0 need to convert to 16 hex bytes and reverse the byte order
215 // Ex: 0x2332fc2c40e66298e511f2782395a361
216
217 const int resp_size = 16; // Response is 16 hex bytes per IPMI Spec
218 uint8_t resp_uuid[resp_size]; // Array to hold the formatted response
219 int resp_loc = resp_size-1; // Point resp end of array to save in reverse order
220 int i = 0;
221 char *tokptr = NULL;
vishwa1eaea4f2016-02-26 11:57:40 -0600222 char *id_octet = NULL;
223
224 // Status code.
225 ipmi_ret_t rc = IPMI_CC_OK;
226 *data_len = 0;
227
228 printf("IPMI GET DEVICE GUID\n");
229
230 // Call Get properties method with the interface and property name
231 r = sd_bus_call_method(bus,busname,objname,iface,
232 "Get",&error, &reply, "ss",
233 chassis_iface, "uuid");
234 if (r < 0)
235 {
236 fprintf(stderr, "Failed to call Get Method: %s\n", strerror(-r));
237 rc = IPMI_CC_UNSPECIFIED_ERROR;
238 goto finish;
239 }
240
241 r = sd_bus_message_read(reply, "v", "s", &uuid);
242 if (r < 0 || uuid == NULL)
243 {
244 fprintf(stderr, "Failed to get a response: %s", strerror(-r));
245 rc = IPMI_CC_RESPONSE_ERROR;
246 goto finish;
247 }
Adriana Kobylakd100ee52015-10-20 17:02:37 -0500248
249 // Traverse the UUID
vishwa1eaea4f2016-02-26 11:57:40 -0600250 id_octet = strtok_r(uuid, "-", &tokptr); // Get the UUID octects separated by dash
Adriana Kobylakd100ee52015-10-20 17:02:37 -0500251
252 if (id_octet == NULL)
vishwa1eaea4f2016-02-26 11:57:40 -0600253 {
254 // Error
Adriana Kobylakd100ee52015-10-20 17:02:37 -0500255 fprintf(stderr, "Unexpected UUID format: %s", uuid);
vishwa1eaea4f2016-02-26 11:57:40 -0600256 rc = IPMI_CC_RESPONSE_ERROR;
257 goto finish;
Adriana Kobylakd100ee52015-10-20 17:02:37 -0500258 }
259
260 while (id_octet != NULL)
261 {
262 // Calculate the octet string size since it varies
263 // Divide it by 2 for the array size since 1 byte is built from 2 chars
264 int tmp_size = strlen(id_octet)/2;
265
266 for(i = 0; i < tmp_size; i++)
267 {
Joel Stanley38310cd2015-11-25 17:32:08 +1030268 char tmp_array[3] = {0}; // Holder of the 2 chars that will become a byte
Adriana Kobylakd100ee52015-10-20 17:02:37 -0500269 strncpy(tmp_array, id_octet, 2); // 2 chars at a time
270
271 int resp_byte = strtoul(tmp_array, NULL, 16); // Convert to hex byte
272 memcpy((void*)&resp_uuid[resp_loc], &resp_byte, 1); // Copy end to first
273 resp_loc--;
274 id_octet+=2; // Finished with the 2 chars, advance
275 }
276 id_octet=strtok_r(NULL, "-", &tokptr); // Get next octet
277 }
278
279 // Data length
280 *data_len = resp_size;
281
282 // Pack the actual response
283 memcpy(response, &resp_uuid, *data_len);
284
vishwa1eaea4f2016-02-26 11:57:40 -0600285finish:
Adriana Kobylakd100ee52015-10-20 17:02:37 -0500286 sd_bus_error_free(&error);
vishwa1eaea4f2016-02-26 11:57:40 -0600287 reply = sd_bus_message_unref(reply);
Adriana Kobylakd100ee52015-10-20 17:02:37 -0500288
289 return rc;
290}
Chris Austen6caf28b2015-10-13 12:40:40 -0500291
Adriana Kobylak3a552e12015-10-19 16:11:00 -0500292ipmi_ret_t ipmi_app_get_bt_capabilities(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
293 ipmi_request_t request, ipmi_response_t response,
vishwabmcba0bd5f2015-09-30 16:50:23 +0530294 ipmi_data_len_t data_len, ipmi_context_t context)
295{
296 printf("Handling Netfn:[0x%X], Cmd:[0x%X]\n",netfn,cmd);
297
298 // Status code.
299 ipmi_ret_t rc = IPMI_CC_OK;
300
Chris Austen6caf28b2015-10-13 12:40:40 -0500301 uint8_t str[] = {0x01, MAX_IPMI_BUFFER, MAX_IPMI_BUFFER, 0x0A, 0x01};
vishwabmcba0bd5f2015-09-30 16:50:23 +0530302
303 // Data length
304 *data_len = sizeof(str);
305
306 // Pack the actual response
307 memcpy(response, &str, *data_len);
308
309 return rc;
310}
311
Chris Austen6caf28b2015-10-13 12:40:40 -0500312
313struct set_wd_data_t {
314 uint8_t t_use;
315 uint8_t t_action;
316 uint8_t preset;
317 uint8_t flags;
318 uint8_t ls;
319 uint8_t ms;
320} __attribute__ ((packed));
321
322
323
Adriana Kobylak3a552e12015-10-19 16:11:00 -0500324ipmi_ret_t ipmi_app_set_watchdog(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
325 ipmi_request_t request, ipmi_response_t response,
Chris Austen6caf28b2015-10-13 12:40:40 -0500326 ipmi_data_len_t data_len, ipmi_context_t context)
327{
Adriana Kobylak3a552e12015-10-19 16:11:00 -0500328 const char *busname = "org.openbmc.watchdog.Host";
Chris Austen454acfe2015-10-29 23:03:34 -0500329 const char *objname = "/org/openbmc/watchdog/host0";
Adriana Kobylak3a552e12015-10-19 16:11:00 -0500330 const char *iface = "org.openbmc.Watchdog";
vishwa1eaea4f2016-02-26 11:57:40 -0600331 sd_bus_message *reply = NULL;
Adriana Kobylak3a552e12015-10-19 16:11:00 -0500332 sd_bus_error error = SD_BUS_ERROR_NULL;
333 int r = 0;
Chris Austen6caf28b2015-10-13 12:40:40 -0500334
335 set_wd_data_t *reqptr = (set_wd_data_t*) request;
336 uint16_t timer = 0;
Adriana Kobylak3a552e12015-10-19 16:11:00 -0500337 uint32_t timer_ms = 0;
Chris Austen6caf28b2015-10-13 12:40:40 -0500338
339 *data_len = 0;
340
Adriana Kobylak3a552e12015-10-19 16:11:00 -0500341 // Get number of 100ms intervals
Chris Austen6caf28b2015-10-13 12:40:40 -0500342 timer = (((uint16_t)reqptr->ms) << 8) + reqptr->ls;
Adriana Kobylak3a552e12015-10-19 16:11:00 -0500343 // Get timer value in ms
344 timer_ms = timer * 100;
Chris Austen6caf28b2015-10-13 12:40:40 -0500345
346 printf("WATCHDOG SET Timer:[0x%X] 100ms intervals\n",timer);
347
Adriana Kobylak3a552e12015-10-19 16:11:00 -0500348 // Set watchdog timer
vishwa1eaea4f2016-02-26 11:57:40 -0600349 r = sd_bus_call_method(bus, busname, objname, iface,
350 "set", &error, &reply, "i", timer_ms);
351 if(r < 0)
Adriana Kobylak0896be32015-10-22 13:27:23 -0500352 {
vishwa1eaea4f2016-02-26 11:57:40 -0600353 fprintf(stderr, "Failed to call the SET method: %s\n", strerror(-r));
354 goto finish;
Adriana Kobylak0896be32015-10-22 13:27:23 -0500355 }
356
Adriana Kobylak3a552e12015-10-19 16:11:00 -0500357 sd_bus_error_free(&error);
vishwa1eaea4f2016-02-26 11:57:40 -0600358 reply = sd_bus_message_unref(reply);
Chris Austen6caf28b2015-10-13 12:40:40 -0500359
vishwa1eaea4f2016-02-26 11:57:40 -0600360 // Stop the current watchdog if any
361 r = sd_bus_call_method(bus, busname, objname, iface,
362 "stop", &error, &reply, NULL);
363 if(r < 0)
364 {
365 fprintf(stderr, "Failed to call the STOP method: %s\n", strerror(-r));
366 goto finish;
367 }
368
369 if (reqptr->t_use & 0x40)
370 {
371 sd_bus_error_free(&error);
372 reply = sd_bus_message_unref(reply);
373
374 // Start the watchdog if requested
375 r = sd_bus_call_method(bus, busname, objname, iface,
376 "start", &error, &reply, NULL);
377 if(r < 0)
378 {
379 fprintf(stderr, "Failed to call the START method: %s\n", strerror(-r));
380 }
381 }
382
383finish:
384 sd_bus_error_free(&error);
385 reply = sd_bus_message_unref(reply);
386
387 return (r < 0) ? -1 : IPMI_CC_OK;
Chris Austen6caf28b2015-10-13 12:40:40 -0500388}
389
390
Adriana Kobylak3a552e12015-10-19 16:11:00 -0500391ipmi_ret_t ipmi_app_reset_watchdog(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
392 ipmi_request_t request, ipmi_response_t response,
Chris Austen6caf28b2015-10-13 12:40:40 -0500393 ipmi_data_len_t data_len, ipmi_context_t context)
394{
Adriana Kobylak3a552e12015-10-19 16:11:00 -0500395 const char *busname = "org.openbmc.watchdog.Host";
Chris Austen454acfe2015-10-29 23:03:34 -0500396 const char *objname = "/org/openbmc/watchdog/host0";
Adriana Kobylak3a552e12015-10-19 16:11:00 -0500397 const char *iface = "org.openbmc.Watchdog";
vishwa1eaea4f2016-02-26 11:57:40 -0600398 sd_bus_message *reply = NULL;
Adriana Kobylak3a552e12015-10-19 16:11:00 -0500399 sd_bus_error error = SD_BUS_ERROR_NULL;
400 int r = 0;
401
Chris Austen6caf28b2015-10-13 12:40:40 -0500402 // Status code.
403 ipmi_ret_t rc = IPMI_CC_OK;
404 *data_len = 0;
405
406 printf("WATCHDOG RESET\n");
Adriana Kobylak3a552e12015-10-19 16:11:00 -0500407
408 // Refresh watchdog
vishwa1eaea4f2016-02-26 11:57:40 -0600409 r = sd_bus_call_method(bus, busname, objname, iface,
410 "poke", &error, &reply, NULL);
Adriana Kobylak3a552e12015-10-19 16:11:00 -0500411 if (r < 0) {
vishwa1eaea4f2016-02-26 11:57:40 -0600412 fprintf(stderr, "Failed to add reset watchdog: %s\n", strerror(-r));
413 rc = -1;
Adriana Kobylak3a552e12015-10-19 16:11:00 -0500414 }
415
416 sd_bus_error_free(&error);
vishwa1eaea4f2016-02-26 11:57:40 -0600417 reply = sd_bus_message_unref(reply);
Adriana Kobylak3a552e12015-10-19 16:11:00 -0500418
Chris Austen6caf28b2015-10-13 12:40:40 -0500419 return rc;
420}
421
Chris Austenc2cd29d2016-02-05 20:02:29 -0600422// ATTENTION: This ipmi function is very hardcoded on purpose
423// OpenBMC does not fully support IPMI. This command is useful
424// to have around because it enables testing of interfaces with
425// the IPMI tool.
426#define GET_CHANNEL_INFO_CHANNEL_OFFSET 0
427// IPMI Table 6-2
428#define IPMI_CHANNEL_TYPE_IPMB 1
429// IPMI Table 6-3
430#define IPMI_CHANNEL_MEDIUM_TYPE_OTHER 6
431
432ipmi_ret_t ipmi_app_channel_info(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
433 ipmi_request_t request, ipmi_response_t response,
434 ipmi_data_len_t data_len, ipmi_context_t context)
435{
436 ipmi_ret_t rc = IPMI_CC_OK;
437 uint8_t resp[] = {
438 1,
439 IPMI_CHANNEL_MEDIUM_TYPE_OTHER,
440 IPMI_CHANNEL_TYPE_IPMB,
441 1,0x41,0xA7,0x00,0,0};
442 uint8_t *p = (uint8_t*) request;
443
444 printf("IPMI APP GET CHANNEL INFO\n");
445
446 // I"m only supporting channel 1. 0xE is the 'default channel'
tomjose13fb4412016-03-08 14:02:34 -0600447 if (*p == 0xe || *p == 1 || *p == 8) {
Chris Austenc2cd29d2016-02-05 20:02:29 -0600448
449 *data_len = sizeof(resp);
450 memcpy(response, resp, *data_len);
451
452 } else {
453 rc = IPMI_CC_PARM_OUT_OF_RANGE;
454 *data_len = 0;
455 }
456
457 return rc;
458}
459
Adriana Kobylakdfc8d772015-10-20 09:34:48 -0500460ipmi_ret_t ipmi_app_set_bmc_global_enables(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
461 ipmi_request_t request, ipmi_response_t response,
462 ipmi_data_len_t data_len, ipmi_context_t context)
463{
464 ipmi_ret_t rc = IPMI_CC_OK;
465 *data_len = 0;
Chris Austen6caf28b2015-10-13 12:40:40 -0500466
Adriana Kobylakdfc8d772015-10-20 09:34:48 -0500467 // Event and message logging enabled by default so return for now
468 printf("IPMI APP SET BMC GLOBAL ENABLES Ignoring for now\n");
469
470 return rc;
471}
Chris Austen6caf28b2015-10-13 12:40:40 -0500472
473
474
Adriana Kobylak3a552e12015-10-19 16:11:00 -0500475ipmi_ret_t ipmi_app_wildcard_handler(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
476 ipmi_request_t request, ipmi_response_t response,
vishwabmcba0bd5f2015-09-30 16:50:23 +0530477 ipmi_data_len_t data_len, ipmi_context_t context)
478{
479 printf("Handling WILDCARD Netfn:[0x%X], Cmd:[0x%X]\n",netfn, cmd);
480
481 // Status code.
482 ipmi_ret_t rc = IPMI_CC_OK;
483
484 *data_len = strlen("THIS IS WILDCARD");
485
486 // Now pack actual response
487 memcpy(response, "THIS IS WILDCARD", *data_len);
488
489 return rc;
490}
491
Chris Austen6caf28b2015-10-13 12:40:40 -0500492void register_netfn_app_functions()
vishwabmcba0bd5f2015-09-30 16:50:23 +0530493{
494 printf("Registering NetFn:[0x%X], Cmd:[0x%X]\n",NETFUN_APP, IPMI_CMD_GET_CAP_BIT);
Chris Austen6caf28b2015-10-13 12:40:40 -0500495 ipmi_register_callback(NETFUN_APP, IPMI_CMD_GET_CAP_BIT, NULL, ipmi_app_get_bt_capabilities);
496
497 printf("Registering NetFn:[0x%X], Cmd:[0x%X]\n",NETFUN_APP, IPMI_CMD_WILDCARD);
498 ipmi_register_callback(NETFUN_APP, IPMI_CMD_WILDCARD, NULL, ipmi_app_wildcard_handler);
499
500 printf("Registering NetFn:[0x%X], Cmd:[0x%X]\n",NETFUN_APP, IPMI_CMD_RESET_WD);
501 ipmi_register_callback(NETFUN_APP, IPMI_CMD_RESET_WD, NULL, ipmi_app_reset_watchdog);
502
503 printf("Registering NetFn:[0x%X], Cmd:[0x%X]\n",NETFUN_APP, IPMI_CMD_SET_WD);
504 ipmi_register_callback(NETFUN_APP, IPMI_CMD_SET_WD, NULL, ipmi_app_set_watchdog);
505
506 printf("Registering NetFn:[0x%X], Cmd:[0x%X]\n",NETFUN_APP, IPMI_CMD_GET_DEVICE_ID);
507 ipmi_register_callback(NETFUN_APP, IPMI_CMD_GET_DEVICE_ID, NULL, ipmi_app_get_device_id);
508
Adriana Kobylakd100ee52015-10-20 17:02:37 -0500509 printf("Registering NetFn:[0x%X], Cmd:[0x%X]\n",NETFUN_APP, IPMI_CMD_GET_DEVICE_GUID);
510 ipmi_register_callback(NETFUN_APP, IPMI_CMD_GET_DEVICE_GUID, NULL, ipmi_app_get_device_guid);
511
Chris Austen6caf28b2015-10-13 12:40:40 -0500512 printf("Registering NetFn:[0x%X], Cmd:[0x%X]\n",NETFUN_APP, IPMI_CMD_SET_ACPI);
513 ipmi_register_callback(NETFUN_APP, IPMI_CMD_SET_ACPI, NULL, ipmi_app_set_acpi_power_state);
514
515 printf("Registering NetFn:[0x%X], Cmd:[0x%X]\n",NETFUN_APP, IPMI_CMD_READ_EVENT);
516 ipmi_register_callback(NETFUN_APP, IPMI_CMD_READ_EVENT, NULL, ipmi_app_read_event);
Adriana Kobylakdfc8d772015-10-20 09:34:48 -0500517
518 printf("Registering NetFn:[0x%X], Cmd:[0x%X]\n",NETFUN_APP,
519 IPMI_CMD_SET_BMC_GLOBAL_ENABLES);
520 ipmi_register_callback(NETFUN_APP, IPMI_CMD_SET_BMC_GLOBAL_ENABLES, NULL,
521 ipmi_app_set_bmc_global_enables);
522
vishwa36993272015-11-20 12:43:49 -0600523 printf("Registering NetFn:[0x%X], Cmd:[0x%X]\n",NETFUN_APP, IPMI_CMD_GET_MSG_FLAGS);
524 ipmi_register_callback(NETFUN_APP, IPMI_CMD_GET_MSG_FLAGS, NULL, ipmi_app_get_msg_flags);
525
Chris Austenc2cd29d2016-02-05 20:02:29 -0600526
527 printf("Registering NetFn:[0x%X], Cmd:[0x%X]\n",NETFUN_APP, IPMI_CMD_GET_CHAN_INFO);
528 ipmi_register_callback(NETFUN_APP, IPMI_CMD_GET_CHAN_INFO, NULL, ipmi_app_channel_info);
529
530
531
vishwabmcba0bd5f2015-09-30 16:50:23 +0530532 return;
533}
534
Chris Austen6caf28b2015-10-13 12:40:40 -0500535