static int64_t opal_cec_reboot2(uint32_t reboot_type, char *diag) { struct errorlog *buf; switch (reboot_type) { case OPAL_REBOOT_NORMAL: return opal_cec_reboot(); case OPAL_REBOOT_PLATFORM_ERROR: prlog(PR_EMERG, "OPAL: Reboot requested due to Platform error."); buf = opal_elog_create(&e_info(OPAL_RC_ABNORMAL_REBOOT), 0); if (buf) { log_append_msg(buf, "OPAL: Reboot requested due to Platform error."); if (diag) { /* Add user section "DESC" */ log_add_section(buf, 0x44455350); log_append_data(buf, diag, strlen(diag)); log_commit(buf); } } else { prerror("OPAL: failed to log an error\n"); } return xscom_trigger_xstop(); default: printf("OPAL: Unsupported reboot request %d\n", reboot_type); return OPAL_UNSUPPORTED; break; } return OPAL_SUCCESS; }
void log_error(struct opal_err_info *e_info, void *data, uint16_t size, const char *fmt, ...) { struct errorlog *buf; int tag = 0x44455343; /* ASCII of DESC */ va_list list; char err_msg[250]; va_start(list, fmt); vsnprintf(err_msg, sizeof(err_msg), fmt, list); va_end(list); /* Log the error on to Sapphire console */ prerror("%s", err_msg); buf = opal_elog_create(e_info); if (buf == NULL) prerror("ELOG: Error getting buffer to log error\n"); else { opal_elog_update_user_dump(buf, err_msg, tag, strlen(err_msg)); /* Append any number of call out dumps */ if (e_info->call_out) e_info->call_out(buf, data, size); if (platform.elog_commit(buf)) prerror("ELOG: Re-try error logging\n"); } }