Adriana Kobylak | 40814c6 | 2015-10-27 15:58:44 -0500 | [diff] [blame] | 1 | #include "chassishandler.h" |
| 2 | #include "ipmid-api.h" |
| 3 | #include <stdio.h> |
| 4 | #include <string.h> |
| 5 | #include <stdint.h> |
Brad Bishop | 3551868 | 2016-07-22 08:35:41 -0400 | [diff] [blame] | 6 | #include <mapper.h> |
Adriana Kobylak | 40814c6 | 2015-10-27 15:58:44 -0500 | [diff] [blame] | 7 | |
ratagupt | a6f6bff | 2016-04-04 06:20:11 -0500 | [diff] [blame] | 8 | |
| 9 | //Defines |
| 10 | #define SET_PARM_VERSION 1 |
| 11 | #define SET_PARM_BOOT_FLAGS_PERMANENT 0x40 //boot flags data1 7th bit on |
| 12 | #define SET_PARM_BOOT_FLAGS_VALID_ONE_TIME 0x80 //boot flags data1 8th bit on |
| 13 | #define SET_PARM_BOOT_FLAGS_VALID_PERMANENT 0xC0 //boot flags data1 7 & 8 bit on |
| 14 | |
| 15 | |
| 16 | |
vishwa | 3699327 | 2015-11-20 12:43:49 -0600 | [diff] [blame] | 17 | // OpenBMC Chassis Manager dbus framework |
| 18 | const char *chassis_bus_name = "org.openbmc.control.Chassis"; |
| 19 | const char *chassis_object_name = "/org/openbmc/control/chassis0"; |
| 20 | const char *chassis_intf_name = "org.openbmc.control.Chassis"; |
| 21 | |
shgoupf | d84fbbf | 2015-12-17 10:05:51 +0800 | [diff] [blame] | 22 | |
Adriana Kobylak | 40814c6 | 2015-10-27 15:58:44 -0500 | [diff] [blame] | 23 | void register_netfn_chassis_functions() __attribute__((constructor)); |
| 24 | |
shgoupf | d84fbbf | 2015-12-17 10:05:51 +0800 | [diff] [blame] | 25 | // Host settings in dbus |
| 26 | // Service name should be referenced by connection name got via object mapper |
| 27 | const char *settings_object_name = "/org/openbmc/settings/host0"; |
| 28 | const char *settings_intf_name = "org.freedesktop.DBus.Properties"; |
| 29 | const char *host_intf_name = "org.openbmc.settings.Host"; |
| 30 | |
ratagupt | a6f6bff | 2016-04-04 06:20:11 -0500 | [diff] [blame] | 31 | int dbus_get_property(const char *name, char **buf) |
shgoupf | d84fbbf | 2015-12-17 10:05:51 +0800 | [diff] [blame] | 32 | { |
| 33 | sd_bus_error error = SD_BUS_ERROR_NULL; |
| 34 | sd_bus_message *m = NULL; |
| 35 | sd_bus *bus = NULL; |
| 36 | char *temp_buf = NULL; |
| 37 | char *connection = NULL; |
| 38 | int r; |
| 39 | |
Brad Bishop | 3551868 | 2016-07-22 08:35:41 -0400 | [diff] [blame] | 40 | // Get the system bus where most system services are provided. |
| 41 | bus = ipmid_get_sd_bus_connection(); |
shgoupf | d84fbbf | 2015-12-17 10:05:51 +0800 | [diff] [blame] | 42 | |
Brad Bishop | 3551868 | 2016-07-22 08:35:41 -0400 | [diff] [blame] | 43 | r = mapper_get_service(bus, settings_object_name, &connection); |
shgoupf | d84fbbf | 2015-12-17 10:05:51 +0800 | [diff] [blame] | 44 | if (r < 0) { |
| 45 | fprintf(stderr, "Failed to get connection, return value: %d.\n", r); |
| 46 | goto finish; |
| 47 | } |
| 48 | |
shgoupf | d84fbbf | 2015-12-17 10:05:51 +0800 | [diff] [blame] | 49 | /* |
| 50 | * Bus, service, object path, interface and method are provided to call |
| 51 | * the method. |
| 52 | * Signatures and input arguments are provided by the arguments at the |
| 53 | * end. |
| 54 | */ |
| 55 | r = sd_bus_call_method(bus, |
| 56 | connection, /* service to contact */ |
| 57 | settings_object_name, /* object path */ |
| 58 | settings_intf_name, /* interface name */ |
| 59 | "Get", /* method name */ |
| 60 | &error, /* object to return error in */ |
| 61 | &m, /* return message on success */ |
| 62 | "ss", /* input signature */ |
| 63 | host_intf_name, /* first argument */ |
ratagupt | a6f6bff | 2016-04-04 06:20:11 -0500 | [diff] [blame] | 64 | name); /* second argument */ |
shgoupf | d84fbbf | 2015-12-17 10:05:51 +0800 | [diff] [blame] | 65 | |
| 66 | if (r < 0) { |
| 67 | fprintf(stderr, "Failed to issue method call: %s\n", error.message); |
| 68 | goto finish; |
| 69 | } |
| 70 | |
| 71 | /* |
| 72 | * The output should be parsed exactly the same as the output formatting |
| 73 | * specified. |
| 74 | */ |
| 75 | r = sd_bus_message_read(m, "v", "s", &temp_buf); |
| 76 | if (r < 0) { |
| 77 | fprintf(stderr, "Failed to parse response message: %s\n", strerror(-r)); |
| 78 | goto finish; |
| 79 | } |
| 80 | |
| 81 | asprintf(buf, "%s", temp_buf); |
| 82 | /* *buf = (char*) malloc(strlen(temp_buf)); |
| 83 | if (*buf) { |
| 84 | strcpy(*buf, temp_buf); |
| 85 | } |
| 86 | */ |
| 87 | printf("IPMID boot option property get: {%s}.\n", (char *) temp_buf); |
| 88 | |
| 89 | finish: |
| 90 | sd_bus_error_free(&error); |
| 91 | sd_bus_message_unref(m); |
| 92 | free(connection); |
| 93 | |
| 94 | return r; |
| 95 | } |
| 96 | |
ratagupt | a6f6bff | 2016-04-04 06:20:11 -0500 | [diff] [blame] | 97 | int dbus_set_property(const char * name, const char *value) |
shgoupf | d84fbbf | 2015-12-17 10:05:51 +0800 | [diff] [blame] | 98 | { |
| 99 | sd_bus_error error = SD_BUS_ERROR_NULL; |
| 100 | sd_bus_message *m = NULL; |
| 101 | sd_bus *bus = NULL; |
| 102 | char *connection = NULL; |
| 103 | int r; |
| 104 | |
Brad Bishop | 3551868 | 2016-07-22 08:35:41 -0400 | [diff] [blame] | 105 | // Get the system bus where most system services are provided. |
| 106 | bus = ipmid_get_sd_bus_connection(); |
shgoupf | d84fbbf | 2015-12-17 10:05:51 +0800 | [diff] [blame] | 107 | |
Brad Bishop | 3551868 | 2016-07-22 08:35:41 -0400 | [diff] [blame] | 108 | r = mapper_get_service(bus, settings_object_name, &connection); |
shgoupf | d84fbbf | 2015-12-17 10:05:51 +0800 | [diff] [blame] | 109 | if (r < 0) { |
| 110 | fprintf(stderr, "Failed to get connection, return value: %d.\n", r); |
| 111 | goto finish; |
| 112 | } |
| 113 | |
shgoupf | d84fbbf | 2015-12-17 10:05:51 +0800 | [diff] [blame] | 114 | /* |
| 115 | * Bus, service, object path, interface and method are provided to call |
| 116 | * the method. |
| 117 | * Signatures and input arguments are provided by the arguments at the |
| 118 | * end. |
| 119 | */ |
| 120 | r = sd_bus_call_method(bus, |
| 121 | connection, /* service to contact */ |
| 122 | settings_object_name, /* object path */ |
| 123 | settings_intf_name, /* interface name */ |
| 124 | "Set", /* method name */ |
| 125 | &error, /* object to return error in */ |
| 126 | &m, /* return message on success */ |
| 127 | "ssv", /* input signature */ |
| 128 | host_intf_name, /* first argument */ |
ratagupt | a6f6bff | 2016-04-04 06:20:11 -0500 | [diff] [blame] | 129 | name, /* second argument */ |
shgoupf | d84fbbf | 2015-12-17 10:05:51 +0800 | [diff] [blame] | 130 | "s", /* third argument */ |
ratagupt | a6f6bff | 2016-04-04 06:20:11 -0500 | [diff] [blame] | 131 | value); /* fourth argument */ |
shgoupf | d84fbbf | 2015-12-17 10:05:51 +0800 | [diff] [blame] | 132 | |
| 133 | if (r < 0) { |
| 134 | fprintf(stderr, "Failed to issue method call: %s\n", error.message); |
| 135 | goto finish; |
| 136 | } |
| 137 | |
ratagupt | a6f6bff | 2016-04-04 06:20:11 -0500 | [diff] [blame] | 138 | printf("IPMID boot option property set: {%s}.\n", value); |
shgoupf | d84fbbf | 2015-12-17 10:05:51 +0800 | [diff] [blame] | 139 | |
| 140 | finish: |
| 141 | sd_bus_error_free(&error); |
| 142 | sd_bus_message_unref(m); |
| 143 | free(connection); |
| 144 | |
| 145 | return r; |
| 146 | } |
| 147 | |
Adriana Kobylak | 40814c6 | 2015-10-27 15:58:44 -0500 | [diff] [blame] | 148 | struct get_sys_boot_options_t { |
| 149 | uint8_t parameter; |
| 150 | uint8_t set; |
| 151 | uint8_t block; |
| 152 | } __attribute__ ((packed)); |
| 153 | |
shgoupf | d84fbbf | 2015-12-17 10:05:51 +0800 | [diff] [blame] | 154 | struct get_sys_boot_options_response_t { |
| 155 | uint8_t version; |
| 156 | uint8_t parm; |
| 157 | uint8_t data[5]; |
| 158 | } __attribute__ ((packed)); |
| 159 | |
| 160 | struct set_sys_boot_options_t { |
| 161 | uint8_t parameter; |
| 162 | uint8_t data[8]; |
| 163 | } __attribute__ ((packed)); |
| 164 | |
Adriana Kobylak | 40814c6 | 2015-10-27 15:58:44 -0500 | [diff] [blame] | 165 | ipmi_ret_t ipmi_chassis_wildcard(ipmi_netfn_t netfn, ipmi_cmd_t cmd, |
| 166 | ipmi_request_t request, ipmi_response_t response, |
| 167 | ipmi_data_len_t data_len, ipmi_context_t context) |
| 168 | { |
| 169 | printf("Handling CHASSIS WILDCARD Netfn:[0x%X], Cmd:[0x%X]\n",netfn, cmd); |
| 170 | // Status code. |
| 171 | ipmi_ret_t rc = IPMI_CC_OK; |
| 172 | *data_len = 0; |
| 173 | return rc; |
| 174 | } |
| 175 | |
vishwa | 3699327 | 2015-11-20 12:43:49 -0600 | [diff] [blame] | 176 | //------------------------------------------------------------ |
| 177 | // Calls into Chassis Control Dbus object to do the power off |
| 178 | //------------------------------------------------------------ |
Chris Austen | 7888c4d | 2015-12-03 15:26:20 -0600 | [diff] [blame] | 179 | int ipmi_chassis_power_control(const char *method) |
vishwa | 3699327 | 2015-11-20 12:43:49 -0600 | [diff] [blame] | 180 | { |
| 181 | // sd_bus error |
| 182 | int rc = 0; |
| 183 | |
| 184 | // SD Bus error report mechanism. |
| 185 | sd_bus_error bus_error = SD_BUS_ERROR_NULL; |
| 186 | |
| 187 | // Response from the call. Although there is no response for this call, |
| 188 | // obligated to mention this to make compiler happy. |
| 189 | sd_bus_message *response = NULL; |
| 190 | |
| 191 | // Gets a hook onto either a SYSTEM or SESSION bus |
| 192 | sd_bus *bus_type = ipmid_get_sd_bus_connection(); |
| 193 | |
| 194 | rc = sd_bus_call_method(bus_type, // On the System Bus |
| 195 | chassis_bus_name, // Service to contact |
| 196 | chassis_object_name, // Object path |
| 197 | chassis_intf_name, // Interface name |
Chris Austen | 7888c4d | 2015-12-03 15:26:20 -0600 | [diff] [blame] | 198 | method, // Method to be called |
vishwa | 3699327 | 2015-11-20 12:43:49 -0600 | [diff] [blame] | 199 | &bus_error, // object to return error |
| 200 | &response, // Response buffer if any |
| 201 | NULL); // No input arguments |
| 202 | if(rc < 0) |
| 203 | { |
| 204 | fprintf(stderr,"ERROR initiating Power Off:[%s]\n",bus_error.message); |
| 205 | } |
| 206 | else |
| 207 | { |
| 208 | printf("Chassis Power Off initiated successfully\n"); |
| 209 | } |
| 210 | |
| 211 | sd_bus_error_free(&bus_error); |
| 212 | sd_bus_message_unref(response); |
| 213 | |
| 214 | return rc; |
| 215 | } |
| 216 | |
Chris Austen | 7888c4d | 2015-12-03 15:26:20 -0600 | [diff] [blame] | 217 | |
vishwa | 3699327 | 2015-11-20 12:43:49 -0600 | [diff] [blame] | 218 | //---------------------------------------------------------------------- |
| 219 | // Chassis Control commands |
| 220 | //---------------------------------------------------------------------- |
| 221 | ipmi_ret_t ipmi_chassis_control(ipmi_netfn_t netfn, ipmi_cmd_t cmd, |
| 222 | ipmi_request_t request, ipmi_response_t response, |
| 223 | ipmi_data_len_t data_len, ipmi_context_t context) |
| 224 | { |
| 225 | // Error from power off. |
| 226 | int rc = 0; |
| 227 | |
| 228 | // No response for this command. |
| 229 | *data_len = 0; |
| 230 | |
| 231 | // Catch the actual operaton by peeking into request buffer |
| 232 | uint8_t chassis_ctrl_cmd = *(uint8_t *)request; |
| 233 | printf("Chassis Control Command: Operation:[0x%X]\n",chassis_ctrl_cmd); |
| 234 | |
| 235 | switch(chassis_ctrl_cmd) |
| 236 | { |
| 237 | case CMD_POWER_OFF: |
Chris Austen | 7888c4d | 2015-12-03 15:26:20 -0600 | [diff] [blame] | 238 | rc = ipmi_chassis_power_control("powerOff"); |
vishwa | 3699327 | 2015-11-20 12:43:49 -0600 | [diff] [blame] | 239 | break; |
Chris Austen | 7888c4d | 2015-12-03 15:26:20 -0600 | [diff] [blame] | 240 | case CMD_HARD_RESET: |
| 241 | rc = ipmi_chassis_power_control("reboot"); |
| 242 | break; |
vishwa | 3699327 | 2015-11-20 12:43:49 -0600 | [diff] [blame] | 243 | default: |
| 244 | { |
| 245 | fprintf(stderr, "Invalid Chassis Control command:[0x%X] received\n",chassis_ctrl_cmd); |
| 246 | rc = -1; |
| 247 | } |
| 248 | } |
| 249 | |
| 250 | return ( (rc < 0) ? IPMI_CC_INVALID : IPMI_CC_OK); |
| 251 | } |
| 252 | |
shgoupf | d84fbbf | 2015-12-17 10:05:51 +0800 | [diff] [blame] | 253 | struct bootOptionTypeMap_t { |
| 254 | uint8_t ipmibootflag; |
| 255 | char dbusname[8]; |
| 256 | }; |
| 257 | |
| 258 | #define INVALID_STRING "Invalid" |
| 259 | // dbus supports this list of boot devices. |
| 260 | bootOptionTypeMap_t g_bootOptionTypeMap_t[] = { |
| 261 | |
| 262 | {0x01, "Network"}, |
| 263 | {0x02, "Disk"}, |
| 264 | {0x03, "Safe"}, |
| 265 | {0x05, "CDROM"}, |
| 266 | {0x06, "Setup"}, |
| 267 | {0x00, "Default"}, |
| 268 | {0xFF, INVALID_STRING} |
| 269 | }; |
| 270 | |
| 271 | uint8_t get_ipmi_boot_option(char *p) { |
| 272 | |
| 273 | bootOptionTypeMap_t *s = g_bootOptionTypeMap_t; |
| 274 | |
| 275 | while (s->ipmibootflag != 0xFF) { |
| 276 | if (!strcmp(s->dbusname,p)) |
| 277 | break; |
| 278 | s++; |
| 279 | } |
| 280 | |
| 281 | if (!s->ipmibootflag) |
| 282 | printf("Failed to find Sensor Type %s\n", p); |
| 283 | |
| 284 | return s->ipmibootflag; |
| 285 | } |
| 286 | |
| 287 | char* get_boot_option_by_ipmi(uint8_t p) { |
| 288 | |
| 289 | bootOptionTypeMap_t *s = g_bootOptionTypeMap_t; |
| 290 | |
| 291 | while (s->ipmibootflag != 0xFF) { |
| 292 | |
| 293 | if (s->ipmibootflag == p) |
| 294 | break; |
| 295 | |
| 296 | s++; |
| 297 | } |
| 298 | |
| 299 | |
| 300 | if (!s->ipmibootflag) |
| 301 | printf("Failed to find Sensor Type 0x%x\n", p); |
| 302 | |
| 303 | return s->dbusname; |
| 304 | } |
| 305 | |
Adriana Kobylak | 40814c6 | 2015-10-27 15:58:44 -0500 | [diff] [blame] | 306 | ipmi_ret_t ipmi_chassis_get_sys_boot_options(ipmi_netfn_t netfn, ipmi_cmd_t cmd, |
| 307 | ipmi_request_t request, ipmi_response_t response, |
| 308 | ipmi_data_len_t data_len, ipmi_context_t context) |
| 309 | { |
shgoupf | d84fbbf | 2015-12-17 10:05:51 +0800 | [diff] [blame] | 310 | ipmi_ret_t rc = IPMI_CC_PARM_NOT_SUPPORTED; |
| 311 | char *p = NULL; |
| 312 | get_sys_boot_options_response_t *resp = (get_sys_boot_options_response_t *) response; |
| 313 | get_sys_boot_options_t *reqptr = (get_sys_boot_options_t*) request; |
| 314 | uint8_t s; |
Adriana Kobylak | 40814c6 | 2015-10-27 15:58:44 -0500 | [diff] [blame] | 315 | |
| 316 | printf("IPMI GET_SYS_BOOT_OPTIONS\n"); |
| 317 | |
shgoupf | d84fbbf | 2015-12-17 10:05:51 +0800 | [diff] [blame] | 318 | memset(resp,0,sizeof(*resp)); |
| 319 | resp->version = SET_PARM_VERSION; |
| 320 | resp->parm = 5; |
ratagupt | a6f6bff | 2016-04-04 06:20:11 -0500 | [diff] [blame] | 321 | resp->data[0] = SET_PARM_BOOT_FLAGS_VALID_ONE_TIME; |
Adriana Kobylak | 40814c6 | 2015-10-27 15:58:44 -0500 | [diff] [blame] | 322 | |
shgoupf | d84fbbf | 2015-12-17 10:05:51 +0800 | [diff] [blame] | 323 | *data_len = sizeof(*resp); |
Adriana Kobylak | 40814c6 | 2015-10-27 15:58:44 -0500 | [diff] [blame] | 324 | |
shgoupf | d84fbbf | 2015-12-17 10:05:51 +0800 | [diff] [blame] | 325 | /* |
| 326 | * Parameter #5 means boot flags. Please refer to 28.13 of ipmi doc. |
| 327 | * This is the only parameter used by petitboot. |
| 328 | */ |
| 329 | if (reqptr->parameter == 5) { |
| 330 | |
ratagupt | a6f6bff | 2016-04-04 06:20:11 -0500 | [diff] [blame] | 331 | /* Get the boot device */ |
| 332 | int r = dbus_get_property("boot_flags",&p); |
shgoupf | d84fbbf | 2015-12-17 10:05:51 +0800 | [diff] [blame] | 333 | |
| 334 | if (r < 0) { |
ratagupt | a6f6bff | 2016-04-04 06:20:11 -0500 | [diff] [blame] | 335 | fprintf(stderr, "Dbus get property(boot_flags) failed for get_sys_boot_options.\n"); |
shgoupf | d84fbbf | 2015-12-17 10:05:51 +0800 | [diff] [blame] | 336 | rc = IPMI_CC_UNSPECIFIED_ERROR; |
| 337 | |
| 338 | } else { |
| 339 | |
| 340 | s = get_ipmi_boot_option(p); |
| 341 | resp->data[1] = (s << 2); |
| 342 | rc = IPMI_CC_OK; |
ratagupt | a6f6bff | 2016-04-04 06:20:11 -0500 | [diff] [blame] | 343 | |
shgoupf | d84fbbf | 2015-12-17 10:05:51 +0800 | [diff] [blame] | 344 | } |
| 345 | |
ratagupt | a6f6bff | 2016-04-04 06:20:11 -0500 | [diff] [blame] | 346 | if (p) |
| 347 | { |
| 348 | free(p); |
| 349 | p = NULL; |
| 350 | } |
| 351 | |
| 352 | /* Get the boot policy */ |
| 353 | r = dbus_get_property("boot_policy",&p); |
| 354 | |
| 355 | if (r < 0) { |
| 356 | fprintf(stderr, "Dbus get property(boot_policy) failed for get_sys_boot_options.\n"); |
| 357 | rc = IPMI_CC_UNSPECIFIED_ERROR; |
| 358 | |
| 359 | } else { |
| 360 | |
| 361 | printf("BootPolicy is[%s]", p); |
| 362 | resp->data[0] = (strncmp(p,"ONETIME",strlen("ONETIME"))==0) ? |
| 363 | SET_PARM_BOOT_FLAGS_VALID_ONE_TIME: |
| 364 | SET_PARM_BOOT_FLAGS_VALID_PERMANENT; |
| 365 | rc = IPMI_CC_OK; |
| 366 | |
| 367 | } |
| 368 | |
| 369 | |
shgoupf | d84fbbf | 2015-12-17 10:05:51 +0800 | [diff] [blame] | 370 | } else { |
Adriana Kobylak | 40814c6 | 2015-10-27 15:58:44 -0500 | [diff] [blame] | 371 | fprintf(stderr, "Unsupported parameter 0x%x\n", reqptr->parameter); |
shgoupf | d84fbbf | 2015-12-17 10:05:51 +0800 | [diff] [blame] | 372 | } |
| 373 | |
| 374 | if (p) |
| 375 | free(p); |
| 376 | |
| 377 | return rc; |
| 378 | } |
| 379 | |
| 380 | |
| 381 | |
| 382 | ipmi_ret_t ipmi_chassis_set_sys_boot_options(ipmi_netfn_t netfn, ipmi_cmd_t cmd, |
| 383 | ipmi_request_t request, ipmi_response_t response, |
| 384 | ipmi_data_len_t data_len, ipmi_context_t context) |
| 385 | { |
| 386 | ipmi_ret_t rc = IPMI_CC_OK; |
| 387 | char *s; |
| 388 | |
| 389 | printf("IPMI SET_SYS_BOOT_OPTIONS\n"); |
| 390 | |
| 391 | set_sys_boot_options_t *reqptr = (set_sys_boot_options_t *) request; |
| 392 | |
| 393 | // This IPMI command does not have any resposne data |
| 394 | *data_len = 0; |
| 395 | |
| 396 | /* 000101 |
| 397 | * Parameter #5 means boot flags. Please refer to 28.13 of ipmi doc. |
| 398 | * This is the only parameter used by petitboot. |
| 399 | */ |
| 400 | if (reqptr->parameter == 5) { |
| 401 | |
| 402 | s = get_boot_option_by_ipmi(((reqptr->data[1] & 0x3C) >> 2)); |
| 403 | |
| 404 | printf("%d: %s\n", __LINE__, s); |
| 405 | if (!strcmp(s,INVALID_STRING)) { |
| 406 | |
| 407 | rc = IPMI_CC_PARM_NOT_SUPPORTED; |
| 408 | |
| 409 | } else { |
| 410 | |
ratagupt | a6f6bff | 2016-04-04 06:20:11 -0500 | [diff] [blame] | 411 | int r = dbus_set_property("boot_flags",s); |
shgoupf | d84fbbf | 2015-12-17 10:05:51 +0800 | [diff] [blame] | 412 | |
| 413 | if (r < 0) { |
ratagupt | a6f6bff | 2016-04-04 06:20:11 -0500 | [diff] [blame] | 414 | fprintf(stderr, "Dbus set property(boot_flags) failed for set_sys_boot_options.\n"); |
shgoupf | d84fbbf | 2015-12-17 10:05:51 +0800 | [diff] [blame] | 415 | rc = IPMI_CC_UNSPECIFIED_ERROR; |
| 416 | } |
| 417 | } |
ratagupt | a6f6bff | 2016-04-04 06:20:11 -0500 | [diff] [blame] | 418 | |
| 419 | /* setting the boot policy */ |
| 420 | s = (char *)(((reqptr->data[0] & SET_PARM_BOOT_FLAGS_PERMANENT) == |
| 421 | SET_PARM_BOOT_FLAGS_PERMANENT) ?"PERMANENT":"ONETIME"); |
| 422 | |
| 423 | printf ( "\nBoot Policy is %s",s); |
| 424 | int r = dbus_set_property("boot_policy",s); |
| 425 | |
| 426 | if (r < 0) { |
| 427 | fprintf(stderr, "Dbus set property(boot_policy) failed for set_sys_boot_options.\n"); |
| 428 | rc = IPMI_CC_UNSPECIFIED_ERROR; |
| 429 | } |
shgoupf | d84fbbf | 2015-12-17 10:05:51 +0800 | [diff] [blame] | 430 | |
| 431 | } else { |
| 432 | fprintf(stderr, "Unsupported parameter 0x%x\n", reqptr->parameter); |
| 433 | rc = IPMI_CC_PARM_NOT_SUPPORTED; |
Adriana Kobylak | 40814c6 | 2015-10-27 15:58:44 -0500 | [diff] [blame] | 434 | } |
| 435 | |
| 436 | return rc; |
| 437 | } |
| 438 | |
| 439 | void register_netfn_chassis_functions() |
| 440 | { |
| 441 | printf("Registering NetFn:[0x%X], Cmd:[0x%X]\n",NETFUN_CHASSIS, IPMI_CMD_WILDCARD); |
| 442 | ipmi_register_callback(NETFUN_CHASSIS, IPMI_CMD_WILDCARD, NULL, ipmi_chassis_wildcard); |
| 443 | |
| 444 | printf("Registering NetFn:[0x%X], Cmd:[0x%X]\n",NETFUN_CHASSIS, IPMI_CMD_GET_SYS_BOOT_OPTIONS); |
| 445 | ipmi_register_callback(NETFUN_CHASSIS, IPMI_CMD_GET_SYS_BOOT_OPTIONS, NULL, ipmi_chassis_get_sys_boot_options); |
Adriana Kobylak | 40814c6 | 2015-10-27 15:58:44 -0500 | [diff] [blame] | 446 | |
vishwa | 3699327 | 2015-11-20 12:43:49 -0600 | [diff] [blame] | 447 | printf("Registering NetFn:[0x%X], Cmd:[0x%X]\n",NETFUN_CHASSIS, IPMI_CMD_CHASSIS_CONTROL); |
| 448 | ipmi_register_callback(NETFUN_CHASSIS, IPMI_CMD_CHASSIS_CONTROL, NULL, ipmi_chassis_control); |
shgoupf | d84fbbf | 2015-12-17 10:05:51 +0800 | [diff] [blame] | 449 | |
| 450 | printf("Registering NetFn:[0x%X], Cmd:[0x%X]\n", NETFUN_CHASSIS, IPMI_CMD_SET_SYS_BOOT_OPTIONS); |
| 451 | ipmi_register_callback(NETFUN_CHASSIS, IPMI_CMD_SET_SYS_BOOT_OPTIONS, NULL, ipmi_chassis_set_sys_boot_options); |
vishwa | 3699327 | 2015-11-20 12:43:49 -0600 | [diff] [blame] | 452 | } |
shgoupf | d84fbbf | 2015-12-17 10:05:51 +0800 | [diff] [blame] | 453 | |