code: def ioctl(fd, request, argp):
      ret = libc.syscall(
          0x1D,
          ctypes.c_int(fd),
          ctypes.c_ulong(request),
          ctypes.c_void_p(argp),
      )
  
      idir, size, itype, nr = (
          (request >> 30),
          (request >> 16) & 0x3FFF,
          (request >> 8) & 0xFF,
          request & 0xFF,
      )
      if nr in nrs and itype == 9:
          name, stype = nrs[nr]
          s = get_struct(argp, stype)
          print(f"{ret:2d} = {name:40s}", " ".join(format_struct(s)))
          if name == "IOCTL_KGSL_GPUOBJ_INFO":
              mmaped[s.gpuaddr] = mmap.mmap(
                  fd, s.size, offset=s.id * 0x1000
              )
          if name == "IOCTL_KGSL_GPU_COMMAND":
              for i in range(s.numcmds):
                  cmd = get_struct(
                      s.cmdlist + s.cmdsize * i,
                      msm_kgsl.struct_kgsl_command_object,
                  )
                  print(f"cmd {i}:", format_struct(cmd))
                  # hexdump(get_mem(cmd.gpuaddr, cmd.size))
                  parse_cmd_buf(get_mem(cmd.gpuaddr, cmd.size))
              for i in range(s.numobjs):
                  obj = get_struct(
                      s.objlist + s.objsize * i,
                      msm_kgsl.struct_kgsl_command_object,
                  )
                  print(f"obj {i}:", format_struct(obj))
                  print(
                      format_struct(
                          msm_kgsl.struct_kgsl_cmdbatch_profiling_buffer.from_buffer_copy(
                              get_mem(obj.gpuaddr, obj.size)
                          )
                      )
                  )
                  # hexdump(get_mem(obj.gpuaddr, obj.size))
      else:
          # print(f"ioctl({fd=}, (dir:{idir}, size:0x{size:3X}, type:{itype:d}, nr:0x{nr:2X}), {argp=:X}) = {ret=}")
          pass
  
      return ret
  
file_path: tinygrad/extra/qcom_gpu_driver/opencl_ioctl.py
imports: import ctypes, ctypes.util, struct, fcntl, re
  from hexdump import hexdump
  from tinygrad.runtime.ops_gpu import CLDevice, CLAllocator
  import pathlib, sys
  import xml.etree.ElementTree
  from extra.qcom_gpu_driver import msm_kgsl
  import mmap
  from tinygrad import Tensor, Device, TinyJit
label_desc: Use image node_id 7 for calling a global function with example usage: ioctl(fd, request, argp) and returns: ret