From patchwork Thu Oct 6 08:06:05 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 117959 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 09C6BB6FD7 for ; Thu, 6 Oct 2011 19:20:15 +1100 (EST) Received: from localhost ([::1]:49080 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RBjBc-0000I4-2w for incoming@patchwork.ozlabs.org; Thu, 06 Oct 2011 04:20:12 -0400 Received: from eggs.gnu.org ([140.186.70.92]:44438) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RBixq-0002pQ-IB for qemu-devel@nongnu.org; Thu, 06 Oct 2011 04:06:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RBixV-000121-Nf for qemu-devel@nongnu.org; Thu, 06 Oct 2011 04:05:58 -0400 Received: from cantor2.suse.de ([195.135.220.15]:34681 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RBixU-00010M-Mo; Thu, 06 Oct 2011 04:05:37 -0400 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.221.2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx2.suse.de (Postfix) with ESMTP id 2610B91240; Thu, 6 Oct 2011 10:05:35 +0200 (CEST) From: Alexander Graf To: qemu-devel@nongnu.org Date: Thu, 6 Oct 2011 10:06:05 +0200 Message-Id: <1317888366-10509-64-git-send-email-agraf@suse.de> X-Mailer: git-send-email 1.7.3.4 In-Reply-To: <1317888366-10509-1-git-send-email-agraf@suse.de> References: <1317888366-10509-1-git-send-email-agraf@suse.de> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4-2.6 X-Received-From: 195.135.220.15 Cc: Blue Swirl , David Gibson , qemu-ppc@nongnu.org, Breno Leitao Subject: [Qemu-devel] [PATCH 63/64] pseries: Implement set-time-of-day RTAS function X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Breno Leitao Currently there is no implementation for set-time-of-day rtas function, which causes the following warning "setting the clock failed (-1)" on the guest. This patch just creates this function, get the timedate diff and store in the papr environment, so that the correct value will be returned by get-time-of-day. In order to try it, just adjust the hardware time, run hwclock --systohc, so that, on when the system runs hwclock --hctosys, the value is correctly adjusted, i.e. the host time plus the timediff. Signed-off-by: Breno Leitao Signed-off-by: David Gibson Signed-off-by: Alexander Graf --- hw/spapr.h | 1 + hw/spapr_rtas.c | 24 +++++++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletions(-) diff --git a/hw/spapr.h b/hw/spapr.h index ec910de..6657c33 100644 --- a/hw/spapr.h +++ b/hw/spapr.h @@ -18,6 +18,7 @@ typedef struct sPAPREnvironment { void *fdt_skel; target_ulong entry_point; int next_irq; + int rtc_offset; } sPAPREnvironment; #define H_SUCCESS 0 diff --git a/hw/spapr_rtas.c b/hw/spapr_rtas.c index 00c8ce5..d1ac74c 100644 --- a/hw/spapr_rtas.c +++ b/hw/spapr_rtas.c @@ -67,7 +67,7 @@ static void rtas_get_time_of_day(sPAPREnvironment *spapr, return; } - qemu_get_timedate(&tm, 0); + qemu_get_timedate(&tm, spapr->rtc_offset); rtas_st(rets, 0, 0); /* Success */ rtas_st(rets, 1, tm.tm_year + 1900); @@ -79,6 +79,27 @@ static void rtas_get_time_of_day(sPAPREnvironment *spapr, rtas_st(rets, 7, 0); /* we don't do nanoseconds */ } +static void rtas_set_time_of_day(sPAPREnvironment *spapr, + uint32_t token, uint32_t nargs, + target_ulong args, + uint32_t nret, target_ulong rets) +{ + struct tm tm; + + tm.tm_year = rtas_ld(args, 0) - 1900; + tm.tm_mon = rtas_ld(args, 1) - 1; + tm.tm_mday = rtas_ld(args, 2); + tm.tm_hour = rtas_ld(args, 3); + tm.tm_min = rtas_ld(args, 4); + tm.tm_sec = rtas_ld(args, 5); + + /* Just generate a monitor event for the change */ + rtc_change_mon_event(&tm); + spapr->rtc_offset = qemu_timedate_diff(&tm); + + rtas_st(rets, 0, 0); /* Success */ +} + static void rtas_power_off(sPAPREnvironment *spapr, uint32_t token, uint32_t nargs, target_ulong args, uint32_t nret, target_ulong rets) @@ -271,6 +292,7 @@ static void register_core_rtas(void) { spapr_rtas_register("display-character", rtas_display_character); spapr_rtas_register("get-time-of-day", rtas_get_time_of_day); + spapr_rtas_register("set-time-of-day", rtas_set_time_of_day); spapr_rtas_register("power-off", rtas_power_off); spapr_rtas_register("query-cpu-stopped-state", rtas_query_cpu_stopped_state);