* [PATCH v2 for 5.0 0/6] linux-user: Add support for real time clock ioctls
@ 2019-11-14 15:13 Filip Bozuta
2019-11-14 15:13 ` [PATCH v2 for 5.0 1/6] linux-user: Add support for enable/disable RTC features using ioctls Filip Bozuta
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: Filip Bozuta @ 2019-11-14 15:13 UTC (permalink / raw)
To: qemu-devel; +Cc: laurent, Filip.Bozuta
Add ioctls for all RTC features that are currently supported in linux kernel.
This series covers following iocts:
* RTC_AIE_ON
* RTC_AIE_OFF
* RTC_UIE_ON
* RTC_UIE_OFF
* RTC_PIE_ON
* RTC_PIE_OFF
* RTC_WIE_ON
* RTC_WIE_OFF
* RTC_ALM_SET
* RTC_ALM_READ
* RTC_RD_TIME
* RTC_SET_TIME
* RTC_IRQP_READ
* RTC_IRQP_SET
* RTC_EPOCH_READ
* RTC_EPOCH_SET
* RTC_WKALM_SET
* RTC_WKALM_RD
* RTC_PLL_GET
* RTC_PLL_SET
* RTC_VL_READ
* RTC_VL_CLR
The functionalities of individual ioctls were described in this series
patch commit messages.
Testing method:
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(R) Core(TM) i7-4790K CPU @ 4.00GHz
*.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 we have used the following test program:
#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;
}
Filip Bozuta (6):
linux-user: Add support for enable/disable RTC features using ioctls
linux-user: Add support for read/set RTC time and alarm using ioctls
linux-user: Add support for read/set RTC periodic interrupt and epoch
using ioctls
linux-user: Add support for get/set RTC wakeup alarm using ioctls
linux-user: Add support for get/set RTC PLL correction using ioctls
linux-user: Add support for read/clear RTC voltage low detector using
ioctls
linux-user/ioctls.h | 23 +++++++++++++++++++++++
linux-user/syscall.c | 1 +
linux-user/syscall_defs.h | 36 ++++++++++++++++++++++++++++++++++++
linux-user/syscall_types.h | 25 +++++++++++++++++++++++++
4 files changed, 85 insertions(+)
--
2.7.4
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2 for 5.0 1/6] linux-user: Add support for enable/disable RTC features using ioctls
2019-11-14 15:13 [PATCH v2 for 5.0 0/6] linux-user: Add support for real time clock ioctls Filip Bozuta
@ 2019-11-14 15:13 ` Filip Bozuta
2019-11-14 15:13 ` [PATCH v2 for 5.0 2/6] linux-user: Add support for read/set RTC time and alarm " Filip Bozuta
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Filip Bozuta @ 2019-11-14 15:13 UTC (permalink / raw)
To: qemu-devel; +Cc: laurent, Filip.Bozuta
This patch implements functionalities of following ioctls:
RTC_AIE_ON, RTC_AIE_OFF - Alarm interrupt enable 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 enable 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 enable 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 enable on/off
Enable or disable the Watchdog interrupt, for RTCs that sup-
port this Watchdog interrupt. The third ioctl's argument is
ignored.
Implementation notes:
Since all of involved ioctls have NULL as their third argument,
their implementation was straightforward.
The line '#include <linux/rtc.h>' was added to recognize
preprocessor definitions for these ioctls. This needs to be
done only once in this series of commits. Also, the content
of this file (with respect to ioctl definitions) remained
unchanged for a long time, therefore there is no need to
worry about supporting older Linux kernel version.
Signed-off-by: Filip Bozuta <Filip.Bozuta@rt-rk.com>
---
linux-user/ioctls.h | 9 +++++++++
linux-user/syscall.c | 1 +
linux-user/syscall_defs.h | 10 ++++++++++
3 files changed, 20 insertions(+)
diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h
index c6b9d6a..97741c7 100644
--- a/linux-user/ioctls.h
+++ b/linux-user/ioctls.h
@@ -69,6 +69,15 @@
IOCTL(KDSETLED, 0, TYPE_INT)
IOCTL_SPECIAL(KDSIGACCEPT, 0, do_ioctl_kdsigaccept, TYPE_INT)
+ IOCTL(RTC_AIE_ON, 0, TYPE_NULL)
+ IOCTL(RTC_AIE_OFF, 0, TYPE_NULL)
+ IOCTL(RTC_UIE_ON, 0, TYPE_NULL)
+ IOCTL(RTC_UIE_OFF, 0, TYPE_NULL)
+ IOCTL(RTC_PIE_ON, 0, TYPE_NULL)
+ IOCTL(RTC_PIE_OFF, 0, TYPE_NULL)
+ IOCTL(RTC_WIE_ON, 0, TYPE_NULL)
+ IOCTL(RTC_WIE_OFF, 0, TYPE_NULL)
+
IOCTL(BLKROSET, IOC_W, MK_PTR(TYPE_INT))
IOCTL(BLKROGET, IOC_R, MK_PTR(TYPE_INT))
IOCTL(BLKRRPART, 0, TYPE_NULL)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index ce399a5..74c3c08 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -107,6 +107,7 @@
#include <netpacket/packet.h>
#include <linux/netlink.h>
#include <linux/if_alg.h>
+#include <linux/rtc.h>
#include "linux_loop.h"
#include "uname.h"
diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
index 98c2119..f91579a 100644
--- a/linux-user/syscall_defs.h
+++ b/linux-user/syscall_defs.h
@@ -763,6 +763,16 @@ struct target_pollfd {
#define TARGET_KDSETLED 0x4B32 /* set led state [lights, not flags] */
#define TARGET_KDSIGACCEPT 0x4B4E
+/* real time clock ioctls */
+#define TARGET_RTC_AIE_ON TARGET_IO('p', 0x01)
+#define TARGET_RTC_AIE_OFF TARGET_IO('p', 0x02)
+#define TARGET_RTC_UIE_ON TARGET_IO('p', 0x03)
+#define TARGET_RTC_UIE_OFF TARGET_IO('p', 0x04)
+#define TARGET_RTC_PIE_ON TARGET_IO('p', 0x05)
+#define TARGET_RTC_PIE_OFF TARGET_IO('p', 0x06)
+#define TARGET_RTC_WIE_ON TARGET_IO('p', 0x0f)
+#define TARGET_RTC_WIE_OFF TARGET_IO('p', 0x10)
+
#if defined(TARGET_ALPHA) || defined(TARGET_MIPS) || defined(TARGET_SH4) || \
defined(TARGET_XTENSA)
#define TARGET_FIOGETOWN TARGET_IOR('f', 123, int)
--
2.7.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v2 for 5.0 2/6] linux-user: Add support for read/set RTC time and alarm using ioctls
2019-11-14 15:13 [PATCH v2 for 5.0 0/6] linux-user: Add support for real time clock ioctls Filip Bozuta
2019-11-14 15:13 ` [PATCH v2 for 5.0 1/6] linux-user: Add support for enable/disable RTC features using ioctls Filip Bozuta
@ 2019-11-14 15:13 ` Filip Bozuta
2019-11-14 15:13 ` [PATCH v2 for 5.0 3/6] linux-user: Add support for read/set RTC periodic interrupt and epoch " Filip Bozuta
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Filip Bozuta @ 2019-11-14 15:13 UTC (permalink / raw)
To: qemu-devel; +Cc: laurent, Filip.Bozuta
This patch implements functionalities of following ioctls:
RTC_RD_TIME - Read 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 for 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 - Set 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 - Read/Set 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.
Signed-off-by: Filip Bozuta <Filip.Bozuta@rt-rk.com>
---
linux-user/ioctls.h | 4 ++++
linux-user/syscall_defs.h | 4 ++++
linux-user/syscall_types.h | 11 +++++++++++
3 files changed, 19 insertions(+)
diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h
index 97741c7..f472794 100644
--- a/linux-user/ioctls.h
+++ b/linux-user/ioctls.h
@@ -77,6 +77,10 @@
IOCTL(RTC_PIE_OFF, 0, TYPE_NULL)
IOCTL(RTC_WIE_ON, 0, TYPE_NULL)
IOCTL(RTC_WIE_OFF, 0, TYPE_NULL)
+ IOCTL(RTC_ALM_READ, IOC_R, MK_PTR(MK_STRUCT(STRUCT_rtc_time)))
+ IOCTL(RTC_ALM_SET, IOC_W, MK_PTR(MK_STRUCT(STRUCT_rtc_time)))
+ IOCTL(RTC_RD_TIME, IOC_R, MK_PTR(MK_STRUCT(STRUCT_rtc_time)))
+ IOCTL(RTC_SET_TIME, IOC_W, MK_PTR(MK_STRUCT(STRUCT_rtc_time)))
IOCTL(BLKROSET, IOC_W, MK_PTR(TYPE_INT))
IOCTL(BLKROGET, IOC_R, MK_PTR(TYPE_INT))
diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
index f91579a..f0bf09d 100644
--- a/linux-user/syscall_defs.h
+++ b/linux-user/syscall_defs.h
@@ -772,6 +772,10 @@ struct target_pollfd {
#define TARGET_RTC_PIE_OFF TARGET_IO('p', 0x06)
#define TARGET_RTC_WIE_ON TARGET_IO('p', 0x0f)
#define TARGET_RTC_WIE_OFF TARGET_IO('p', 0x10)
+#define TARGET_RTC_ALM_READ TARGET_IOR('p', 0x08, struct rtc_time)
+#define TARGET_RTC_ALM_SET TARGET_IOW('p', 0x07, struct rtc_time)
+#define TARGET_RTC_RD_TIME TARGET_IOR('p', 0x09, struct rtc_time)
+#define TARGET_RTC_SET_TIME TARGET_IOW('p', 0x0a, struct rtc_time)
#if defined(TARGET_ALPHA) || defined(TARGET_MIPS) || defined(TARGET_SH4) || \
defined(TARGET_XTENSA)
diff --git a/linux-user/syscall_types.h b/linux-user/syscall_types.h
index 4e36983..a35072a 100644
--- a/linux-user/syscall_types.h
+++ b/linux-user/syscall_types.h
@@ -255,6 +255,17 @@ STRUCT(blkpg_partition,
MK_ARRAY(TYPE_CHAR, BLKPG_DEVNAMELTH), /* devname */
MK_ARRAY(TYPE_CHAR, BLKPG_VOLNAMELTH)) /* volname */
+STRUCT(rtc_time,
+ TYPE_INT, /* tm_sec */
+ TYPE_INT, /* tm_min */
+ TYPE_INT, /* tm_hour */
+ TYPE_INT, /* tm_mday */
+ TYPE_INT, /* tm_mon */
+ TYPE_INT, /* tm_year */
+ TYPE_INT, /* tm_wday */
+ TYPE_INT, /* tm_yday */
+ TYPE_INT) /* tm_isdst */
+
STRUCT(blkpg_ioctl_arg,
TYPE_INT, /* op */
TYPE_INT, /* flags */
--
2.7.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v2 for 5.0 3/6] linux-user: Add support for read/set RTC periodic interrupt and epoch using ioctls
2019-11-14 15:13 [PATCH v2 for 5.0 0/6] linux-user: Add support for real time clock ioctls Filip Bozuta
2019-11-14 15:13 ` [PATCH v2 for 5.0 1/6] linux-user: Add support for enable/disable RTC features using ioctls Filip Bozuta
2019-11-14 15:13 ` [PATCH v2 for 5.0 2/6] linux-user: Add support for read/set RTC time and alarm " Filip Bozuta
@ 2019-11-14 15:13 ` Filip Bozuta
2019-11-14 15:13 ` [PATCH v2 for 5.0 4/6] linux-user: Add support for get/set RTC wakeup alarm " Filip Bozuta
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Filip Bozuta @ 2019-11-14 15:13 UTC (permalink / raw)
To: qemu-devel; +Cc: laurent, Filip.Bozuta
This patch implements functionalities of following ioctls:
RTC_IRQP_READ, RTC_IRQP_SET - Read/Set 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 - Read/Set epoch
Many RTCs encode the year in an 8-bit register which is either
interpreted as an 8-bit binary number or as a BCD number. In
both cases, the number is interpreted relative to this RTC's
Epoch. The RTC's Epoch is initialized to 1900 on most systems
but on Alpha and MIPS it might also be initialized to 1952,
1980, or 2000, depending on the value of an RTC register for
the year. With some RTCs, these operations can be used to
read or to set the RTC's Epoch, respectively. The third
ioctl's argument is an unsigned long * or an unsigned long,
respectively, and the value returned (or assigned) is the
Epoch. To set the RTC's Epoch the process must be privileged
(i.e., have the CAP_SYS_TIME capability).
Implementation notes:
All ioctls in this patch have a pointer to 'ulong' as their
third argument. That is the reason why corresponding parts
of added code in linux-user/syscall_defs.h contain special
handling related to 'ulong' type: they use 'abi_ulong' type
to make sure that ioctl's code is calculated correctly for
both 32-bit and 64-bit targets. Also, 'MK_PTR(TYPE_ULONG)'
is used for the similar reason in linux-user/ioctls.h.
Signed-off-by: Filip Bozuta <Filip.Bozuta@rt-rk.com>
---
linux-user/ioctls.h | 4 ++++
linux-user/syscall_defs.h | 4 ++++
2 files changed, 8 insertions(+)
diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h
index f472794..fa2fe7f 100644
--- a/linux-user/ioctls.h
+++ b/linux-user/ioctls.h
@@ -81,6 +81,10 @@
IOCTL(RTC_ALM_SET, IOC_W, MK_PTR(MK_STRUCT(STRUCT_rtc_time)))
IOCTL(RTC_RD_TIME, IOC_R, MK_PTR(MK_STRUCT(STRUCT_rtc_time)))
IOCTL(RTC_SET_TIME, IOC_W, MK_PTR(MK_STRUCT(STRUCT_rtc_time)))
+ IOCTL(RTC_IRQP_READ, IOC_R, MK_PTR(TYPE_ULONG))
+ IOCTL(RTC_IRQP_SET, IOC_W, MK_PTR(TYPE_ULONG))
+ IOCTL(RTC_EPOCH_READ, IOC_R, MK_PTR(TYPE_ULONG))
+ IOCTL(RTC_EPOCH_SET, IOC_W, MK_PTR(TYPE_ULONG))
IOCTL(BLKROSET, IOC_W, MK_PTR(TYPE_INT))
IOCTL(BLKROGET, IOC_R, MK_PTR(TYPE_INT))
diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
index f0bf09d..bbfa935 100644
--- a/linux-user/syscall_defs.h
+++ b/linux-user/syscall_defs.h
@@ -776,6 +776,10 @@ struct target_pollfd {
#define TARGET_RTC_ALM_SET TARGET_IOW('p', 0x07, struct rtc_time)
#define TARGET_RTC_RD_TIME TARGET_IOR('p', 0x09, struct rtc_time)
#define TARGET_RTC_SET_TIME TARGET_IOW('p', 0x0a, struct rtc_time)
+#define TARGET_RTC_IRQP_READ TARGET_IOR('p', 0x0b, abi_ulong)
+#define TARGET_RTC_IRQP_SET TARGET_IOW('p', 0x0c, abi_ulong)
+#define TARGET_RTC_EPOCH_READ TARGET_IOR('p', 0x0d, abi_ulong)
+#define TARGET_RTC_EPOCH_SET TARGET_IOW('p', 0x0e, abi_ulong)
#if defined(TARGET_ALPHA) || defined(TARGET_MIPS) || defined(TARGET_SH4) || \
defined(TARGET_XTENSA)
--
2.7.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v2 for 5.0 4/6] linux-user: Add support for get/set RTC wakeup alarm using ioctls
2019-11-14 15:13 [PATCH v2 for 5.0 0/6] linux-user: Add support for real time clock ioctls Filip Bozuta
` (2 preceding siblings ...)
2019-11-14 15:13 ` [PATCH v2 for 5.0 3/6] linux-user: Add support for read/set RTC periodic interrupt and epoch " Filip Bozuta
@ 2019-11-14 15:13 ` Filip Bozuta
2019-11-14 15:13 ` [PATCH v2 for 5.0 5/6] linux-user: Add support for get/set RTC PLL correction " Filip Bozuta
2019-11-14 15:13 ` [PATCH v2 for 5.0 6/6] linux-user: Add support for read/clear RTC voltage low detector " Filip Bozuta
5 siblings, 0 replies; 7+ messages in thread
From: Filip Bozuta @ 2019-11-14 15:13 UTC (permalink / raw)
To: qemu-devel; +Cc: laurent, Filip.Bozuta
This patch implements functionalities of following ioctls:
RTC_WKALM_SET, RTC_WKALM_GET - Get/Set wakeup alarm
Some RTCs support a more powerful alarm interface, using these
ioctls to read or write the RTC's alarm time (respectively)
with this structure:
struct rtc_wkalrm {
unsigned char enabled;
unsigned char pending;
struct rtc_time time;
};
The enabled flag is used to enable or disable the alarm inter‐
rupt, or to read its current status; when using these calls,
RTC_AIE_ON and RTC_AIE_OFF are not used. The pending flag is
used by RTC_WKALM_RD to report a pending interrupt (so it's
mostly useless on Linux, except when talking to the RTC man‐
aged by EFI firmware). The time field is as used with
RTC_ALM_READ and RTC_ALM_SET except that the tm_mday, tm_mon,
and tm_year fields are also valid. A pointer to this struc‐
ture should be passed as the third ioctl's argument.
Implementation notes:
All ioctls in this patch have pointer to a structure rtc_wkalrm
as their third argument. That is the reason why corresponding
definition is added in linux-user/syscall_types.h. Since all
elements of this structure are either of type 'unsigned char'
or 'struct rtc_time' (that was covered in one of previous
patches), the rest of the implementation is straightforward.
Signed-off-by: Filip Bozuta <Filip.Bozuta@rt-rk.com>
---
linux-user/ioctls.h | 2 ++
linux-user/syscall_defs.h | 2 ++
linux-user/syscall_types.h | 5 +++++
3 files changed, 9 insertions(+)
diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h
index fa2fe7f..e4d89c2 100644
--- a/linux-user/ioctls.h
+++ b/linux-user/ioctls.h
@@ -85,6 +85,8 @@
IOCTL(RTC_IRQP_SET, IOC_W, MK_PTR(TYPE_ULONG))
IOCTL(RTC_EPOCH_READ, IOC_R, MK_PTR(TYPE_ULONG))
IOCTL(RTC_EPOCH_SET, IOC_W, MK_PTR(TYPE_ULONG))
+ IOCTL(RTC_WKALM_RD, IOC_R, MK_PTR(MK_STRUCT(STRUCT_rtc_wkalrm)))
+ IOCTL(RTC_WKALM_SET, IOC_W, MK_PTR(MK_STRUCT(STRUCT_rtc_wkalrm)))
IOCTL(BLKROSET, IOC_W, MK_PTR(TYPE_INT))
IOCTL(BLKROGET, IOC_R, MK_PTR(TYPE_INT))
diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
index bbfa935..37504a2 100644
--- a/linux-user/syscall_defs.h
+++ b/linux-user/syscall_defs.h
@@ -780,6 +780,8 @@ struct target_pollfd {
#define TARGET_RTC_IRQP_SET TARGET_IOW('p', 0x0c, abi_ulong)
#define TARGET_RTC_EPOCH_READ TARGET_IOR('p', 0x0d, abi_ulong)
#define TARGET_RTC_EPOCH_SET TARGET_IOW('p', 0x0e, abi_ulong)
+#define TARGET_RTC_WKALM_RD TARGET_IOR('p', 0x10, struct rtc_wkalrm)
+#define TARGET_RTC_WKALM_SET TARGET_IOW('p', 0x0f, struct rtc_wkalrm)
#if defined(TARGET_ALPHA) || defined(TARGET_MIPS) || defined(TARGET_SH4) || \
defined(TARGET_XTENSA)
diff --git a/linux-user/syscall_types.h b/linux-user/syscall_types.h
index a35072a..820bc8e 100644
--- a/linux-user/syscall_types.h
+++ b/linux-user/syscall_types.h
@@ -266,6 +266,11 @@ STRUCT(rtc_time,
TYPE_INT, /* tm_yday */
TYPE_INT) /* tm_isdst */
+STRUCT(rtc_wkalrm,
+ TYPE_CHAR, /* enabled */
+ TYPE_CHAR, /* pending */
+ MK_STRUCT(STRUCT_rtc_time)) /* time */
+
STRUCT(blkpg_ioctl_arg,
TYPE_INT, /* op */
TYPE_INT, /* flags */
--
2.7.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v2 for 5.0 5/6] linux-user: Add support for get/set RTC PLL correction using ioctls
2019-11-14 15:13 [PATCH v2 for 5.0 0/6] linux-user: Add support for real time clock ioctls Filip Bozuta
` (3 preceding siblings ...)
2019-11-14 15:13 ` [PATCH v2 for 5.0 4/6] linux-user: Add support for get/set RTC wakeup alarm " Filip Bozuta
@ 2019-11-14 15:13 ` Filip Bozuta
2019-11-14 15:13 ` [PATCH v2 for 5.0 6/6] linux-user: Add support for read/clear RTC voltage low detector " Filip Bozuta
5 siblings, 0 replies; 7+ messages in thread
From: Filip Bozuta @ 2019-11-14 15:13 UTC (permalink / raw)
To: qemu-devel; +Cc: laurent, Filip.Bozuta
This patch implements functionalities of following ioctls:
RTC_PLL_GET - Get 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 - Set 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 pointer to a structure rtc_pll_info
as their third argument. All elements of this structure are of
type 'int', except the last one that is of type 'long'. That is
the reason why a separate target structure (target_rtc_pll_info)
is defined in linux-user/syscall_defs. The rest of the
implementation is straightforward.
Signed-off-by: Filip Bozuta <Filip.Bozuta@rt-rk.com>
---
linux-user/ioctls.h | 2 ++
linux-user/syscall_defs.h | 14 ++++++++++++++
linux-user/syscall_types.h | 9 +++++++++
3 files changed, 25 insertions(+)
diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h
index e4d89c2..a8dd235 100644
--- a/linux-user/ioctls.h
+++ b/linux-user/ioctls.h
@@ -87,6 +87,8 @@
IOCTL(RTC_EPOCH_SET, IOC_W, MK_PTR(TYPE_ULONG))
IOCTL(RTC_WKALM_RD, IOC_R, MK_PTR(MK_STRUCT(STRUCT_rtc_wkalrm)))
IOCTL(RTC_WKALM_SET, IOC_W, MK_PTR(MK_STRUCT(STRUCT_rtc_wkalrm)))
+ IOCTL(RTC_PLL_GET, IOC_R, MK_PTR(MK_STRUCT(STRUCT_rtc_pll_info)))
+ IOCTL(RTC_PLL_SET, IOC_W, MK_PTR(MK_STRUCT(STRUCT_rtc_pll_info)))
IOCTL(BLKROSET, IOC_W, MK_PTR(TYPE_INT))
IOCTL(BLKROGET, IOC_R, MK_PTR(TYPE_INT))
diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
index 37504a2..8370f41 100644
--- a/linux-user/syscall_defs.h
+++ b/linux-user/syscall_defs.h
@@ -763,6 +763,16 @@ struct target_pollfd {
#define TARGET_KDSETLED 0x4B32 /* set led state [lights, not flags] */
#define TARGET_KDSIGACCEPT 0x4B4E
+struct target_rtc_pll_info {
+ int pll_ctrl;
+ int pll_value;
+ int pll_max;
+ int pll_min;
+ int pll_posmult;
+ int pll_negmult;
+ abi_long pll_clock;
+};
+
/* real time clock ioctls */
#define TARGET_RTC_AIE_ON TARGET_IO('p', 0x01)
#define TARGET_RTC_AIE_OFF TARGET_IO('p', 0x02)
@@ -782,6 +792,10 @@ struct target_pollfd {
#define TARGET_RTC_EPOCH_SET TARGET_IOW('p', 0x0e, abi_ulong)
#define TARGET_RTC_WKALM_RD TARGET_IOR('p', 0x10, struct rtc_wkalrm)
#define TARGET_RTC_WKALM_SET TARGET_IOW('p', 0x0f, struct rtc_wkalrm)
+#define TARGET_RTC_PLL_GET TARGET_IOR('p', 0x11, \
+ struct target_rtc_pll_info)
+#define TARGET_RTC_PLL_SET TARGET_IOW('p', 0x12, \
+ struct target_rtc_pll_info)
#if defined(TARGET_ALPHA) || defined(TARGET_MIPS) || defined(TARGET_SH4) || \
defined(TARGET_XTENSA)
diff --git a/linux-user/syscall_types.h b/linux-user/syscall_types.h
index 820bc8e..4027272 100644
--- a/linux-user/syscall_types.h
+++ b/linux-user/syscall_types.h
@@ -271,6 +271,15 @@ STRUCT(rtc_wkalrm,
TYPE_CHAR, /* pending */
MK_STRUCT(STRUCT_rtc_time)) /* time */
+STRUCT(rtc_pll_info,
+ TYPE_INT, /* pll_ctrl */
+ TYPE_INT, /* pll_value */
+ TYPE_INT, /* pll_max */
+ TYPE_INT, /* pll_min */
+ TYPE_INT, /* pll_posmult */
+ TYPE_INT, /* pll_negmult */
+ TYPE_LONG) /* pll_clock */
+
STRUCT(blkpg_ioctl_arg,
TYPE_INT, /* op */
TYPE_INT, /* flags */
--
2.7.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v2 for 5.0 6/6] linux-user: Add support for read/clear RTC voltage low detector using ioctls
2019-11-14 15:13 [PATCH v2 for 5.0 0/6] linux-user: Add support for real time clock ioctls Filip Bozuta
` (4 preceding siblings ...)
2019-11-14 15:13 ` [PATCH v2 for 5.0 5/6] linux-user: Add support for get/set RTC PLL correction " Filip Bozuta
@ 2019-11-14 15:13 ` Filip Bozuta
5 siblings, 0 replies; 7+ messages in thread
From: Filip Bozuta @ 2019-11-14 15:13 UTC (permalink / raw)
To: qemu-devel; +Cc: laurent, Filip.Bozuta
RTC_VL_READ - Read voltage low detection information
Read the voltage low for RTCs that support voltage low.
The third ioctl's' argument points to an int in which
the voltage low is returned.
RTC_VL_CLR - Clear voltage low information
Clear the information about voltage low for RTCs that
support voltage low. The third ioctl(2) argument is
ignored.
Implementation notes:
Since one ioctl has a pointer to 'int' as its third agrument,
and another ioctl has NULL as its third argument, their
implementation was straightforward.
Signed-off-by: Filip Bozuta <Filip.Bozuta@rt-rk.com>
---
linux-user/ioctls.h | 2 ++
linux-user/syscall_defs.h | 2 ++
2 files changed, 4 insertions(+)
diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h
index a8dd235..371c25e 100644
--- a/linux-user/ioctls.h
+++ b/linux-user/ioctls.h
@@ -89,6 +89,8 @@
IOCTL(RTC_WKALM_SET, IOC_W, MK_PTR(MK_STRUCT(STRUCT_rtc_wkalrm)))
IOCTL(RTC_PLL_GET, IOC_R, MK_PTR(MK_STRUCT(STRUCT_rtc_pll_info)))
IOCTL(RTC_PLL_SET, IOC_W, MK_PTR(MK_STRUCT(STRUCT_rtc_pll_info)))
+ IOCTL(RTC_VL_READ, IOC_R, MK_PTR(TYPE_INT))
+ IOCTL(RTC_VL_CLR, 0, TYPE_NULL)
IOCTL(BLKROSET, IOC_W, MK_PTR(TYPE_INT))
IOCTL(BLKROGET, IOC_R, MK_PTR(TYPE_INT))
diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
index 8370f41..af4f366 100644
--- a/linux-user/syscall_defs.h
+++ b/linux-user/syscall_defs.h
@@ -796,6 +796,8 @@ struct target_rtc_pll_info {
struct target_rtc_pll_info)
#define TARGET_RTC_PLL_SET TARGET_IOW('p', 0x12, \
struct target_rtc_pll_info)
+#define TARGET_RTC_VL_READ TARGET_IOR('p', 0x13, int)
+#define TARGET_RTC_VL_CLR TARGET_IO('p', 0x14)
#if defined(TARGET_ALPHA) || defined(TARGET_MIPS) || defined(TARGET_SH4) || \
defined(TARGET_XTENSA)
--
2.7.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
end of thread, other threads:[~2019-11-14 15:21 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-14 15:13 [PATCH v2 for 5.0 0/6] linux-user: Add support for real time clock ioctls Filip Bozuta
2019-11-14 15:13 ` [PATCH v2 for 5.0 1/6] linux-user: Add support for enable/disable RTC features using ioctls Filip Bozuta
2019-11-14 15:13 ` [PATCH v2 for 5.0 2/6] linux-user: Add support for read/set RTC time and alarm " Filip Bozuta
2019-11-14 15:13 ` [PATCH v2 for 5.0 3/6] linux-user: Add support for read/set RTC periodic interrupt and epoch " Filip Bozuta
2019-11-14 15:13 ` [PATCH v2 for 5.0 4/6] linux-user: Add support for get/set RTC wakeup alarm " Filip Bozuta
2019-11-14 15:13 ` [PATCH v2 for 5.0 5/6] linux-user: Add support for get/set RTC PLL correction " Filip Bozuta
2019-11-14 15:13 ` [PATCH v2 for 5.0 6/6] linux-user: Add support for read/clear RTC voltage low detector " Filip Bozuta
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).