From patchwork Fri Jan 30 00:31:50 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Stanley X-Patchwork-Id: 434693 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 5D59614007D for ; Fri, 30 Jan 2015 11:32:37 +1100 (AEDT) Received: from ozlabs.org (ozlabs.org [103.22.144.67]) by lists.ozlabs.org (Postfix) with ESMTP id 36F8F1A0D34 for ; Fri, 30 Jan 2015 11:32:37 +1100 (AEDT) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Received: from mail-pa0-x230.google.com (mail-pa0-x230.google.com [IPv6:2607:f8b0:400e:c03::230]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 2F19D1A0D21 for ; Fri, 30 Jan 2015 11:32:33 +1100 (AEDT) Received: by mail-pa0-f48.google.com with SMTP id ey11so45120996pad.7 for ; Thu, 29 Jan 2015 16:32:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jms.id.au; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=dVFEWjgfyt2qKwjCsjv2FM2z5bpKXA4ZRk/7zfaNaOs=; b=kBdxZG4KeXO4ary9hims7CJ3WhNA02+q1+PZ5BOIGNNyJzgJsU+x2cXOpdLrajt485 Z/Wf6S5Mw9rJTekyb3bNSeSun2aQdopehuRbWfhoKdoYn4FxlmSZx9R734PV/sLinvEn yOCz32BOENdQOODUGa7wRuDShJKYtmf2jA0y8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=dVFEWjgfyt2qKwjCsjv2FM2z5bpKXA4ZRk/7zfaNaOs=; b=iO0nFcWtAi8Qn8xQ4upVRRZo/AVz1K3g1kpWcMixLzakLCnXi+ry4SzYnj32uXlBWX Ipp85HzLEe0bz+bbeKLrA5wXGOrkbAv88Cbh/exUg1tuQ7/XuuumK+MRfogWzWOxFpOQ VODztTq1fAm75NXK0ta8E4xF7POpmrzhOO1REnkmk8emF3Xh8IehqqSlO80SHzAmk3dP IN3cEEAUw1lhieYfEsnebeyCTdaCsdfAGsBN5VaAPmZcYs8M/2l3RFJFRC+weDbZ4734 9gFwwDZUQVdx+OOCg/r5FcDSlhp/BRFCqMfzVrcirfFltOq1fX3iQ/MgMNpNOCo5+YUK vRAg== X-Gm-Message-State: ALoCoQkrdIA+On2MSYtG9YyKoZ93N7a9mG84j9SRsa53bu6FgRyYA0u8W20EELWU8aAt0BNymhjQ X-Received: by 10.66.102.41 with SMTP id fl9mr4731592pab.7.1422577951491; Thu, 29 Jan 2015 16:32:31 -0800 (PST) Received: from icarus.au.ibm.com (ppp121-45-7-169.lns20.adl2.internode.on.net. [121.45.7.169]) by mx.google.com with ESMTPSA id ca2sm8864916pbc.68.2015.01.29.16.32.28 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 29 Jan 2015 16:32:30 -0800 (PST) From: Joel Stanley To: skiboot@lists.ozlabs.org Date: Fri, 30 Jan 2015 11:01:50 +1030 Message-Id: <1422577911-18394-5-git-send-email-joel@jms.id.au> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1422577911-18394-1-git-send-email-joel@jms.id.au> References: <1422577911-18394-1-git-send-email-joel@jms.id.au> Subject: [Skiboot] [PATCH 4/5] ipmi: Message Linux to perform graceful shutdown X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" This sends the previously unused OPAL_MSG_SHUTDOWN using opal_queue_msg to initiate a graceful shutdown. The message provides a single parameter indicating weather the shutdown is will result in a power-off, or a reboot. Signed-off-by: Joel Stanley --- hw/ipmi/ipmi-sel.c | 22 ++++++++++++++++++++++ include/opal.h | 2 +- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/hw/ipmi/ipmi-sel.c b/hw/ipmi/ipmi-sel.c index 301e559..291f279 100644 --- a/hw/ipmi/ipmi-sel.c +++ b/hw/ipmi/ipmi-sel.c @@ -21,6 +21,7 @@ #include #include #include +#include /* OEM SEL fields */ #define SEL_OEM_ID_0 0x55 @@ -37,6 +38,9 @@ #define CMD_AMI_POWER 0x04 #define CMD_AMI_PNOR_ACCESS 0x07 +#define SOFT_OFF 0x00 +#define SOFT_REBOOT 0x01 + struct oem_sel { /* SEL header */ uint8_t id[2]; @@ -176,6 +180,23 @@ int ipmi_elog_commit(struct errorlog *elog_buf) return 0; } +static void sel_power(uint8_t power) +{ + switch (power) { + case SOFT_OFF: + prlog(PR_NOTICE, "IPMI: soft shutdown requested\n"); + opal_queue_msg(OPAL_MSG_SHUTDOWN, NULL, NULL, SOFT_OFF); + break; + case SOFT_REBOOT: + prlog(PR_NOTICE, "IPMI: soft reboot rqeuested\n"); + opal_queue_msg(OPAL_MSG_SHUTDOWN, NULL, NULL, SOFT_REBOOT); + break; + default: + prlog(PR_WARNING, "IPMI: requested bad power state: %02x\n", + power); + } +} + static void dump_sel(struct oem_sel *sel) { const int level = PR_DEBUG; @@ -224,6 +245,7 @@ void ipmi_parse_sel(struct ipmi_msg *msg) switch (sel.cmd) { case CMD_AMI_POWER: + sel_power(sel.data[0]); break; case CMD_AMI_PNOR_ACCESS: break; diff --git a/include/opal.h b/include/opal.h index 6c9b13a..679a0d9 100644 --- a/include/opal.h +++ b/include/opal.h @@ -395,7 +395,7 @@ enum OpalMessageType { */ OPAL_MSG_MEM_ERR, OPAL_MSG_EPOW, - OPAL_MSG_SHUTDOWN, + OPAL_MSG_SHUTDOWN, /* params[0] = 1 reboot, 0 shutdown */ OPAL_MSG_HMI_EVT, OPAL_MSG_DPO, OPAL_MSG_TYPE_MAX,