From patchwork Wed Jan 15 19:36:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Filip Bozuta X-Patchwork-Id: 1223823 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 47yd2t4mrFz9sR1 for ; Thu, 16 Jan 2020 06:40:22 +1100 (AEDT) Received: from localhost ([::1]:59740 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iroWZ-0001BA-W9 for incoming@patchwork.ozlabs.org; Wed, 15 Jan 2020 14:40:20 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38630) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iroTZ-0005ep-WD for qemu-devel@nongnu.org; Wed, 15 Jan 2020 14:37:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iroTR-0004oA-E7 for qemu-devel@nongnu.org; Wed, 15 Jan 2020 14:37:09 -0500 Received: from mx2.rt-rk.com ([89.216.37.149]:43190 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 1iroTQ-0004hm-Na for qemu-devel@nongnu.org; Wed, 15 Jan 2020 14:37:05 -0500 Received: from localhost (localhost [127.0.0.1]) by mail.rt-rk.com (Postfix) with ESMTP id ED8921A1E6D; Wed, 15 Jan 2020 20:36:52 +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 CDEE81A20AB; Wed, 15 Jan 2020 20:36:52 +0100 (CET) From: Filip Bozuta To: qemu-devel@nongnu.org Subject: [PATCH v8 01/13] linux-user: Add support for enabling/disabling RTC features using ioctls Date: Wed, 15 Jan 2020 20:36:35 +0100 Message-Id: <1579117007-7565-2-git-send-email-Filip.Bozuta@rt-rk.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1579117007-7565-1-git-send-email-Filip.Bozuta@rt-rk.com> References: <1579117007-7565-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: peter.maydell@linaro.org, berrange@redhat.com, arnd@arndb.de, richard.henderson@linaro.org, laurent@vivier.eu, jcmvbkbc@gmail.com, amarkovic@wavecomp.com, philmd@redhat.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" This patch implements functionalities of following ioctls: RTC_AIE_ON, RTC_AIE_OFF - Alarm interrupt enabling on/off Enable or disable the alarm interrupt, for RTCs that support alarms. The third ioctl's argument is ignored. RTC_UIE_ON, RTC_UIE_OFF - Update interrupt enabling on/off Enable or disable the interrupt on every clock update, for RTCs that support this once-per-second interrupt. The third ioctl's argument is ignored. RTC_PIE_ON, RTC_PIE_OFF - Periodic interrupt enabling on/off Enable or disable the periodic interrupt, for RTCs that sup‐ port these periodic interrupts. The third ioctl's argument is ignored. Only a privileged process (i.e., one having the CAP_SYS_RESOURCE capability) can enable the periodic interrupt if the frequency is currently set above the value specified in /proc/sys/dev/rtc/max-user-freq. RTC_WIE_ON, RTC_WIE_OFF - Watchdog interrupt enabling on/off Enable or disable the Watchdog interrupt, for RTCs that sup- port this Watchdog interrupt. The third ioctl's argument is ignored. Implementation notes: Since all of involved ioctls have NULL as their third argument, their implementation was straightforward. The line '#include ' was added to recognize preprocessor definitions for these ioctls. This needs to be done only once in this series of commits. Also, the content of this file (with respect to ioctl definitions) remained unchanged for a long time, therefore there is no need to worry about supporting older Linux kernel version. Reviewed-by: Laurent Vivier Signed-off-by: Filip Bozuta --- linux-user/ioctls.h | 9 +++++++++ linux-user/syscall.c | 1 + linux-user/syscall_defs.h | 10 ++++++++++ 3 files changed, 20 insertions(+) diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h index c6b9d6a..97741c7 100644 --- a/linux-user/ioctls.h +++ b/linux-user/ioctls.h @@ -69,6 +69,15 @@ IOCTL(KDSETLED, 0, TYPE_INT) IOCTL_SPECIAL(KDSIGACCEPT, 0, do_ioctl_kdsigaccept, TYPE_INT) + IOCTL(RTC_AIE_ON, 0, TYPE_NULL) + IOCTL(RTC_AIE_OFF, 0, TYPE_NULL) + IOCTL(RTC_UIE_ON, 0, TYPE_NULL) + IOCTL(RTC_UIE_OFF, 0, TYPE_NULL) + IOCTL(RTC_PIE_ON, 0, TYPE_NULL) + IOCTL(RTC_PIE_OFF, 0, TYPE_NULL) + IOCTL(RTC_WIE_ON, 0, TYPE_NULL) + IOCTL(RTC_WIE_OFF, 0, TYPE_NULL) + IOCTL(BLKROSET, IOC_W, MK_PTR(TYPE_INT)) IOCTL(BLKROGET, IOC_R, MK_PTR(TYPE_INT)) IOCTL(BLKRRPART, 0, TYPE_NULL) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index ce399a5..74c3c08 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -107,6 +107,7 @@ #include #include #include +#include #include "linux_loop.h" #include "uname.h" diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index 98c2119..f91579a 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -763,6 +763,16 @@ struct target_pollfd { #define TARGET_KDSETLED 0x4B32 /* set led state [lights, not flags] */ #define TARGET_KDSIGACCEPT 0x4B4E +/* real time clock ioctls */ +#define TARGET_RTC_AIE_ON TARGET_IO('p', 0x01) +#define TARGET_RTC_AIE_OFF TARGET_IO('p', 0x02) +#define TARGET_RTC_UIE_ON TARGET_IO('p', 0x03) +#define TARGET_RTC_UIE_OFF TARGET_IO('p', 0x04) +#define TARGET_RTC_PIE_ON TARGET_IO('p', 0x05) +#define TARGET_RTC_PIE_OFF TARGET_IO('p', 0x06) +#define TARGET_RTC_WIE_ON TARGET_IO('p', 0x0f) +#define TARGET_RTC_WIE_OFF TARGET_IO('p', 0x10) + #if defined(TARGET_ALPHA) || defined(TARGET_MIPS) || defined(TARGET_SH4) || \ defined(TARGET_XTENSA) #define TARGET_FIOGETOWN TARGET_IOR('f', 123, int) From patchwork Wed Jan 15 19:36:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filip Bozuta X-Patchwork-Id: 1223826 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 47yd596c4xz9sR4 for ; Thu, 16 Jan 2020 06:42:21 +1100 (AEDT) Received: from localhost ([::1]:59774 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iroYV-0004ZQ-II for incoming@patchwork.ozlabs.org; Wed, 15 Jan 2020 14:42:19 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38591) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iroTU-0005em-MC for qemu-devel@nongnu.org; Wed, 15 Jan 2020 14:37:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iroTQ-0004nV-Q9 for qemu-devel@nongnu.org; Wed, 15 Jan 2020 14:37:08 -0500 Received: from mx2.rt-rk.com ([89.216.37.149]:43196 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 1iroTP-0004hs-HR for qemu-devel@nongnu.org; Wed, 15 Jan 2020 14:37:04 -0500 Received: from localhost (localhost [127.0.0.1]) by mail.rt-rk.com (Postfix) with ESMTP id 0A6891A219F; Wed, 15 Jan 2020 20:36:53 +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 D7E801A20B0; Wed, 15 Jan 2020 20:36:52 +0100 (CET) From: Filip Bozuta To: qemu-devel@nongnu.org Subject: [PATCH v8 02/13] linux-user: Add support for getting/setting RTC time and alarm using ioctls Date: Wed, 15 Jan 2020 20:36:36 +0100 Message-Id: <1579117007-7565-3-git-send-email-Filip.Bozuta@rt-rk.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1579117007-7565-1-git-send-email-Filip.Bozuta@rt-rk.com> References: <1579117007-7565-1-git-send-email-Filip.Bozuta@rt-rk.com> 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: peter.maydell@linaro.org, berrange@redhat.com, arnd@arndb.de, richard.henderson@linaro.org, laurent@vivier.eu, jcmvbkbc@gmail.com, amarkovic@wavecomp.com, philmd@redhat.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" This patch implements functionalities of following ioctls: RTC_RD_TIME - Getting RTC time Returns this RTC's time in the following structure: struct rtc_time { int tm_sec; int tm_min; int tm_hour; int tm_mday; int tm_mon; int tm_year; int tm_wday; /* unused */ int tm_yday; /* unused */ int tm_isdst; /* unused */ }; The fields in this structure have the same meaning and ranges as the tm structure described in gmtime man page. A pointer to this structure should be passed as the third ioctl's argument. RTC_SET_TIME - Setting RTC time Sets this RTC's time to the time specified by the rtc_time structure pointed to by the third ioctl's argument. To set the RTC's time the process must be privileged (i.e., have the CAP_SYS_TIME capability). RTC_ALM_READ, RTC_ALM_SET - Getting/Setting alarm time Read and set the alarm time, for RTCs that support alarms. The alarm interrupt must be separately enabled or disabled using the RTC_AIE_ON, RTC_AIE_OFF requests. The third ioctl's argument is a pointer to a rtc_time structure. Only the tm_sec, tm_min, and tm_hour fields of this structure are used. Implementation notes: All ioctls in this patch have pointer to a structure rtc_time 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 of type 'int', the rest of the implementation is straightforward. Reviewed-by: Laurent Vivier Signed-off-by: Filip Bozuta --- linux-user/ioctls.h | 4 ++++ linux-user/syscall_defs.h | 4 ++++ linux-user/syscall_types.h | 11 +++++++++++ 3 files changed, 19 insertions(+) diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h index 97741c7..f472794 100644 --- a/linux-user/ioctls.h +++ b/linux-user/ioctls.h @@ -77,6 +77,10 @@ IOCTL(RTC_PIE_OFF, 0, TYPE_NULL) IOCTL(RTC_WIE_ON, 0, TYPE_NULL) IOCTL(RTC_WIE_OFF, 0, TYPE_NULL) + IOCTL(RTC_ALM_READ, IOC_R, MK_PTR(MK_STRUCT(STRUCT_rtc_time))) + IOCTL(RTC_ALM_SET, IOC_W, MK_PTR(MK_STRUCT(STRUCT_rtc_time))) + IOCTL(RTC_RD_TIME, IOC_R, MK_PTR(MK_STRUCT(STRUCT_rtc_time))) + IOCTL(RTC_SET_TIME, IOC_W, MK_PTR(MK_STRUCT(STRUCT_rtc_time))) 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 f91579a..f0bf09d 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -772,6 +772,10 @@ struct target_pollfd { #define TARGET_RTC_PIE_OFF TARGET_IO('p', 0x06) #define TARGET_RTC_WIE_ON TARGET_IO('p', 0x0f) #define TARGET_RTC_WIE_OFF TARGET_IO('p', 0x10) +#define TARGET_RTC_ALM_READ TARGET_IOR('p', 0x08, struct rtc_time) +#define TARGET_RTC_ALM_SET TARGET_IOW('p', 0x07, struct rtc_time) +#define TARGET_RTC_RD_TIME TARGET_IOR('p', 0x09, struct rtc_time) +#define TARGET_RTC_SET_TIME TARGET_IOW('p', 0x0a, struct rtc_time) #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 4e36983..a35072a 100644 --- a/linux-user/syscall_types.h +++ b/linux-user/syscall_types.h @@ -255,6 +255,17 @@ STRUCT(blkpg_partition, MK_ARRAY(TYPE_CHAR, BLKPG_DEVNAMELTH), /* devname */ MK_ARRAY(TYPE_CHAR, BLKPG_VOLNAMELTH)) /* volname */ +STRUCT(rtc_time, + TYPE_INT, /* tm_sec */ + TYPE_INT, /* tm_min */ + TYPE_INT, /* tm_hour */ + TYPE_INT, /* tm_mday */ + TYPE_INT, /* tm_mon */ + TYPE_INT, /* tm_year */ + TYPE_INT, /* tm_wday */ + TYPE_INT, /* tm_yday */ + TYPE_INT) /* tm_isdst */ + STRUCT(blkpg_ioctl_arg, TYPE_INT, /* op */ TYPE_INT, /* flags */ From patchwork Wed Jan 15 19:36:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Filip Bozuta X-Patchwork-Id: 1223818 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 47yd0M0pgLz9sPW for ; Thu, 16 Jan 2020 06:38:10 +1100 (AEDT) Received: from localhost ([::1]:59716 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iroUR-0005hH-KS for incoming@patchwork.ozlabs.org; Wed, 15 Jan 2020 14:38:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38594) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iroTU-0005eo-JW for qemu-devel@nongnu.org; Wed, 15 Jan 2020 14:37:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iroTQ-0004nO-Pf for qemu-devel@nongnu.org; Wed, 15 Jan 2020 14:37:08 -0500 Received: from mx2.rt-rk.com ([89.216.37.149]:43204 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 1iroTP-0004hv-HS for qemu-devel@nongnu.org; Wed, 15 Jan 2020 14:37:04 -0500 Received: from localhost (localhost [127.0.0.1]) by mail.rt-rk.com (Postfix) with ESMTP id 163F21A2197; Wed, 15 Jan 2020 20:36:53 +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 E2F3F1A20B7; Wed, 15 Jan 2020 20:36:52 +0100 (CET) From: Filip Bozuta To: qemu-devel@nongnu.org Subject: [PATCH v8 03/13] linux-user: Add support for getting/setting RTC periodic interrupt and epoch using ioctls Date: Wed, 15 Jan 2020 20:36:37 +0100 Message-Id: <1579117007-7565-4-git-send-email-Filip.Bozuta@rt-rk.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1579117007-7565-1-git-send-email-Filip.Bozuta@rt-rk.com> References: <1579117007-7565-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: peter.maydell@linaro.org, berrange@redhat.com, arnd@arndb.de, richard.henderson@linaro.org, laurent@vivier.eu, jcmvbkbc@gmail.com, amarkovic@wavecomp.com, philmd@redhat.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" This patch implements functionalities of following ioctls: RTC_IRQP_READ, RTC_IRQP_SET - Getting/Setting IRQ rate Read and set the frequency for periodic interrupts, for RTCs that support periodic interrupts. The periodic interrupt must be separately enabled or disabled using the RTC_PIE_ON, RTC_PIE_OFF requests. The third ioctl's argument is an unsigned long * or an unsigned long, respectively. The value is the frequency in interrupts per second. The set of allow‐ able frequencies is the multiples of two in the range 2 to 8192. Only a privileged process (i.e., one having the CAP_SYS_RESOURCE capability) can set frequencies above the value specified in /proc/sys/dev/rtc/max-user-freq. (This file contains the value 64 by default.) RTC_EPOCH_READ, RTC_EPOCH_SET - Getting/Setting epoch Many RTCs encode the year in an 8-bit register which is either interpreted as an 8-bit binary number or as a BCD number. In both cases, the number is interpreted relative to this RTC's Epoch. The RTC's Epoch is initialized to 1900 on most systems but on Alpha and MIPS it might also be initialized to 1952, 1980, or 2000, depending on the value of an RTC register for the year. With some RTCs, these operations can be used to read or to set the RTC's Epoch, respectively. The third ioctl's argument is an unsigned long * or an unsigned long, respectively, and the value returned (or assigned) is the Epoch. To set the RTC's Epoch the process must be privileged (i.e., have the CAP_SYS_TIME capability). Implementation notes: All ioctls in this patch have a pointer to 'ulong' as their third argument. That is the reason why corresponding parts of added code in linux-user/syscall_defs.h contain special handling related to 'ulong' type: they use 'abi_ulong' type to make sure that ioctl's code is calculated correctly for both 32-bit and 64-bit targets. Also, 'MK_PTR(TYPE_ULONG)' is used for the similar reason in linux-user/ioctls.h. Reviewed-by: Laurent Vivier Signed-off-by: Filip Bozuta --- linux-user/ioctls.h | 4 ++++ linux-user/syscall_defs.h | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h index f472794..accbdee 100644 --- a/linux-user/ioctls.h +++ b/linux-user/ioctls.h @@ -81,6 +81,10 @@ IOCTL(RTC_ALM_SET, IOC_W, MK_PTR(MK_STRUCT(STRUCT_rtc_time))) IOCTL(RTC_RD_TIME, IOC_R, MK_PTR(MK_STRUCT(STRUCT_rtc_time))) IOCTL(RTC_SET_TIME, IOC_W, MK_PTR(MK_STRUCT(STRUCT_rtc_time))) + IOCTL(RTC_IRQP_READ, IOC_R, MK_PTR(TYPE_ULONG)) + IOCTL(RTC_IRQP_SET, IOC_W, TYPE_ULONG) + IOCTL(RTC_EPOCH_READ, IOC_R, MK_PTR(TYPE_ULONG)) + IOCTL(RTC_EPOCH_SET, IOC_W, TYPE_ULONG) 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 f0bf09d..bbfa935 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -776,6 +776,10 @@ struct target_pollfd { #define TARGET_RTC_ALM_SET TARGET_IOW('p', 0x07, struct rtc_time) #define TARGET_RTC_RD_TIME TARGET_IOR('p', 0x09, struct rtc_time) #define TARGET_RTC_SET_TIME TARGET_IOW('p', 0x0a, struct rtc_time) +#define TARGET_RTC_IRQP_READ TARGET_IOR('p', 0x0b, abi_ulong) +#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) #if defined(TARGET_ALPHA) || defined(TARGET_MIPS) || defined(TARGET_SH4) || \ defined(TARGET_XTENSA) From patchwork Wed Jan 15 19:36:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filip Bozuta X-Patchwork-Id: 1223821 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 47yd0R2F1Rz9sR1 for ; Thu, 16 Jan 2020 06:38:14 +1100 (AEDT) Received: from localhost ([::1]:59720 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iroUW-0005ik-0f for incoming@patchwork.ozlabs.org; Wed, 15 Jan 2020 14:38:12 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38643) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iroTa-0005ev-0V for qemu-devel@nongnu.org; Wed, 15 Jan 2020 14:37:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iroTU-0004px-Ds for qemu-devel@nongnu.org; Wed, 15 Jan 2020 14:37:11 -0500 Received: from mx2.rt-rk.com ([89.216.37.149]:43304 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 1iroTS-0004nj-Ib for qemu-devel@nongnu.org; Wed, 15 Jan 2020 14:37:07 -0500 Received: from localhost (localhost [127.0.0.1]) by mail.rt-rk.com (Postfix) with ESMTP id 3B3FE1A21CB; Wed, 15 Jan 2020 20:36:53 +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 EC6DB1A2151; Wed, 15 Jan 2020 20:36:52 +0100 (CET) From: Filip Bozuta To: qemu-devel@nongnu.org Subject: [PATCH v8 04/13] linux-user: Add support for getting/setting RTC wakeup alarm using ioctls Date: Wed, 15 Jan 2020 20:36:38 +0100 Message-Id: <1579117007-7565-5-git-send-email-Filip.Bozuta@rt-rk.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1579117007-7565-1-git-send-email-Filip.Bozuta@rt-rk.com> References: <1579117007-7565-1-git-send-email-Filip.Bozuta@rt-rk.com> 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: peter.maydell@linaro.org, berrange@redhat.com, arnd@arndb.de, richard.henderson@linaro.org, laurent@vivier.eu, jcmvbkbc@gmail.com, amarkovic@wavecomp.com, philmd@redhat.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 - Getting/Setting 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 interrupt, 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 managed 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 structure should be passed as the third ioctl's argument. Implementation notes: All ioctls in this patch have a 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. Reviewed-by: Laurent Vivier 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 accbdee..b09396e 100644 --- a/linux-user/ioctls.h +++ b/linux-user/ioctls.h @@ -85,6 +85,8 @@ IOCTL(RTC_IRQP_SET, IOC_W, TYPE_ULONG) IOCTL(RTC_EPOCH_READ, IOC_R, MK_PTR(TYPE_ULONG)) IOCTL(RTC_EPOCH_SET, IOC_W, 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 */ From patchwork Wed Jan 15 19:36:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filip Bozuta X-Patchwork-Id: 1223832 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 47yd7k14TSz9sPW for ; Thu, 16 Jan 2020 06:44:34 +1100 (AEDT) Received: from localhost ([::1]:59812 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iroad-0007f8-DG for incoming@patchwork.ozlabs.org; Wed, 15 Jan 2020 14:44:32 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38592) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iroTU-0005en-M4 for qemu-devel@nongnu.org; Wed, 15 Jan 2020 14:37:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iroTQ-0004nU-Q8 for qemu-devel@nongnu.org; Wed, 15 Jan 2020 14:37:08 -0500 Received: from mx2.rt-rk.com ([89.216.37.149]:43211 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 1iroTP-0004hy-HS for qemu-devel@nongnu.org; Wed, 15 Jan 2020 14:37:04 -0500 Received: from localhost (localhost [127.0.0.1]) by mail.rt-rk.com (Postfix) with ESMTP id 26F3A1A20B7; Wed, 15 Jan 2020 20:36:53 +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 014C41A2158; Wed, 15 Jan 2020 20:36:53 +0100 (CET) From: Filip Bozuta To: qemu-devel@nongnu.org Subject: [PATCH v8 05/13] linux-user: Add support for getting/setting RTC PLL correction using ioctls Date: Wed, 15 Jan 2020 20:36:39 +0100 Message-Id: <1579117007-7565-6-git-send-email-Filip.Bozuta@rt-rk.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1579117007-7565-1-git-send-email-Filip.Bozuta@rt-rk.com> References: <1579117007-7565-1-git-send-email-Filip.Bozuta@rt-rk.com> 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: peter.maydell@linaro.org, berrange@redhat.com, arnd@arndb.de, richard.henderson@linaro.org, laurent@vivier.eu, jcmvbkbc@gmail.com, amarkovic@wavecomp.com, philmd@redhat.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" This patch implements functionalities of following ioctls: RTC_PLL_GET - Getting PLL correction Read the PLL correction for RTCs that support PLL. The PLL correction is returned in the following structure: struct rtc_pll_info { int pll_ctrl; /* placeholder for fancier control */ int pll_value; /* get/set correction value */ int pll_max; /* max +ve (faster) adjustment value */ int pll_min; /* max -ve (slower) adjustment value */ int pll_posmult; /* factor for +ve correction */ int pll_negmult; /* factor for -ve correction */ long pll_clock; /* base PLL frequency */ }; A pointer to this structure should be passed as the third ioctl's argument. RTC_PLL_SET - Setting PLL correction Sets the PLL correction for RTCs that support PLL. The PLL correction that is set is specified by the rtc_pll_info structure pointed to by the third ioctl's' argument. Implementation notes: All ioctls in this patch have a pointer to a structure rtc_pll_info as their third argument. All elements of this structure are of type 'int', except the last one that is of type 'long'. That is the reason why a separate target structure (target_rtc_pll_info) is defined in linux-user/syscall_defs. The rest of the implementation is straightforward. Reviewed-by: Laurent Vivier Signed-off-by: Filip Bozuta --- linux-user/ioctls.h | 2 ++ linux-user/syscall_defs.h | 14 ++++++++++++++ linux-user/syscall_types.h | 9 +++++++++ 3 files changed, 25 insertions(+) diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h index b09396e..0a4e3f1 100644 --- a/linux-user/ioctls.h +++ b/linux-user/ioctls.h @@ -87,6 +87,8 @@ IOCTL(RTC_EPOCH_SET, IOC_W, 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(RTC_PLL_GET, IOC_R, MK_PTR(MK_STRUCT(STRUCT_rtc_pll_info))) + IOCTL(RTC_PLL_SET, IOC_W, MK_PTR(MK_STRUCT(STRUCT_rtc_pll_info))) 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 37504a2..8370f41 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -763,6 +763,16 @@ struct target_pollfd { #define TARGET_KDSETLED 0x4B32 /* set led state [lights, not flags] */ #define TARGET_KDSIGACCEPT 0x4B4E +struct target_rtc_pll_info { + int pll_ctrl; + int pll_value; + int pll_max; + int pll_min; + int pll_posmult; + int pll_negmult; + abi_long pll_clock; +}; + /* real time clock ioctls */ #define TARGET_RTC_AIE_ON TARGET_IO('p', 0x01) #define TARGET_RTC_AIE_OFF TARGET_IO('p', 0x02) @@ -782,6 +792,10 @@ struct target_pollfd { #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) +#define TARGET_RTC_PLL_GET TARGET_IOR('p', 0x11, \ + struct target_rtc_pll_info) +#define TARGET_RTC_PLL_SET TARGET_IOW('p', 0x12, \ + struct target_rtc_pll_info) #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 820bc8e..4027272 100644 --- a/linux-user/syscall_types.h +++ b/linux-user/syscall_types.h @@ -271,6 +271,15 @@ STRUCT(rtc_wkalrm, TYPE_CHAR, /* pending */ MK_STRUCT(STRUCT_rtc_time)) /* time */ +STRUCT(rtc_pll_info, + TYPE_INT, /* pll_ctrl */ + TYPE_INT, /* pll_value */ + TYPE_INT, /* pll_max */ + TYPE_INT, /* pll_min */ + TYPE_INT, /* pll_posmult */ + TYPE_INT, /* pll_negmult */ + TYPE_LONG) /* pll_clock */ + STRUCT(blkpg_ioctl_arg, TYPE_INT, /* op */ TYPE_INT, /* flags */ From patchwork Wed Jan 15 19:36:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filip Bozuta X-Patchwork-Id: 1223822 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 47yd2q2JXfz9sPW for ; Thu, 16 Jan 2020 06:40:19 +1100 (AEDT) Received: from localhost ([::1]:59736 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iroWW-00018t-HB for incoming@patchwork.ozlabs.org; Wed, 15 Jan 2020 14:40:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38637) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iroTZ-0005et-Mu for qemu-devel@nongnu.org; Wed, 15 Jan 2020 14:37:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iroTS-0004p6-PZ for qemu-devel@nongnu.org; Wed, 15 Jan 2020 14:37:10 -0500 Received: from mx2.rt-rk.com ([89.216.37.149]:43305 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 1iroTS-0004nk-IQ for qemu-devel@nongnu.org; Wed, 15 Jan 2020 14:37:06 -0500 Received: from localhost (localhost [127.0.0.1]) by mail.rt-rk.com (Postfix) with ESMTP id 413B01A21D0; Wed, 15 Jan 2020 20:36:53 +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 0A27A1A20AB; Wed, 15 Jan 2020 20:36:53 +0100 (CET) From: Filip Bozuta To: qemu-devel@nongnu.org Subject: [PATCH v8 06/13] linux-user: Add support for read/clear RTC voltage low detector using ioctls Date: Wed, 15 Jan 2020 20:36:40 +0100 Message-Id: <1579117007-7565-7-git-send-email-Filip.Bozuta@rt-rk.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1579117007-7565-1-git-send-email-Filip.Bozuta@rt-rk.com> References: <1579117007-7565-1-git-send-email-Filip.Bozuta@rt-rk.com> 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: peter.maydell@linaro.org, berrange@redhat.com, arnd@arndb.de, richard.henderson@linaro.org, laurent@vivier.eu, jcmvbkbc@gmail.com, amarkovic@wavecomp.com, philmd@redhat.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" This patch implements functionalities of following ioctls: RTC_VL_READ - Read voltage low detection information Read the voltage low for RTCs that support voltage low. The third ioctl's' argument points to an int in which the voltage low is returned. RTC_VL_CLR - Clear voltage low information Clear the information about voltage low for RTCs that support voltage low. The third ioctl(2) argument is ignored. Implementation notes: Since one ioctl has a pointer to 'int' as its third agrument, and another ioctl has NULL as its third argument, their implementation was straightforward. Reviewed-by: Laurent Vivier Signed-off-by: Filip Bozuta --- linux-user/ioctls.h | 2 ++ linux-user/syscall_defs.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h index 0a4e3f1..1f1f3e6 100644 --- a/linux-user/ioctls.h +++ b/linux-user/ioctls.h @@ -89,6 +89,8 @@ IOCTL(RTC_WKALM_SET, IOC_W, MK_PTR(MK_STRUCT(STRUCT_rtc_wkalrm))) IOCTL(RTC_PLL_GET, IOC_R, MK_PTR(MK_STRUCT(STRUCT_rtc_pll_info))) IOCTL(RTC_PLL_SET, IOC_W, MK_PTR(MK_STRUCT(STRUCT_rtc_pll_info))) + IOCTL(RTC_VL_READ, IOC_R, MK_PTR(TYPE_INT)) + IOCTL(RTC_VL_CLR, 0, TYPE_NULL) 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 8370f41..af4f366 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -796,6 +796,8 @@ struct target_rtc_pll_info { struct target_rtc_pll_info) #define TARGET_RTC_PLL_SET TARGET_IOW('p', 0x12, \ struct target_rtc_pll_info) +#define TARGET_RTC_VL_READ TARGET_IOR('p', 0x13, int) +#define TARGET_RTC_VL_CLR TARGET_IO('p', 0x14) #if defined(TARGET_ALPHA) || defined(TARGET_MIPS) || defined(TARGET_SH4) || \ defined(TARGET_XTENSA) From patchwork Wed Jan 15 19:36:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filip Bozuta X-Patchwork-Id: 1223833 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 47yd9H1QBWz9sPW for ; Thu, 16 Jan 2020 06:45:54 +1100 (AEDT) Received: from localhost ([::1]:59864 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irobw-0001TR-Qw for incoming@patchwork.ozlabs.org; Wed, 15 Jan 2020 14:45:52 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38677) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iroTc-0005gG-BT for qemu-devel@nongnu.org; Wed, 15 Jan 2020 14:37:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iroTU-0004q6-Db for qemu-devel@nongnu.org; Wed, 15 Jan 2020 14:37:16 -0500 Received: from mx2.rt-rk.com ([89.216.37.149]:43308 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 1iroTS-0004np-Il for qemu-devel@nongnu.org; Wed, 15 Jan 2020 14:37:07 -0500 Received: from localhost (localhost [127.0.0.1]) by mail.rt-rk.com (Postfix) with ESMTP id 4D9F41A2151; Wed, 15 Jan 2020 20:36:53 +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 148AB1A20B0; Wed, 15 Jan 2020 20:36:53 +0100 (CET) From: Filip Bozuta To: qemu-devel@nongnu.org Subject: [PATCH v8 07/13] linux-user: Add support for getting alsa timer version and id Date: Wed, 15 Jan 2020 20:36:41 +0100 Message-Id: <1579117007-7565-8-git-send-email-Filip.Bozuta@rt-rk.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1579117007-7565-1-git-send-email-Filip.Bozuta@rt-rk.com> References: <1579117007-7565-1-git-send-email-Filip.Bozuta@rt-rk.com> 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: peter.maydell@linaro.org, berrange@redhat.com, arnd@arndb.de, richard.henderson@linaro.org, laurent@vivier.eu, jcmvbkbc@gmail.com, amarkovic@wavecomp.com, philmd@redhat.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" This patch implements functionalities of following ioctls: SNDRV_TIMER_IOCTL_PVERSION - Getting the sound timer version Read the sound timer version. The third ioctl's argument is a pointer to an int in which the specified timers version is returned. SNDRV_TIMER_IOCTL_NEXT_DEVICE - Getting id information about next timer Read id information about the next timer device from the sound timer device list. The id infomration is returned in the following structure: struct snd_timer_id { int dev_class; /* timer device class number */ int dev_sclass; /* slave device class number (unused) */ int card; /* card number */ int device; /* device number */ int subdevice; /* sub-device number */ }; The devices in the sound timer device list are arranged by the fields of this structure respectively (first by dev_class number, then by card number, ...). A pointer to this structure should be passed as the third ioctl's argument. Before calling the ioctl, the parameters of this structure should be initialized in relation to the next timer device which information is to be obtained. For example, if a wanted timer device has the device class number equal to or bigger then 2, the field dev_class should be initialized to 2. After the ioctl call, the structure fields are filled with values from the next device in the sound timer device list. If there is no next device in the list, the structure is filled with "zero" id values (in that case all fields are filled with value -1). Implementation notes: The ioctl 'SNDRV_TIMER_IOCTL_NEXT_DEVICE' has a pointer to a 'struct snd_timer_id' as its third argument. That is the reason why corresponding definition is added in 'linux-user/syscall_types.h'. Since all elements of this structure are of type 'int', the rest of the implementation was straightforward. The line '#include ' was added to recognize preprocessor definitions for these ioctls. This needs to be done only once in this series of commits. Also, the content of this file (with respect to ioctl definitions) remained unchanged for a long time, therefore there is no need to worry about supporting older Linux kernel version. Reviewed-by: Laurent Vivier Signed-off-by: Filip Bozuta --- linux-user/ioctls.h | 4 ++++ linux-user/syscall.c | 1 + linux-user/syscall_defs.h | 5 +++++ linux-user/syscall_types.h | 7 +++++++ 4 files changed, 17 insertions(+) diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h index 1f1f3e6..ed1bd4c 100644 --- a/linux-user/ioctls.h +++ b/linux-user/ioctls.h @@ -449,6 +449,10 @@ IOCTL(SOUND_MIXER_WRITE_LOUD, IOC_W, MK_PTR(TYPE_INT)) IOCTL(SOUND_MIXER_WRITE_RECSRC, IOC_W, MK_PTR(TYPE_INT)) + IOCTL(SNDRV_TIMER_IOCTL_PVERSION, IOC_R, MK_PTR(TYPE_INT)) + IOCTL(SNDRV_TIMER_IOCTL_NEXT_DEVICE, IOC_RW, + MK_PTR(MK_STRUCT(STRUCT_snd_timer_id))) + IOCTL(HDIO_GETGEO, IOC_R, MK_PTR(MK_STRUCT(STRUCT_hd_geometry))) IOCTL(HDIO_GET_UNMASKINTR, IOC_R, MK_PTR(TYPE_INT)) IOCTL(HDIO_GET_MULTCOUNT, IOC_R, MK_PTR(TYPE_INT)) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 74c3c08..a3993a2 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -108,6 +108,7 @@ #include #include #include +#include #include "linux_loop.h" #include "uname.h" diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index af4f366..7ceb6f8 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -2425,6 +2425,11 @@ struct target_statfs64 { #define TARGET_SOUND_MIXER_WRITE_RECSRC TARGET_MIXER_WRITE(SOUND_MIXER_RECSRC) +/* alsa timer ioctls */ +#define TARGET_SNDRV_TIMER_IOCTL_PVERSION TARGET_IOR('T', 0x00, int) +#define TARGET_SNDRV_TIMER_IOCTL_NEXT_DEVICE TARGET_IOWR('T', 0x01, \ + struct snd_timer_id) + /* vfat ioctls */ #define TARGET_VFAT_IOCTL_READDIR_BOTH TARGET_IORU('r', 1) #define TARGET_VFAT_IOCTL_READDIR_SHORT TARGET_IORU('r', 2) diff --git a/linux-user/syscall_types.h b/linux-user/syscall_types.h index 4027272..2f4cd78 100644 --- a/linux-user/syscall_types.h +++ b/linux-user/syscall_types.h @@ -83,6 +83,13 @@ STRUCT(buffmem_desc, STRUCT(mixer_info, MK_ARRAY(TYPE_CHAR, 16), MK_ARRAY(TYPE_CHAR, 32), TYPE_INT, MK_ARRAY(TYPE_INT, 10)) +STRUCT(snd_timer_id, + TYPE_INT, /* dev_class */ + TYPE_INT, /* dev_sclass */ + TYPE_INT, /* card */ + TYPE_INT, /* device */ + TYPE_INT) /* subdevice */ + /* loop device ioctls */ STRUCT(loop_info, TYPE_INT, /* lo_number */ From patchwork Wed Jan 15 19:36:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filip Bozuta X-Patchwork-Id: 1223829 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 47yd5N1hT2z9sPW for ; Thu, 16 Jan 2020 06:42:32 +1100 (AEDT) Received: from localhost ([::1]:59786 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iroYf-0004uM-QZ for incoming@patchwork.ozlabs.org; Wed, 15 Jan 2020 14:42:29 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38724) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iroTg-0005kV-Ck for qemu-devel@nongnu.org; Wed, 15 Jan 2020 14:37:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iroTc-0004uY-PP for qemu-devel@nongnu.org; Wed, 15 Jan 2020 14:37:20 -0500 Received: from mx2.rt-rk.com ([89.216.37.149]:43307 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 1iroTc-0004nq-IY for qemu-devel@nongnu.org; Wed, 15 Jan 2020 14:37:16 -0500 Received: from localhost (localhost [127.0.0.1]) by mail.rt-rk.com (Postfix) with ESMTP id 4671D1A21E2; Wed, 15 Jan 2020 20:36:53 +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 1E26F1A21BC; Wed, 15 Jan 2020 20:36:53 +0100 (CET) From: Filip Bozuta To: qemu-devel@nongnu.org Subject: [PATCH v8 08/13] linux-user: Add support for setting alsa timer enhanced read using ioctl Date: Wed, 15 Jan 2020 20:36:42 +0100 Message-Id: <1579117007-7565-9-git-send-email-Filip.Bozuta@rt-rk.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1579117007-7565-1-git-send-email-Filip.Bozuta@rt-rk.com> References: <1579117007-7565-1-git-send-email-Filip.Bozuta@rt-rk.com> 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: peter.maydell@linaro.org, berrange@redhat.com, arnd@arndb.de, richard.henderson@linaro.org, laurent@vivier.eu, jcmvbkbc@gmail.com, amarkovic@wavecomp.com, philmd@redhat.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" This patch implements functionality of following ioctl: SNDRV_TIMER_IOCTL_TREAD - Setting enhanced time read Sets enhanced time read which is used for reading time with timestamps and events. The third ioctl's argument is a pointer to an 'int'. Enhanced reading is set if the third argument is different than 0, otherwise normal time reading is set. Implementation notes: Because the implemented ioctl has 'int' as its third argument, the implementation was straightforward. Reviewed-by: Laurent Vivier Signed-off-by: Filip Bozuta --- linux-user/ioctls.h | 1 + linux-user/syscall_defs.h | 1 + 2 files changed, 2 insertions(+) diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h index ed1bd4c..9106773 100644 --- a/linux-user/ioctls.h +++ b/linux-user/ioctls.h @@ -452,6 +452,7 @@ IOCTL(SNDRV_TIMER_IOCTL_PVERSION, IOC_R, MK_PTR(TYPE_INT)) IOCTL(SNDRV_TIMER_IOCTL_NEXT_DEVICE, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_snd_timer_id))) + IOCTL(SNDRV_TIMER_IOCTL_TREAD, IOC_W, MK_PTR(TYPE_INT)) IOCTL(HDIO_GETGEO, IOC_R, MK_PTR(MK_STRUCT(STRUCT_hd_geometry))) IOCTL(HDIO_GET_UNMASKINTR, IOC_R, MK_PTR(TYPE_INT)) diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index 7ceb6f8..0971623 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -2429,6 +2429,7 @@ struct target_statfs64 { #define TARGET_SNDRV_TIMER_IOCTL_PVERSION TARGET_IOR('T', 0x00, int) #define TARGET_SNDRV_TIMER_IOCTL_NEXT_DEVICE TARGET_IOWR('T', 0x01, \ struct snd_timer_id) +#define TARGET_SNDRV_TIMER_IOCTL_TREAD TARGET_IOW('T', 0x02, int) /* vfat ioctls */ #define TARGET_VFAT_IOCTL_READDIR_BOTH TARGET_IORU('r', 1) From patchwork Wed Jan 15 19:36:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filip Bozuta X-Patchwork-Id: 1223825 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 47yd311KQvz9sPW for ; Thu, 16 Jan 2020 06:40:29 +1100 (AEDT) Received: from localhost ([::1]:59748 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iroWg-0001Nl-IJ for incoming@patchwork.ozlabs.org; Wed, 15 Jan 2020 14:40:26 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38678) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iroTc-0005gH-BI for qemu-devel@nongnu.org; Wed, 15 Jan 2020 14:37:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iroTU-0004qG-DS for qemu-devel@nongnu.org; Wed, 15 Jan 2020 14:37:16 -0500 Received: from mx2.rt-rk.com ([89.216.37.149]:43306 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 1iroTS-0004nl-JJ for qemu-devel@nongnu.org; Wed, 15 Jan 2020 14:37:07 -0500 Received: from localhost (localhost [127.0.0.1]) by mail.rt-rk.com (Postfix) with ESMTP id 63F5A1A21BB; Wed, 15 Jan 2020 20:36:53 +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 283B91A21CA; Wed, 15 Jan 2020 20:36:53 +0100 (CET) From: Filip Bozuta To: qemu-devel@nongnu.org Subject: [PATCH v8 09/13] linux-user: Add support for getting/setting specified alsa timer parameters using ioctls Date: Wed, 15 Jan 2020 20:36:43 +0100 Message-Id: <1579117007-7565-10-git-send-email-Filip.Bozuta@rt-rk.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1579117007-7565-1-git-send-email-Filip.Bozuta@rt-rk.com> References: <1579117007-7565-1-git-send-email-Filip.Bozuta@rt-rk.com> 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: peter.maydell@linaro.org, berrange@redhat.com, arnd@arndb.de, richard.henderson@linaro.org, laurent@vivier.eu, jcmvbkbc@gmail.com, amarkovic@wavecomp.com, philmd@redhat.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" This patch implements functionalities of following ioctls: SNDRV_TIMER_IOCTL_GINFO - Getting information about specified timer Read information about the specified timer. The information about the timer is returned in the following structure: struct snd_timer_ginfo { struct snd_timer_id tid; /* requested timer ID */ unsigned int flags; /* timer flags - SNDRV_TIMER_FLG_* */ int card; /* card number */ unsigned char id[64]; /* timer identification */ unsigned char name[80]; /* timer name */ unsigned long reserved0; /* reserved for future use */ unsigned long resolution; /* average period resolution in ns */ unsigned long resolution_min; /* minimal period resolution in ns */ unsigned long resolution_max; /* maximal period resolution in ns */ unsigned int clients; /* active timer clients */ unsigned char reserved[32]; /* reserved */ }; A pointer to this structure should be passed as the third ioctl's argument. Before calling the ioctl, the field "tid" should be initialized with the id information for the timer which information is to be obtained. After the ioctl call, the rest of the structure fields are filled with values from the timer device with the specified id. If there is no device with the specified id, the error ENODEV ("No such device") is returned. SNDRV_TIMER_IOCTL_GPARAMS - Setting precise period duration Sets timer precise period duration numerator and denominator in seconds. The period duration is set in the following structure: struct snd_timer_gparams { struct snd_timer_id tid; /* requested timer ID */ unsigned long period_num; /* period duration - numerator */ unsigned long period_den; /* period duration - denominator */ unsigned char reserved[32]; /* reserved */ }; A pointer to this structure should be passed as the third ioctl's argument. Before calling the ioctl, the field "tid" should be initialized with the id information for the timer which period duration is to be set. Also, the fileds "period_num" and "period_den" should be filled with the period duration numerator and denominator values that are to be set respectively. If there is no device with the specified id, the error ENODEV ("No such device") is returned. SNDRV_TIMER_IOCTL_GSTATUS - Getting current period resolution Read timer current period resolution in nanoseconds and period resolution numerator and denominator in seconds. The period resolution information is returned in the following structure: struct snd_timer_gstatus { struct snd_timer_id tid; /* requested timer ID */ unsigned long resolution; /* current period resolution in ns */ unsigned long resolution_num; /* period resolution - numerator */ unsigned long resolution_den; /* period resolution - denominator */ unsigned char reserved[32]; /* reserved for future use */ }; A pointer to this structure should be passed as the third ioctl's argument. Before calling the ioctl, the field "tid" should be initialized with the id information for the timer which period resolution is to be obtained. After the ioctl call, the rest of the structure fields are filled with values from the timer device with the specified id. If there is no device with the specified id, the error ENODEV ("No such device") is returned. Implementation notes: All ioctls in this patch have pointer to some kind of a structure as their third argument. That is the reason why corresponding definitions were added in 'linux-user/syscall_types.h'. All of these strcutures have some fields that are of type 'unsigned long'. That is the reason why separate target structures were defined in 'linux-user/syscall_defs.h'. Also, all of the structures have a field with type 'struct snd_timer_id' which is the reason why a separate target structure 'struct target_snd_timer_id' was also defined. The rest of the implementation was straightforward. Reviewed-by: Laurent Vivier Signed-off-by: Filip Bozuta --- linux-user/ioctls.h | 6 ++++++ linux-user/syscall_defs.h | 43 +++++++++++++++++++++++++++++++++++++++++++ linux-user/syscall_types.h | 26 ++++++++++++++++++++++++++ 3 files changed, 75 insertions(+) diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h index 9106773..989eb9b 100644 --- a/linux-user/ioctls.h +++ b/linux-user/ioctls.h @@ -453,6 +453,12 @@ IOCTL(SNDRV_TIMER_IOCTL_NEXT_DEVICE, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_snd_timer_id))) IOCTL(SNDRV_TIMER_IOCTL_TREAD, IOC_W, MK_PTR(TYPE_INT)) + IOCTL(SNDRV_TIMER_IOCTL_GINFO, IOC_RW, + MK_PTR(MK_STRUCT(STRUCT_snd_timer_ginfo))) + IOCTL(SNDRV_TIMER_IOCTL_GPARAMS, IOC_W, + MK_PTR(MK_STRUCT(STRUCT_snd_timer_gparams))) + IOCTL(SNDRV_TIMER_IOCTL_GSTATUS, IOC_RW, + MK_PTR(MK_STRUCT(STRUCT_snd_timer_gstatus))) IOCTL(HDIO_GETGEO, IOC_R, MK_PTR(MK_STRUCT(STRUCT_hd_geometry))) IOCTL(HDIO_GET_UNMASKINTR, IOC_R, MK_PTR(TYPE_INT)) diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index 0971623..a675b92 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -2425,11 +2425,54 @@ struct target_statfs64 { #define TARGET_SOUND_MIXER_WRITE_RECSRC TARGET_MIXER_WRITE(SOUND_MIXER_RECSRC) +struct target_snd_timer_id { + int dev_class; + int dev_sclass; + int card; + int device; + int subdevice; +}; + +struct target_snd_timer_ginfo { + struct target_snd_timer_id tid; + unsigned int flags; + int card; + unsigned char id[64]; + unsigned char name[80]; + abi_ulong reserved0; + abi_ulong resolution; + abi_ulong resolution_min; + abi_ulong resolution_max; + unsigned int clients; + unsigned char reserved[32]; +}; + +struct target_snd_timer_gparams { + struct target_snd_timer_id tid; + abi_ulong period_num; + abi_ulong period_den; + unsigned char reserved[32]; +}; + +struct target_snd_timer_gstatus { + struct target_snd_timer_id tid; + abi_ulong resolution; + abi_ulong resolution_num; + abi_ulong resolution_den; + unsigned char reserved[32]; +}; + /* alsa timer ioctls */ #define TARGET_SNDRV_TIMER_IOCTL_PVERSION TARGET_IOR('T', 0x00, int) #define TARGET_SNDRV_TIMER_IOCTL_NEXT_DEVICE TARGET_IOWR('T', 0x01, \ struct snd_timer_id) #define TARGET_SNDRV_TIMER_IOCTL_TREAD TARGET_IOW('T', 0x02, int) +#define TARGET_SNDRV_TIMER_IOCTL_GINFO TARGET_IOWR('T', 0x03, \ + struct target_snd_timer_ginfo) +#define TARGET_SNDRV_TIMER_IOCTL_GPARAMS TARGET_IOW('T', 0x04, \ + struct target_snd_timer_gparams) +#define TARGET_SNDRV_TIMER_IOCTL_GSTATUS TARGET_IOWR('T', 0x05, \ + struct target_snd_timer_gstatus) /* vfat ioctls */ #define TARGET_VFAT_IOCTL_READDIR_BOTH TARGET_IORU('r', 1) diff --git a/linux-user/syscall_types.h b/linux-user/syscall_types.h index 2f4cd78..4e90716 100644 --- a/linux-user/syscall_types.h +++ b/linux-user/syscall_types.h @@ -90,6 +90,32 @@ STRUCT(snd_timer_id, TYPE_INT, /* device */ TYPE_INT) /* subdevice */ +STRUCT(snd_timer_ginfo, + MK_STRUCT(STRUCT_snd_timer_id), /* tid */ + TYPE_INT, /* flags */ + TYPE_INT, /* card */ + MK_ARRAY(TYPE_CHAR, 64), /* id */ + MK_ARRAY(TYPE_CHAR, 80), /* name */ + TYPE_ULONG, /* reserved0 */ + TYPE_ULONG, /* resolution */ + TYPE_ULONG, /* resolution_min */ + TYPE_ULONG, /* resolution_max */ + TYPE_INT, /* clients */ + MK_ARRAY(TYPE_CHAR, 32)) /* reserved */ + +STRUCT(snd_timer_gparams, + MK_STRUCT(STRUCT_snd_timer_id), /* tid */ + TYPE_ULONG, /* period_num */ + TYPE_ULONG, /* period_den */ + MK_ARRAY(TYPE_CHAR, 32)) /* reserved */ + +STRUCT(snd_timer_gstatus, + MK_STRUCT(STRUCT_snd_timer_id), /* tid */ + TYPE_ULONG, /* resolution */ + TYPE_ULONG, /* resolution_num */ + TYPE_ULONG, /* resolution_den */ + MK_ARRAY(TYPE_CHAR, 32)) /* reserved */ + /* loop device ioctls */ STRUCT(loop_info, TYPE_INT, /* lo_number */ From patchwork Wed Jan 15 19:36:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filip Bozuta X-Patchwork-Id: 1223819 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 47yd0N2vnJz9sPW for ; Thu, 16 Jan 2020 06:38:12 +1100 (AEDT) Received: from localhost ([::1]:59718 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iroUS-0005ht-TK for incoming@patchwork.ozlabs.org; Wed, 15 Jan 2020 14:38:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38642) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iroTa-0005eu-08 for qemu-devel@nongnu.org; Wed, 15 Jan 2020 14:37:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iroTU-0004pr-DG for qemu-devel@nongnu.org; Wed, 15 Jan 2020 14:37:11 -0500 Received: from mx2.rt-rk.com ([89.216.37.149]:43310 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 1iroTS-0004nx-IU for qemu-devel@nongnu.org; Wed, 15 Jan 2020 14:37:07 -0500 Received: from localhost (localhost [127.0.0.1]) by mail.rt-rk.com (Postfix) with ESMTP id 70BD61A21BC; Wed, 15 Jan 2020 20:36:53 +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 32A331A2158; Wed, 15 Jan 2020 20:36:53 +0100 (CET) From: Filip Bozuta To: qemu-devel@nongnu.org Subject: [PATCH v8 10/13] linux-user: Add support for selecting alsa timer using ioctl Date: Wed, 15 Jan 2020 20:36:44 +0100 Message-Id: <1579117007-7565-11-git-send-email-Filip.Bozuta@rt-rk.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1579117007-7565-1-git-send-email-Filip.Bozuta@rt-rk.com> References: <1579117007-7565-1-git-send-email-Filip.Bozuta@rt-rk.com> 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: peter.maydell@linaro.org, berrange@redhat.com, arnd@arndb.de, richard.henderson@linaro.org, laurent@vivier.eu, jcmvbkbc@gmail.com, amarkovic@wavecomp.com, philmd@redhat.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" This patch implements functionality of following ioctl: SNDRV_TIMER_IOCTL_SELECT - Selecting timer Selects the timer which id is specified. The timer id is specified in the following strcuture: struct snd_timer_select { struct snd_timer_id id; /* timer ID */ unsigned char reserved[32]; /* reserved */ }; A pointer to this structure should be passed as the third ioctl's argument. Before calling the ioctl, the field "tid" should be initialized with the id information for the timer which is to be selected. If there is no timer device with the specified id, the error ENODEV ("No such device") is returned. Implementation notes: Ioctl implemented in this patch has a pointer to a 'struct snd_timer_select' as its third argument. That is the reason why a corresponding definition was added in 'linux-user/syscall_types.h'. The rest of the implementation was straightforward. Reviewed-by: Laurent Vivier Signed-off-by: Filip Bozuta --- linux-user/ioctls.h | 2 ++ linux-user/syscall_defs.h | 7 +++++++ linux-user/syscall_types.h | 4 ++++ 3 files changed, 13 insertions(+) diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h index 989eb9b..7652117 100644 --- a/linux-user/ioctls.h +++ b/linux-user/ioctls.h @@ -459,6 +459,8 @@ MK_PTR(MK_STRUCT(STRUCT_snd_timer_gparams))) IOCTL(SNDRV_TIMER_IOCTL_GSTATUS, IOC_RW, MK_PTR(MK_STRUCT(STRUCT_snd_timer_gstatus))) + IOCTL(SNDRV_TIMER_IOCTL_SELECT, IOC_W, + MK_PTR(MK_STRUCT(STRUCT_snd_timer_select))) IOCTL(HDIO_GETGEO, IOC_R, MK_PTR(MK_STRUCT(STRUCT_hd_geometry))) IOCTL(HDIO_GET_UNMASKINTR, IOC_R, MK_PTR(TYPE_INT)) diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index a675b92..39b9739 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -2462,6 +2462,11 @@ struct target_snd_timer_gstatus { unsigned char reserved[32]; }; +struct target_snd_timer_select { + struct target_snd_timer_id id; + unsigned char reserved[32]; +}; + /* alsa timer ioctls */ #define TARGET_SNDRV_TIMER_IOCTL_PVERSION TARGET_IOR('T', 0x00, int) #define TARGET_SNDRV_TIMER_IOCTL_NEXT_DEVICE TARGET_IOWR('T', 0x01, \ @@ -2473,6 +2478,8 @@ struct target_snd_timer_gstatus { struct target_snd_timer_gparams) #define TARGET_SNDRV_TIMER_IOCTL_GSTATUS TARGET_IOWR('T', 0x05, \ struct target_snd_timer_gstatus) +#define TARGET_SNDRV_TIMER_IOCTL_SELECT TARGET_IOW('T', 0x10, \ + struct target_snd_timer_select) /* vfat ioctls */ #define TARGET_VFAT_IOCTL_READDIR_BOTH TARGET_IORU('r', 1) diff --git a/linux-user/syscall_types.h b/linux-user/syscall_types.h index 4e90716..767632d 100644 --- a/linux-user/syscall_types.h +++ b/linux-user/syscall_types.h @@ -116,6 +116,10 @@ STRUCT(snd_timer_gstatus, TYPE_ULONG, /* resolution_den */ MK_ARRAY(TYPE_CHAR, 32)) /* reserved */ +STRUCT(snd_timer_select, + MK_STRUCT(STRUCT_snd_timer_id), /* id */ + MK_ARRAY(TYPE_CHAR, 32)) /* reserved */ + /* loop device ioctls */ STRUCT(loop_info, TYPE_INT, /* lo_number */ From patchwork Wed Jan 15 19:36:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filip Bozuta X-Patchwork-Id: 1223820 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 47yd0P68W9z9sPW for ; Thu, 16 Jan 2020 06:38:13 +1100 (AEDT) Received: from localhost ([::1]:59722 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iroUV-0005jR-D5 for incoming@patchwork.ozlabs.org; Wed, 15 Jan 2020 14:38:11 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38645) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iroTa-0005ew-12 for qemu-devel@nongnu.org; Wed, 15 Jan 2020 14:37:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iroTU-0004q7-F6 for qemu-devel@nongnu.org; Wed, 15 Jan 2020 14:37:12 -0500 Received: from mx2.rt-rk.com ([89.216.37.149]:43312 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 1iroTS-0004oP-JR for qemu-devel@nongnu.org; Wed, 15 Jan 2020 14:37:07 -0500 Received: from localhost (localhost [127.0.0.1]) by mail.rt-rk.com (Postfix) with ESMTP id 78E631A21CA; Wed, 15 Jan 2020 20:36:53 +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 3E13E1A21CF; Wed, 15 Jan 2020 20:36:53 +0100 (CET) From: Filip Bozuta To: qemu-devel@nongnu.org Subject: [PATCH v8 11/13] linux-user: Add support for getting/setting selected alsa timer parameters using ioctls Date: Wed, 15 Jan 2020 20:36:45 +0100 Message-Id: <1579117007-7565-12-git-send-email-Filip.Bozuta@rt-rk.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1579117007-7565-1-git-send-email-Filip.Bozuta@rt-rk.com> References: <1579117007-7565-1-git-send-email-Filip.Bozuta@rt-rk.com> 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: peter.maydell@linaro.org, berrange@redhat.com, arnd@arndb.de, richard.henderson@linaro.org, laurent@vivier.eu, jcmvbkbc@gmail.com, amarkovic@wavecomp.com, philmd@redhat.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" This patch implements functionalities of following ioctls: SNDRV_TIMER_IOCTL_INFO - Getting information about selected timer Read information about the selected timer. The information is returned in the following structure: struct snd_timer_info { unsigned int flags; /* timer flags - SNDRV_TIMER_FLG_* */ int card; /* card number */ unsigned char id[64]; /* timer identificator */ unsigned char name[80]; /* timer name */ unsigned long reserved0; /* reserved for future use */ unsigned long resolution; /* average period resolution in ns */ unsigned char reserved[64]; /* reserved for future use */ }; A pointer to this structure should be passed as the third ioctl's argument. Before calling this ioctl, the ioctl "SNDRV_TIMER_IOCTL_SELECT" should be called first to select the timer which information is to be obtained. If no timer is selected, the error EBADFD ("File descriptor in bad shape") is returned. SNDRV_TIMER_IOCTL_PARAMS - Setting parameters for selected timer Sets parameters for the selected timer. The paramaters are set in the following structure: struct snd_timer_params { unsigned int flags; /* flags - SNDRV_TIMER_PSFLG_* */ unsigned int ticks; /* requested resolution in ticks */ unsigned int queue_size; /* total size of queue (32-1024) */ unsigned int reserved0; /* reserved, was: failure locations */ unsigned int filter; /* event filter */ unsigned char reserved[60]; /* reserved */ }; A pointer to this structure should be passed as the third ioctl's argument. Before calling this ioctl, the ioctl "SNDRV_TIMER_IOCTL_SELECT" should be called first to select the timer which parameters are to be set. If no timer is selected, the error EBADFD ("File descriptor in bad shape") is returned. SNDRV_TIMER_IOCTL_STATUS - Getting status of selected timer Read status of the selected timer. The status of the timer is returned in the following structure: struct snd_timer_status { struct timespec tstamp; /* Timestamp - last update */ unsigned int resolution; /* current period resolution in ns */ unsigned int lost; /* counter of master tick lost */ unsigned int overrun; /* count of read queue overruns */ unsigned int queue; /* used queue size */ unsigned char reserved[64]; /* reserved */ }; A pointer to this structure should be passed as the third ioctl's argument. Before calling this ioctl, the ioctl "SNDRV_TIMER_IOCTL_SELECT" should be called first to select the timer which status is to be obtained. If no timer is selected, the error EBADFD ("File descriptor in bad shape") is returned. Implementation notes: All ioctls in this patch have pointer to some kind of a structure as their third argument. That is the reason why corresponding definitions were added in 'linux-user/syscall_types.h'. Structure 'snd_timer_status' has field of type 'struct timespec' which is why a corresponding definition of that structure was also added in 'linux-user/syscall_types.h'. All of these strucutures have some fields that are of type 'unsigned long'. That is the reason why separate target structures were defined in 'linux-user/syscall_defs.h'. Structure 'struct timespec' already had a separate target definition so that definition was used to define a target structure for 'snd_timer_status'. The rest of the implementation was straightforward. Reviewed-by: Laurent Vivier Signed-off-by: Filip Bozuta --- linux-user/ioctls.h | 5 +++++ linux-user/syscall_defs.h | 25 +++++++++++++++++++++++++ linux-user/syscall_types.h | 29 +++++++++++++++++++++++++++++ 3 files changed, 59 insertions(+) diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h index 7652117..43e7e5d 100644 --- a/linux-user/ioctls.h +++ b/linux-user/ioctls.h @@ -461,6 +461,11 @@ MK_PTR(MK_STRUCT(STRUCT_snd_timer_gstatus))) IOCTL(SNDRV_TIMER_IOCTL_SELECT, IOC_W, MK_PTR(MK_STRUCT(STRUCT_snd_timer_select))) + IOCTL(SNDRV_TIMER_IOCTL_INFO, IOC_R, MK_PTR(MK_STRUCT(STRUCT_snd_timer_info))) + IOCTL(SNDRV_TIMER_IOCTL_PARAMS, IOC_W, + MK_PTR(MK_STRUCT(STRUCT_snd_timer_params))) + IOCTL(SNDRV_TIMER_IOCTL_STATUS, IOC_R, + MK_PTR(MK_STRUCT(STRUCT_snd_timer_status))) IOCTL(HDIO_GETGEO, IOC_R, MK_PTR(MK_STRUCT(STRUCT_hd_geometry))) IOCTL(HDIO_GET_UNMASKINTR, IOC_R, MK_PTR(TYPE_INT)) diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index 39b9739..d5f5cad 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -2467,6 +2467,25 @@ struct target_snd_timer_select { unsigned char reserved[32]; }; +struct target_snd_timer_info { + unsigned int flags; + int card; + unsigned char id[64]; + unsigned char name[80]; + abi_ulong reserved0; + abi_ulong resolution; + unsigned char reserved[64]; +}; + +struct target_snd_timer_status { + struct target_timespec tstamp; + unsigned int resolution; + unsigned int lost; + unsigned int overrun; + unsigned int queue; + unsigned char reserved[64]; +}; + /* alsa timer ioctls */ #define TARGET_SNDRV_TIMER_IOCTL_PVERSION TARGET_IOR('T', 0x00, int) #define TARGET_SNDRV_TIMER_IOCTL_NEXT_DEVICE TARGET_IOWR('T', 0x01, \ @@ -2480,6 +2499,12 @@ struct target_snd_timer_select { struct target_snd_timer_gstatus) #define TARGET_SNDRV_TIMER_IOCTL_SELECT TARGET_IOW('T', 0x10, \ struct target_snd_timer_select) +#define TARGET_SNDRV_TIMER_IOCTL_INFO TARGET_IOR('T', 0x11, \ + struct target_snd_timer_info) +#define TARGET_SNDRV_TIMER_IOCTL_PARAMS TARGET_IOW('T', 0x12, \ + struct snd_timer_params) +#define TARGET_SNDRV_TIMER_IOCTL_STATUS TARGET_IOR('T', 0x14, \ + struct target_snd_timer_status) /* vfat ioctls */ #define TARGET_VFAT_IOCTL_READDIR_BOTH TARGET_IORU('r', 1) diff --git a/linux-user/syscall_types.h b/linux-user/syscall_types.h index 767632d..fbc4be7 100644 --- a/linux-user/syscall_types.h +++ b/linux-user/syscall_types.h @@ -120,6 +120,35 @@ STRUCT(snd_timer_select, MK_STRUCT(STRUCT_snd_timer_id), /* id */ MK_ARRAY(TYPE_CHAR, 32)) /* reserved */ +STRUCT(snd_timer_info, + TYPE_INT, /* flags */ + TYPE_INT, /* card */ + MK_ARRAY(TYPE_CHAR, 64), /* id */ + MK_ARRAY(TYPE_CHAR, 80), /* name */ + TYPE_ULONG, /* reserved0 */ + TYPE_ULONG, /* resolution */ + MK_ARRAY(TYPE_CHAR, 64)) /* reserved */ + +STRUCT(snd_timer_params, + TYPE_INT, /* flags */ + TYPE_INT, /* ticks */ + TYPE_INT, /* queue_size */ + TYPE_INT, /* reserved0 */ + TYPE_INT, /* filter */ + MK_ARRAY(TYPE_CHAR, 60)) /* reserved */ + +STRUCT(timespec, + TYPE_LONG, /* tv_sec */ + TYPE_LONG) /* tv_nsec */ + +STRUCT(snd_timer_status, + MK_STRUCT(STRUCT_timespec), /* tstamp */ + TYPE_INT, /* resolution */ + TYPE_INT, /* lost */ + TYPE_INT, /* overrun */ + TYPE_INT, /* queue */ + MK_ARRAY(TYPE_CHAR, 64)) /* reserved */ + /* loop device ioctls */ STRUCT(loop_info, TYPE_INT, /* lo_number */ From patchwork Wed Jan 15 19:36:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filip Bozuta X-Patchwork-Id: 1223827 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 47yd5F2f5Tz9sR1 for ; Thu, 16 Jan 2020 06:42:25 +1100 (AEDT) Received: from localhost ([::1]:59778 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iroYY-0004gu-T7 for incoming@patchwork.ozlabs.org; Wed, 15 Jan 2020 14:42:22 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38725) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iroTh-0005kX-FM for qemu-devel@nongnu.org; Wed, 15 Jan 2020 14:37:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iroTc-0004uq-Th for qemu-devel@nongnu.org; Wed, 15 Jan 2020 14:37:20 -0500 Received: from mx2.rt-rk.com ([89.216.37.149]:43311 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 1iroTc-0004oO-JN for qemu-devel@nongnu.org; Wed, 15 Jan 2020 14:37:16 -0500 Received: from localhost (localhost [127.0.0.1]) by mail.rt-rk.com (Postfix) with ESMTP id 7FEA31A2158; Wed, 15 Jan 2020 20:36:53 +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 4945A1A21E3; Wed, 15 Jan 2020 20:36:53 +0100 (CET) From: Filip Bozuta To: qemu-devel@nongnu.org Subject: [PATCH v8 12/13] linux-user: Add support for selected alsa timer instructions using ioctls Date: Wed, 15 Jan 2020 20:36:46 +0100 Message-Id: <1579117007-7565-13-git-send-email-Filip.Bozuta@rt-rk.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1579117007-7565-1-git-send-email-Filip.Bozuta@rt-rk.com> References: <1579117007-7565-1-git-send-email-Filip.Bozuta@rt-rk.com> 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: peter.maydell@linaro.org, berrange@redhat.com, arnd@arndb.de, richard.henderson@linaro.org, laurent@vivier.eu, jcmvbkbc@gmail.com, amarkovic@wavecomp.com, philmd@redhat.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" This patch implements functionalities of following ioctls: SNDRV_TIMER_IOCTL_START - Start selected alsa timer Starts the timer device that is selected. The third ioctl's argument is ignored. Before calling this ioctl, the ioctl "SNDRV_TIMER_IOCTL_SELECT" should be called first to select the timer that is to be started. If no timer is selected, the error EBADFD ("File descriptor in bad shape") is returned. SNDRV_TIMER_IOCTL_STOP - Stop selected alsa timer Stops the timer device that is selected. The third ioctl's argument is ignored. Before calling this ioctl, the ioctl "SNDRV_TIMER_IOCTL_SELECT" should be called first to select the timer that is to be stopped. If no timer is selected, the error EBADFD ("File descriptor in bad shape") is returned. SNDRV_TIMER_IOCTL_CONTINUE - Continue selected alsa timer Continues the timer device that is selected. The third ioctl's argument is ignored. Before calling this ioctl, the ioctl "SNDRV_TIMER_IOCTL_SELECT" should be called first to select the timer that is to be continued. If no timer is selected, the error EBADFD ("File descriptor in bad shape") is returned. SNDRV_TIMER_IOCTL_PAUSE - Pause selected alsa timer Pauses the timer device that is selected. The third ioctl's argument is ignored. Before calling this ioctl, the ioctl "SNDRV_TIMER_IOCTL_SELECT" should be called first to select the timer that is to be paused. If no timer is selected, the error EBADFD ("File descriptor in bad shape") is returned. Implementation notes: Since all of the implemented ioctls have NULL as their third argument, their implementation was straightforward. Reviewed-by: Laurent Vivier Signed-off-by: Filip Bozuta --- linux-user/ioctls.h | 4 ++++ linux-user/syscall_defs.h | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h index 43e7e5d..75a2f0e 100644 --- a/linux-user/ioctls.h +++ b/linux-user/ioctls.h @@ -466,6 +466,10 @@ MK_PTR(MK_STRUCT(STRUCT_snd_timer_params))) IOCTL(SNDRV_TIMER_IOCTL_STATUS, IOC_R, MK_PTR(MK_STRUCT(STRUCT_snd_timer_status))) + IOCTL(SNDRV_TIMER_IOCTL_START, 0, TYPE_NULL) + IOCTL(SNDRV_TIMER_IOCTL_STOP, 0, TYPE_NULL) + IOCTL(SNDRV_TIMER_IOCTL_CONTINUE, 0, TYPE_NULL) + IOCTL(SNDRV_TIMER_IOCTL_PAUSE, 0, TYPE_NULL) IOCTL(HDIO_GETGEO, IOC_R, MK_PTR(MK_STRUCT(STRUCT_hd_geometry))) IOCTL(HDIO_GET_UNMASKINTR, IOC_R, MK_PTR(TYPE_INT)) diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index d5f5cad..2d86d78 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -2505,6 +2505,10 @@ struct target_snd_timer_status { struct snd_timer_params) #define TARGET_SNDRV_TIMER_IOCTL_STATUS TARGET_IOR('T', 0x14, \ struct target_snd_timer_status) +#define TARGET_SNDRV_TIMER_IOCTL_START TARGET_IO('T', 0xa0) +#define TARGET_SNDRV_TIMER_IOCTL_STOP TARGET_IO('T', 0xa1) +#define TARGET_SNDRV_TIMER_IOCTL_CONTINUE TARGET_IO('T', 0xa2) +#define TARGET_SNDRV_TIMER_IOCTL_PAUSE TARGET_IO('T', 0xa3) /* vfat ioctls */ #define TARGET_VFAT_IOCTL_READDIR_BOTH TARGET_IORU('r', 1) From patchwork Wed Jan 15 19:36:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filip Bozuta X-Patchwork-Id: 1223834 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 47ydC46BkHz9sPW for ; Thu, 16 Jan 2020 06:47:28 +1100 (AEDT) Received: from localhost ([::1]:59880 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1irodS-0002zk-GK for incoming@patchwork.ozlabs.org; Wed, 15 Jan 2020 14:47:26 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38723) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iroTg-0005kU-Ct for qemu-devel@nongnu.org; Wed, 15 Jan 2020 14:37:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iroTc-0004uZ-PT for qemu-devel@nongnu.org; Wed, 15 Jan 2020 14:37:20 -0500 Received: from mx2.rt-rk.com ([89.216.37.149]:43313 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 1iroTc-0004oQ-JC for qemu-devel@nongnu.org; Wed, 15 Jan 2020 14:37:16 -0500 Received: from localhost (localhost [127.0.0.1]) by mail.rt-rk.com (Postfix) with ESMTP id 8DB811A20AB; Wed, 15 Jan 2020 20:36:53 +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 5338F1A2173; Wed, 15 Jan 2020 20:36:53 +0100 (CET) From: Filip Bozuta To: qemu-devel@nongnu.org Subject: [PATCH v8 13/13] linux-user: Add support for TYPE_LONG and TYPE_ULONG in do_ioctl() Date: Wed, 15 Jan 2020 20:36:47 +0100 Message-Id: <1579117007-7565-14-git-send-email-Filip.Bozuta@rt-rk.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1579117007-7565-1-git-send-email-Filip.Bozuta@rt-rk.com> References: <1579117007-7565-1-git-send-email-Filip.Bozuta@rt-rk.com> 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: peter.maydell@linaro.org, berrange@redhat.com, arnd@arndb.de, richard.henderson@linaro.org, laurent@vivier.eu, jcmvbkbc@gmail.com, amarkovic@wavecomp.com, philmd@redhat.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Function "do_ioctl()" located in file "syscall.c" was missing an option for TYPE_LONG and TYPE_ULONG. This caused some ioctls to not be recognised because they had the third argument that was of type 'long' or 'unsigned long'. For example: Since implemented ioctls RTC_IRQP_SET and RTC_EPOCH_SET are of type IOW(writing type) that have unsigned long as their third argument, they were not recognised in QEMU before the changes of this patch. Signed-off-by: Filip Bozuta Reviewed-by: Laurent Vivier --- linux-user/syscall.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index a3993a2..2ba2c5c 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -5176,6 +5176,8 @@ static abi_long do_ioctl(int fd, int cmd, abi_long arg) break; case TYPE_PTRVOID: case TYPE_INT: + case TYPE_LONG: + case TYPE_ULONG: ret = get_errno(safe_ioctl(fd, ie->host_cmd, arg)); break; case TYPE_PTR: