ioctl32.c 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /* $Id: ioctl32.c,v 1.136 2002/01/14 09:49:52 davem Exp $
  2. * ioctl32.c: Conversion between 32bit and 64bit native ioctls.
  3. *
  4. * Copyright (C) 1997-2000 Jakub Jelinek (jakub@redhat.com)
  5. * Copyright (C) 1998 Eddie C. Dost (ecd@skynet.be)
  6. * Copyright (C) 2003 Pavel Machek (pavel@suse.cz)
  7. *
  8. * These routines maintain argument size conversion between 32bit and 64bit
  9. * ioctls.
  10. */
  11. #define INCLUDES
  12. #include "compat_ioctl.c"
  13. #include <linux/syscalls.h>
  14. #include <asm/fbio.h>
  15. /* Use this to get at 32-bit user passed pointers.
  16. * See sys_sparc32.c for description about it.
  17. */
  18. #define A(__x) compat_ptr(__x)
  19. #define CODE
  20. #include "compat_ioctl.c"
  21. struct fbcmap32 {
  22. int index; /* first element (0 origin) */
  23. int count;
  24. u32 red;
  25. u32 green;
  26. u32 blue;
  27. };
  28. #define FBIOPUTCMAP32 _IOW('F', 3, struct fbcmap32)
  29. #define FBIOGETCMAP32 _IOW('F', 4, struct fbcmap32)
  30. static int fbiogetputcmap(unsigned int fd, unsigned int cmd, unsigned long arg)
  31. {
  32. struct fbcmap32 __user *argp = (void __user *)arg;
  33. struct fbcmap __user *p = compat_alloc_user_space(sizeof(*p));
  34. u32 addr;
  35. int ret;
  36. ret = copy_in_user(p, argp, 2 * sizeof(int));
  37. ret |= get_user(addr, &argp->red);
  38. ret |= put_user(compat_ptr(addr), &p->red);
  39. ret |= get_user(addr, &argp->green);
  40. ret |= put_user(compat_ptr(addr), &p->green);
  41. ret |= get_user(addr, &argp->blue);
  42. ret |= put_user(compat_ptr(addr), &p->blue);
  43. if (ret)
  44. return -EFAULT;
  45. return sys_ioctl(fd, (cmd == FBIOPUTCMAP32) ? FBIOPUTCMAP_SPARC : FBIOGETCMAP_SPARC, (unsigned long)p);
  46. }
  47. struct fbcursor32 {
  48. short set; /* what to set, choose from the list above */
  49. short enable; /* cursor on/off */
  50. struct fbcurpos pos; /* cursor position */
  51. struct fbcurpos hot; /* cursor hot spot */
  52. struct fbcmap32 cmap; /* color map info */
  53. struct fbcurpos size; /* cursor bit map size */
  54. u32 image; /* cursor image bits */
  55. u32 mask; /* cursor mask bits */
  56. };
  57. #define FBIOSCURSOR32 _IOW('F', 24, struct fbcursor32)
  58. #define FBIOGCURSOR32 _IOW('F', 25, struct fbcursor32)
  59. static int fbiogscursor(unsigned int fd, unsigned int cmd, unsigned long arg)
  60. {
  61. struct fbcursor __user *p = compat_alloc_user_space(sizeof(*p));
  62. struct fbcursor32 __user *argp = (void __user *)arg;
  63. compat_uptr_t addr;
  64. int ret;
  65. ret = copy_in_user(p, argp,
  66. 2 * sizeof (short) + 2 * sizeof(struct fbcurpos));
  67. ret |= copy_in_user(&p->size, &argp->size, sizeof(struct fbcurpos));
  68. ret |= copy_in_user(&p->cmap, &argp->cmap, 2 * sizeof(int));
  69. ret |= get_user(addr, &argp->cmap.red);
  70. ret |= put_user(compat_ptr(addr), &p->cmap.red);
  71. ret |= get_user(addr, &argp->cmap.green);
  72. ret |= put_user(compat_ptr(addr), &p->cmap.green);
  73. ret |= get_user(addr, &argp->cmap.blue);
  74. ret |= put_user(compat_ptr(addr), &p->cmap.blue);
  75. ret |= get_user(addr, &argp->mask);
  76. ret |= put_user(compat_ptr(addr), &p->mask);
  77. ret |= get_user(addr, &argp->image);
  78. ret |= put_user(compat_ptr(addr), &p->image);
  79. if (ret)
  80. return -EFAULT;
  81. return sys_ioctl (fd, FBIOSCURSOR, (unsigned long)p);
  82. }
  83. #define COMPATIBLE_IOCTL(cmd) HANDLE_IOCTL((cmd),sys_ioctl)
  84. #define HANDLE_IOCTL(cmd,handler) { (cmd), (ioctl_trans_handler_t)(handler), NULL },
  85. #define IOCTL_TABLE_START \
  86. struct ioctl_trans ioctl_start[] = {
  87. #define IOCTL_TABLE_END \
  88. };
  89. IOCTL_TABLE_START
  90. #include <linux/compat_ioctl.h>
  91. #define DECLARES
  92. #include "compat_ioctl.c"
  93. COMPATIBLE_IOCTL(FBIOGTYPE)
  94. COMPATIBLE_IOCTL(FBIOSATTR)
  95. COMPATIBLE_IOCTL(FBIOGATTR)
  96. COMPATIBLE_IOCTL(FBIOSVIDEO)
  97. COMPATIBLE_IOCTL(FBIOGVIDEO)
  98. COMPATIBLE_IOCTL(FBIOGCURSOR32) /* This is not implemented yet. Later it should be converted... */
  99. COMPATIBLE_IOCTL(FBIOSCURPOS)
  100. COMPATIBLE_IOCTL(FBIOGCURPOS)
  101. COMPATIBLE_IOCTL(FBIOGCURMAX)
  102. /* Little k */
  103. /* Little v, the video4linux ioctls */
  104. COMPATIBLE_IOCTL(_IOR('p', 20, int[7])) /* RTCGET */
  105. COMPATIBLE_IOCTL(_IOW('p', 21, int[7])) /* RTCSET */
  106. /* And these ioctls need translation */
  107. /* Note SIOCRTMSG is no longer, so this is safe and * the user would have seen just an -EINVAL anyways. */
  108. HANDLE_IOCTL(FBIOPUTCMAP32, fbiogetputcmap)
  109. HANDLE_IOCTL(FBIOGETCMAP32, fbiogetputcmap)
  110. HANDLE_IOCTL(FBIOSCURSOR32, fbiogscursor)
  111. #if 0
  112. HANDLE_IOCTL(RTC32_IRQP_READ, do_rtc_ioctl)
  113. HANDLE_IOCTL(RTC32_IRQP_SET, do_rtc_ioctl)
  114. HANDLE_IOCTL(RTC32_EPOCH_READ, do_rtc_ioctl)
  115. HANDLE_IOCTL(RTC32_EPOCH_SET, do_rtc_ioctl)
  116. #endif
  117. /* take care of sizeof(sizeof()) breakage */
  118. IOCTL_TABLE_END
  119. int ioctl_table_size = ARRAY_SIZE(ioctl_start);