drm: Add decoding for DRM/KMS and i915 ioctls
v2 cover drm: Add decoding for DRM/KMS and i915 ioctls
This set of patches adds a dispatcher for handling DRM ioctls. The kernel headers for DRM might not be available on all distributions so we depend on libdrm for those. If libdrm is not available we fall back on the kernel headers. Since DRM drivers share the same range of private ioctl numbers I've added a function for detecting the driver based on it's name.
Changes in v2:
* Rebased to master
* Added Changelog to commits
* Keep strace_SOURCES list sorted
* Removed unneeded includes
* Reduced number of driver name checks by adding tcb private data
* Use tprints() for regular strings
* Reworked entering() / exiting() handling for all ioctls
* Use printstr() to print strings in properly quoted form
Patrik Jakobsson (5):
drm: Add config for detecting libdrm
drm: Add private data field to trace control block
drm: Add dispatcher and driver identification for DRM
drm: Add decoding of i915 ioctls
drm: Add decoding of DRM and KMS ioctls
Makefile.am | 2 + configure.ac | 4 + defs.h | 11 +- drm.c | 632 +++++++++++++++++++++++++++++++++++++++++++++ drm_i915.c | 332 ++++++++++++++++++++++++ io.c | 2 +- ioctl.c | 6 +- xlat/drm_i915_getparams.in | 28 ++ xlat/drm_i915_ioctls.in | 51 ++++ xlat/drm_i915_setparams.in | 4 + 10 files changed, 1069 insertions(+), 3 deletions(-) create mode 100644 drm.c create mode 100644 drm_i915.c create mode 100644 xlat/drm_i915_getparams.in create mode 100644 xlat/drm_i915_ioctls.in create mode 100644 xlat/drm_i915_setparams.in
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 1/5 drm: Add config for detecting libdrm
Use pkg-config to try to find libdrm. If that fails use the standard include directory for kernel drm headers in /usr/include/drm.
* configure.ac: Use pkg-config to find libdrm
--- configure.ac | 4 ++++ 1 file changed, 4 insertions(+)
configure.ac +4 -0
@@ -844,6 +844,10 @@ fi AM_CONDITIONAL([USE_LIBUNWIND], [test "x$use_libunwind" = xyes]) AC_MSG_RESULT([$use_libunwind]) +PKG_CHECK_MODULES([libdrm], [libdrm], + [CPPFLAGS="$CPPFLAGS $libdrm_CFLAGS"], + [CPPFLAGS="$CPPFLAGS -I/usr/include/drm"]) + if test "$arch" = mips && test "$no_create" != yes; then mkdir -p linux/mips if $srcdir/linux/mips/genstub.sh linux/mips; then
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 2/5 drm: Add private data field to trace control block
In reply to Patrik JakobssonThis field can be used by the decode functions of a syscall. The main usecase for now is to allow storing the driver name for drm devices across the lifetime of a trace control block. This allows us to do the driver identification once and reuse the information in all the decode stages of the ioctl.
* defs.h: Add private data field in struct tcb
--- defs.h | 7 +++++++ 1 file changed, 7 insertions(+)
defs.h +7 -0
@@ -266,6 +266,13 @@ struct tcb {int u_error;/* Error code */ long scno;/* System call number */ long u_arg[MAX_ARGS ];/* System call arguments */ + +/* +* Private data for the decoding functions of the syscall. TCB core does +* _not_ handle allocation / deallocation of this data. +*/ +void *priv_data; +#if defined(LINUX_MIPSN32 ) || defined(X32 )long long ext_arg[MAX_ARGS ];long long u_lrval;/* long long return value */
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 3/5 drm: Add dispatcher and driver identification for DRM
In reply to Patrik Jakobsson* Makefile.am: Add compilation of drm.c
* defs.h: Declarations of drm functions
* drm.c: Utility functions for drm driver detection
* io.c: Dispatch drm ioctls
* ioctl.c: Distpatch generic and driver specific ioctls
--- Makefile.am | 1 + defs.h | 4 ++- drm.c | 108 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ io.c | 2 +- ioctl.c | 6 +++- 5 files changed, 118 insertions(+), 3 deletions(-) create mode 100644 drm.c
Makefile.am +1 -0
@@ -41,6 +41,7 @@ strace_SOURCES = \ count.c \ desc.c \ dirent.c \ + drm.c \ evdev.c \ execve.c \ exit.c \
defs.h +3 -1
@@ -573,8 +573,10 @@ extern const struct_ioctlent *ioctl_lookup(const unsigned int);extern const struct_ioctlent *ioctl_next_match (const struct_ioctlent *);extern void ioctl_print_code (const unsigned int );extern int ioctl_decode (struct tcb *,const unsigned int ,long ); -extern int ioctl_decode_command_number (const unsigned int ); +extern int ioctl_decode_command_number (struct tcb *,const unsigned int );extern int block_ioctl (struct tcb *,const unsigned int ,long ); +extern int drm_decode_number (struct tcb *tcp,unsigned int arg); +extern int drm_ioctl (struct tcb *,const unsigned int ,long );extern int evdev_ioctl (struct tcb *,const unsigned int ,long );extern int loop_ioctl (struct tcb *,const unsigned int ,long );extern int mtd_ioctl (struct tcb *,const unsigned int ,long );
drm.c new file +108 -0
108 lines not on this page · raw message
io.c +1 -1
@@ -391,7 +391,7 @@ SYS_FUNC(ioctl)if (entering (tcp)) {printfd (tcp, tcp->u_arg[0 ]);tprints (", " ); -if (!ioctl_decode_command_number (tcp->u_arg[1 ])) { +if (!ioctl_decode_command_number (tcp, tcp->u_arg[1 ])) { iop =ioctl_lookup (tcp->u_arg[1 ]);if (iop) {tprints (iop->symbol);
ioctl.c +5 -1
@@ -182,7 +182,7 @@ hiddev_decode_number(unsigned int arg) }int -ioctl_decode_command_number (unsigned int arg) +ioctl_decode_command_number (struct tcb *tcp,unsigned int arg) {switch (_IOC_TYPE (arg)) {case 'E' :
@@ -204,6 +204,8 @@ ioctl_decode_command_number(unsigned int arg)return 1 ; }return 0 ; +case 'd' : +return drm_decode_number (tcp, arg);case 'j' :if (_IOC_DIR (arg) == _IOC_READ &&_IOC_NR (arg) ==0x13 ) {tprintf ("JSIOCGNAME(%u)" ,_IOC_SIZE (arg));
@@ -243,6 +245,8 @@ ioctl_decode(struct tcb *tcp, unsigned int code, long arg)case 0x22 :return scsi_ioctl (tcp, code, arg);#endif +case 'd' : +return drm_ioctl (tcp, code, arg);case 'L' :return loop_ioctl (tcp, code, arg);case 'M' :
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 5/5 drm: Add decoding of DRM and KMS ioctls
In reply to Patrik JakobssonThis patch adds many of the DRM and KMS ioctls. The rest can be added as needed.
* drm.c: Decode DRM_IOCTL_VERSION
* drm.c: Decode DRM_IOCTL_GET_UNIQUE
* drm.c: Decode DRM_IOCTL_GET_MAGIC
* drm.c: Decode DRM_IOCTL_WAIT_VBLANK
* drm.c: Decode DRM_IOCTL_MODE_GETRESOURCES
* drm.c: Decode DRM_IOCTL_MODE_GETCRTC
* drm.c: Decode DRM_IOCTL_MODE_SETCRTC
* drm.c: Decode DRM_IOCTL_MODE_CURSOR
* drm.c: Decode DRM_IOCTL_MODE_CURSOR2
* drm.c: Decode DRM_IOCTL_MODE_GETGAMMA
* drm.c: Decode DRM_IOCTL_MODE_SETGAMMA
* drm.c: Decode DRM_IOCTL_MODE_GETENCODER
* drm.c: Decode DRM_IOCTL_MODE_GETCONNECTOR
* drm.c: Decode DRM_IOCTL_MODE_GETPROPERTY
* drm.c: Decode DRM_IOCTL_MODE_SETPROPERTY
* drm.c: Decode DRM_IOCTL_MODE_GETPROPBLOB
* drm.c: Decode DRM_IOCTL_MODE_GETFB
* drm.c: Decode DRM_IOCTL_MODE_ADDFB
* drm.c: Decode DRM_IOCTL_MODE_RMFB
* drm.c: Decode DRM_IOCTL_MODE_PAGE_FLIP
* drm.c: Decode DRM_IOCTL_DIRTYFB
* drm.c: Decode DRM_IOCTL_CREATE_DUMB
* drm.c: Decode DRM_IOCTL_MAP_DUMB
* drm.c: Decode DRM_IOCTL_DESTROY_DUMB
* drm.c: Decode DRM_IOCTL_GEM_CLOSE
--- drm.c | 510 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 510 insertions(+)
drm.c +510 -0
@@ -104,6 +104,463 @@ int drm_decode_number(struct tcb *tcp, unsigned int arg)return 0 ; } +static int drm_version (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_version ver; + +if (umove (tcp, arg, &ver)) +return 0 ; + +if (exiting (tcp)) { +tprintf (", {version_major=%d, version_minor=%d, version_patchlevel=%d, " +"name_len=%lu, name=" , ver.version_major, + ver.version_minor, ver.version_patchlevel, + ver.name_len); +printstr (tcp, (long )ver.name, ver.name_len); +tprintf (", date_len=%lu, date=" , ver.date_len); +printstr (tcp, (long )ver.date, ver.date_len); +tprintf (", desc_len=%lu, desc=" , ver.desc_len); +printstr (tcp, (long )ver.desc, ver.desc_len); +tprints ("}" ); + } + +return 1 ; +} + +static int drm_get_unique (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_unique unique; + +if (umove (tcp, arg, &unique)) +return 0 ; + +if (exiting (tcp)) { +tprintf (", {unique_len=%lu, unique=}" , unique.unique_len); +printstr (tcp, (long )unique.unique, unique.unique_len); +tprints ("}" ); + } + +return 1 ; +} + +static int drm_get_magic (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_auth auth; + +if (umove (tcp, arg, &auth)) +return 0 ; + +if (exiting (tcp)) +tprintf (", {magic=%u}" , auth.magic); + +return 1 ; +} + +static int drm_wait_vblank (struct tcb *tcp,const unsigned int code,long arg) +{ +union drm_wait_vblank vblank; + +if (umove (tcp, arg, &vblank)) +return 0 ; + +if (entering (tcp)) { +tprintf (", {request={type=%u, sequence=%u, signal=%lu}" , + vblank.request.type, vblank.request.sequence, + vblank.request.signal); + }else if (exiting (tcp)) { +tprintf (", reply={type=%u, sequence=%u, tval_sec=%ld, tval_usec=%ld}}" , + vblank.reply.type, vblank.reply.sequence, + vblank.reply.tval_sec, vblank.reply.tval_usec); + } + +return 1 ; +} + +static int drm_mode_get_resources (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_mode_card_res res; + +if (umove (tcp, arg, &res)) +return 0 ; + +if (exiting (tcp)) { +tprintf (", {fb_id_ptr=%p, crtc_id_ptr=%p, connector_id_ptr=%p, " +"encoder_id_ptr=%p, count_fbs=%u, count_crtcs=%u, " +"count_connectors=%u, count_encoders=%u, min_width=%u, " +"max_width=%u, min_height=%u, max_height=%u}" , + (void *)res.fb_id_ptr, (void *)res.crtc_id_ptr, + (void *)res.connector_id_ptr, (void *)res.encoder_id_ptr, + res.count_fbs, res.count_crtcs, res.count_connectors, + res.count_encoders, res.min_width, res.max_width, + res.min_height, res.max_height); + } + +return 1 ; +} + +static void drm_mode_print_modeinfo (struct drm_mode_modeinfo *info) +{ +tprintf ("clock=%u, hdisplay=%hu, hsync_start=%hu, hsync_end=%hu, " +"htotal=%hu, hskew=%hu, vdisplay=%hu, vsync_start=%hu, " +"vsync_end=%hu, vtotal=%hu, vscan=%hu, vrefresh=%u, " +"flags=0x%x, type=%u, name=%s" , info->clock, info->hdisplay, + info->hsync_start, info->hsync_end, info->htotal, info->hskew, + info->vdisplay, info->vsync_start, info->vsync_end, + info->vtotal, info->vscan, info->vrefresh, info->flags, + info->type, info->name); +} + +static int drm_mode_get_crtc (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_mode_crtc crtc; + +if (umove (tcp, arg, &crtc)) +return 0 ; + +if (entering (tcp)) { +tprintf (", {crtc_id=%u" , crtc.crtc_id); + }else if (exiting (tcp)) { +tprintf (", set_connectors_ptr=%p, count_connectors=%u, " +"fb_id=%u, x=%u, y=%u, gamma_size=%u, mode_valid=%u, " +"mode={" , (void *)crtc.set_connectors_ptr, + crtc.count_connectors, crtc.fb_id, crtc.x, crtc.y, + crtc.gamma_size, crtc.mode_valid); + +drm_mode_print_modeinfo (&crtc.mode); +tprintf ("}}" ); + } + +return 1 ; +} + +static int drm_mode_set_crtc (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_mode_crtc crtc; + +if (umove (tcp, arg, &crtc)) +return 0 ; + +if (entering (tcp)) { +tprintf (", {set_connectors_ptr=%p, count_connectors=%u, " +"crtc_id=%u, fb_id=%u, x=%u, y=%u, gamma_size=%u, " +"mode_valid=%u, mode={" , (void *)crtc.set_connectors_ptr, + crtc.count_connectors, crtc.crtc_id, crtc.fb_id, crtc.x, + crtc.y, crtc.gamma_size, crtc.mode_valid); + +drm_mode_print_modeinfo (&crtc.mode); +tprintf ("}}" ); + } + +return 1 ; +} + +static int drm_mode_cursor (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_mode_cursor cursor; + +if (umove (tcp, arg, &cursor)) +return 0 ; + +if (entering (tcp)) { +tprintf (", {flags=0x%x, crtc_id=%u, x=%d, y=%d, width=%u, " +"height=%u, handle=%u}" , cursor.flags, cursor.crtc_id, + cursor.x, cursor.y, cursor.width, cursor.height, + cursor.handle); + } + +return 1 ; +} + +static int drm_mode_cursor2 (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_mode_cursor2 cursor; + +if (umove (tcp, arg, &cursor)) +return 0 ; + +if (entering (tcp)) { +tprintf (", {flags=0x%x, crtc_id=%u, x=%d, y=%d, width=%u, " +"height=%u, handle=%u, hot_x=%d, hot_y=%d}" , + cursor.flags, cursor.crtc_id, cursor.x, cursor.y, + cursor.width, cursor.height, cursor.handle, + cursor.hot_x, cursor.hot_y); + } + +return 1 ; +} + +static int drm_mode_get_gamma (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_mode_crtc_lut lut; + +if (umove (tcp, arg, &lut)) +return 0 ; + +if (entering (tcp)) { +/* We don't print the entire table, just the pointers */ +tprintf (", {crtc_id=%u, gamma_size=%u, red=%p, green=%p, " +"blue=%p}" , lut.crtc_id, lut.gamma_size, + (void *)lut.red, (void *)lut.green, (void *)lut.blue); + } + +return 1 ; +} + +static int drm_mode_set_gamma (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_mode_crtc_lut lut; + +if (umove (tcp, arg, &lut)) +return 0 ; + +if (entering (tcp)) { +/* We don't print the entire table, just the rgb pointers */ +tprintf (", {crtc_id=%u, gamma_size=%u, red=%p, green=%p, " +"blue=%p}" , lut.crtc_id, lut.gamma_size, + (void *)lut.red, (void *)lut.green, (void *)lut.blue); + } + +return 1 ; +} + +static int drm_mode_get_encoder (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_mode_get_encoder enc; + +if (umove (tcp, arg, &enc)) +return 0 ; + +if (entering (tcp)) { +tprintf (", {encoder_id=%u" , enc.encoder_id); + }else if (exiting (tcp)) { +/* TODO: Print name of encoder type */ +tprintf (", encoder_type=%u, crtc_id=%u, possible_crtcs=0x%x, " +"possible_clones=0x%x}" , enc.encoder_type, + enc.crtc_id, enc.possible_crtcs, enc.possible_clones); + } + +return 1 ; +} + +static int drm_mode_get_connector (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_mode_get_connector con; + +if (umove (tcp, arg, &con)) +return 0 ; + +/* We could be very verbose here but keep is simple for now */ +if (entering (tcp)) { +tprintf (", {connector_id=%u" , con.connector_id); + }else if (exiting (tcp)) { +tprintf (", encoders_ptr=%p, modes_ptr=%p, props_ptr=%p, " +"prop_values_ptr=%p, count_modes=%u, count_props=%u, " +"count_encoders=%u, encoder_id=%u, connector_type=%u, " +"connector_type_id=%u, connection=%u, mm_width=%u, " +"mm_height=%u, subpixel=%u}" , (void *)con.encoders_ptr, + (void *)con.modes_ptr, (void *)con.props_ptr, + (void *)con.prop_values_ptr, con.count_modes, + con.count_props, con.count_encoders, con.encoder_id, + con.connector_type, con.connector_type_id, + con.connection, con.mm_width, con.mm_height, + con.subpixel); + } + +return 1 ; +} + +static int drm_mode_get_property (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_mode_get_property prop; + +if (umove (tcp, arg, &prop)) +return 0 ; + +if (entering (tcp)) { +tprintf (", {prop_id=%u" , prop.prop_id); + }else if (exiting (tcp)) { +tprintf (", values_ptr=%p, enum_blob_ptr=%p, flags=0x%x, " +"name=%s, count_values=%u, count_enum_blobs=%u}" , + (void *)prop.values_ptr, (void *)prop.enum_blob_ptr, + prop.flags, prop.name, prop.count_values, + prop.count_enum_blobs); + } + +return 1 ; +} + +static int drm_mode_set_property (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_mode_connector_set_property prop; + +if (umove (tcp, arg, &prop)) +return 0 ; + +if (entering (tcp)) { +tprintf (", {value=%Lu, prop_id=%u, connector_id=%u}" , + prop.value, prop.prop_id, prop.connector_id); + } + +return 1 ; +} + +static int drm_mode_get_prop_blob (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_mode_get_blob blob; + +if (umove (tcp, arg, &blob)) +return 0 ; + +if (entering (tcp)) { +tprintf (", {blob_id=%u" , blob.blob_id); + }else if (exiting (tcp)) { +tprintf (", length=%u, data=%p}" , blob.length, + (void *)blob.data); + } + +return 1 ; +} + +static int drm_mode_add_fb (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_mode_fb_cmd cmd; + +if (umove (tcp, arg, &cmd)) +return 0 ; + +if (entering (tcp)) { +tprintf (", {width=%u, height=%u, pitch=%u, bpp=%u, depth=%u, " +"handle=%u" , cmd.width, cmd.height, cmd.pitch, + cmd.bpp, cmd.depth, cmd.handle); + }else if (exiting (tcp)) { +tprintf (", fb_id=%u}" , cmd.fb_id); + } + +return 1 ; +} + +static int drm_mode_get_fb (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_mode_fb_cmd cmd; + +if (umove (tcp, arg, &cmd)) +return 0 ; + +if (entering (tcp)) { +tprintf (", {fb_id=%u" , cmd.fb_id); + }else { +tprintf (", width=%u, height=%u, pitch=%u, bpp=%u, depth=%u, " +"handle=%u}" , cmd.width, cmd.height, cmd.pitch, + cmd.bpp, cmd.depth, cmd.handle); + } + +return 1 ; +} + +static int drm_mode_rm_fb (struct tcb *tcp,const unsigned int code,long arg) +{ +unsigned int handle; + +if (umove (tcp, arg, &handle)) +return 0 ; + +if (entering (tcp)) +tprintf (", %u" , handle); + +return 1 ; +} + +static int drm_mode_page_flip (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_mode_crtc_page_flip flip; + +if (umove (tcp, arg, &flip)) +return 0 ; + +if (entering (tcp)) { +tprintf (", {crtc_id=%u, fb_id=%u, flags=0x%x, user_data=0x%Lx}" , + flip.crtc_id, flip.fb_id, flip.flags, flip.user_data); + } + +return 1 ; +} + +static int drm_mode_dirty_fb (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_mode_fb_dirty_cmd cmd; + +if (umove (tcp, arg, &cmd)) +return 0 ; + +if (entering (tcp)) { +tprintf (", {fb_id=%u, flags=0x%x, color=0x%x, num_clips=%u, " +"clips_ptr=%p}" , cmd.fb_id, cmd.flags, cmd.color, + cmd.num_clips, (void *)cmd.clips_ptr); + } + +return 1 ; +} + +static int drm_mode_create_dumb (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_mode_create_dumb dumb; + +if (umove (tcp, arg, &dumb)) +return 0 ; + +if (entering (tcp)) { +tprintf (", {width=%u, height=%u, bpp=%u, flags=0x%x" , + dumb.width, dumb.height, dumb.bpp, dumb.flags); + }else if (exiting (tcp)) { +tprintf (", handle=%u, pitch=%u, size=%Lu}" , dumb.handle, + dumb.pitch, dumb.size); + } + +return 1 ; +} + +static int drm_mode_map_dumb (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_mode_map_dumb dumb; + +if (umove (tcp, arg, &dumb)) +return 0 ; + +if (entering (tcp)) { +tprintf (", {handle=%u" , dumb.handle); + }else if (exiting (tcp)) { +tprintf (", offset=%Lu}" , dumb.offset); + } + +return 1 ; +} + +static int drm_mode_destroy_dumb (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_mode_destroy_dumb dumb; + +if (umove (tcp, arg, &dumb)) +return 0 ; + +if (entering (tcp)) +tprintf (", {handle=%u}" , dumb.handle); + +return 1 ; +} + +static int drm_gem_close (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_gem_close close; + +if (umove (tcp, arg, &close)) +return 0 ; + +if (entering (tcp)) +tprintf (", {handle=%u}" , close.handle); + +return 1 ; +} +int drm_ioctl (struct tcb *tcp,const unsigned int code,long arg) {/* Check for device specific ioctls */
@@ -112,6 +569,59 @@ int drm_ioctl(struct tcb *tcp, const unsigned int code, long arg)return drm_i915_ioctl (tcp, code, arg); } +switch (code) { +case DRM_IOCTL_VERSION : +return drm_version (tcp, code, arg); +case DRM_IOCTL_GET_UNIQUE : +return drm_get_unique (tcp, code, arg); +case DRM_IOCTL_GET_MAGIC : +return drm_get_magic (tcp, code, arg); +case DRM_IOCTL_WAIT_VBLANK : +return drm_wait_vblank (tcp, code, arg); +case DRM_IOCTL_MODE_GETRESOURCES : +return drm_mode_get_resources (tcp, code, arg); +case DRM_IOCTL_MODE_GETCRTC : +return drm_mode_get_crtc (tcp, code, arg); +case DRM_IOCTL_MODE_SETCRTC : +return drm_mode_set_crtc (tcp, code, arg); +case DRM_IOCTL_MODE_CURSOR : +return drm_mode_cursor (tcp, code, arg); +case DRM_IOCTL_MODE_CURSOR2 : +return drm_mode_cursor2 (tcp, code, arg); +case DRM_IOCTL_MODE_GETGAMMA : +return drm_mode_get_gamma (tcp, code, arg); +case DRM_IOCTL_MODE_SETGAMMA : +return drm_mode_set_gamma (tcp, code, arg); +case DRM_IOCTL_MODE_GETENCODER : +return drm_mode_get_encoder (tcp, code, arg); +case DRM_IOCTL_MODE_GETCONNECTOR : +return drm_mode_get_connector (tcp, code, arg); +case DRM_IOCTL_MODE_GETPROPERTY : +return drm_mode_get_property (tcp, code, arg); +case DRM_IOCTL_MODE_SETPROPERTY : +return drm_mode_set_property (tcp, code, arg); +case DRM_IOCTL_MODE_GETPROPBLOB : +return drm_mode_get_prop_blob (tcp, code, arg); +case DRM_IOCTL_MODE_GETFB : +return drm_mode_get_fb (tcp, code, arg); +case DRM_IOCTL_MODE_ADDFB : +return drm_mode_add_fb (tcp, code, arg); +case DRM_IOCTL_MODE_RMFB : +return drm_mode_rm_fb (tcp, code, arg); +case DRM_IOCTL_MODE_PAGE_FLIP : +return drm_mode_page_flip (tcp, code, arg); +case DRM_IOCTL_MODE_DIRTYFB : +return drm_mode_dirty_fb (tcp, code, arg); +case DRM_IOCTL_MODE_CREATE_DUMB : +return drm_mode_create_dumb (tcp, code, arg); +case DRM_IOCTL_MODE_MAP_DUMB : +return drm_mode_map_dumb (tcp, code, arg); +case DRM_IOCTL_MODE_DESTROY_DUMB : +return drm_mode_destroy_dumb (tcp, code, arg); +case DRM_IOCTL_GEM_CLOSE : +return drm_gem_close (tcp, code, arg); + } +/* Free any allocated private data */ if (exiting (tcp) && tcp->priv_data !=NULL ) {free (tcp->priv_data);
Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v2 5/5] drm: Add decoding of DRM and KMS ioctls
Quoted 39 lines · On Thu, 18 Jun 2015 10:42:45 +0200 Patrik Jakobsson…
This patch adds many of the DRM and KMS ioctls. The rest can be added as needed.
*
drm.c: DecodeDRM_IOCTL_VERSION
*drm.c: DecodeDRM_IOCTL_GET_UNIQUE
*drm.c: DecodeDRM_IOCTL_GET_MAGIC
*drm.c: DecodeDRM_IOCTL_WAIT_VBLANK
*drm.c: DecodeDRM_IOCTL_MODE_GETRESOURCES
*drm.c: DecodeDRM_IOCTL_MODE_GETCRTC
*drm.c: DecodeDRM_IOCTL_MODE_SETCRTC
*drm.c: DecodeDRM_IOCTL_MODE_CURSOR
*drm.c: DecodeDRM_IOCTL_MODE_CURSOR2
*drm.c: DecodeDRM_IOCTL_MODE_GETGAMMA
*drm.c: DecodeDRM_IOCTL_MODE_SETGAMMA
*drm.c: DecodeDRM_IOCTL_MODE_GETENCODER
*drm.c: DecodeDRM_IOCTL_MODE_GETCONNECTOR
*drm.c: DecodeDRM_IOCTL_MODE_GETPROPERTY
*drm.c: DecodeDRM_IOCTL_MODE_SETPROPERTY
*drm.c: DecodeDRM_IOCTL_MODE_GETPROPBLOB
*drm.c: DecodeDRM_IOCTL_MODE_GETFB
*drm.c: DecodeDRM_IOCTL_MODE_ADDFB
*drm.c: DecodeDRM_IOCTL_MODE_RMFB
*drm.c: DecodeDRM_IOCTL_MODE_PAGE_FLIP
*drm.c: DecodeDRM_IOCTL_DIRTYFB
*drm.c: DecodeDRM_IOCTL_CREATE_DUMB
*drm.c: DecodeDRM_IOCTL_MAP_DUMB
*drm.c: DecodeDRM_IOCTL_DESTROY_DUMB
*drm.c: DecodeDRM_IOCTL_GEM_CLOSESigned-off-by Patrik Jakobsson <[email protected]>--- drm.c | 510 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 510 insertions(+)drm.c +0
-0
drm.c int drm_decode_number(struct tcb *tcp, unsigned int arg) · line 113
Quoted 10 lines
drm.c +7
-0@@ -104,6 +104,463 @@ int drm_decode_number(struct tcb *tcp, unsigned int arg)return 0 ; } +static int drm_version (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_version ver; + +if (umove (tcp, arg, &ver)) +return 0 ; +
The umove() should be done only on exiting and if the ioctl succeded ?
Same thing for most of the read only ioctl.
Quoted 15 lines
drm.c +15
-0+if (exiting (tcp)) { +tprintf (", {version_major=%d, version_minor=%d, version_patchlevel=%d, " +"name_len=%lu, name=" , ver.version_major, + ver.version_minor, ver.version_patchlevel, + ver.name_len); +printstr (tcp, (long )ver.name, ver.name_len); +tprintf (", date_len=%lu, date=" , ver.date_len); +printstr (tcp, (long )ver.date, ver.date_len); +tprintf (", desc_len=%lu, desc=" , ver.desc_len); +printstr (tcp, (long )ver.desc, ver.desc_len); +tprints ("}" ); + } + +return 1 ; +}
drm.c int drm_decode_number(struct tcb *tcp, unsigned int arg) · line 138
Quoted 10 lines
drm.c +10
-0+ +static int drm_get_unique (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_unique unique; + +if (umove (tcp, arg, &unique)) +return 0 ; + +if (exiting (tcp)) { +tprintf (", {unique_len=%lu, unique=}" , unique.unique_len);
There is an extra '}'
Quoted 488 lines
drm.c +478
-0+printstr (tcp, (long )unique.unique, unique.unique_len); +tprints ("}" ); + } + +return 1 ; +} + +static int drm_get_magic (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_auth auth; + +if (umove (tcp, arg, &auth)) +return 0 ; + +if (exiting (tcp)) +tprintf (", {magic=%u}" , auth.magic); + +return 1 ; +} + +static int drm_wait_vblank (struct tcb *tcp,const unsigned int code,long arg) +{ +union drm_wait_vblank vblank; + +if (umove (tcp, arg, &vblank)) +return 0 ; + +if (entering (tcp)) { +tprintf (", {request={type=%u, sequence=%u, signal=%lu}" , + vblank.request.type, vblank.request.sequence, + vblank.request.signal); + }else if (exiting (tcp)) { +tprintf (", reply={type=%u, sequence=%u, tval_sec=%ld, tval_usec=%ld}}" , + vblank.reply.type, vblank.reply.sequence, + vblank.reply.tval_sec, vblank.reply.tval_usec); + } + +return 1 ; +} + +static int drm_mode_get_resources (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_mode_card_res res; + +if (umove (tcp, arg, &res)) +return 0 ; + +if (exiting (tcp)) { +tprintf (", {fb_id_ptr=%p, crtc_id_ptr=%p, connector_id_ptr=%p, " +"encoder_id_ptr=%p, count_fbs=%u, count_crtcs=%u, " +"count_connectors=%u, count_encoders=%u, min_width=%u, " +"max_width=%u, min_height=%u, max_height=%u}" , + (void *)res.fb_id_ptr, (void *)res.crtc_id_ptr, + (void *)res.connector_id_ptr, (void *)res.encoder_id_ptr, + res.count_fbs, res.count_crtcs, res.count_connectors, + res.count_encoders, res.min_width, res.max_width, + res.min_height, res.max_height); + } + +return 1 ; +} + +static void drm_mode_print_modeinfo (struct drm_mode_modeinfo *info) +{ +tprintf ("clock=%u, hdisplay=%hu, hsync_start=%hu, hsync_end=%hu, " +"htotal=%hu, hskew=%hu, vdisplay=%hu, vsync_start=%hu, " +"vsync_end=%hu, vtotal=%hu, vscan=%hu, vrefresh=%u, " +"flags=0x%x, type=%u, name=%s" , info->clock, info->hdisplay, + info->hsync_start, info->hsync_end, info->htotal, info->hskew, + info->vdisplay, info->vsync_start, info->vsync_end, + info->vtotal, info->vscan, info->vrefresh, info->flags, + info->type, info->name); +} + +static int drm_mode_get_crtc (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_mode_crtc crtc; + +if (umove (tcp, arg, &crtc)) +return 0 ; + +if (entering (tcp)) { +tprintf (", {crtc_id=%u" , crtc.crtc_id); + }else if (exiting (tcp)) { +tprintf (", set_connectors_ptr=%p, count_connectors=%u, " +"fb_id=%u, x=%u, y=%u, gamma_size=%u, mode_valid=%u, " +"mode={" , (void *)crtc.set_connectors_ptr, + crtc.count_connectors, crtc.fb_id, crtc.x, crtc.y, + crtc.gamma_size, crtc.mode_valid); + +drm_mode_print_modeinfo (&crtc.mode); +tprintf ("}}" ); + } + +return 1 ; +} + +static int drm_mode_set_crtc (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_mode_crtc crtc; + +if (umove (tcp, arg, &crtc)) +return 0 ; + +if (entering (tcp)) { +tprintf (", {set_connectors_ptr=%p, count_connectors=%u, " +"crtc_id=%u, fb_id=%u, x=%u, y=%u, gamma_size=%u, " +"mode_valid=%u, mode={" , (void *)crtc.set_connectors_ptr, + crtc.count_connectors, crtc.crtc_id, crtc.fb_id, crtc.x, + crtc.y, crtc.gamma_size, crtc.mode_valid); + +drm_mode_print_modeinfo (&crtc.mode); +tprintf ("}}" ); + } + +return 1 ; +} + +static int drm_mode_cursor (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_mode_cursor cursor; + +if (umove (tcp, arg, &cursor)) +return 0 ; + +if (entering (tcp)) { +tprintf (", {flags=0x%x, crtc_id=%u, x=%d, y=%d, width=%u, " +"height=%u, handle=%u}" , cursor.flags, cursor.crtc_id, + cursor.x, cursor.y, cursor.width, cursor.height, + cursor.handle); + } + +return 1 ; +} + +static int drm_mode_cursor2 (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_mode_cursor2 cursor; + +if (umove (tcp, arg, &cursor)) +return 0 ; + +if (entering (tcp)) { +tprintf (", {flags=0x%x, crtc_id=%u, x=%d, y=%d, width=%u, " +"height=%u, handle=%u, hot_x=%d, hot_y=%d}" , + cursor.flags, cursor.crtc_id, cursor.x, cursor.y, + cursor.width, cursor.height, cursor.handle, + cursor.hot_x, cursor.hot_y); + } + +return 1 ; +} + +static int drm_mode_get_gamma (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_mode_crtc_lut lut; + +if (umove (tcp, arg, &lut)) +return 0 ; + +if (entering (tcp)) { +/* We don't print the entire table, just the pointers */ +tprintf (", {crtc_id=%u, gamma_size=%u, red=%p, green=%p, " +"blue=%p}" , lut.crtc_id, lut.gamma_size, + (void *)lut.red, (void *)lut.green, (void *)lut.blue); + } + +return 1 ; +} + +static int drm_mode_set_gamma (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_mode_crtc_lut lut; + +if (umove (tcp, arg, &lut)) +return 0 ; + +if (entering (tcp)) { +/* We don't print the entire table, just the rgb pointers */ +tprintf (", {crtc_id=%u, gamma_size=%u, red=%p, green=%p, " +"blue=%p}" , lut.crtc_id, lut.gamma_size, + (void *)lut.red, (void *)lut.green, (void *)lut.blue); + } + +return 1 ; +} + +static int drm_mode_get_encoder (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_mode_get_encoder enc; + +if (umove (tcp, arg, &enc)) +return 0 ; + +if (entering (tcp)) { +tprintf (", {encoder_id=%u" , enc.encoder_id); + }else if (exiting (tcp)) { +/* TODO: Print name of encoder type */ +tprintf (", encoder_type=%u, crtc_id=%u, possible_crtcs=0x%x, " +"possible_clones=0x%x}" , enc.encoder_type, + enc.crtc_id, enc.possible_crtcs, enc.possible_clones); + } + +return 1 ; +} + +static int drm_mode_get_connector (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_mode_get_connector con; + +if (umove (tcp, arg, &con)) +return 0 ; + +/* We could be very verbose here but keep is simple for now */ +if (entering (tcp)) { +tprintf (", {connector_id=%u" , con.connector_id); + }else if (exiting (tcp)) { +tprintf (", encoders_ptr=%p, modes_ptr=%p, props_ptr=%p, " +"prop_values_ptr=%p, count_modes=%u, count_props=%u, " +"count_encoders=%u, encoder_id=%u, connector_type=%u, " +"connector_type_id=%u, connection=%u, mm_width=%u, " +"mm_height=%u, subpixel=%u}" , (void *)con.encoders_ptr, + (void *)con.modes_ptr, (void *)con.props_ptr, + (void *)con.prop_values_ptr, con.count_modes, + con.count_props, con.count_encoders, con.encoder_id, + con.connector_type, con.connector_type_id, + con.connection, con.mm_width, con.mm_height, + con.subpixel); + } + +return 1 ; +} + +static int drm_mode_get_property (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_mode_get_property prop; + +if (umove (tcp, arg, &prop)) +return 0 ; + +if (entering (tcp)) { +tprintf (", {prop_id=%u" , prop.prop_id); + }else if (exiting (tcp)) { +tprintf (", values_ptr=%p, enum_blob_ptr=%p, flags=0x%x, " +"name=%s, count_values=%u, count_enum_blobs=%u}" , + (void *)prop.values_ptr, (void *)prop.enum_blob_ptr, + prop.flags, prop.name, prop.count_values, + prop.count_enum_blobs); + } + +return 1 ; +} + +static int drm_mode_set_property (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_mode_connector_set_property prop; + +if (umove (tcp, arg, &prop)) +return 0 ; + +if (entering (tcp)) { +tprintf (", {value=%Lu, prop_id=%u, connector_id=%u}" , + prop.value, prop.prop_id, prop.connector_id); + } + +return 1 ; +} + +static int drm_mode_get_prop_blob (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_mode_get_blob blob; + +if (umove (tcp, arg, &blob)) +return 0 ; + +if (entering (tcp)) { +tprintf (", {blob_id=%u" , blob.blob_id); + }else if (exiting (tcp)) { +tprintf (", length=%u, data=%p}" , blob.length, + (void *)blob.data); + } + +return 1 ; +} + +static int drm_mode_add_fb (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_mode_fb_cmd cmd; + +if (umove (tcp, arg, &cmd)) +return 0 ; + +if (entering (tcp)) { +tprintf (", {width=%u, height=%u, pitch=%u, bpp=%u, depth=%u, " +"handle=%u" , cmd.width, cmd.height, cmd.pitch, + cmd.bpp, cmd.depth, cmd.handle); + }else if (exiting (tcp)) { +tprintf (", fb_id=%u}" , cmd.fb_id); + } + +return 1 ; +} + +static int drm_mode_get_fb (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_mode_fb_cmd cmd; + +if (umove (tcp, arg, &cmd)) +return 0 ; + +if (entering (tcp)) { +tprintf (", {fb_id=%u" , cmd.fb_id); + }else { +tprintf (", width=%u, height=%u, pitch=%u, bpp=%u, depth=%u, " +"handle=%u}" , cmd.width, cmd.height, cmd.pitch, + cmd.bpp, cmd.depth, cmd.handle); + } + +return 1 ; +} + +static int drm_mode_rm_fb (struct tcb *tcp,const unsigned int code,long arg) +{ +unsigned int handle; + +if (umove (tcp, arg, &handle)) +return 0 ; + +if (entering (tcp)) +tprintf (", %u" , handle); + +return 1 ; +} + +static int drm_mode_page_flip (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_mode_crtc_page_flip flip; + +if (umove (tcp, arg, &flip)) +return 0 ; + +if (entering (tcp)) { +tprintf (", {crtc_id=%u, fb_id=%u, flags=0x%x, user_data=0x%Lx}" , + flip.crtc_id, flip.fb_id, flip.flags, flip.user_data); + } + +return 1 ; +} + +static int drm_mode_dirty_fb (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_mode_fb_dirty_cmd cmd; + +if (umove (tcp, arg, &cmd)) +return 0 ; + +if (entering (tcp)) { +tprintf (", {fb_id=%u, flags=0x%x, color=0x%x, num_clips=%u, " +"clips_ptr=%p}" , cmd.fb_id, cmd.flags, cmd.color, + cmd.num_clips, (void *)cmd.clips_ptr); + } + +return 1 ; +} + +static int drm_mode_create_dumb (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_mode_create_dumb dumb; + +if (umove (tcp, arg, &dumb)) +return 0 ; + +if (entering (tcp)) { +tprintf (", {width=%u, height=%u, bpp=%u, flags=0x%x" , + dumb.width, dumb.height, dumb.bpp, dumb.flags); + }else if (exiting (tcp)) { +tprintf (", handle=%u, pitch=%u, size=%Lu}" , dumb.handle, + dumb.pitch, dumb.size); + } + +return 1 ; +} + +static int drm_mode_map_dumb (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_mode_map_dumb dumb; + +if (umove (tcp, arg, &dumb)) +return 0 ; + +if (entering (tcp)) { +tprintf (", {handle=%u" , dumb.handle); + }else if (exiting (tcp)) { +tprintf (", offset=%Lu}" , dumb.offset); + } + +return 1 ; +} + +static int drm_mode_destroy_dumb (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_mode_destroy_dumb dumb; + +if (umove (tcp, arg, &dumb)) +return 0 ; + +if (entering (tcp)) +tprintf (", {handle=%u}" , dumb.handle); + +return 1 ; +} + +static int drm_gem_close (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_gem_close close; + +if (umove (tcp, arg, &close)) +return 0 ; + +if (entering (tcp)) +tprintf (", {handle=%u}" , close.handle); + +return 1 ; +} +int drm_ioctl (struct tcb *tcp,const unsigned int code,long arg) {/* Check for device specific ioctls */ @@ -112,6 +569,59 @@ int drm_ioctl(struct tcb *tcp, const unsigned int code, long arg)return drm_i915_ioctl (tcp, code, arg); } +switch (code) { +case DRM_IOCTL_VERSION : +return drm_version (tcp, code, arg); +case DRM_IOCTL_GET_UNIQUE : +return drm_get_unique (tcp, code, arg); +case DRM_IOCTL_GET_MAGIC : +return drm_get_magic (tcp, code, arg); +case DRM_IOCTL_WAIT_VBLANK : +return drm_wait_vblank (tcp, code, arg); +case DRM_IOCTL_MODE_GETRESOURCES : +return drm_mode_get_resources (tcp, code, arg); +case DRM_IOCTL_MODE_GETCRTC : +return drm_mode_get_crtc (tcp, code, arg); +case DRM_IOCTL_MODE_SETCRTC : +return drm_mode_set_crtc (tcp, code, arg); +case DRM_IOCTL_MODE_CURSOR : +return drm_mode_cursor (tcp, code, arg); +case DRM_IOCTL_MODE_CURSOR2 : +return drm_mode_cursor2 (tcp, code, arg); +case DRM_IOCTL_MODE_GETGAMMA : +return drm_mode_get_gamma (tcp, code, arg); +case DRM_IOCTL_MODE_SETGAMMA : +return drm_mode_set_gamma (tcp, code, arg); +case DRM_IOCTL_MODE_GETENCODER : +return drm_mode_get_encoder (tcp, code, arg); +case DRM_IOCTL_MODE_GETCONNECTOR : +return drm_mode_get_connector (tcp, code, arg); +case DRM_IOCTL_MODE_GETPROPERTY : +return drm_mode_get_property (tcp, code, arg); +case DRM_IOCTL_MODE_SETPROPERTY : +return drm_mode_set_property (tcp, code, arg); +case DRM_IOCTL_MODE_GETPROPBLOB : +return drm_mode_get_prop_blob (tcp, code, arg); +case DRM_IOCTL_MODE_GETFB : +return drm_mode_get_fb (tcp, code, arg); +case DRM_IOCTL_MODE_ADDFB : +return drm_mode_add_fb (tcp, code, arg); +case DRM_IOCTL_MODE_RMFB : +return drm_mode_rm_fb (tcp, code, arg); +case DRM_IOCTL_MODE_PAGE_FLIP : +return drm_mode_page_flip (tcp, code, arg); +case DRM_IOCTL_MODE_DIRTYFB : +return drm_mode_dirty_fb (tcp, code, arg); +case DRM_IOCTL_MODE_CREATE_DUMB : +return drm_mode_create_dumb (tcp, code, arg); +case DRM_IOCTL_MODE_MAP_DUMB : +return drm_mode_map_dumb (tcp, code, arg); +case DRM_IOCTL_MODE_DESTROY_DUMB : +return drm_mode_destroy_dumb (tcp, code, arg); +case DRM_IOCTL_GEM_CLOSE : +return drm_gem_close (tcp, code, arg); + } +/* Free any allocated private data */ if (exiting (tcp) && tcp->priv_data !=NULL ) {free (tcp->priv_data);
Signature · 5 lines
Gabriel Laskar _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
A message that is not in the archive (sent off-list or not yet received): 20150629193500.6cbc3a35-krIL5v34lyW+8jMViQwUxmazZaUMDOZU@public.gmane.org
Re: [PATCH v2 5/5] drm: Add decoding of DRM and KMS ioctls
Quoted 55 lines · Gabriel Laskar
Quoted 39 lines · On Thu, 18 Jun 2015 10:42:45 +0200 Patrik Jakobsson…
This patch adds many of the DRM and KMS ioctls. The rest can be added as needed.
*
drm.c: DecodeDRM_IOCTL_VERSION
*drm.c: DecodeDRM_IOCTL_GET_UNIQUE
*drm.c: DecodeDRM_IOCTL_GET_MAGIC
*drm.c: DecodeDRM_IOCTL_WAIT_VBLANK
*drm.c: DecodeDRM_IOCTL_MODE_GETRESOURCES
*drm.c: DecodeDRM_IOCTL_MODE_GETCRTC
*drm.c: DecodeDRM_IOCTL_MODE_SETCRTC
*drm.c: DecodeDRM_IOCTL_MODE_CURSOR
*drm.c: DecodeDRM_IOCTL_MODE_CURSOR2
*drm.c: DecodeDRM_IOCTL_MODE_GETGAMMA
*drm.c: DecodeDRM_IOCTL_MODE_SETGAMMA
*drm.c: DecodeDRM_IOCTL_MODE_GETENCODER
*drm.c: DecodeDRM_IOCTL_MODE_GETCONNECTOR
*drm.c: DecodeDRM_IOCTL_MODE_GETPROPERTY
*drm.c: DecodeDRM_IOCTL_MODE_SETPROPERTY
*drm.c: DecodeDRM_IOCTL_MODE_GETPROPBLOB
*drm.c: DecodeDRM_IOCTL_MODE_GETFB
*drm.c: DecodeDRM_IOCTL_MODE_ADDFB
*drm.c: DecodeDRM_IOCTL_MODE_RMFB
*drm.c: DecodeDRM_IOCTL_MODE_PAGE_FLIP
*drm.c: DecodeDRM_IOCTL_DIRTYFB
*drm.c: DecodeDRM_IOCTL_CREATE_DUMB
*drm.c: DecodeDRM_IOCTL_MAP_DUMB
*drm.c: DecodeDRM_IOCTL_DESTROY_DUMB
*drm.c: DecodeDRM_IOCTL_GEM_CLOSE--- drm.c | 510 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 510 insertions(+)drm.c +0
-0drm.c int drm_decode_number(struct tcb *tcp, unsigned int arg) · line 113
Quoted 10 lines
drm.c +7
-0@@ -104,6 +104,463 @@ int drm_decode_number(struct tcb *tcp, unsigned int arg)return 0 ; } +static int drm_version (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_version ver; + +if (umove (tcp, arg, &ver)) +return 0 ; +The
umove()should be done only on exiting and if the ioctl succeded ?
Quoted 2 lines
Same thing for most of the read only ioctl.
Yes, that could be moved into exiting. Will fix for all "single phase" ioctls.
Quoted 19 lines
Quoted 19 lines
drm.c +19
-0+if (exiting (tcp)) { +tprintf (", {version_major=%d, version_minor=%d, version_patchlevel=%d, " +"name_len=%lu, name=" , ver.version_major, + ver.version_minor, ver.version_patchlevel, + ver.name_len); +printstr (tcp, (long )ver.name, ver.name_len); +tprintf (", date_len=%lu, date=" , ver.date_len); +printstr (tcp, (long )ver.date, ver.date_len); +tprintf (", desc_len=%lu, desc=" , ver.desc_len); +printstr (tcp, (long )ver.desc, ver.desc_len); +tprints ("}" ); + } + +return 1 ; +} + +static int drm_get_unique (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_unique unique;
Quoted 9 lines
drm.c int drm_decode_number(struct tcb *tcp, unsigned int arg) · line 138
Quoted 6 lines
drm.c +6
-0+ +if (umove (tcp, arg, &unique)) +return 0 ; + +if (exiting (tcp)) { +tprintf (", {unique_len=%lu, unique=}" , unique.unique_len);There is an extra '}'
Oops
Quoted 480 lines
Quoted 480 lines
drm.c +473
-0+printstr (tcp, (long )unique.unique, unique.unique_len); +tprints ("}" ); + } + +return 1 ; +} + +static int drm_get_magic (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_auth auth; + +if (umove (tcp, arg, &auth)) +return 0 ; + +if (exiting (tcp)) +tprintf (", {magic=%u}" , auth.magic); + +return 1 ; +} + +static int drm_wait_vblank (struct tcb *tcp,const unsigned int code,long arg) +{ +union drm_wait_vblank vblank; + +if (umove (tcp, arg, &vblank)) +return 0 ; + +if (entering (tcp)) { +tprintf (", {request={type=%u, sequence=%u, signal=%lu}" , + vblank.request.type, vblank.request.sequence, + vblank.request.signal); + }else if (exiting (tcp)) { +tprintf (", reply={type=%u, sequence=%u, tval_sec=%ld, tval_usec=%ld}}" , + vblank.reply.type, vblank.reply.sequence, + vblank.reply.tval_sec, vblank.reply.tval_usec); + } + +return 1 ; +} + +static int drm_mode_get_resources (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_mode_card_res res; + +if (umove (tcp, arg, &res)) +return 0 ; + +if (exiting (tcp)) { +tprintf (", {fb_id_ptr=%p, crtc_id_ptr=%p, connector_id_ptr=%p, " +"encoder_id_ptr=%p, count_fbs=%u, count_crtcs=%u, " +"count_connectors=%u, count_encoders=%u, min_width=%u, " +"max_width=%u, min_height=%u, max_height=%u}" , + (void *)res.fb_id_ptr, (void *)res.crtc_id_ptr, + (void *)res.connector_id_ptr, (void *)res.encoder_id_ptr, + res.count_fbs, res.count_crtcs, res.count_connectors, + res.count_encoders, res.min_width, res.max_width, + res.min_height, res.max_height); + } + +return 1 ; +} + +static void drm_mode_print_modeinfo (struct drm_mode_modeinfo *info) +{ +tprintf ("clock=%u, hdisplay=%hu, hsync_start=%hu, hsync_end=%hu, " +"htotal=%hu, hskew=%hu, vdisplay=%hu, vsync_start=%hu, " +"vsync_end=%hu, vtotal=%hu, vscan=%hu, vrefresh=%u, " +"flags=0x%x, type=%u, name=%s" , info->clock, info->hdisplay, + info->hsync_start, info->hsync_end, info->htotal, info->hskew, + info->vdisplay, info->vsync_start, info->vsync_end, + info->vtotal, info->vscan, info->vrefresh, info->flags, + info->type, info->name); +} + +static int drm_mode_get_crtc (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_mode_crtc crtc; + +if (umove (tcp, arg, &crtc)) +return 0 ; + +if (entering (tcp)) { +tprintf (", {crtc_id=%u" , crtc.crtc_id); + }else if (exiting (tcp)) { +tprintf (", set_connectors_ptr=%p, count_connectors=%u, " +"fb_id=%u, x=%u, y=%u, gamma_size=%u, mode_valid=%u, " +"mode={" , (void *)crtc.set_connectors_ptr, + crtc.count_connectors, crtc.fb_id, crtc.x, crtc.y, + crtc.gamma_size, crtc.mode_valid); + +drm_mode_print_modeinfo (&crtc.mode); +tprintf ("}}" ); + } + +return 1 ; +} + +static int drm_mode_set_crtc (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_mode_crtc crtc; + +if (umove (tcp, arg, &crtc)) +return 0 ; + +if (entering (tcp)) { +tprintf (", {set_connectors_ptr=%p, count_connectors=%u, " +"crtc_id=%u, fb_id=%u, x=%u, y=%u, gamma_size=%u, " +"mode_valid=%u, mode={" , (void *)crtc.set_connectors_ptr, + crtc.count_connectors, crtc.crtc_id, crtc.fb_id, crtc.x, + crtc.y, crtc.gamma_size, crtc.mode_valid); + +drm_mode_print_modeinfo (&crtc.mode); +tprintf ("}}" ); + } + +return 1 ; +} + +static int drm_mode_cursor (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_mode_cursor cursor; + +if (umove (tcp, arg, &cursor)) +return 0 ; + +if (entering (tcp)) { +tprintf (", {flags=0x%x, crtc_id=%u, x=%d, y=%d, width=%u, " +"height=%u, handle=%u}" , cursor.flags, cursor.crtc_id, + cursor.x, cursor.y, cursor.width, cursor.height, + cursor.handle); + } + +return 1 ; +} + +static int drm_mode_cursor2 (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_mode_cursor2 cursor; + +if (umove (tcp, arg, &cursor)) +return 0 ; + +if (entering (tcp)) { +tprintf (", {flags=0x%x, crtc_id=%u, x=%d, y=%d, width=%u, " +"height=%u, handle=%u, hot_x=%d, hot_y=%d}" , + cursor.flags, cursor.crtc_id, cursor.x, cursor.y, + cursor.width, cursor.height, cursor.handle, + cursor.hot_x, cursor.hot_y); + } + +return 1 ; +} + +static int drm_mode_get_gamma (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_mode_crtc_lut lut; + +if (umove (tcp, arg, &lut)) +return 0 ; + +if (entering (tcp)) { +/* We don't print the entire table, just the pointers */ +tprintf (", {crtc_id=%u, gamma_size=%u, red=%p, green=%p, " +"blue=%p}" , lut.crtc_id, lut.gamma_size, + (void *)lut.red, (void *)lut.green, (void *)lut.blue); + } + +return 1 ; +} + +static int drm_mode_set_gamma (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_mode_crtc_lut lut; + +if (umove (tcp, arg, &lut)) +return 0 ; + +if (entering (tcp)) { +/* We don't print the entire table, just the rgb pointers */ +tprintf (", {crtc_id=%u, gamma_size=%u, red=%p, green=%p, " +"blue=%p}" , lut.crtc_id, lut.gamma_size, + (void *)lut.red, (void *)lut.green, (void *)lut.blue); + } + +return 1 ; +} + +static int drm_mode_get_encoder (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_mode_get_encoder enc; + +if (umove (tcp, arg, &enc)) +return 0 ; + +if (entering (tcp)) { +tprintf (", {encoder_id=%u" , enc.encoder_id); + }else if (exiting (tcp)) { +/* TODO: Print name of encoder type */ +tprintf (", encoder_type=%u, crtc_id=%u, possible_crtcs=0x%x, " +"possible_clones=0x%x}" , enc.encoder_type, + enc.crtc_id, enc.possible_crtcs, enc.possible_clones); + } + +return 1 ; +} + +static int drm_mode_get_connector (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_mode_get_connector con; + +if (umove (tcp, arg, &con)) +return 0 ; + +/* We could be very verbose here but keep is simple for now */ +if (entering (tcp)) { +tprintf (", {connector_id=%u" , con.connector_id); + }else if (exiting (tcp)) { +tprintf (", encoders_ptr=%p, modes_ptr=%p, props_ptr=%p, " +"prop_values_ptr=%p, count_modes=%u, count_props=%u, " +"count_encoders=%u, encoder_id=%u, connector_type=%u, " +"connector_type_id=%u, connection=%u, mm_width=%u, " +"mm_height=%u, subpixel=%u}" , (void *)con.encoders_ptr, + (void *)con.modes_ptr, (void *)con.props_ptr, + (void *)con.prop_values_ptr, con.count_modes, + con.count_props, con.count_encoders, con.encoder_id, + con.connector_type, con.connector_type_id, + con.connection, con.mm_width, con.mm_height, + con.subpixel); + } + +return 1 ; +} + +static int drm_mode_get_property (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_mode_get_property prop; + +if (umove (tcp, arg, &prop)) +return 0 ; + +if (entering (tcp)) { +tprintf (", {prop_id=%u" , prop.prop_id); + }else if (exiting (tcp)) { +tprintf (", values_ptr=%p, enum_blob_ptr=%p, flags=0x%x, " +"name=%s, count_values=%u, count_enum_blobs=%u}" , + (void *)prop.values_ptr, (void *)prop.enum_blob_ptr, + prop.flags, prop.name, prop.count_values, + prop.count_enum_blobs); + } + +return 1 ; +} + +static int drm_mode_set_property (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_mode_connector_set_property prop; + +if (umove (tcp, arg, &prop)) +return 0 ; + +if (entering (tcp)) { +tprintf (", {value=%Lu, prop_id=%u, connector_id=%u}" , + prop.value, prop.prop_id, prop.connector_id); + } + +return 1 ; +} + +static int drm_mode_get_prop_blob (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_mode_get_blob blob; + +if (umove (tcp, arg, &blob)) +return 0 ; + +if (entering (tcp)) { +tprintf (", {blob_id=%u" , blob.blob_id); + }else if (exiting (tcp)) { +tprintf (", length=%u, data=%p}" , blob.length, + (void *)blob.data); + } + +return 1 ; +} + +static int drm_mode_add_fb (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_mode_fb_cmd cmd; + +if (umove (tcp, arg, &cmd)) +return 0 ; + +if (entering (tcp)) { +tprintf (", {width=%u, height=%u, pitch=%u, bpp=%u, depth=%u, " +"handle=%u" , cmd.width, cmd.height, cmd.pitch, + cmd.bpp, cmd.depth, cmd.handle); + }else if (exiting (tcp)) { +tprintf (", fb_id=%u}" , cmd.fb_id); + } + +return 1 ; +} + +static int drm_mode_get_fb (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_mode_fb_cmd cmd; + +if (umove (tcp, arg, &cmd)) +return 0 ; + +if (entering (tcp)) { +tprintf (", {fb_id=%u" , cmd.fb_id); + }else { +tprintf (", width=%u, height=%u, pitch=%u, bpp=%u, depth=%u, " +"handle=%u}" , cmd.width, cmd.height, cmd.pitch, + cmd.bpp, cmd.depth, cmd.handle); + } + +return 1 ; +} + +static int drm_mode_rm_fb (struct tcb *tcp,const unsigned int code,long arg) +{ +unsigned int handle; + +if (umove (tcp, arg, &handle)) +return 0 ; + +if (entering (tcp)) +tprintf (", %u" , handle); + +return 1 ; +} + +static int drm_mode_page_flip (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_mode_crtc_page_flip flip; + +if (umove (tcp, arg, &flip)) +return 0 ; + +if (entering (tcp)) { +tprintf (", {crtc_id=%u, fb_id=%u, flags=0x%x, user_data=0x%Lx}" , + flip.crtc_id, flip.fb_id, flip.flags, flip.user_data); + } + +return 1 ; +} + +static int drm_mode_dirty_fb (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_mode_fb_dirty_cmd cmd; + +if (umove (tcp, arg, &cmd)) +return 0 ; + +if (entering (tcp)) { +tprintf (", {fb_id=%u, flags=0x%x, color=0x%x, num_clips=%u, " +"clips_ptr=%p}" , cmd.fb_id, cmd.flags, cmd.color, + cmd.num_clips, (void *)cmd.clips_ptr); + } + +return 1 ; +} + +static int drm_mode_create_dumb (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_mode_create_dumb dumb; + +if (umove (tcp, arg, &dumb)) +return 0 ; + +if (entering (tcp)) { +tprintf (", {width=%u, height=%u, bpp=%u, flags=0x%x" , + dumb.width, dumb.height, dumb.bpp, dumb.flags); + }else if (exiting (tcp)) { +tprintf (", handle=%u, pitch=%u, size=%Lu}" , dumb.handle, + dumb.pitch, dumb.size); + } + +return 1 ; +} + +static int drm_mode_map_dumb (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_mode_map_dumb dumb; + +if (umove (tcp, arg, &dumb)) +return 0 ; + +if (entering (tcp)) { +tprintf (", {handle=%u" , dumb.handle); + }else if (exiting (tcp)) { +tprintf (", offset=%Lu}" , dumb.offset); + } + +return 1 ; +} + +static int drm_mode_destroy_dumb (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_mode_destroy_dumb dumb; + +if (umove (tcp, arg, &dumb)) +return 0 ; + +if (entering (tcp)) +tprintf (", {handle=%u}" , dumb.handle); + +return 1 ; +} + +static int drm_gem_close (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_gem_close close; + +if (umove (tcp, arg, &close)) +return 0 ; + +if (entering (tcp)) +tprintf (", {handle=%u}" , close.handle); + +return 1 ; +} +int drm_ioctl (struct tcb *tcp,const unsigned int code,long arg) {/* Check for device specific ioctls */ @@ -112,6 +569,59 @@ int drm_ioctl(struct tcb *tcp, const unsigned int code, long arg)return drm_i915_ioctl (tcp, code, arg); } +switch (code) { +case DRM_IOCTL_VERSION : +return drm_version (tcp, code, arg); +case DRM_IOCTL_GET_UNIQUE : +return drm_get_unique (tcp, code, arg); +case DRM_IOCTL_GET_MAGIC : +return drm_get_magic (tcp, code, arg); +case DRM_IOCTL_WAIT_VBLANK : +return drm_wait_vblank (tcp, code, arg); +case DRM_IOCTL_MODE_GETRESOURCES : +return drm_mode_get_resources (tcp, code, arg); +case DRM_IOCTL_MODE_GETCRTC : +return drm_mode_get_crtc (tcp, code, arg); +case DRM_IOCTL_MODE_SETCRTC : +return drm_mode_set_crtc (tcp, code, arg); +case DRM_IOCTL_MODE_CURSOR : +return drm_mode_cursor (tcp, code, arg); +case DRM_IOCTL_MODE_CURSOR2 : +return drm_mode_cursor2 (tcp, code, arg); +case DRM_IOCTL_MODE_GETGAMMA : +return drm_mode_get_gamma (tcp, code, arg); +case DRM_IOCTL_MODE_SETGAMMA : +return drm_mode_set_gamma (tcp, code, arg); +case DRM_IOCTL_MODE_GETENCODER : +return drm_mode_get_encoder (tcp, code, arg); +case DRM_IOCTL_MODE_GETCONNECTOR : +return drm_mode_get_connector (tcp, code, arg); +case DRM_IOCTL_MODE_GETPROPERTY : +return drm_mode_get_property (tcp, code, arg); +case DRM_IOCTL_MODE_SETPROPERTY : +return drm_mode_set_property (tcp, code, arg); +case DRM_IOCTL_MODE_GETPROPBLOB : +return drm_mode_get_prop_blob (tcp, code, arg); +case DRM_IOCTL_MODE_GETFB : +return drm_mode_get_fb (tcp, code, arg); +case DRM_IOCTL_MODE_ADDFB : +return drm_mode_add_fb (tcp, code, arg); +case DRM_IOCTL_MODE_RMFB : +return drm_mode_rm_fb (tcp, code, arg); +case DRM_IOCTL_MODE_PAGE_FLIP : +return drm_mode_page_flip (tcp, code, arg); +case DRM_IOCTL_MODE_DIRTYFB : +return drm_mode_dirty_fb (tcp, code, arg); +case DRM_IOCTL_MODE_CREATE_DUMB : +return drm_mode_create_dumb (tcp, code, arg); +case DRM_IOCTL_MODE_MAP_DUMB : +return drm_mode_map_dumb (tcp, code, arg); +case DRM_IOCTL_MODE_DESTROY_DUMB :
Quoted 13 lines
Quoted 8 lines
drm.c +5
-0+return drm_mode_destroy_dumb (tcp, code, arg); +case DRM_IOCTL_GEM_CLOSE : +return drm_gem_close (tcp, code, arg); + } +/* Free any allocated private data */ if (exiting (tcp) && tcp->priv_data !=NULL ) {free (tcp->priv_data);Signature · 1 line
Gabriel Laskar
------------------------------------------------------------------------------
Don't Limit Your Business. Reach for the Cloud.
GigeNET's Cloud Solutions provide you with the tools and support that you need to offload your IT needs and focus on growing your business. Configured For All Businesses. Start Your Cloud Today.
https://www.gigenetcloud.com/
Re: [PATCH v2 5/5] drm: Add decoding of DRM and KMS ioctls
In reply to Patrik JakobssonQuoted 549 lines · Patrik Jakobsson
This patch adds many of the DRM and KMS ioctls. The rest can be added as needed.
*
drm.c: DecodeDRM_IOCTL_VERSION
*drm.c: DecodeDRM_IOCTL_GET_UNIQUE
*drm.c: DecodeDRM_IOCTL_GET_MAGIC
*drm.c: DecodeDRM_IOCTL_WAIT_VBLANK
*drm.c: DecodeDRM_IOCTL_MODE_GETRESOURCES
*drm.c: DecodeDRM_IOCTL_MODE_GETCRTC
*drm.c: DecodeDRM_IOCTL_MODE_SETCRTC
*drm.c: DecodeDRM_IOCTL_MODE_CURSOR
*drm.c: DecodeDRM_IOCTL_MODE_CURSOR2
*drm.c: DecodeDRM_IOCTL_MODE_GETGAMMA
*drm.c: DecodeDRM_IOCTL_MODE_SETGAMMA
*drm.c: DecodeDRM_IOCTL_MODE_GETENCODER
*drm.c: DecodeDRM_IOCTL_MODE_GETCONNECTOR
*drm.c: DecodeDRM_IOCTL_MODE_GETPROPERTY
*drm.c: DecodeDRM_IOCTL_MODE_SETPROPERTY
*drm.c: DecodeDRM_IOCTL_MODE_GETPROPBLOB
*drm.c: DecodeDRM_IOCTL_MODE_GETFB
*drm.c: DecodeDRM_IOCTL_MODE_ADDFB
*drm.c: DecodeDRM_IOCTL_MODE_RMFB
*drm.c: DecodeDRM_IOCTL_MODE_PAGE_FLIP
*drm.c: DecodeDRM_IOCTL_DIRTYFB
*drm.c: DecodeDRM_IOCTL_CREATE_DUMB
*drm.c: DecodeDRM_IOCTL_MAP_DUMB
*drm.c: DecodeDRM_IOCTL_DESTROY_DUMB
*drm.c: DecodeDRM_IOCTL_GEM_CLOSESigned-off-by Patrik Jakobsson <[email protected]>--- drm.c | 510 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 510 insertions(+)drm.c +500
-0@@ -104,6 +104,463 @@ int drm_decode_number(struct tcb *tcp, unsigned int arg)return 0 ; } +static int drm_version (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_version ver; + +if (umove (tcp, arg, &ver)) +return 0 ; + +if (exiting (tcp)) { +tprintf (", {version_major=%d, version_minor=%d, version_patchlevel=%d, " +"name_len=%lu, name=" , ver.version_major, + ver.version_minor, ver.version_patchlevel, + ver.name_len); +printstr (tcp, (long )ver.name, ver.name_len); +tprintf (", date_len=%lu, date=" , ver.date_len); +printstr (tcp, (long )ver.date, ver.date_len); +tprintf (", desc_len=%lu, desc=" , ver.desc_len); +printstr (tcp, (long )ver.desc, ver.desc_len); +tprints ("}" ); + } + +return 1 ; +} + +static int drm_get_unique (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_unique unique; + +if (umove (tcp, arg, &unique)) +return 0 ; + +if (exiting (tcp)) { +tprintf (", {unique_len=%lu, unique=}" , unique.unique_len); +printstr (tcp, (long )unique.unique, unique.unique_len); +tprints ("}" ); + } + +return 1 ; +} + +static int drm_get_magic (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_auth auth; + +if (umove (tcp, arg, &auth)) +return 0 ; + +if (exiting (tcp)) +tprintf (", {magic=%u}" , auth.magic); + +return 1 ; +} + +static int drm_wait_vblank (struct tcb *tcp,const unsigned int code,long arg) +{ +union drm_wait_vblank vblank; + +if (umove (tcp, arg, &vblank)) +return 0 ; + +if (entering (tcp)) { +tprintf (", {request={type=%u, sequence=%u, signal=%lu}" , + vblank.request.type, vblank.request.sequence, + vblank.request.signal); + }else if (exiting (tcp)) { +tprintf (", reply={type=%u, sequence=%u, tval_sec=%ld, tval_usec=%ld}}" , + vblank.reply.type, vblank.reply.sequence, + vblank.reply.tval_sec, vblank.reply.tval_usec); + } + +return 1 ; +} + +static int drm_mode_get_resources (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_mode_card_res res; + +if (umove (tcp, arg, &res)) +return 0 ; + +if (exiting (tcp)) { +tprintf (", {fb_id_ptr=%p, crtc_id_ptr=%p, connector_id_ptr=%p, " +"encoder_id_ptr=%p, count_fbs=%u, count_crtcs=%u, " +"count_connectors=%u, count_encoders=%u, min_width=%u, " +"max_width=%u, min_height=%u, max_height=%u}" , + (void *)res.fb_id_ptr, (void *)res.crtc_id_ptr, + (void *)res.connector_id_ptr, (void *)res.encoder_id_ptr, + res.count_fbs, res.count_crtcs, res.count_connectors, + res.count_encoders, res.min_width, res.max_width, + res.min_height, res.max_height); + } + +return 1 ; +} + +static void drm_mode_print_modeinfo (struct drm_mode_modeinfo *info) +{ +tprintf ("clock=%u, hdisplay=%hu, hsync_start=%hu, hsync_end=%hu, " +"htotal=%hu, hskew=%hu, vdisplay=%hu, vsync_start=%hu, " +"vsync_end=%hu, vtotal=%hu, vscan=%hu, vrefresh=%u, " +"flags=0x%x, type=%u, name=%s" , info->clock, info->hdisplay, + info->hsync_start, info->hsync_end, info->htotal, info->hskew, + info->vdisplay, info->vsync_start, info->vsync_end, + info->vtotal, info->vscan, info->vrefresh, info->flags, + info->type, info->name); +} + +static int drm_mode_get_crtc (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_mode_crtc crtc; + +if (umove (tcp, arg, &crtc)) +return 0 ; + +if (entering (tcp)) { +tprintf (", {crtc_id=%u" , crtc.crtc_id); + }else if (exiting (tcp)) { +tprintf (", set_connectors_ptr=%p, count_connectors=%u, " +"fb_id=%u, x=%u, y=%u, gamma_size=%u, mode_valid=%u, " +"mode={" , (void *)crtc.set_connectors_ptr, + crtc.count_connectors, crtc.fb_id, crtc.x, crtc.y, + crtc.gamma_size, crtc.mode_valid); + +drm_mode_print_modeinfo (&crtc.mode); +tprintf ("}}" ); + } + +return 1 ; +} + +static int drm_mode_set_crtc (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_mode_crtc crtc; + +if (umove (tcp, arg, &crtc)) +return 0 ; + +if (entering (tcp)) { +tprintf (", {set_connectors_ptr=%p, count_connectors=%u, " +"crtc_id=%u, fb_id=%u, x=%u, y=%u, gamma_size=%u, " +"mode_valid=%u, mode={" , (void *)crtc.set_connectors_ptr, + crtc.count_connectors, crtc.crtc_id, crtc.fb_id, crtc.x, + crtc.y, crtc.gamma_size, crtc.mode_valid); + +drm_mode_print_modeinfo (&crtc.mode); +tprintf ("}}" ); + } + +return 1 ; +} + +static int drm_mode_cursor (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_mode_cursor cursor; + +if (umove (tcp, arg, &cursor)) +return 0 ; + +if (entering (tcp)) { +tprintf (", {flags=0x%x, crtc_id=%u, x=%d, y=%d, width=%u, " +"height=%u, handle=%u}" , cursor.flags, cursor.crtc_id, + cursor.x, cursor.y, cursor.width, cursor.height, + cursor.handle); + } + +return 1 ; +} + +static int drm_mode_cursor2 (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_mode_cursor2 cursor; + +if (umove (tcp, arg, &cursor)) +return 0 ; + +if (entering (tcp)) { +tprintf (", {flags=0x%x, crtc_id=%u, x=%d, y=%d, width=%u, " +"height=%u, handle=%u, hot_x=%d, hot_y=%d}" , + cursor.flags, cursor.crtc_id, cursor.x, cursor.y, + cursor.width, cursor.height, cursor.handle, + cursor.hot_x, cursor.hot_y); + } + +return 1 ; +} + +static int drm_mode_get_gamma (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_mode_crtc_lut lut; + +if (umove (tcp, arg, &lut)) +return 0 ; + +if (entering (tcp)) { +/* We don't print the entire table, just the pointers */ +tprintf (", {crtc_id=%u, gamma_size=%u, red=%p, green=%p, " +"blue=%p}" , lut.crtc_id, lut.gamma_size, + (void *)lut.red, (void *)lut.green, (void *)lut.blue); + } + +return 1 ; +} + +static int drm_mode_set_gamma (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_mode_crtc_lut lut; + +if (umove (tcp, arg, &lut)) +return 0 ; + +if (entering (tcp)) { +/* We don't print the entire table, just the rgb pointers */ +tprintf (", {crtc_id=%u, gamma_size=%u, red=%p, green=%p, " +"blue=%p}" , lut.crtc_id, lut.gamma_size, + (void *)lut.red, (void *)lut.green, (void *)lut.blue); + } + +return 1 ; +} + +static int drm_mode_get_encoder (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_mode_get_encoder enc; + +if (umove (tcp, arg, &enc)) +return 0 ; + +if (entering (tcp)) { +tprintf (", {encoder_id=%u" , enc.encoder_id); + }else if (exiting (tcp)) { +/* TODO: Print name of encoder type */ +tprintf (", encoder_type=%u, crtc_id=%u, possible_crtcs=0x%x, " +"possible_clones=0x%x}" , enc.encoder_type, + enc.crtc_id, enc.possible_crtcs, enc.possible_clones); + } + +return 1 ; +} + +static int drm_mode_get_connector (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_mode_get_connector con; + +if (umove (tcp, arg, &con)) +return 0 ; + +/* We could be very verbose here but keep is simple for now */ +if (entering (tcp)) { +tprintf (", {connector_id=%u" , con.connector_id); + }else if (exiting (tcp)) { +tprintf (", encoders_ptr=%p, modes_ptr=%p, props_ptr=%p, " +"prop_values_ptr=%p, count_modes=%u, count_props=%u, " +"count_encoders=%u, encoder_id=%u, connector_type=%u, " +"connector_type_id=%u, connection=%u, mm_width=%u, " +"mm_height=%u, subpixel=%u}" , (void *)con.encoders_ptr, + (void *)con.modes_ptr, (void *)con.props_ptr, + (void *)con.prop_values_ptr, con.count_modes, + con.count_props, con.count_encoders, con.encoder_id, + con.connector_type, con.connector_type_id, + con.connection, con.mm_width, con.mm_height, + con.subpixel); + } + +return 1 ; +} + +static int drm_mode_get_property (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_mode_get_property prop; + +if (umove (tcp, arg, &prop)) +return 0 ; + +if (entering (tcp)) { +tprintf (", {prop_id=%u" , prop.prop_id); + }else if (exiting (tcp)) { +tprintf (", values_ptr=%p, enum_blob_ptr=%p, flags=0x%x, " +"name=%s, count_values=%u, count_enum_blobs=%u}" , + (void *)prop.values_ptr, (void *)prop.enum_blob_ptr, + prop.flags, prop.name, prop.count_values, + prop.count_enum_blobs); + } + +return 1 ; +} + +static int drm_mode_set_property (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_mode_connector_set_property prop; + +if (umove (tcp, arg, &prop)) +return 0 ; + +if (entering (tcp)) { +tprintf (", {value=%Lu, prop_id=%u, connector_id=%u}" , + prop.value, prop.prop_id, prop.connector_id); + } + +return 1 ; +} + +static int drm_mode_get_prop_blob (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_mode_get_blob blob; + +if (umove (tcp, arg, &blob)) +return 0 ; + +if (entering (tcp)) { +tprintf (", {blob_id=%u" , blob.blob_id); + }else if (exiting (tcp)) { +tprintf (", length=%u, data=%p}" , blob.length, + (void *)blob.data); + } + +return 1 ; +} + +static int drm_mode_add_fb (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_mode_fb_cmd cmd; + +if (umove (tcp, arg, &cmd)) +return 0 ; + +if (entering (tcp)) { +tprintf (", {width=%u, height=%u, pitch=%u, bpp=%u, depth=%u, " +"handle=%u" , cmd.width, cmd.height, cmd.pitch, + cmd.bpp, cmd.depth, cmd.handle); + }else if (exiting (tcp)) { +tprintf (", fb_id=%u}" , cmd.fb_id); + } + +return 1 ; +} + +static int drm_mode_get_fb (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_mode_fb_cmd cmd; + +if (umove (tcp, arg, &cmd)) +return 0 ; + +if (entering (tcp)) { +tprintf (", {fb_id=%u" , cmd.fb_id); + }else { +tprintf (", width=%u, height=%u, pitch=%u, bpp=%u, depth=%u, " +"handle=%u}" , cmd.width, cmd.height, cmd.pitch, + cmd.bpp, cmd.depth, cmd.handle); + } + +return 1 ; +} + +static int drm_mode_rm_fb (struct tcb *tcp,const unsigned int code,long arg) +{ +unsigned int handle; + +if (umove (tcp, arg, &handle)) +return 0 ; + +if (entering (tcp)) +tprintf (", %u" , handle); + +return 1 ; +} + +static int drm_mode_page_flip (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_mode_crtc_page_flip flip; + +if (umove (tcp, arg, &flip)) +return 0 ; + +if (entering (tcp)) { +tprintf (", {crtc_id=%u, fb_id=%u, flags=0x%x, user_data=0x%Lx}" , + flip.crtc_id, flip.fb_id, flip.flags, flip.user_data); + } + +return 1 ; +} + +static int drm_mode_dirty_fb (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_mode_fb_dirty_cmd cmd; + +if (umove (tcp, arg, &cmd)) +return 0 ; + +if (entering (tcp)) { +tprintf (", {fb_id=%u, flags=0x%x, color=0x%x, num_clips=%u, " +"clips_ptr=%p}" , cmd.fb_id, cmd.flags, cmd.color, + cmd.num_clips, (void *)cmd.clips_ptr); + } + +return 1 ; +} + +static int drm_mode_create_dumb (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_mode_create_dumb dumb; + +if (umove (tcp, arg, &dumb)) +return 0 ; + +if (entering (tcp)) { +tprintf (", {width=%u, height=%u, bpp=%u, flags=0x%x" , + dumb.width, dumb.height, dumb.bpp, dumb.flags); + }else if (exiting (tcp)) { +tprintf (", handle=%u, pitch=%u, size=%Lu}" , dumb.handle, + dumb.pitch, dumb.size); + } + +return 1 ; +} + +static int drm_mode_map_dumb (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_mode_map_dumb dumb; + +if (umove (tcp, arg, &dumb)) +return 0 ; + +if (entering (tcp)) { +tprintf (", {handle=%u" , dumb.handle); + }else if (exiting (tcp)) { +tprintf (", offset=%Lu}" , dumb.offset); + } + +return 1 ; +} + +static int drm_mode_destroy_dumb (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_mode_destroy_dumb dumb; + +if (umove (tcp, arg, &dumb)) +return 0 ; + +if (entering (tcp)) +tprintf (", {handle=%u}" , dumb.handle); + +return 1 ; +} + +static int drm_gem_close (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_gem_close close; + +if (umove (tcp, arg, &close)) +return 0 ; + +if (entering (tcp)) +tprintf (", {handle=%u}" , close.handle); + +return 1 ; +} +int drm_ioctl (struct tcb *tcp,const unsigned int code,long arg) {/* Check for device specific ioctls */ @@ -112,6 +569,59 @@ int drm_ioctl(struct tcb *tcp, const unsigned int code, long arg)return drm_i915_ioctl (tcp, code, arg); } +switch (code) { +case DRM_IOCTL_VERSION : +return drm_version (tcp, code, arg); +case DRM_IOCTL_GET_UNIQUE : +return drm_get_unique (tcp, code, arg); +case DRM_IOCTL_GET_MAGIC : +return drm_get_magic (tcp, code, arg); +case DRM_IOCTL_WAIT_VBLANK : +return drm_wait_vblank (tcp, code, arg); +case DRM_IOCTL_MODE_GETRESOURCES : +return drm_mode_get_resources (tcp, code, arg); +case DRM_IOCTL_MODE_GETCRTC : +return drm_mode_get_crtc (tcp, code, arg); +case DRM_IOCTL_MODE_SETCRTC : +return drm_mode_set_crtc (tcp, code, arg); +case DRM_IOCTL_MODE_CURSOR : +return drm_mode_cursor (tcp, code, arg); +case DRM_IOCTL_MODE_CURSOR2 : +return drm_mode_cursor2 (tcp, code, arg); +case DRM_IOCTL_MODE_GETGAMMA : +return drm_mode_get_gamma (tcp, code, arg); +case DRM_IOCTL_MODE_SETGAMMA : +return drm_mode_set_gamma (tcp, code, arg); +case DRM_IOCTL_MODE_GETENCODER : +return drm_mode_get_encoder (tcp, code, arg); +case DRM_IOCTL_MODE_GETCONNECTOR : +return drm_mode_get_connector (tcp, code, arg); +case DRM_IOCTL_MODE_GETPROPERTY : +return drm_mode_get_property (tcp, code, arg); +case DRM_IOCTL_MODE_SETPROPERTY : +return drm_mode_set_property (tcp, code, arg); +case DRM_IOCTL_MODE_GETPROPBLOB : +return drm_mode_get_prop_blob (tcp, code, arg); +case DRM_IOCTL_MODE_GETFB : +return drm_mode_get_fb (tcp, code, arg); +case DRM_IOCTL_MODE_ADDFB : +return drm_mode_add_fb (tcp, code, arg); +case DRM_IOCTL_MODE_RMFB : +return drm_mode_rm_fb (tcp, code, arg); +case DRM_IOCTL_MODE_PAGE_FLIP : +return drm_mode_page_flip (tcp, code, arg); +case DRM_IOCTL_MODE_DIRTYFB : +return drm_mode_dirty_fb (tcp, code, arg);
drm.c int drm_ioctl(struct tcb *tcp, const unsigned int code, long arg) · line 624
Quoted 10 lines
drm.c +10
-0+case DRM_IOCTL_MODE_CREATE_DUMB : +return drm_mode_create_dumb (tcp, code, arg); +case DRM_IOCTL_MODE_MAP_DUMB : +return drm_mode_map_dumb (tcp, code, arg); +case DRM_IOCTL_MODE_DESTROY_DUMB : +return drm_mode_destroy_dumb (tcp, code, arg); +case DRM_IOCTL_GEM_CLOSE : +return drm_gem_close (tcp, code, arg); + } +
Just realized I'm leaking memory here because of those returns. Will take care of that.
Quoted 10 lines
drm.c +0
-0/* Free any allocated private data */ if (exiting (tcp) && tcp->priv_data !=NULL ) {free (tcp->priv_data);Signature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
A message that is not in the archive (sent off-list or not yet received): 1434616965-5157-1-git-send-email-patrik.jakobsson-VuQAYsv1563Yd54FQh9/[email protected]
PATCH v2 4/5 drm: Add decoding of i915 ioctls
There are more ioctls to add but the ones in this patch are most commonly used.
* Makefile.am: Add compilation of drm_i915.c
* drm.c: Dispatch i915 ioctls
* drm_i915.c: Decode DRM_IOCTL_I915_GETPARAM
* drm_i915.c: Decode DRM_IOCTL_I915_SETPARAM
* drm_i915.c: Decode DRM_IOCTL_I915_GEM_EXECBUFFER2
* drm_i915.c: Decode DRM_IOCTL_I915_GEM_BUSY
* drm_i915.c: Decode DRM_IOCTL_I915_GEM_CREATE
* drm_i915.c: Decode DRM_IOCTL_I915_GEM_PREAD
* drm_i915.c: Decode DRM_IOCTL_I915_GEM_PWRITE
* drm_i915.c: Decode DRM_IOCTL_I915_GEM_MMAP
* drm_i915.c: Decode DRM_IOCTL_I915_GEM_MMAP_GTT
* drm_i915.c: Decode DRM_IOCTL_I915_SET_DOMAIN
* drm_i915.c: Decode DRM_IOCTL_I915_MADVISE
* drm_i915.c: Decode DRM_IOCTL_I915_GET_TILING
* drm_i915.c: Decode DRM_IOCTL_I915_SET_TILING
* drm_i915.c: Decode DRM_IOCTL_I915_USERPTR
* xlat/drm_i915_getparams.in: List GETPARAM parameters
* xlat/drm_i915_setparams.in: List SETPARAM parameters
* xlat/drm_i915_ioctls.in: List i915 ioctls
--- Makefile.am | 1 + drm.c | 14 ++ drm_i915.c | 332 +++++++++++++++++++++++++++++++++++++++++++++ xlat/drm_i915_getparams.in | 28 ++++ xlat/drm_i915_ioctls.in | 51 +++++++ xlat/drm_i915_setparams.in | 4 + 6 files changed, 430 insertions(+) create mode 100644 drm_i915.c create mode 100644 xlat/drm_i915_getparams.in create mode 100644 xlat/drm_i915_ioctls.in create mode 100644 xlat/drm_i915_setparams.in
Makefile.am +1 -0
@@ -42,6 +42,7 @@ strace_SOURCES = \ desc.c \ dirent.c \ drm.c \ + drm_i915.c \ evdev.c \ execve.c \ exit.c \
drm.c +14 -0
@@ -35,6 +35,9 @@#define DRM_MAX_NAME_LEN 128 +extern int drm_i915_decode_number (struct tcb *tcp,unsigned int arg); +extern int drm_i915_ioctl (struct tcb *tcp,const unsigned int code,long arg); +struct drm_ioctl_priv {char name[DRM_MAX_NAME_LEN ]; };
@@ -93,11 +96,22 @@ int drm_is_driver(struct tcb *tcp, const char *name)int drm_decode_number (struct tcb *tcp,unsigned int arg) { +if (drm_is_priv (tcp->u_arg[1 ])) { +if (verbose (tcp) &&drm_is_driver (tcp,"i915" )) +return drm_i915_decode_number (tcp, arg); + } +return 0 ; }int drm_ioctl (struct tcb *tcp,const unsigned int code,long arg) { +/* Check for device specific ioctls */ +if (drm_is_priv (tcp->u_arg[1 ])) { +if (verbose (tcp) &&drm_is_driver (tcp,"i915" )) +return drm_i915_ioctl (tcp, code, arg); + } +/* Free any allocated private data */ if (exiting (tcp) && tcp->priv_data !=NULL ) {free (tcp->priv_data);
drm_i915.c new file +332 -0
332 lines not on this page · raw message
xlat/drm_i915_getparams.in new file +28 -0
@@ -0,0 +1,28 @@ +I915_PARAM_IRQ_ACTIVE +I915_PARAM_ALLOW_BATCHBUFFER +I915_PARAM_LAST_DISPATCH +I915_PARAM_CHIPSET_ID +I915_PARAM_HAS_GEM +I915_PARAM_NUM_FENCES_AVAIL +I915_PARAM_HAS_OVERLAY +I915_PARAM_HAS_PAGEFLIPPING +I915_PARAM_HAS_EXECBUF2 +I915_PARAM_HAS_BSD +I915_PARAM_HAS_BLT +I915_PARAM_HAS_RELAXED_FENCING +I915_PARAM_HAS_COHERENT_RINGS +I915_PARAM_HAS_EXEC_CONSTANTS +I915_PARAM_HAS_RELAXED_DELTA +I915_PARAM_HAS_GEN7_SOL_RESET +I915_PARAM_HAS_LLC +I915_PARAM_HAS_ALIASING_PPGTT +I915_PARAM_HAS_WAIT_TIMEOUT +I915_PARAM_HAS_SEMAPHORES +I915_PARAM_HAS_PRIME_VMAP_FLUSH +I915_PARAM_HAS_VEBOX +I915_PARAM_HAS_SECURE_BATCHES +I915_PARAM_HAS_PINNED_BATCHES +I915_PARAM_HAS_EXEC_NO_RELOC +I915_PARAM_HAS_EXEC_HANDLE_LUT +I915_PARAM_HAS_WT +I915_PARAM_CMD_PARSER_VERSION
xlat/drm_i915_ioctls.in new file +51 -0
51 lines not on this page · raw message
xlat/drm_i915_setparams.in new file +4 -0
@@ -0,0 +1,4 @@ +I915_SETPARAM_USE_MI_BATCHBUFFER_START +I915_SETPARAM_TEX_LRU_LOG_GRANULARITY +I915_SETPARAM_ALLOW_BATCHBUFFER +I915_SETPARAM_NUM_USED_FENCES
Signature · 4 lines
2.1.4 ------------------------------------------------------------------------------
Re: [PATCH v2 4/5] drm: Add decoding of i915 ioctls
Quoted 162 lines · On Thu, 18 Jun 2015 10:42:44 +0200 Patrik Jakobsson…
There are more ioctls to add but the ones in this patch are most commonly used.
* Makefile.am: Add compilation of
drm_i915.c
*drm.c: Dispatch i915 ioctls
*drm_i915.c: DecodeDRM_IOCTL_I915_GETPARAM
*drm_i915.c: DecodeDRM_IOCTL_I915_SETPARAM
*drm_i915.c: DecodeDRM_IOCTL_I915_GEM_EXECBUFFER2
*drm_i915.c: DecodeDRM_IOCTL_I915_GEM_BUSY
*drm_i915.c: DecodeDRM_IOCTL_I915_GEM_CREATE
*drm_i915.c: DecodeDRM_IOCTL_I915_GEM_PREAD
*drm_i915.c: DecodeDRM_IOCTL_I915_GEM_PWRITE
*drm_i915.c: DecodeDRM_IOCTL_I915_GEM_MMAP
*drm_i915.c: DecodeDRM_IOCTL_I915_GEM_MMAP_GTT
*drm_i915.c: DecodeDRM_IOCTL_I915_SET_DOMAIN
*drm_i915.c: DecodeDRM_IOCTL_I915_MADVISE
*drm_i915.c: DecodeDRM_IOCTL_I915_GET_TILING
*drm_i915.c: DecodeDRM_IOCTL_I915_SET_TILING
*drm_i915.c: DecodeDRM_IOCTL_I915_USERPTR
* xlat/drm_i915_getparams.in: List GETPARAM parameters
* xlat/drm_i915_setparams.in: List SETPARAM parameters
* xlat/drm_i915_ioctls.in: List i915 ioctlsSigned-off-by Patrik Jakobsson <[email protected]>--- Makefile.am | 1 + drm.c | 14 ++ drm_i915.c | 332 +++++++++++++++++++++++++++++++++++++++++++++ xlat/drm_i915_getparams.in | 28 ++++ xlat/drm_i915_ioctls.in | 51 +++++++ xlat/drm_i915_setparams.in | 4 + 6 files changed, 430 insertions(+) create mode 100644 drm_i915.c create mode 100644 xlat/drm_i915_getparams.in create mode 100644 xlat/drm_i915_ioctls.in create mode 100644 xlat/drm_i915_setparams.inMakefile.am +1
-0@@ -42,6 +42,7 @@ strace_SOURCES = \ desc.c \ dirent.c \ drm.c \ + drm_i915.c \ evdev.c \ execve.c \ exit.c \drm.c +14
-0@@ -35,6 +35,9 @@#define DRM_MAX_NAME_LEN 128 +extern int drm_i915_decode_number (struct tcb *tcp,unsigned int arg); +extern int drm_i915_ioctl (struct tcb *tcp,const unsigned int code,long arg); +struct drm_ioctl_priv {char name[DRM_MAX_NAME_LEN ]; };@@ -93,11 +96,22 @@ int drm_is_driver(struct tcb *tcp, const char *name)int drm_decode_number (struct tcb *tcp,unsigned int arg) { +if (drm_is_priv (tcp->u_arg[1 ])) { +if (verbose (tcp) &&drm_is_driver (tcp,"i915" )) +return drm_i915_decode_number (tcp, arg); + } +return 0 ; }int drm_ioctl (struct tcb *tcp,const unsigned int code,long arg) { +/* Check for device specific ioctls */ +if (drm_is_priv (tcp->u_arg[1 ])) { +if (verbose (tcp) &&drm_is_driver (tcp,"i915" )) +return drm_i915_ioctl (tcp, code, arg); + } +/* Free any allocated private data */ if (exiting (tcp) && tcp->priv_data !=NULL ) {free (tcp->priv_data);drm_i915.c new file +70
-0@@ -0,0 +1,332 @@ +/* +* Copyright (c) 2015 Intel Corporation +* All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* 1. Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* 2. Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* 3. The name of the author may not be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* Authors: +* Patrik Jakobsson <[email protected]> +*/ + +#include "defs.h" + +#include <drm.h> +#include <i915_drm.h> +#include "xlat/drm_i915_ioctls.h" +#include "xlat/drm_i915_getparams.h" +#include "xlat/drm_i915_setparams.h" + +static int i915_getparam (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_i915_getparam param; +int value; + +if (umove (tcp, arg, ¶m)) +return 0 ; + +if (entering (tcp)) { +tprints (", {param=" ); +printxval (drm_i915_getparams, param.param,"I915_PARAM_???" ); + }else if (exiting (tcp)) { +if (umove (tcp, (long )param.value, &value)) +return 0 ; + +tprints (", value=" ); +switch (param.param) { +case I915_PARAM_CHIPSET_ID : +tprintf ("0x%04x" , value); +break ; +default : +tprintf ("%d" , value); + } +tprints ("}" ); + } + +return 1 ; +} + +static int i915_setparam (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_i915_setparam param;
drm_i915.c line 80
Quoted 10 lines
drm_i915.c new file +10
-0+ +if (umove (tcp, arg, ¶m)) +return 0 ; + +if (entering (tcp)) { +tprints (", {param=" ); +printxval (drm_i915_setparams, param.param,"I915_PARAM_???" ); + }else if (exiting (tcp)) { +tprintf (", value=%d}" , param.value); + }
Here, it seems that param.value can be printed on entering.
Quoted 353 lines
drm_i915.c new file +252
-0+ +return 1 ; +} + +static int i915_gem_execbuffer2 (struct tcb *tcp,const unsigned int code, +long arg) +{ +struct drm_i915_gem_execbuffer2 eb; + +if (umove (tcp, arg, &eb)) +return 0 ; + +if (entering (tcp)) { +tprintf (", {buffers_ptr=%p, buffer_count=%u, " +"batch_start_offset=%x, batch_len=%u, DR1=%u, DR4=%u, " +"num_cliprects=%u, cliprects_ptr=%p, flags=0x%Lx}" , + (void *)eb.buffers_ptr, eb.buffer_count, + eb.batch_start_offset, eb.batch_len, eb.DR1, eb.DR4, + eb.num_cliprects, (void *)eb.cliprects_ptr, eb.flags); + } + +return 1 ; +} + +static int i915_gem_busy (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_i915_gem_busy busy; + +if (umove (tcp, arg, &busy)) +return 0 ; + +if (entering (tcp)) { +tprintf (", {handle=%u" , busy.handle); + }else if (exiting (tcp)) { +tprintf (", busy=%c, ring=%u}" , + (busy.busy &0x1 ) ?'Y' :'N' , (busy.busy >>16 )); + } + +return 1 ; +} + +static int i915_gem_create (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_i915_gem_create create; + +if (umove (tcp, arg, &create)) +return 0 ; + +if (entering (tcp)) { +tprintf (", {size=%Lu" , create.size); + }else if (exiting (tcp)) { +tprintf (", handle=%u}" , create.handle); + } + +return 1 ; +} + +static int i915_gem_pread (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_i915_gem_pread pr; + +if (umove (tcp, arg, &pr)) +return 0 ; + +if (entering (tcp)) { +tprintf (", {handle=%u, offset=%Lu, size=%Lu, data_ptr=%p}" , + pr.handle, pr.offset, pr.size, (void *)pr.data_ptr); + } + +return 1 ; +} + +static int i915_gem_pwrite (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_i915_gem_pwrite pw; + +if (umove (tcp, arg, &pw)) +return 0 ; + +if (entering (tcp)) { +tprintf (", {handle=%u, offset=%Lu, size=%Lu, data_ptr=%p}" , + pw.handle, pw.offset, pw.size, (void *)pw.data_ptr); + } + +return 1 ; +} + +static int i915_gem_mmap (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_i915_gem_mmap mmap; + +if (umove (tcp, arg, &mmap)) +return 0 ; + +if (entering (tcp)) { +tprintf (", {handle=%u, size=%Lu" , mmap.handle, mmap.size); + }else if (exiting (tcp)) { +tprintf (", offset=%Lu, addr_ptr=%p}" , + mmap.offset, (void *)mmap.addr_ptr); + } + +return 1 ; +} + +static int i915_gem_mmap_gtt (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_i915_gem_mmap_gtt mmap; + +if (umove (tcp, arg, &mmap)) +return 0 ; + +if (entering (tcp)) { +tprintf (", {handle=%u" , mmap.handle); + }else if (exiting (tcp)) { +tprintf (", offset=%Lu}" , mmap.offset); + } + +return 1 ; +} + +static int i915_gem_set_domain (struct tcb *tcp,const unsigned int code, +long arg) +{ +struct drm_i915_gem_set_domain dom; + +if (umove (tcp, arg, &dom)) +return 0 ; + +if (entering (tcp)) { +tprintf (", {handle=%u, read_domains=%x, write_domain=%x}" , + dom.handle, dom.read_domains, dom.write_domain); + } + +return 1 ; +} + +static int i915_gem_madvise (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_i915_gem_madvise madv; + +if (umove (tcp, arg, &madv)) +return 0 ; + +if (entering (tcp)) { +tprintf (", {handle=%u, madv=%u" , madv.handle, madv.madv); + }else if (exiting (tcp)) { +tprintf (", retained=%u}" , madv.retained); + } + +return 1 ; +} + +static int i915_gem_get_tiling (struct tcb *tcp,const unsigned int code, +long arg) +{ +struct drm_i915_gem_get_tiling tiling; + +if (umove (tcp, arg, &tiling)) +return 0 ; + +if (entering (tcp)) { +tprintf (", {handle=%u" , tiling.handle); + }else if (exiting (tcp)) { +tprintf (", tiling_mode=%u, swizzle_mode=%u}" , tiling.tiling_mode, + tiling.swizzle_mode); + } + +return 1 ; +} + +static int i915_gem_set_tiling (struct tcb *tcp,const unsigned int code, +long arg) +{ +struct drm_i915_gem_set_tiling tiling; + +if (umove (tcp, arg, &tiling)) +return 0 ; + +if (entering (tcp)) { +tprintf (", {handle=%u, tiling_mode=%u, stride=%u" , + tiling.handle, tiling.tiling_mode, tiling.stride); + }else if (exiting (tcp)) { +tprintf (", swizzle_mode=%u}" , tiling.swizzle_mode); + } + +return 1 ; +} + +static int i915_gem_userptr (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_i915_gem_userptr uptr; + +if (umove (tcp, arg, &uptr)) +return 0 ; + +if (entering (tcp)) { +tprintf (", {user_ptr=%p, user_size=%Lu" , (void *)uptr.user_ptr, + uptr.user_size); + }else if (exiting (tcp)) { +tprintf (", flags=0x%x, handle=%u}" , uptr.flags, uptr.handle); + } + +return 1 ; +} + +int drm_i915_decode_number (struct tcb *tcp,unsigned int arg) +{ +const char *str =xlookup (drm_i915_ioctls, arg); + +if (str) { +tprintf ("%s" , str); +return 1 ; + } + +return 0 ; +} + +int drm_i915_ioctl (struct tcb *tcp,const unsigned int code,long arg) +{ +switch (code) { +case DRM_IOCTL_I915_GETPARAM : +return i915_getparam (tcp, code, arg); +case DRM_IOCTL_I915_SETPARAM : +return i915_setparam (tcp, code, arg); +case DRM_IOCTL_I915_GEM_EXECBUFFER2 : +return i915_gem_execbuffer2 (tcp, code, arg); +case DRM_IOCTL_I915_GEM_BUSY : +return i915_gem_busy (tcp, code, arg); +case DRM_IOCTL_I915_GEM_CREATE : +return i915_gem_create (tcp, code, arg); +case DRM_IOCTL_I915_GEM_PREAD : +return i915_gem_pread (tcp, code, arg); +case DRM_IOCTL_I915_GEM_PWRITE : +return i915_gem_pwrite (tcp, code, arg); +case DRM_IOCTL_I915_GEM_MMAP : +return i915_gem_mmap (tcp, code, arg); +case DRM_IOCTL_I915_GEM_MMAP_GTT : +return i915_gem_mmap_gtt (tcp, code, arg); +case DRM_IOCTL_I915_GEM_SET_DOMAIN : +return i915_gem_set_domain (tcp, code, arg); +case DRM_IOCTL_I915_GEM_MADVISE : +return i915_gem_madvise (tcp, code, arg); +case DRM_IOCTL_I915_GEM_GET_TILING : +return i915_gem_get_tiling (tcp, code, arg); +case DRM_IOCTL_I915_GEM_SET_TILING : +return i915_gem_set_tiling (tcp, code, arg); +case DRM_IOCTL_I915_GEM_USERPTR : +return i915_gem_userptr (tcp, code, arg); + } + +return 0 ; +}xlat/drm_i915_getparams.in new file +28
-0@@ -0,0 +1,28 @@ +I915_PARAM_IRQ_ACTIVE +I915_PARAM_ALLOW_BATCHBUFFER +I915_PARAM_LAST_DISPATCH +I915_PARAM_CHIPSET_ID +I915_PARAM_HAS_GEM +I915_PARAM_NUM_FENCES_AVAIL +I915_PARAM_HAS_OVERLAY +I915_PARAM_HAS_PAGEFLIPPING +I915_PARAM_HAS_EXECBUF2 +I915_PARAM_HAS_BSD +I915_PARAM_HAS_BLT +I915_PARAM_HAS_RELAXED_FENCING +I915_PARAM_HAS_COHERENT_RINGS +I915_PARAM_HAS_EXEC_CONSTANTS +I915_PARAM_HAS_RELAXED_DELTA +I915_PARAM_HAS_GEN7_SOL_RESET +I915_PARAM_HAS_LLC +I915_PARAM_HAS_ALIASING_PPGTT +I915_PARAM_HAS_WAIT_TIMEOUT +I915_PARAM_HAS_SEMAPHORES +I915_PARAM_HAS_PRIME_VMAP_FLUSH +I915_PARAM_HAS_VEBOX +I915_PARAM_HAS_SECURE_BATCHES +I915_PARAM_HAS_PINNED_BATCHES +I915_PARAM_HAS_EXEC_NO_RELOC +I915_PARAM_HAS_EXEC_HANDLE_LUT +I915_PARAM_HAS_WT +I915_PARAM_CMD_PARSER_VERSIONxlat/drm_i915_ioctls.in new file +51
-0@@ -0,0 +1,51 @@ +/* Unfortunately i915 collides with other DRM drivers so we must specify these */ +DRM_IOCTL_I915_INIT +DRM_IOCTL_I915_FLUSH +DRM_IOCTL_I915_FLIP +DRM_IOCTL_I915_BATCHBUFFER +DRM_IOCTL_I915_IRQ_EMIT +DRM_IOCTL_I915_IRQ_WAIT +DRM_IOCTL_I915_GETPARAM +DRM_IOCTL_I915_SETPARAM +DRM_IOCTL_I915_ALLOC +DRM_IOCTL_I915_FREE +DRM_IOCTL_I915_INIT_HEAP +DRM_IOCTL_I915_CMDBUFFER +DRM_IOCTL_I915_DESTROY_HEAP +DRM_IOCTL_I915_SET_VBLANK_PIPE +DRM_IOCTL_I915_GET_VBLANK_PIPE +DRM_IOCTL_I915_VBLANK_SWAP +DRM_IOCTL_I915_HWS_ADDR +DRM_IOCTL_I915_GEM_INIT +DRM_IOCTL_I915_GEM_EXECBUFFER +DRM_IOCTL_I915_GEM_EXECBUFFER2 +DRM_IOCTL_I915_GEM_PIN +DRM_IOCTL_I915_GEM_UNPIN +DRM_IOCTL_I915_GEM_BUSY +DRM_IOCTL_I915_GEM_SET_CACHING +DRM_IOCTL_I915_GEM_GET_CACHING +DRM_IOCTL_I915_GEM_THROTTLE +DRM_IOCTL_I915_GEM_ENTERVT +DRM_IOCTL_I915_GEM_LEAVEVT +DRM_IOCTL_I915_GEM_CREATE +DRM_IOCTL_I915_GEM_PREAD +DRM_IOCTL_I915_GEM_PWRITE +DRM_IOCTL_I915_GEM_MMAP +DRM_IOCTL_I915_GEM_MMAP_GTT +DRM_IOCTL_I915_GEM_SET_DOMAIN +DRM_IOCTL_I915_GEM_SW_FINISH +DRM_IOCTL_I915_GEM_SET_TILING +DRM_IOCTL_I915_GEM_GET_TILING +DRM_IOCTL_I915_GEM_GET_APERTURE +DRM_IOCTL_I915_GET_PIPE_FROM_CRTC_ID +DRM_IOCTL_I915_GEM_MADVISE +DRM_IOCTL_I915_OVERLAY_PUT_IMAGE +DRM_IOCTL_I915_OVERLAY_ATTRS +DRM_IOCTL_I915_SET_SPRITE_COLORKEY +DRM_IOCTL_I915_GET_SPRITE_COLORKEY +DRM_IOCTL_I915_GEM_WAIT +DRM_IOCTL_I915_GEM_CONTEXT_CREATE +DRM_IOCTL_I915_GEM_CONTEXT_DESTROY +DRM_IOCTL_I915_REG_READ +DRM_IOCTL_I915_GET_RESET_STATS +DRM_IOCTL_I915_GEM_USERPTRxlat/drm_i915_setparams.in new file +4
-0@@ -0,0 +1,4 @@ +I915_SETPARAM_USE_MI_BATCHBUFFER_START +I915_SETPARAM_TEX_LRU_LOG_GRANULARITY +I915_SETPARAM_ALLOW_BATCHBUFFER +I915_SETPARAM_NUM_USED_FENCES
Signature · 5 lines
Gabriel Laskar _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v2 4/5] drm: Add decoding of i915 ioctls
Quoted 169 lines · Gabriel Laskar
Quoted 166 lines · On Thu, 18 Jun 2015 10:42:44 +0200 Patrik Jakobsson…
There are more ioctls to add but the ones in this patch are most commonly used.
* Makefile.am: Add compilation of
drm_i915.c
*drm.c: Dispatch i915 ioctls
*drm_i915.c: DecodeDRM_IOCTL_I915_GETPARAM
*drm_i915.c: DecodeDRM_IOCTL_I915_SETPARAM
*drm_i915.c: DecodeDRM_IOCTL_I915_GEM_EXECBUFFER2
*drm_i915.c: DecodeDRM_IOCTL_I915_GEM_BUSY
*drm_i915.c: DecodeDRM_IOCTL_I915_GEM_CREATE
*drm_i915.c: DecodeDRM_IOCTL_I915_GEM_PREAD
*drm_i915.c: DecodeDRM_IOCTL_I915_GEM_PWRITE
*drm_i915.c: DecodeDRM_IOCTL_I915_GEM_MMAP
*drm_i915.c: DecodeDRM_IOCTL_I915_GEM_MMAP_GTT
*drm_i915.c: DecodeDRM_IOCTL_I915_SET_DOMAIN
*drm_i915.c: DecodeDRM_IOCTL_I915_MADVISE
*drm_i915.c: DecodeDRM_IOCTL_I915_GET_TILING
*drm_i915.c: DecodeDRM_IOCTL_I915_SET_TILING
*drm_i915.c: DecodeDRM_IOCTL_I915_USERPTR
* xlat/drm_i915_getparams.in: List GETPARAM parameters
* xlat/drm_i915_setparams.in: List SETPARAM parameters
* xlat/drm_i915_ioctls.in: List i915 ioctlsSigned-off-by Patrik Jakobsson <[email protected]>--- Makefile.am | 1 + drm.c | 14 ++ drm_i915.c | 332 +++++++++++++++++++++++++++++++++++++++++++++ xlat/drm_i915_getparams.in | 28 ++++ xlat/drm_i915_ioctls.in | 51 +++++++ xlat/drm_i915_setparams.in | 4 + 6 files changed, 430 insertions(+) create mode 100644 drm_i915.c create mode 100644 xlat/drm_i915_getparams.in create mode 100644 xlat/drm_i915_ioctls.in create mode 100644 xlat/drm_i915_setparams.inMakefile.am +1
-0@@ -42,6 +42,7 @@ strace_SOURCES = \ desc.c \ dirent.c \ drm.c \ + drm_i915.c \ evdev.c \ execve.c \ exit.c \drm.c +14
-0@@ -35,6 +35,9 @@#define DRM_MAX_NAME_LEN 128 +extern int drm_i915_decode_number (struct tcb *tcp,unsigned int arg); +extern int drm_i915_ioctl (struct tcb *tcp,const unsigned int code,long arg); +struct drm_ioctl_priv {char name[DRM_MAX_NAME_LEN ]; };@@ -93,11 +96,22 @@ int drm_is_driver(struct tcb *tcp, const char *name)int drm_decode_number (struct tcb *tcp,unsigned int arg) { +if (drm_is_priv (tcp->u_arg[1 ])) { +if (verbose (tcp) &&drm_is_driver (tcp,"i915" )) +return drm_i915_decode_number (tcp, arg); + } +return 0 ; }int drm_ioctl (struct tcb *tcp,const unsigned int code,long arg) { +/* Check for device specific ioctls */ +if (drm_is_priv (tcp->u_arg[1 ])) { +if (verbose (tcp) &&drm_is_driver (tcp,"i915" )) +return drm_i915_ioctl (tcp, code, arg); + } +/* Free any allocated private data */ if (exiting (tcp) && tcp->priv_data !=NULL ) {free (tcp->priv_data);drm_i915.c new file +74
-0@@ -0,0 +1,332 @@ +/* +* Copyright (c) 2015 Intel Corporation +* All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* 1. Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* 2. Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* 3. The name of the author may not be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +* Authors: +* Patrik Jakobsson <[email protected]> +*/ + +#include "defs.h" + +#include <drm.h> +#include <i915_drm.h> +#include "xlat/drm_i915_ioctls.h" +#include "xlat/drm_i915_getparams.h" +#include "xlat/drm_i915_setparams.h" + +static int i915_getparam (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_i915_getparam param; +int value; + +if (umove (tcp, arg, ¶m)) +return 0 ; + +if (entering (tcp)) { +tprints (", {param=" ); +printxval (drm_i915_getparams, param.param,"I915_PARAM_???" ); + }else if (exiting (tcp)) { +if (umove (tcp, (long )param.value, &value)) +return 0 ; + +tprints (", value=" ); +switch (param.param) { +case I915_PARAM_CHIPSET_ID : +tprintf ("0x%04x" , value); +break ; +default : +tprintf ("%d" , value); + } +tprints ("}" ); + } + +return 1 ; +} + +static int i915_setparam (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_i915_setparam param; + +if (umove (tcp, arg, ¶m)) +return 0 ; +
Quoted 9 lines
drm_i915.c line 80
Quoted 6 lines
drm_i915.c new file +6
-0+if (entering (tcp)) { +tprints (", {param=" ); +printxval (drm_i915_setparams, param.param,"I915_PARAM_???" ); + }else if (exiting (tcp)) { +tprintf (", value=%d}" , param.value); + }Here, it seems that param.value can be printed on entering.
Ah yes
Quoted 345 lines
Quoted 345 lines
drm_i915.c new file +252
-0+ +return 1 ; +} + +static int i915_gem_execbuffer2 (struct tcb *tcp,const unsigned int code, +long arg) +{ +struct drm_i915_gem_execbuffer2 eb; + +if (umove (tcp, arg, &eb)) +return 0 ; + +if (entering (tcp)) { +tprintf (", {buffers_ptr=%p, buffer_count=%u, " +"batch_start_offset=%x, batch_len=%u, DR1=%u, DR4=%u, " +"num_cliprects=%u, cliprects_ptr=%p, flags=0x%Lx}" , + (void *)eb.buffers_ptr, eb.buffer_count, + eb.batch_start_offset, eb.batch_len, eb.DR1, eb.DR4, + eb.num_cliprects, (void *)eb.cliprects_ptr, eb.flags); + } + +return 1 ; +} + +static int i915_gem_busy (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_i915_gem_busy busy; + +if (umove (tcp, arg, &busy)) +return 0 ; + +if (entering (tcp)) { +tprintf (", {handle=%u" , busy.handle); + }else if (exiting (tcp)) { +tprintf (", busy=%c, ring=%u}" , + (busy.busy &0x1 ) ?'Y' :'N' , (busy.busy >>16 )); + } + +return 1 ; +} + +static int i915_gem_create (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_i915_gem_create create; + +if (umove (tcp, arg, &create)) +return 0 ; + +if (entering (tcp)) { +tprintf (", {size=%Lu" , create.size); + }else if (exiting (tcp)) { +tprintf (", handle=%u}" , create.handle); + } + +return 1 ; +} + +static int i915_gem_pread (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_i915_gem_pread pr; + +if (umove (tcp, arg, &pr)) +return 0 ; + +if (entering (tcp)) { +tprintf (", {handle=%u, offset=%Lu, size=%Lu, data_ptr=%p}" , + pr.handle, pr.offset, pr.size, (void *)pr.data_ptr); + } + +return 1 ; +} + +static int i915_gem_pwrite (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_i915_gem_pwrite pw; + +if (umove (tcp, arg, &pw)) +return 0 ; + +if (entering (tcp)) { +tprintf (", {handle=%u, offset=%Lu, size=%Lu, data_ptr=%p}" , + pw.handle, pw.offset, pw.size, (void *)pw.data_ptr); + } + +return 1 ; +} + +static int i915_gem_mmap (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_i915_gem_mmap mmap; + +if (umove (tcp, arg, &mmap)) +return 0 ; + +if (entering (tcp)) { +tprintf (", {handle=%u, size=%Lu" , mmap.handle, mmap.size); + }else if (exiting (tcp)) { +tprintf (", offset=%Lu, addr_ptr=%p}" , + mmap.offset, (void *)mmap.addr_ptr); + } + +return 1 ; +} + +static int i915_gem_mmap_gtt (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_i915_gem_mmap_gtt mmap; + +if (umove (tcp, arg, &mmap)) +return 0 ; + +if (entering (tcp)) { +tprintf (", {handle=%u" , mmap.handle); + }else if (exiting (tcp)) { +tprintf (", offset=%Lu}" , mmap.offset); + } + +return 1 ; +} + +static int i915_gem_set_domain (struct tcb *tcp,const unsigned int code, +long arg) +{ +struct drm_i915_gem_set_domain dom; + +if (umove (tcp, arg, &dom)) +return 0 ; + +if (entering (tcp)) { +tprintf (", {handle=%u, read_domains=%x, write_domain=%x}" , + dom.handle, dom.read_domains, dom.write_domain); + } + +return 1 ; +} + +static int i915_gem_madvise (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_i915_gem_madvise madv; + +if (umove (tcp, arg, &madv)) +return 0 ; + +if (entering (tcp)) { +tprintf (", {handle=%u, madv=%u" , madv.handle, madv.madv); + }else if (exiting (tcp)) { +tprintf (", retained=%u}" , madv.retained); + } + +return 1 ; +} + +static int i915_gem_get_tiling (struct tcb *tcp,const unsigned int code, +long arg) +{ +struct drm_i915_gem_get_tiling tiling; + +if (umove (tcp, arg, &tiling)) +return 0 ; + +if (entering (tcp)) { +tprintf (", {handle=%u" , tiling.handle); + }else if (exiting (tcp)) { +tprintf (", tiling_mode=%u, swizzle_mode=%u}" , tiling.tiling_mode, + tiling.swizzle_mode); + } + +return 1 ; +} + +static int i915_gem_set_tiling (struct tcb *tcp,const unsigned int code, +long arg) +{ +struct drm_i915_gem_set_tiling tiling; + +if (umove (tcp, arg, &tiling)) +return 0 ; + +if (entering (tcp)) { +tprintf (", {handle=%u, tiling_mode=%u, stride=%u" , + tiling.handle, tiling.tiling_mode, tiling.stride); + }else if (exiting (tcp)) { +tprintf (", swizzle_mode=%u}" , tiling.swizzle_mode); + } + +return 1 ; +} + +static int i915_gem_userptr (struct tcb *tcp,const unsigned int code,long arg) +{ +struct drm_i915_gem_userptr uptr; + +if (umove (tcp, arg, &uptr)) +return 0 ; + +if (entering (tcp)) { +tprintf (", {user_ptr=%p, user_size=%Lu" , (void *)uptr.user_ptr, + uptr.user_size); + }else if (exiting (tcp)) { +tprintf (", flags=0x%x, handle=%u}" , uptr.flags, uptr.handle); + } + +return 1 ; +} + +int drm_i915_decode_number (struct tcb *tcp,unsigned int arg) +{ +const char *str =xlookup (drm_i915_ioctls, arg); + +if (str) { +tprintf ("%s" , str); +return 1 ; + } + +return 0 ; +} + +int drm_i915_ioctl (struct tcb *tcp,const unsigned int code,long arg) +{ +switch (code) { +case DRM_IOCTL_I915_GETPARAM : +return i915_getparam (tcp, code, arg); +case DRM_IOCTL_I915_SETPARAM : +return i915_setparam (tcp, code, arg); +case DRM_IOCTL_I915_GEM_EXECBUFFER2 : +return i915_gem_execbuffer2 (tcp, code, arg); +case DRM_IOCTL_I915_GEM_BUSY : +return i915_gem_busy (tcp, code, arg); +case DRM_IOCTL_I915_GEM_CREATE : +return i915_gem_create (tcp, code, arg); +case DRM_IOCTL_I915_GEM_PREAD : +return i915_gem_pread (tcp, code, arg); +case DRM_IOCTL_I915_GEM_PWRITE : +return i915_gem_pwrite (tcp, code, arg); +case DRM_IOCTL_I915_GEM_MMAP : +return i915_gem_mmap (tcp, code, arg); +case DRM_IOCTL_I915_GEM_MMAP_GTT : +return i915_gem_mmap_gtt (tcp, code, arg); +case DRM_IOCTL_I915_GEM_SET_DOMAIN : +return i915_gem_set_domain (tcp, code, arg); +case DRM_IOCTL_I915_GEM_MADVISE : +return i915_gem_madvise (tcp, code, arg); +case DRM_IOCTL_I915_GEM_GET_TILING : +return i915_gem_get_tiling (tcp, code, arg); +case DRM_IOCTL_I915_GEM_SET_TILING : +return i915_gem_set_tiling (tcp, code, arg); +case DRM_IOCTL_I915_GEM_USERPTR : +return i915_gem_userptr (tcp, code, arg); + } + +return 0 ; +}xlat/drm_i915_getparams.in new file +28
-0@@ -0,0 +1,28 @@ +I915_PARAM_IRQ_ACTIVE +I915_PARAM_ALLOW_BATCHBUFFER +I915_PARAM_LAST_DISPATCH +I915_PARAM_CHIPSET_ID +I915_PARAM_HAS_GEM +I915_PARAM_NUM_FENCES_AVAIL +I915_PARAM_HAS_OVERLAY +I915_PARAM_HAS_PAGEFLIPPING +I915_PARAM_HAS_EXECBUF2 +I915_PARAM_HAS_BSD +I915_PARAM_HAS_BLT +I915_PARAM_HAS_RELAXED_FENCING +I915_PARAM_HAS_COHERENT_RINGS +I915_PARAM_HAS_EXEC_CONSTANTS +I915_PARAM_HAS_RELAXED_DELTA +I915_PARAM_HAS_GEN7_SOL_RESET +I915_PARAM_HAS_LLC +I915_PARAM_HAS_ALIASING_PPGTT +I915_PARAM_HAS_WAIT_TIMEOUT +I915_PARAM_HAS_SEMAPHORES +I915_PARAM_HAS_PRIME_VMAP_FLUSH +I915_PARAM_HAS_VEBOX +I915_PARAM_HAS_SECURE_BATCHES +I915_PARAM_HAS_PINNED_BATCHES +I915_PARAM_HAS_EXEC_NO_RELOC +I915_PARAM_HAS_EXEC_HANDLE_LUT +I915_PARAM_HAS_WT +I915_PARAM_CMD_PARSER_VERSIONxlat/drm_i915_ioctls.in new file +51
-0@@ -0,0 +1,51 @@ +/* Unfortunately i915 collides with other DRM drivers so we must specify these */ +DRM_IOCTL_I915_INIT +DRM_IOCTL_I915_FLUSH +DRM_IOCTL_I915_FLIP +DRM_IOCTL_I915_BATCHBUFFER +DRM_IOCTL_I915_IRQ_EMIT +DRM_IOCTL_I915_IRQ_WAIT +DRM_IOCTL_I915_GETPARAM +DRM_IOCTL_I915_SETPARAM +DRM_IOCTL_I915_ALLOC +DRM_IOCTL_I915_FREE +DRM_IOCTL_I915_INIT_HEAP +DRM_IOCTL_I915_CMDBUFFER +DRM_IOCTL_I915_DESTROY_HEAP +DRM_IOCTL_I915_SET_VBLANK_PIPE +DRM_IOCTL_I915_GET_VBLANK_PIPE +DRM_IOCTL_I915_VBLANK_SWAP +DRM_IOCTL_I915_HWS_ADDR +DRM_IOCTL_I915_GEM_INIT +DRM_IOCTL_I915_GEM_EXECBUFFER +DRM_IOCTL_I915_GEM_EXECBUFFER2 +DRM_IOCTL_I915_GEM_PIN +DRM_IOCTL_I915_GEM_UNPIN +DRM_IOCTL_I915_GEM_BUSY +DRM_IOCTL_I915_GEM_SET_CACHING +DRM_IOCTL_I915_GEM_GET_CACHING +DRM_IOCTL_I915_GEM_THROTTLE +DRM_IOCTL_I915_GEM_ENTERVT +DRM_IOCTL_I915_GEM_LEAVEVT +DRM_IOCTL_I915_GEM_CREATE +DRM_IOCTL_I915_GEM_PREAD +DRM_IOCTL_I915_GEM_PWRITE +DRM_IOCTL_I915_GEM_MMAP +DRM_IOCTL_I915_GEM_MMAP_GTT +DRM_IOCTL_I915_GEM_SET_DOMAIN +DRM_IOCTL_I915_GEM_SW_FINISH +DRM_IOCTL_I915_GEM_SET_TILING +DRM_IOCTL_I915_GEM_GET_TILING +DRM_IOCTL_I915_GEM_GET_APERTURE +DRM_IOCTL_I915_GET_PIPE_FROM_CRTC_ID +DRM_IOCTL_I915_GEM_MADVISE +DRM_IOCTL_I915_OVERLAY_PUT_IMAGE +DRM_IOCTL_I915_OVERLAY_ATTRS +DRM_IOCTL_I915_SET_SPRITE_COLORKEY +DRM_IOCTL_I915_GET_SPRITE_COLORKEY +DRM_IOCTL_I915_GEM_WAIT +DRM_IOCTL_I915_GEM_CONTEXT_CREATE +DRM_IOCTL_I915_GEM_CONTEXT_DESTROY +DRM_IOCTL_I915_REG_READ +DRM_IOCTL_I915_GET_RESET_STATS +DRM_IOCTL_I915_GEM_USERPTRxlat/drm_i915_setparams.in new file +0
-0
Quoted 13 lines
Quoted 8 lines
index 0000000..d93d2ea
xlat/drm_i915_setparams.in new file +4
-0@@ -0,0 +1,4 @@ +I915_SETPARAM_USE_MI_BATCHBUFFER_START +I915_SETPARAM_TEX_LRU_LOG_GRANULARITY +I915_SETPARAM_ALLOW_BATCHBUFFER +I915_SETPARAM_NUM_USED_FENCESSignature · 1 line
Gabriel Laskar
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 6 lines · Patrik Jakobsson
This set of patches adds a dispatcher for handling DRM ioctls. The kernel headers for DRM might not be available on all distributions so we depend on libdrm for those. If libdrm is not available we fall back on the kernel headers. Since DRM drivers share the same range of private ioctl numbers I've added a function for detecting the driver based on it's name.
Anyone had a chance to look at this yet?
Thanks
Patrik
Quoted 18 lines
Changes in v2:
* Rebased to master
* Added Changelog to commits
* Keepstrace_SOURCESlist sorted
* Removed unneeded includes
* Reduced number of driver name checks by adding tcb private data
* Usetprints()for regular strings
* Reworkedentering()/exiting()handling for all ioctls
* Useprintstr()to print strings in properly quoted formPatrik Jakobsson (5):
drm: Add config for detecting libdrm
drm: Add private data field to trace control block
drm: Add dispatcher and driver identification for DRM
drm: Add decoding of i915 ioctls
drm: Add decoding of DRM and KMS ioctls
Quoted 24 lines
Makefile.am | 2 + configure.ac | 4 + defs.h | 11 +- drm.c | 632 +++++++++++++++++++++++++++++++++++++++++++++ drm_i915.c | 332 ++++++++++++++++++++++++ io.c | 2 +- ioctl.c | 6 +- xlat/drm_i915_getparams.in | 28 ++ xlat/drm_i915_ioctls.in | 51 ++++ xlat/drm_i915_setparams.in | 4 + 10 files changed, 1069 insertions(+), 3 deletions(-) create mode 100644 drm.c create mode 100644 drm_i915.c create mode 100644 xlat/drm_i915_getparams.in create mode 100644 xlat/drm_i915_ioctls.in create mode 100644 xlat/drm_i915_setparams.inSignature · 6 lines
2.1.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 9 lines · On Mon, 29 Jun 2015 12:47:20 +0200 Patrik Jakobsson…
Quoted 6 lines · Patrik Jakobsson
This set of patches adds a dispatcher for handling DRM ioctls. The kernel headers for DRM might not be available on all distributions so we depend on libdrm for those. If libdrm is not available we fall back on the kernel headers. Since DRM drivers share the same range of private ioctl numbers I've added a function for detecting the driver based on it's name.
Anyone had a chance to look at this yet?
Besides the 2 or 3 remarks inlined in the patches, this looks good to me.
Signature · 5 lines
Gabriel Laskar _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx