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