From patchwork Thu Nov 14 15:13:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Filip Bozuta X-Patchwork-Id: 1194917 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=rt-rk.com Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47DQ5024Nbz9sP6 for ; Fri, 15 Nov 2019 02:14:44 +1100 (AEDT) Received: from localhost ([::1]:58576 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iVGpU-0004Pg-QY for incoming@patchwork.ozlabs.org; Thu, 14 Nov 2019 10:14:40 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58305) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iVGon-0004Nk-KK for qemu-devel@nongnu.org; Thu, 14 Nov 2019 10:13:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iVGol-0007Nz-PC for qemu-devel@nongnu.org; Thu, 14 Nov 2019 10:13:56 -0500 Received: from mx2.rt-rk.com ([89.216.37.149]:52299 helo=mail.rt-rk.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iVGol-0007Mb-7s for qemu-devel@nongnu.org; Thu, 14 Nov 2019 10:13:55 -0500 Received: from localhost (localhost [127.0.0.1]) by mail.rt-rk.com (Postfix) with ESMTP id 8933D1A22A8; Thu, 14 Nov 2019 16:13:50 +0100 (CET) X-Virus-Scanned: amavisd-new at rt-rk.com Received: from rtrkw493-lin.domain.local (rtrkw493-lin.domain.local [10.10.14.93]) by mail.rt-rk.com (Postfix) with ESMTPSA id 4A2E71A22BA; Thu, 14 Nov 2019 16:13:50 +0100 (CET) From: Filip Bozuta To: qemu-devel@nongnu.org Subject: [PATCH v2 for 5.0 4/6] linux-user: Add support for get/set RTC wakeup alarm using ioctls Date: Thu, 14 Nov 2019 16:13:40 +0100 Message-Id: <1573744422-9974-5-git-send-email-Filip.Bozuta@rt-rk.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1573744422-9974-1-git-send-email-Filip.Bozuta@rt-rk.com> References: <1573744422-9974-1-git-send-email-Filip.Bozuta@rt-rk.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 89.216.37.149 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@viver.eu, Filip.Bozuta@rt-rk.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" This patch implements functionalities of following ioctls: RTC_WKALM_SET, RTC_WKALM_GET - Get/Set wakeup alarm Some RTCs support a more powerful alarm interface, using these ioctls to read or write the RTC's alarm time (respectively) with this structure: struct rtc_wkalrm { unsigned char enabled; unsigned char pending; struct rtc_time time; }; The enabled flag is used to enable or disable the alarm inter‐ rupt, or to read its current status; when using these calls, RTC_AIE_ON and RTC_AIE_OFF are not used. The pending flag is used by RTC_WKALM_RD to report a pending interrupt (so it's mostly useless on Linux, except when talking to the RTC man‐ aged by EFI firmware). The time field is as used with RTC_ALM_READ and RTC_ALM_SET except that the tm_mday, tm_mon, and tm_year fields are also valid. A pointer to this struc‐ ture should be passed as the third ioctl's argument. Implementation notes: All ioctls in this patch have pointer to a structure rtc_wkalrm as their third argument. That is the reason why corresponding definition is added in linux-user/syscall_types.h. Since all elements of this structure are either of type 'unsigned char' or 'struct rtc_time' (that was covered in one of previous patches), the rest of the implementation is straightforward. Signed-off-by: Filip Bozuta --- linux-user/ioctls.h | 2 ++ linux-user/syscall_defs.h | 2 ++ linux-user/syscall_types.h | 5 +++++ 3 files changed, 9 insertions(+) diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h index fa2fe7f..e4d89c2 100644 --- a/linux-user/ioctls.h +++ b/linux-user/ioctls.h @@ -85,6 +85,8 @@ IOCTL(RTC_IRQP_SET, IOC_W, MK_PTR(TYPE_ULONG)) IOCTL(RTC_EPOCH_READ, IOC_R, MK_PTR(TYPE_ULONG)) IOCTL(RTC_EPOCH_SET, IOC_W, MK_PTR(TYPE_ULONG)) + IOCTL(RTC_WKALM_RD, IOC_R, MK_PTR(MK_STRUCT(STRUCT_rtc_wkalrm))) + IOCTL(RTC_WKALM_SET, IOC_W, MK_PTR(MK_STRUCT(STRUCT_rtc_wkalrm))) IOCTL(BLKROSET, IOC_W, MK_PTR(TYPE_INT)) IOCTL(BLKROGET, IOC_R, MK_PTR(TYPE_INT)) diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index bbfa935..37504a2 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -780,6 +780,8 @@ struct target_pollfd { #define TARGET_RTC_IRQP_SET TARGET_IOW('p', 0x0c, abi_ulong) #define TARGET_RTC_EPOCH_READ TARGET_IOR('p', 0x0d, abi_ulong) #define TARGET_RTC_EPOCH_SET TARGET_IOW('p', 0x0e, abi_ulong) +#define TARGET_RTC_WKALM_RD TARGET_IOR('p', 0x10, struct rtc_wkalrm) +#define TARGET_RTC_WKALM_SET TARGET_IOW('p', 0x0f, struct rtc_wkalrm) #if defined(TARGET_ALPHA) || defined(TARGET_MIPS) || defined(TARGET_SH4) || \ defined(TARGET_XTENSA) diff --git a/linux-user/syscall_types.h b/linux-user/syscall_types.h index a35072a..820bc8e 100644 --- a/linux-user/syscall_types.h +++ b/linux-user/syscall_types.h @@ -266,6 +266,11 @@ STRUCT(rtc_time, TYPE_INT, /* tm_yday */ TYPE_INT) /* tm_isdst */ +STRUCT(rtc_wkalrm, + TYPE_CHAR, /* enabled */ + TYPE_CHAR, /* pending */ + MK_STRUCT(STRUCT_rtc_time)) /* time */ + STRUCT(blkpg_ioctl_arg, TYPE_INT, /* op */ TYPE_INT, /* flags */