* [PATCH v7 00/13] linux-user: Add support for real time clock and
@ 2020-01-15 19:11 Filip Bozuta
2020-01-15 19:11 ` [PATCH v7 01/13] linux-user: Add support for enabling/disabling RTC features using ioctls Filip Bozuta
` (12 more replies)
0 siblings, 13 replies; 15+ messages in thread
From: Filip Bozuta @ 2020-01-15 19:11 UTC (permalink / raw)
To: qemu-devel
Cc: peter.maydell, berrange, arnd, richard.henderson, laurent,
jcmvbkbc, amarkovic, philmd
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This series covers following RTC and sound timer ioctls:
RTC ioctls(22):
* RTC_AIE_ON * RTC_ALM_SET * RTC_WKALM_SET
* RTC_AIE_OFF * RTC_ALM_READ * RTC_WKALM_RD
* RTC_UIE_ON * RTC_RD_TIME * RTC_PLL_GET
* RTC_UIE_OFF * RTC_SET_TIME * RTC_PLL_SET
* RTC_PIE_ON * RTC_IRQP_READ * RTC_VL_READ
* RTC_PIE_OFF * RTC_IRQP_SET * RTC_VL_CLR
* RTC_WIE_ON * RTC_EPOCH_READ
* RTC_WIE_OFF * RTC_EPOCH_SET
Sound timer ioctls(14):
* SNDRV_TIMER_IOCTL_PVERSION * SNDRV_TIMER_IOCTL_INFO
* SNDRV_TIMER_IOCTL_NEXT_DEVICE * SNDRV_TIMER_IOCTL_PARAMS
* SNDRV_TIMER_IOCTL_TREAD * SNDRV_TIMER_IOCTL_STATUS
* SNDRV_TIMER_IOCTL_GINFO * SNDRV_TIMER_IOCTL_START
* SNDRV_TIMER_IOCTL_GPARAMS * SNDRV_TIMER_IOCTL_STOP
* SNDRV_TIMER_IOCTL_GSTATUS * SNDRV_TIMER_IOCTL_CONTINUE
* SNDRV_TIMER_IOCTL_SELECT * SNDRV_TIMER_IOCTL_PAUSE
The functionalities of individual ioctls were described in this series
patch commit messages.
Testing method for RTC ioctls:
Mini test programs were written for each ioctl. Those programs were
compiled (sometimes using cross-compilers) for the following
architectures:
* Intel 64-bit (little endian)
* Power pc 32-bit (big endian)
* Power pc 64-bit (big endian)
The corresponding native programs were executed without using
QEMU on following hosts:
* Intel Core i7-4790K (x86_64 host)
* Power 7447A (ppc32 host)
All applicable compiled programs were in turn executed through QEMU
and the results obtained were the same ones gotten for native
execution.
Example of a test program:
For ioctl RTC_RD_TIME the following test program was used:
#include <stdio.h>
#include <stdlib.h>
#include <linux/rtc.h>
#include <fcntl.h>
#include <linux/input.h>
#include <sys/types.h>
#include <unistd.h>
#define ERROR -1
int main()
{
int fd = open("/dev/rtc", O_RDWR | O_NONBLOCK);
if(fd == ERROR)
{
perror("open");
return -1;
}
struct rtc_time cur_time;
if(ioctl(fd, RTC_RD_TIME, &cur_time) < 0)
{
perror("ioctl");
return -1;
}
printf("Second: %d, Minute: %d, Hour: %d, Day: %d, Month: %d, Year: %d,",
cur_time.tm_sec, cur_time.tm_min, cur_time.tm_hour,
cur_time.tm_mday, cur_time.tm_mon, cur_time.tm_year);
return 0;
}
Limitations of testing:
The test host pc that was used for testing (intel pc) has RTC
that doesn't support all RTC features that are accessible
through ioctls. This means that testing can't discover
functionality errors related to the third argument of ioctls
that are used for features which are not supported. For example,
running the test program for ioctl RTC_EPOCH_READ gives
the error output: inappropriate ioctl for device. As expected,
the same output was obtained through QEMU which means that this
ioctl is recognized in QEMU but doesn't really do anything
because it is not supported in the host computer's RTC.
Conclusion: Some RTC ioctls need to be tested on computers
that support their functionalities so that it can be inferred
that they are really supported in QEMU. In absence of such
test hosts, the specifications of those ioctls need to be
carefully checked manually and the implementations should be
updated accordingly.
Testing method for sound timer ioctls:
The alsa ioctl test suite, that can be found on github
("https://github.com/alsa-project/alsa-utils"), was used the test
the implemented ioctls. The file "timer.c", located in this test
suite, contains test functions that are used to test alsa timer
ioctls. This file was compiled (sometimes using cross-compilers)
for the following architectures:
* Intel 64-bit (little endian)
* Power pc 32-bit (big endian)
* Power pc 64-bit (big endian)
The corresponding compiled test files were executed without using
QEMU on following hosts:
* Intel Core i7-4790K (x86_64 host)
* Power 7447A (ppc32 host)
The corresponding native compiled test files were executed without using
QEMU on following hosts:
* Intel Core i7-4790K (x86_64 host)
* Power 7447A (ppc32 host)
All compiled test files were in turn executed through QEMU
and the results obtained were the same ones gotten for native
execution.
Also, mini test programs were written to test further functionalities
of individual ioctls. Those programs were, like the file "timer.c",
compiled for different architectures and were executed both natively
and thgrough QEMU to compare the results.
Example of a test program:
For ioctl SNDRV_TIMER_IOCTL_GINFO the following test program was used:
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sound/asound.h>
#define ERROR -1
int main()
{
int fd = open("/dev/snd/timer", O_RDWR);
if(fd == ERROR)
{
perror("open");
return -1;
}
struct snd_timer_id id = {SNDRV_TIMER_CLASS_GLOBAL,
SNDRV_TIMER_SCLASS_NONE, -1,
SNDRV_TIMER_GLOBAL_SYSTEM, 0};
struct snd_timer_ginfo ginfo;
ginfo.tid = id;
if(ioctl(fd, SNDRV_TIMER_IOCTL_GINFO, &ginfo) == ERROR)
{
perror("ioctl");
return -1;
}
printf("flags: %u\n", ginfo.flags);
printf("card: %d\n", ginfo.card);
printf("id: %s\n", ginfo.id);
printf("name: %s\n", ginfo.name);
printf("reserved0: %lu\n", ginfo.reserved0);
printf("resolution: %lu\n", ginfo.resolution);
printf("resolution_min: %lu\n", ginfo.resolution_min);
printf("reolution_max: %lu\n", ginfo.resolution_max);
printf("clients: %u\n", ginfo.clients);
printf("reserved: %s\n", ginfo.reserved);
return 0;
}
v7:
* added separate patch for support for ioctls that have 'long' and
'unsigned long' as third argument (this functionality was added
in v6 but in v7 a separate patch was added for it)
* modified coding style for files that had styling problems
detected by script located in 'scripts/checkpatch.pl'
v6:
* fixed one patch by adding a case statement for 'unsigned long'
to recognize two ioctls that are implemented in that patch
* changed patch descriptions a little bit so that they are more
comprehensible
v5:
* added support for alsa sound timer ioctls
v4:
* changed patch descriptions so that they are better
formatted and more comprehensible
v3:
* changed two instances of MK_PTR(TYPE_ULONG) to TYPE_ULONG
v2:
* added description of each ioctl in patches
* wrote a more detailed cover letter with description of testing
* changed one instance of TYPE_INT to MK_PTR(TYPE_INT)
Filip Bozuta (13):
linux-user: Add support for enabling/disabling RTC features using
ioctls
linux-user: Add support for getting/setting RTC time and alarm using
ioctls
linux-user: Add support for getting/setting RTC periodic interrupt and
epoch using ioctls
linux-user: Add support for getting/setting RTC wakeup alarm using
ioctls
linux-user: Add support for getting/setting RTC PLL correction using
ioctls
linux-user: Add support for read/clear RTC voltage low detector using
ioctls
linux-user: Add support for getting alsa timer version and id
linux-user: Add support for setting alsa timer enhanced read using
ioctl
linux-user: Add support for getting/setting specified alsa timer
parameters using ioctls
linux-user: Add support for selecting alsa timer using ioctl
linux-user: Add support for getting/setting selected alsa timer
parameters using ioctls
linux-user: Add support for selected alsa timer instructions using
ioctls
linux-user: Add support for TYPE_LONG and TYPE_ULONG in do_ioctl()
linux-user/ioctls.h | 45 +++++++++++++++++
linux-user/syscall.c | 4 ++
linux-user/syscall_defs.h | 121 +++++++++++++++++++++++++++++++++++++++++++++
linux-user/syscall_types.h | 91 ++++++++++++++++++++++++++++++++++
4 files changed, 261 insertions(+)
--
2.7.4
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH v7 01/13] linux-user: Add support for enabling/disabling RTC features using ioctls
2020-01-15 19:11 [PATCH v7 00/13] linux-user: Add support for real time clock and Filip Bozuta
@ 2020-01-15 19:11 ` Filip Bozuta
2020-01-15 19:11 ` [PATCH v7 02/13] linux-user: Add support for getting/setting RTC time and alarm " Filip Bozuta
` (11 subsequent siblings)
12 siblings, 0 replies; 15+ messages in thread
From: Filip Bozuta @ 2020-01-15 19:11 UTC (permalink / raw)
To: qemu-devel
Cc: peter.maydell, berrange, arnd, richard.henderson, laurent,
jcmvbkbc, amarkovic, philmd
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 <linux/rtc.h>' 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.
Signed-off-by: Filip Bozuta <Filip.Bozuta@rt-rk.com>
---
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 <netpacket/packet.h>
#include <linux/netlink.h>
#include <linux/if_alg.h>
+#include <linux/rtc.h>
#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)
--
2.7.4
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v7 02/13] linux-user: Add support for getting/setting RTC time and alarm using ioctls
2020-01-15 19:11 [PATCH v7 00/13] linux-user: Add support for real time clock and Filip Bozuta
2020-01-15 19:11 ` [PATCH v7 01/13] linux-user: Add support for enabling/disabling RTC features using ioctls Filip Bozuta
@ 2020-01-15 19:11 ` Filip Bozuta
2020-01-15 19:11 ` [PATCH v7 03/13] linux-user: Add support for getting/setting RTC periodic interrupt and epoch " Filip Bozuta
` (10 subsequent siblings)
12 siblings, 0 replies; 15+ messages in thread
From: Filip Bozuta @ 2020-01-15 19:11 UTC (permalink / raw)
To: qemu-devel
Cc: peter.maydell, berrange, arnd, richard.henderson, laurent,
jcmvbkbc, amarkovic, philmd
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.
Signed-off-by: Filip Bozuta <Filip.Bozuta@rt-rk.com>
---
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 */
--
2.7.4
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v7 03/13] linux-user: Add support for getting/setting RTC periodic interrupt and epoch using ioctls
2020-01-15 19:11 [PATCH v7 00/13] linux-user: Add support for real time clock and Filip Bozuta
2020-01-15 19:11 ` [PATCH v7 01/13] linux-user: Add support for enabling/disabling RTC features using ioctls Filip Bozuta
2020-01-15 19:11 ` [PATCH v7 02/13] linux-user: Add support for getting/setting RTC time and alarm " Filip Bozuta
@ 2020-01-15 19:11 ` Filip Bozuta
2020-01-15 19:11 ` [PATCH v7 04/13] linux-user: Add support for getting/setting RTC wakeup alarm " Filip Bozuta
` (9 subsequent siblings)
12 siblings, 0 replies; 15+ messages in thread
From: Filip Bozuta @ 2020-01-15 19:11 UTC (permalink / raw)
To: qemu-devel
Cc: peter.maydell, berrange, arnd, richard.henderson, laurent,
jcmvbkbc, amarkovic, philmd
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.
Signed-off-by: Filip Bozuta <Filip.Bozuta@rt-rk.com>
---
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)
--
2.7.4
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v7 04/13] linux-user: Add support for getting/setting RTC wakeup alarm using ioctls
2020-01-15 19:11 [PATCH v7 00/13] linux-user: Add support for real time clock and Filip Bozuta
` (2 preceding siblings ...)
2020-01-15 19:11 ` [PATCH v7 03/13] linux-user: Add support for getting/setting RTC periodic interrupt and epoch " Filip Bozuta
@ 2020-01-15 19:11 ` Filip Bozuta
2020-01-15 19:11 ` [PATCH v7 05/13] linux-user: Add support for getting/setting RTC PLL correction " Filip Bozuta
` (8 subsequent siblings)
12 siblings, 0 replies; 15+ messages in thread
From: Filip Bozuta @ 2020-01-15 19:11 UTC (permalink / raw)
To: qemu-devel
Cc: peter.maydell, berrange, arnd, richard.henderson, laurent,
jcmvbkbc, amarkovic, philmd
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.
Signed-off-by: Filip Bozuta <Filip.Bozuta@rt-rk.com>
---
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 */
--
2.7.4
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v7 05/13] linux-user: Add support for getting/setting RTC PLL correction using ioctls
2020-01-15 19:11 [PATCH v7 00/13] linux-user: Add support for real time clock and Filip Bozuta
` (3 preceding siblings ...)
2020-01-15 19:11 ` [PATCH v7 04/13] linux-user: Add support for getting/setting RTC wakeup alarm " Filip Bozuta
@ 2020-01-15 19:11 ` Filip Bozuta
2020-01-15 19:11 ` [PATCH v7 06/13] linux-user: Add support for read/clear RTC voltage low detector " Filip Bozuta
` (7 subsequent siblings)
12 siblings, 0 replies; 15+ messages in thread
From: Filip Bozuta @ 2020-01-15 19:11 UTC (permalink / raw)
To: qemu-devel
Cc: peter.maydell, berrange, arnd, richard.henderson, laurent,
jcmvbkbc, amarkovic, philmd
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.
Signed-off-by: Filip Bozuta <Filip.Bozuta@rt-rk.com>
---
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 */
--
2.7.4
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v7 06/13] linux-user: Add support for read/clear RTC voltage low detector using ioctls
2020-01-15 19:11 [PATCH v7 00/13] linux-user: Add support for real time clock and Filip Bozuta
` (4 preceding siblings ...)
2020-01-15 19:11 ` [PATCH v7 05/13] linux-user: Add support for getting/setting RTC PLL correction " Filip Bozuta
@ 2020-01-15 19:11 ` Filip Bozuta
2020-01-15 19:11 ` [PATCH v7 07/13] linux-user: Add support for getting alsa timer version and id Filip Bozuta
` (6 subsequent siblings)
12 siblings, 0 replies; 15+ messages in thread
From: Filip Bozuta @ 2020-01-15 19:11 UTC (permalink / raw)
To: qemu-devel
Cc: peter.maydell, berrange, arnd, richard.henderson, laurent,
jcmvbkbc, amarkovic, philmd
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.
Signed-off-by: Filip Bozuta <Filip.Bozuta@rt-rk.com>
---
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)
--
2.7.4
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v7 07/13] linux-user: Add support for getting alsa timer version and id
2020-01-15 19:11 [PATCH v7 00/13] linux-user: Add support for real time clock and Filip Bozuta
` (5 preceding siblings ...)
2020-01-15 19:11 ` [PATCH v7 06/13] linux-user: Add support for read/clear RTC voltage low detector " Filip Bozuta
@ 2020-01-15 19:11 ` Filip Bozuta
2020-01-15 19:11 ` [PATCH v7 08/13] linux-user: Add support for setting alsa timer enhanced read using ioctl Filip Bozuta
` (5 subsequent siblings)
12 siblings, 0 replies; 15+ messages in thread
From: Filip Bozuta @ 2020-01-15 19:11 UTC (permalink / raw)
To: qemu-devel
Cc: peter.maydell, berrange, arnd, richard.henderson, laurent,
jcmvbkbc, amarkovic, philmd
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 <linux/rtc.h>' 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.
Signed-off-by: Filip Bozuta <Filip.Bozuta@rt-rk.com>
---
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 <linux/netlink.h>
#include <linux/if_alg.h>
#include <linux/rtc.h>
+#include <sound/asound.h>
#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 */
--
2.7.4
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v7 08/13] linux-user: Add support for setting alsa timer enhanced read using ioctl
2020-01-15 19:11 [PATCH v7 00/13] linux-user: Add support for real time clock and Filip Bozuta
` (6 preceding siblings ...)
2020-01-15 19:11 ` [PATCH v7 07/13] linux-user: Add support for getting alsa timer version and id Filip Bozuta
@ 2020-01-15 19:11 ` Filip Bozuta
2020-01-15 19:11 ` [PATCH v7 09/13] linux-user: Add support for getting/setting specified alsa timer parameters using ioctls Filip Bozuta
` (4 subsequent siblings)
12 siblings, 0 replies; 15+ messages in thread
From: Filip Bozuta @ 2020-01-15 19:11 UTC (permalink / raw)
To: qemu-devel
Cc: peter.maydell, berrange, arnd, richard.henderson, laurent,
jcmvbkbc, amarkovic, philmd
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.
Signed-off-by: Filip Bozuta <Filip.Bozuta@rt-rk.com>
---
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)
--
2.7.4
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v7 09/13] linux-user: Add support for getting/setting specified alsa timer parameters using ioctls
2020-01-15 19:11 [PATCH v7 00/13] linux-user: Add support for real time clock and Filip Bozuta
` (7 preceding siblings ...)
2020-01-15 19:11 ` [PATCH v7 08/13] linux-user: Add support for setting alsa timer enhanced read using ioctl Filip Bozuta
@ 2020-01-15 19:11 ` Filip Bozuta
2020-01-15 19:12 ` [PATCH v7 10/13] linux-user: Add support for selecting alsa timer using ioctl Filip Bozuta
` (3 subsequent siblings)
12 siblings, 0 replies; 15+ messages in thread
From: Filip Bozuta @ 2020-01-15 19:11 UTC (permalink / raw)
To: qemu-devel
Cc: peter.maydell, berrange, arnd, richard.henderson, laurent,
jcmvbkbc, amarkovic, philmd
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.
Signed-off-by: Filip Bozuta <Filip.Bozuta@rt-rk.com>
---
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 */
--
2.7.4
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v7 10/13] linux-user: Add support for selecting alsa timer using ioctl
2020-01-15 19:11 [PATCH v7 00/13] linux-user: Add support for real time clock and Filip Bozuta
` (8 preceding siblings ...)
2020-01-15 19:11 ` [PATCH v7 09/13] linux-user: Add support for getting/setting specified alsa timer parameters using ioctls Filip Bozuta
@ 2020-01-15 19:12 ` Filip Bozuta
2020-01-15 19:12 ` [PATCH v7 11/13] linux-user: Add support for getting/setting selected alsa timer parameters using ioctls Filip Bozuta
` (2 subsequent siblings)
12 siblings, 0 replies; 15+ messages in thread
From: Filip Bozuta @ 2020-01-15 19:12 UTC (permalink / raw)
To: qemu-devel
Cc: peter.maydell, berrange, arnd, richard.henderson, laurent,
jcmvbkbc, amarkovic, philmd
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.
Signed-off-by: Filip Bozuta <Filip.Bozuta@rt-rk.com>
---
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 */
--
2.7.4
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v7 11/13] linux-user: Add support for getting/setting selected alsa timer parameters using ioctls
2020-01-15 19:11 [PATCH v7 00/13] linux-user: Add support for real time clock and Filip Bozuta
` (9 preceding siblings ...)
2020-01-15 19:12 ` [PATCH v7 10/13] linux-user: Add support for selecting alsa timer using ioctl Filip Bozuta
@ 2020-01-15 19:12 ` Filip Bozuta
2020-01-15 19:12 ` [PATCH v7 12/13] linux-user: Add support for selected alsa timer instructions " Filip Bozuta
2020-01-15 19:12 ` [PATCH v7 13/13] linux-user: Add support for TYPE_LONG and TYPE_ULONG in do_ioctl() Filip Bozuta
12 siblings, 0 replies; 15+ messages in thread
From: Filip Bozuta @ 2020-01-15 19:12 UTC (permalink / raw)
To: qemu-devel
Cc: peter.maydell, berrange, arnd, richard.henderson, laurent,
jcmvbkbc, amarkovic, philmd
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.
Signed-off-by: Filip Bozuta <Filip.Bozuta@rt-rk.com>
---
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 */
--
2.7.4
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v7 12/13] linux-user: Add support for selected alsa timer instructions using ioctls
2020-01-15 19:11 [PATCH v7 00/13] linux-user: Add support for real time clock and Filip Bozuta
` (10 preceding siblings ...)
2020-01-15 19:12 ` [PATCH v7 11/13] linux-user: Add support for getting/setting selected alsa timer parameters using ioctls Filip Bozuta
@ 2020-01-15 19:12 ` Filip Bozuta
2020-01-15 19:12 ` [PATCH v7 13/13] linux-user: Add support for TYPE_LONG and TYPE_ULONG in do_ioctl() Filip Bozuta
12 siblings, 0 replies; 15+ messages in thread
From: Filip Bozuta @ 2020-01-15 19:12 UTC (permalink / raw)
To: qemu-devel
Cc: peter.maydell, berrange, arnd, richard.henderson, laurent,
jcmvbkbc, amarkovic, philmd
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.
Signed-off-by: Filip Bozuta <Filip.Bozuta@rt-rk.com>
---
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)
--
2.7.4
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v7 13/13] linux-user: Add support for TYPE_LONG and TYPE_ULONG in do_ioctl()
2020-01-15 19:11 [PATCH v7 00/13] linux-user: Add support for real time clock and Filip Bozuta
` (11 preceding siblings ...)
2020-01-15 19:12 ` [PATCH v7 12/13] linux-user: Add support for selected alsa timer instructions " Filip Bozuta
@ 2020-01-15 19:12 ` Filip Bozuta
2020-01-15 21:53 ` Laurent Vivier
12 siblings, 1 reply; 15+ messages in thread
From: Filip Bozuta @ 2020-01-15 19:12 UTC (permalink / raw)
To: qemu-devel
Cc: peter.maydell, berrange, arnd, richard.henderson, laurent,
jcmvbkbc, amarkovic, philmd
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 <Filip.Bozuta@rt-rk.com>
---
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:
--
2.7.4
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH v7 13/13] linux-user: Add support for TYPE_LONG and TYPE_ULONG in do_ioctl()
2020-01-15 19:12 ` [PATCH v7 13/13] linux-user: Add support for TYPE_LONG and TYPE_ULONG in do_ioctl() Filip Bozuta
@ 2020-01-15 21:53 ` Laurent Vivier
0 siblings, 0 replies; 15+ messages in thread
From: Laurent Vivier @ 2020-01-15 21:53 UTC (permalink / raw)
To: Filip Bozuta, qemu-devel
Cc: peter.maydell, berrange, arnd, richard.henderson, jcmvbkbc,
amarkovic, philmd
Le 15/01/2020 à 20:12, Filip Bozuta a écrit :
> 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 <Filip.Bozuta@rt-rk.com>
> ---
> 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:
>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2020-01-15 21:54 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-15 19:11 [PATCH v7 00/13] linux-user: Add support for real time clock and Filip Bozuta
2020-01-15 19:11 ` [PATCH v7 01/13] linux-user: Add support for enabling/disabling RTC features using ioctls Filip Bozuta
2020-01-15 19:11 ` [PATCH v7 02/13] linux-user: Add support for getting/setting RTC time and alarm " Filip Bozuta
2020-01-15 19:11 ` [PATCH v7 03/13] linux-user: Add support for getting/setting RTC periodic interrupt and epoch " Filip Bozuta
2020-01-15 19:11 ` [PATCH v7 04/13] linux-user: Add support for getting/setting RTC wakeup alarm " Filip Bozuta
2020-01-15 19:11 ` [PATCH v7 05/13] linux-user: Add support for getting/setting RTC PLL correction " Filip Bozuta
2020-01-15 19:11 ` [PATCH v7 06/13] linux-user: Add support for read/clear RTC voltage low detector " Filip Bozuta
2020-01-15 19:11 ` [PATCH v7 07/13] linux-user: Add support for getting alsa timer version and id Filip Bozuta
2020-01-15 19:11 ` [PATCH v7 08/13] linux-user: Add support for setting alsa timer enhanced read using ioctl Filip Bozuta
2020-01-15 19:11 ` [PATCH v7 09/13] linux-user: Add support for getting/setting specified alsa timer parameters using ioctls Filip Bozuta
2020-01-15 19:12 ` [PATCH v7 10/13] linux-user: Add support for selecting alsa timer using ioctl Filip Bozuta
2020-01-15 19:12 ` [PATCH v7 11/13] linux-user: Add support for getting/setting selected alsa timer parameters using ioctls Filip Bozuta
2020-01-15 19:12 ` [PATCH v7 12/13] linux-user: Add support for selected alsa timer instructions " Filip Bozuta
2020-01-15 19:12 ` [PATCH v7 13/13] linux-user: Add support for TYPE_LONG and TYPE_ULONG in do_ioctl() Filip Bozuta
2020-01-15 21:53 ` Laurent Vivier
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.