linux-user: Add support for real time clock and
cover linux-user: Add support for real time clock and
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_SETSound 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_PAUSEThe 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;
}v5:
* added support for alsa sound timer ioctls
v4:
* changed patch descriptions so that they are better formatted and more cemprehensible
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 (12):
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/ioctls.h | 45 +++++++++++++++++ linux-user/syscall.c | 2 + linux-user/syscall_defs.h | 121 +++++++++++++++++++++++++++++++++++++++++++++ linux-user/syscall_types.h | 91 ++++++++++++++++++++++++++++++++++ 4 files changed, 259 insertions(+)
Signature · 1 line
2.7.4
PATCH 1/12 linux-user: Add support for enabling/disabling RTC features using ioctls
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.
--- linux-user/ioctls.h | 9 +++++++++ linux-user/syscall.c | 1 + linux-user/syscall_defs.h | 10 ++++++++++ 3 files changed, 20 insertions(+)
linux-user/ioctls.h +9 -0
@@ -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 )
linux-user/syscall.c +1 -0
@@ -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"
linux-user/syscall_defs.h +10 -0
@@ -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)
Signature · 1 line
2.7.4
Re: [PATCH 01/12] linux-user: Add support for enabling/disabling RTC features using ioctls
Le 09/01/2020 à 13:59, Filip Bozuta a écrit :
Quoted 91 lines
This patch implements functionalities of following ioctls:
RTC_AIE_ON,RTC_AIE_OFF- Alarm interrupt enabling on/offEnable 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/offEnable 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/offEnable 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_RESOURCEcapability) 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/offEnable 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 <[email protected]>--- linux-user/ioctls.h | 9 +++++++++ linux-user/syscall.c | 1 + linux-user/syscall_defs.h | 10 ++++++++++ 3 files changed, 20 insertions(+)linux-user/ioctls.h +9
-0@@ -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 )linux-user/syscall.c +1
-0@@ -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" linux-user/syscall_defs.h +3
-0@@ -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)
linux-user/syscall_defs.h struct target_pollfd { · line 778
Quoted 10 lines
linux-user/syscall_defs.h +7
-0+#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)
PATCH 2/12 linux-user: Add support for getting/setting RTC time and alarm using ioctls
In reply to Filip BozutaThis 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 an 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.
--- linux-user/ioctls.h | 4 ++++ linux-user/syscall_defs.h | 4 ++++ linux-user/syscall_types.h | 11 +++++++++++ 3 files changed, 19 insertions(+)
linux-user/ioctls.h +4 -0
@@ -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 ))
linux-user/syscall_defs.h +4 -0
@@ -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 )
linux-user/syscall_types.h +11 -0
@@ -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 */
Signature · 1 line
2.7.4
Re: [PATCH 02/12] linux-user: Add support for getting/setting RTC time and alarm using ioctls
Le 09/01/2020 à 13:59, Filip Bozuta a écrit :
Quoted 96 lines
This patch implements functionalities of following ioctls:
RTC_RD_TIME- Getting RTC timeReturns 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 timeSets this RTC's time to the time specified by the
rtc_timestructure pointed to by the third ioctl's argument. To set the RTC's time the process must be privileged (i.e., have theCAP_SYS_TIMEcapability).
RTC_ALM_READ,RTC_ALM_SET- Getting/Setting alarm timeRead 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_OFFrequests. The third ioctl's argument is a pointer to anrtc_timestructure. Only thetm_sec,tm_min, andtm_hourfields of this structure are used.Implementation notes:
All ioctls in this patch have pointer to a structure
rtc_timeas their third argument. That is the reason why corresponding definition is added inlinux-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 <[email protected]>--- linux-user/ioctls.h | 4 ++++ linux-user/syscall_defs.h | 4 ++++ linux-user/syscall_types.h | 11 +++++++++++ 3 files changed, 19 insertions(+)linux-user/ioctls.h +4
-0@@ -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 ))linux-user/syscall_defs.h +4
-0@@ -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 )linux-user/syscall_types.h +4
-0@@ -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 */
linux-user/syscall_types.h STRUCT(blkpg_partition, · line 271
Quoted 10 lines
linux-user/syscall_types.h +7
-0+ 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 */
PATCH 3/12 linux-user: Add support for getting/setting RTC periodic interrupt and epoch using ioctls
In reply to Filip BozutaThis 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.
--- linux-user/ioctls.h | 4 ++++ linux-user/syscall_defs.h | 4 ++++ 2 files changed, 8 insertions(+)
linux-user/ioctls.h +4 -0
@@ -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 ))
linux-user/syscall_defs.h +4 -0
@@ -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 )
Signature · 1 line
2.7.4
Re: [PATCH 03/12] linux-user: Add support for getting/setting RTC periodic interrupt and epoch using ioctls
Le 09/01/2020 à 13:59, Filip Bozuta a écrit :
Quoted 68 lines
This patch implements functionalities of following ioctls:
RTC_IRQP_READ,RTC_IRQP_SET- Getting/Setting IRQ rateRead 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_OFFrequests. 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 theCAP_SYS_RESOURCEcapability) 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 epochMany 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_TIMEcapability).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.hcontain 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 inlinux-user/ioctls.h.Signed-off-by Filip Bozuta <[email protected]>--- linux-user/ioctls.h | 4 ++++ linux-user/syscall_defs.h | 4 ++++ 2 files changed, 8 insertions(+)linux-user/ioctls.h +4
-0@@ -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 ))linux-user/syscall_defs.h +0
-0
linux-user/syscall_defs.h struct target_pollfd { · line 785
Quoted 10 lines
linux-user/syscall_defs.h +4
-0@@ -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 )
PATCH 4/12 linux-user: Add support for getting/setting RTC wakeup alarm using ioctls
In reply to Filip BozutaThis 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.
--- linux-user/ioctls.h | 2 ++ linux-user/syscall_defs.h | 2 ++ linux-user/syscall_types.h | 5 +++++ 3 files changed, 9 insertions(+)
linux-user/ioctls.h +2 -0
@@ -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 ))
linux-user/syscall_defs.h +2 -0
@@ -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 )
linux-user/syscall_types.h +5 -0
@@ -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 */
Signature · 1 line
2.7.4
Re: [PATCH 04/12] linux-user: Add support for getting/setting RTC wakeup alarm using ioctls
Le 09/01/2020 à 13:59, Filip Bozuta a écrit :
Quoted 74 lines
This patch implements functionalities of following ioctls:
RTC_WKALM_SET,RTC_WKALM_GET- Getting/Setting wakeup alarmSome 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;
structrtc_timetime;
};The enabled flag is used to enable or disable the alarm interrupt, or to read its current status; when using these calls,
RTC_AIE_ONandRTC_AIE_OFFare not used. The pending flag is used byRTC_WKALM_RDto 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 withRTC_ALM_READandRTC_ALM_SETexcept that thetm_mday,tm_mon, andtm_yearfields 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_wkalrmas their third argument. That is the reason why corresponding definition is added inlinux-user/syscall_types.h. Since all elements of this structure are either of type 'unsigned char' or 'structrtc_time' (that was covered in one of previous patches), the rest of the implementation is straightforward.Signed-off-by Filip Bozuta <[email protected]>--- linux-user/ioctls.h | 2 ++ linux-user/syscall_defs.h | 2 ++ linux-user/syscall_types.h | 5 +++++ 3 files changed, 9 insertions(+)linux-user/ioctls.h +2
-0@@ -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 ))linux-user/syscall_defs.h +2
-0@@ -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 )linux-user/syscall_types.h +0
-0@@ -266,6 +266,11 @@ STRUCT(rtc_time, TYPE_INT, /* tm_yday */
linux-user/syscall_types.h STRUCT(rtc_time, · line 276
Quoted 10 lines
linux-user/syscall_types.h +5
-0TYPE_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 */
PATCH 5/12 linux-user: Add support for getting/setting RTC PLL correction using ioctls
In reply to Filip BozutaThis 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.
--- linux-user/ioctls.h | 2 ++ linux-user/syscall_defs.h | 14 ++++++++++++++ linux-user/syscall_types.h | 9 +++++++++ 3 files changed, 25 insertions(+)
linux-user/ioctls.h +2 -0
@@ -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 ))
linux-user/syscall_defs.h +14 -0
@@ -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 )
linux-user/syscall_types.h +9 -0
@@ -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 */
Signature · 1 line
2.7.4
Re: [PATCH 05/12] linux-user: Add support for getting/setting RTC PLL correction using ioctls
Le 09/01/2020 à 13:59, Filip Bozuta a écrit :
Quoted 98 lines
This patch implements functionalities of following ioctls:
RTC_PLL_GET- Getting PLL correctionRead the PLL correction for RTCs that support PLL. The PLL correction is returned in the following structure:
struct
rtc_pll_info{
intpll_ctrl; /* placeholder for fancier control */
intpll_value; /* get/set correction value */
intpll_max; /* max +ve (faster) adjustment value */
intpll_min; /* max -ve (slower) adjustment value */
intpll_posmult; /* factor for +ve correction */
intpll_negmult; /* factor for -ve correction */
longpll_clock; /* base PLL frequency */
};A pointer to this structure should be passed as the third ioctl's argument.
RTC_PLL_SET- Setting PLL correctionSets the PLL correction for RTCs that support PLL. The PLL correction that is set is specified by the
rtc_pll_infostructure pointed to by the third ioctl's' argument.Implementation notes:
All ioctls in this patch have a pointer to a structure
rtc_pll_infoas 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 <[email protected]>--- linux-user/ioctls.h | 2 ++ linux-user/syscall_defs.h | 14 ++++++++++++++ linux-user/syscall_types.h | 9 +++++++++ 3 files changed, 25 insertions(+)linux-user/ioctls.h +2
-0@@ -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 ))linux-user/syscall_defs.h +14
-0@@ -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 )linux-user/syscall_types.h +2
-0@@ -271,6 +271,15 @@ STRUCT(rtc_wkalrm, TYPE_CHAR, /* pending */ MK_STRUCT(STRUCT_rtc_time)) /* time */ +STRUCT(rtc_pll_info, + TYPE_INT, /* pll_ctrl */
linux-user/syscall_types.h STRUCT(rtc_wkalrm, · line 285
Quoted 10 lines
linux-user/syscall_types.h +7
-0+ 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 */
PATCH 6/12 linux-user: Add support for read/clear RTC voltage low detector using ioctls
In reply to Filip BozutaRTC_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.
--- linux-user/ioctls.h | 2 ++ linux-user/syscall_defs.h | 2 ++ 2 files changed, 4 insertions(+)
linux-user/ioctls.h +2 -0
@@ -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 ))
linux-user/syscall_defs.h +2 -0
@@ -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 )
Signature · 1 line
2.7.4
Re: [PATCH 06/12] linux-user: Add support for read/clear RTC voltage low detector using ioctls
Le 09/01/2020 à 13:59, Filip Bozuta a écrit :
Quoted 43 lines
RTC_VL_READ- Read voltage low detection informationRead 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 informationClear 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 <[email protected]>--- linux-user/ioctls.h | 2 ++ linux-user/syscall_defs.h | 2 ++ 2 files changed, 4 insertions(+)linux-user/ioctls.h +2
-0@@ -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 ))linux-user/syscall_defs.h +0
-0
linux-user/syscall_defs.h struct target_rtc_pll_info { · line 803
Quoted 8 lines
linux-user/syscall_defs.h +2
-0@@ -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 )
PATCH 7/12 linux-user: Add support for getting alsa timer version and id
In reply to Filip BozutaThis 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, then 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 is 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.
--- 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(+)
linux-user/ioctls.h +4 -0
@@ -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 ))
linux-user/syscall.c +1 -0
@@ -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"
linux-user/syscall_defs.h +5 -0
@@ -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)
linux-user/syscall_types.h +7 -0
@@ -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 */
Signature · 1 line
2.7.4
Re: [PATCH 07/12] linux-user: Add support for getting alsa timer version and id
Le 09/01/2020 à 13:59, Filip Bozuta a écrit :
Quoted 109 lines
This patch implements functionalities of following ioctls:
SNDRV_TIMER_IOCTL_PVERSION- Getting the sound timer versionRead 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 timerRead 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{
intdev_class; /* timer device class number */
intdev_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_classnumber, 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 fielddev_classshould 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, then 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 'structsnd_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 is 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 <[email protected]>--- 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(+)linux-user/ioctls.h +4
-0@@ -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 ))linux-user/syscall.c +1
-0@@ -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" linux-user/syscall_defs.h +5
-0@@ -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)linux-user/syscall_types.h +0
-0@@ -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 ))
linux-user/syscall_types.h STRUCT(buffmem_desc, · line 95
Quoted 10 lines
linux-user/syscall_types.h +7
-0+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 */
PATCH 8/12 linux-user: Add support for setting alsa timer enhanced read using ioctl
In reply to Filip BozutaThis patch implements functionalities 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.
--- linux-user/ioctls.h | 1 + linux-user/syscall_defs.h | 1 + 2 files changed, 2 insertions(+)
linux-user/ioctls.h +1 -0
@@ -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 ))
linux-user/syscall_defs.h +1 -0
@@ -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)
Signature · 1 line
2.7.4
Re: [PATCH 08/12] linux-user: Add support for setting alsa timer enhanced read using ioctl
Le 09/01/2020 à 13:59, Filip Bozuta a écrit :
Quoted 38 lines
This patch implements functionalities of following ioctl:
SNDRV_TIMER_IOCTL_TREAD- Setting enhanced time readSets 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 <[email protected]>--- linux-user/ioctls.h | 1 + linux-user/syscall_defs.h | 1 + 2 files changed, 2 insertions(+)linux-user/ioctls.h +1
-0@@ -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 ))linux-user/syscall_defs.h +0
-0
linux-user/syscall_defs.h struct target_statfs64 { · line 2435
Quoted 7 lines
linux-user/syscall_defs.h +1
-0@@ -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)
PATCH 9/12 linux-user: Add support for getting/setting specified alsa timer parameters using ioctls
In reply to Filip BozutaThis 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.
--- linux-user/ioctls.h | 6 ++++++ linux-user/syscall_defs.h | 43 +++++++++++++++++++++++++++++++++++++++++++ linux-user/syscall_types.h | 26 ++++++++++++++++++++++++++ 3 files changed, 75 insertions(+)
linux-user/ioctls.h +6 -0
@@ -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 ))
linux-user/syscall_defs.h +43 -0
54 lines not on this page · raw message
linux-user/syscall_types.h +26 -0
@@ -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 */
Signature · 1 line
2.7.4
Re: [PATCH 09/12] linux-user: Add support for getting/setting specified alsa timer parameters using ioctls
Le 09/01/2020 à 13:59, Filip Bozuta a écrit :
Quoted 191 lines
This patch implements functionalities of following ioctls:
SNDRV_TIMER_IOCTL_GINFO- Getting information about specified timerRead information about the specified timer. The information about the timer is returned in the following structure:
struct
snd_timer_ginfo{
structsnd_timer_idtid; /* 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 longresolution_min; /* minimal period resolution in ns */ unsigned longresolution_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 durationSets timer precise period duration numerator and denominator in seconds. The period duration is set in the following structure:
struct
snd_timer_gparams{
structsnd_timer_idtid; /* requested timer ID */
unsigned longperiod_num; /* period duration - numerator */
unsigned longperiod_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 resolutionRead 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{
structsnd_timer_idtid; /* requested timer ID */
unsigned long resolution; /* current period resolution in ns */
unsigned longresolution_num; /* period resolution - numerator */
unsigned longresolution_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 'structsnd_timer_id' which is the reason why a separate target structure 'structtarget_snd_timer_id' was also defined. The rest of the implementation was straightforward.Signed-off-by Filip Bozuta <[email protected]>--- linux-user/ioctls.h | 6 ++++++ linux-user/syscall_defs.h | 43 +++++++++++++++++++++++++++++++++++++++++++ linux-user/syscall_types.h | 26 ++++++++++++++++++++++++++ 3 files changed, 75 insertions(+)linux-user/ioctls.h +6
-0@@ -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 ))linux-user/syscall_defs.h +43
-0@@ -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)linux-user/syscall_types.h +19
-0@@ -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 */ +
linux-user/syscall_types.h STRUCT(snd_timer_id, · line 121
Quoted 10 lines
linux-user/syscall_types.h +7
-0+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 */
PATCH 10/12 linux-user: Add support for selecting alsa timer using ioctl
In reply to Filip BozutaThis 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.
--- linux-user/ioctls.h | 2 ++ linux-user/syscall_defs.h | 7 +++++++ linux-user/syscall_types.h | 4 ++++ 3 files changed, 13 insertions(+)
linux-user/ioctls.h +2 -0
@@ -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 ))
linux-user/syscall_defs.h +7 -0
@@ -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)
linux-user/syscall_types.h +4 -0
@@ -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 */
Signature · 1 line
2.7.4
Re: [PATCH 10/12] linux-user: Add support for selecting alsa timer using ioctl
Le 09/01/2020 à 13:59, Filip Bozuta a écrit :
Quoted 77 lines
This patch implements functionality of following ioctl:
SNDRV_TIMER_IOCTL_SELECT- Selecting timerSelects the timer which id is specified. The timer id is specified in the following strcuture:
struct
snd_timer_select{
structsnd_timer_idid; /* 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 <[email protected]>--- linux-user/ioctls.h | 2 ++ linux-user/syscall_defs.h | 7 +++++++ linux-user/syscall_types.h | 4 ++++ 3 files changed, 13 insertions(+)linux-user/ioctls.h +2
-0@@ -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 ))linux-user/syscall_defs.h +7
-0@@ -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)linux-user/syscall_types.h +0
-0
linux-user/syscall_types.h STRUCT(snd_timer_gstatus, · line 125
Quoted 10 lines
linux-user/syscall_types.h +4
-0@@ -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 */
PATCH 11/12 linux-user: Add support for getting/setting selected alsa timer parameters using ioctls
In reply to Filip BozutaThis 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.
--- linux-user/ioctls.h | 5 +++++ linux-user/syscall_defs.h | 25 +++++++++++++++++++++++++ linux-user/syscall_types.h | 29 +++++++++++++++++++++++++++++ 3 files changed, 59 insertions(+)
linux-user/ioctls.h +5 -0
@@ -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 ))
linux-user/syscall_defs.h +25 -0
@@ -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)
linux-user/syscall_types.h +29 -0
@@ -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 */
Signature · 1 line
2.7.4
Re: [PATCH 11/12] linux-user: Add support for getting/setting selected alsa timer parameters using ioctls
Le 09/01/2020 à 13:59, Filip Bozuta a écrit :
Quoted 174 lines
This patch implements functionalities of following ioctls:
SNDRV_TIMER_IOCTL_INFO- Getting information about selected timerRead 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 timerSets 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 intqueue_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 timerRead 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 <[email protected]>--- linux-user/ioctls.h | 5 +++++ linux-user/syscall_defs.h | 25 +++++++++++++++++++++++++ linux-user/syscall_types.h | 29 +++++++++++++++++++++++++++++ 3 files changed, 59 insertions(+)linux-user/ioctls.h +5
-0@@ -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 ))linux-user/syscall_defs.h +25
-0@@ -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)linux-user/syscall_types.h +22
-0@@ -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,
linux-user/syscall_types.h STRUCT(snd_timer_select, · line 154
Quoted 10 lines
linux-user/syscall_types.h +7
-0+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 */
PATCH 12/12 linux-user: Add support for selected alsa timer instructions using ioctls
In reply to Filip BozutaThis 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.
--- linux-user/ioctls.h | 4 ++++ linux-user/syscall_defs.h | 4 ++++ 2 files changed, 8 insertions(+)
linux-user/ioctls.h +4 -0
@@ -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 ))
linux-user/syscall_defs.h +4 -0
@@ -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)
Signature · 1 line
2.7.4
Re: [PATCH 12/12] linux-user: Add support for selected alsa timer instructions using ioctls
Le 09/01/2020 à 13:59, Filip Bozuta a écrit :
Quoted 66 lines
This patch implements functionalities of following ioctls:
SNDRV_TIMER_IOCTL_START- Start selected alsa timerStarts 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 timerStops 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 timerContinues 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 timerPauses 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 <[email protected]>--- linux-user/ioctls.h | 4 ++++ linux-user/syscall_defs.h | 4 ++++ 2 files changed, 8 insertions(+)linux-user/ioctls.h +4
-0@@ -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 ))linux-user/syscall_defs.h +0
-0
linux-user/syscall_defs.h struct target_snd_timer_status { · line 2514
Quoted 10 lines
linux-user/syscall_defs.h +4
-0@@ -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)
Hi Filip,
This is v5.
Quoted 103 lines · Filip Bozuta
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bitThis 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_SETSound 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_PAUSEThe 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_64host)
* 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_TIMEthe 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_timecur_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_READgives 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.
Quoted 6 lines
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.
We should be able to check if the host supports these features and run your different tests. Can you add them in the repository? Maybe under tests/tcg/multiarch/.
Quoted 134 lines
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; }v5:
* added support for alsa sound timer ioctls
v4:
* changed patch descriptions so that they are better formatted and more cemprehensible
v3:
* changed two instances of
MK_PTR(TYPE_ULONG)toTYPE_ULONGv2:
* added description of each ioctl in patches
* wrote a more detailed cover letter with description of testing
* changed one instance ofTYPE_INTtoMK_PTR(TYPE_INT)Filip Bozuta (12):
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
ioctlslinux-user/ioctls.h | 45 +++++++++++++++++ linux-user/syscall.c | 2 + linux-user/syscall_defs.h | 121 +++++++++++++++++++++++++++++++++++++++++++++ linux-user/syscall_types.h | 91 ++++++++++++++++++++++++++++++++++ 4 files changed, 259 insertions(+)
Le 14/01/2020 à 13:39, Philippe Mathieu-Daudé a écrit :
Quoted 116 lines
Hi Filip,
This is v5.
Quoted 104 lines · Filip Bozuta
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bitThis 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_SETSound 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_PAUSEThe 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_64host)
* 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_TIMEthe 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_timecur_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_READgives 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.Quoted 6 lines
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.
Quoted 4 lines
We should be able to check if the host supports these features and run your different tests.
Can you add them in the repository? Maybe under tests/tcg/multiarch/.
I agree with Philippe. If you provide the test we will also be able to run non-regression tests. You can add them in a separate patch if it's easier for you.
Thanks,
Laurent