linux-user: syscall: ioctls: support DRM_IOCTL_VERSION
PATCH 1/1 linux-user: syscall: ioctls: support DRM_IOCTL_VERSION
From: Chen Gang <[email protected]>
The other DRM_IOCTL_* commands will be done later.
--- linux-user/ioctls.h | 3 + linux-user/syscall.c | 134 +++++++++++++++++++++++++++++++++++++ linux-user/syscall_defs.h | 16 +++++ linux-user/syscall_types.h | 12 ++++ 4 files changed, 165 insertions(+)
linux-user/ioctls.h +3 -0
@@ -574,6 +574,9 @@IOCTL_SPECIAL (SIOCDELRT ,IOC_W , do_ioctl_rt, MK_PTR(MK_STRUCT(STRUCT_rtentry))) +IOCTL_SPECIAL (DRM_IOCTL_VERSION ,IOC_RW , do_ioctl_drm, + MK_PTR(MK_STRUCT(STRUCT_drm_version))) +#ifdef TARGET_TIOCSTART IOCTL_IGNORE (TIOCSTART)IOCTL_IGNORE (TIOCSTOP)
linux-user/syscall.c +134 -0
146 lines not on this page · raw message
linux-user/syscall_defs.h +15 -0
@@ -1167,6 +1167,9 @@ struct target_rtc_pll_info {#define TARGET_DM_TARGET_MSG TARGET_IOWRU(0xfd, 0x0e)#define TARGET_DM_DEV_SET_GEOMETRY TARGET_IOWRU(0xfd, 0x0f) +/* drm ioctls */ +#define TARGET_DRM_IOCTL_VERSION TARGET_IOWRU('d', 0x00) +/* from asm/termbits.h */ #define TARGET_NCC 8
@@ -2598,6 +2602,18 @@ struct target_mq_attr {abi_long mq_curmsgs; }; +struct target_drm_version { +int version_major; +int version_minor; +int version_patchlevel; +abi_ulong name_len; +abi_ulong name; +abi_ulong date_len; +abi_ulong date; +abi_ulong desc_len; +abi_ulong desc; +}; +#include "socket.h" #include "errno_defs.h"
linux-user/syscall_types.h +12 -0
@@ -292,6 +292,18 @@ STRUCT(dm_target_versions,STRUCT (dm_target_msg,TYPE_ULONGLONG )/* sector */ +/* TODO: use #ifdef 32 bit #else 64 bit, next */ +STRUCT (drm_version, +TYPE_INT ,/* version_major */ +TYPE_INT ,/* version_minor */ +TYPE_INT ,/* version_patchlevel */ +TYPE_ULONG ,/* name_len */ +TYPE_PTRVOID ,/* name */ +TYPE_ULONG ,/* date_len */ +TYPE_PTRVOID ,/* date */ +TYPE_ULONG ,/* desc_len */ + TYPE_PTRVOID) /* desc */ + STRUCT(file_clone_range, TYPE_LONGLONG, /* src_fd */ TYPE_ULONGLONG, /* src_offset */
Signature · 1 line
2.24.0.308.g228f53135a
Le 26/02/2020 à 12:38, [email protected] a écrit :
Quoted 17 lines
From: Chen Gang <[email protected]>
The other DRM_IOCTL_* commands will be done later.
Signed-off-by Chen Gang <[email protected]>--- linux-user/ioctls.h | 3 + linux-user/syscall.c | 134 +++++++++++++++++++++++++++++++++++++ linux-user/syscall_defs.h | 16 +++++ linux-user/syscall_types.h | 12 ++++ 4 files changed, 165 insertions(+)linux-user/ioctls.h +0
-0
linux-user/ioctls.h line 579
Quoted 6 lines
linux-user/ioctls.h +3
-0@@ -574,6 +574,9 @@IOCTL_SPECIAL (SIOCDELRT ,IOC_W , do_ioctl_rt, MK_PTR(MK_STRUCT(STRUCT_rtentry))) +IOCTL_SPECIAL (DRM_IOCTL_VERSION ,IOC_RW , do_ioctl_drm, +MK_PTR (MK_STRUCT (STRUCT_drm_version))) +
Rather than adding a specific function to process the structure, perhaps we can add this in a generic way?
The problem with drm_version structure is the pointers to the strings.
Did you try to add a TYPE_STRING in thunk_type_size()/thunk_type_align()/think_convert()/do_ioctl() to do that?
...
linux-user/syscall_defs.h struct target_rtc_pll_info { · line 1171
Quoted 10 lines
linux-user/syscall_defs.h +2
-0@@ -1167,6 +1167,9 @@ struct target_rtc_pll_info {#define TARGET_DM_TARGET_MSG TARGET_IOWRU(0xfd, 0x0e)#define TARGET_DM_DEV_SET_GEOMETRY TARGET_IOWRU(0xfd, 0x0f) +/* drm ioctls */ +#define TARGET_DRM_IOCTL_VERSION TARGET_IOWRU('d', 0x00)
Why do you use the TARGET_IOWRU variant?
Can't you use TARGET_IOWR('d', 0x00, struct target_drm_version)?
Quoted 33 lines
linux-user/syscall_defs.h +13
-0+/* from asm/termbits.h */ #define TARGET_NCC 8@@ -2598,6 +2602,18 @@ struct target_mq_attr {abi_long mq_curmsgs; }; +struct target_drm_version { +int version_major; +int version_minor; +int version_patchlevel; +abi_ulong name_len; +abi_ulong name; +abi_ulong date_len; +abi_ulong date; +abi_ulong desc_len; +abi_ulong desc; +}; +#include "socket.h" #include "errno_defs.h" linux-user/syscall_types.h +2
-0@@ -292,6 +292,18 @@ STRUCT(dm_target_versions,STRUCT (dm_target_msg,TYPE_ULONGLONG )/* sector */ +/* TODO: use #ifdef 32 bit #else 64 bit, next */ +STRUCT(drm_version,
linux-user/syscall_types.h STRUCT(dm_target_versions, · line 306
Quoted 10 lines
linux-user/syscall_types.h +10
-0+TYPE_INT ,/* version_major */ +TYPE_INT ,/* version_minor */ +TYPE_INT ,/* version_patchlevel */ +TYPE_ULONG ,/* name_len */ +TYPE_PTRVOID ,/* name */ +TYPE_ULONG ,/* date_len */ +TYPE_PTRVOID ,/* date */ +TYPE_ULONG ,/* desc_len */ + TYPE_PTRVOID) /* desc */ +
After defining a TYPE_STRING, you could use MKPTR(TYPE_STRING) for name, date and desc.
Thanks,
Laurent
Le 10/03/2020 à 21:16, Laurent Vivier a écrit :
Quoted 28 lines
Le 26/02/2020 à 12:38, [email protected] a écrit :
Quoted 17 lines
From: Chen Gang <[email protected]>
The other DRM_IOCTL_* commands will be done later.
Signed-off-by Chen Gang <[email protected]>--- linux-user/ioctls.h | 3 + linux-user/syscall.c | 134 +++++++++++++++++++++++++++++++++++++ linux-user/syscall_defs.h | 16 +++++ linux-user/syscall_types.h | 12 ++++ 4 files changed, 165 insertions(+)linux-user/ioctls.h +0
-0linux-user/ioctls.h line 579
Quoted 6 lines
linux-user/ioctls.h +3
-0@@ -574,6 +574,9 @@IOCTL_SPECIAL (SIOCDELRT ,IOC_W , do_ioctl_rt, MK_PTR(MK_STRUCT(STRUCT_rtentry))) +IOCTL_SPECIAL (DRM_IOCTL_VERSION ,IOC_RW , do_ioctl_drm, +MK_PTR (MK_STRUCT (STRUCT_drm_version))) +Rather than adding a specific function to process the structure, perhaps we can add this in a generic way?
Quoted 4 lines
The problem with
drm_versionstructure is the pointers to the strings.Did you try to add a
TYPE_STRINGin thunk_type_size()/thunk_type_align()/think_convert()/do_ioctl() to do that?
In fact we can't do that because we need to know the size of the buffer to allocate and it is provided by another field. It cannot be generic, so I think what you do is the best we can do.
Thanks,
LAurent
Thank you very much for your reply. :)
DRM_IOCTL_VERSION has to be a special one, but my patch really need be improved. The string pointers should be translated, but the new string buffers need not be allocated.
I will try to send patch v2 within this week end.
DRM_IOCTL_* really have many commands, at present, I have implemented about 20+ commands for i965 gpu using, although some of them are not generic enough. I will try to send all of them when I have free time.
Thanks.
Quoted 45 lines · Laurent Vivier
Le 10/03/2020 à 21:16, Laurent Vivier a écrit :
Quoted 28 lines
Le 26/02/2020 à 12:38, [email protected] a écrit :
Quoted 17 lines
From: Chen Gang <[email protected]>
The other DRM_IOCTL_* commands will be done later.
Signed-off-by Chen Gang <[email protected]>--- linux-user/ioctls.h | 3 + linux-user/syscall.c | 134 +++++++++++++++++++++++++++++++++++++ linux-user/syscall_defs.h | 16 +++++ linux-user/syscall_types.h | 12 ++++ 4 files changed, 165 insertions(+)linux-user/ioctls.h +0
-0linux-user/ioctls.h line 579
Quoted 6 lines
linux-user/ioctls.h +3
-0@@ -574,6 +574,9 @@IOCTL_SPECIAL (SIOCDELRT ,IOC_W , do_ioctl_rt, MK_PTR(MK_STRUCT(STRUCT_rtentry))) +IOCTL_SPECIAL (DRM_IOCTL_VERSION ,IOC_RW , do_ioctl_drm, +MK_PTR (MK_STRUCT (STRUCT_drm_version))) +Rather than adding a specific function to process the structure, perhaps we can add this in a generic way?
Quoted 4 lines
The problem with
drm_versionstructure is the pointers to the strings.Did you try to add a
TYPE_STRINGin thunk_type_size()/thunk_type_align()/think_convert()/do_ioctl() to do that?In fact we can't do that because we need to know the size of the buffer to allocate and it is provided by another field. It cannot be generic, so I think what you do is the best we can do.
Thanks,
LAurent