1 /* $Id: ia32_ioctl.c,v 1.25 2002/10/11 07:17:06 ak Exp $
2 * ioctl32.c: Conversion between 32bit and 64bit native ioctls.
4 * Copyright (C) 1997-2000 Jakub Jelinek (jakub@redhat.com)
5 * Copyright (C) 1998 Eddie C. Dost (ecd@skynet.be)
6 * Copyright (C) 2001,2002 Andi Kleen, SuSE Labs
8 * These routines maintain argument size conversion between 32bit and 64bit
13 #include "compat_ioctl.c"
17 extern asmlinkage long sys_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg);
20 #include "compat_ioctl.c"
23 #define TIOCGDEV _IOR('T',0x32, unsigned int)
25 static int tiocgdev(unsigned fd, unsigned cmd, unsigned int *ptr)
28 struct file *file = fget(fd);
29 struct tty_struct *real_tty;
33 if (file->f_op->ioctl != tty_ioctl)
35 real_tty = (struct tty_struct *)file->private_data;
38 return put_user(new_encode_dev(tty_devnum(real_tty)), ptr);
41 #define RTC_IRQP_READ32 _IOR('p', 0x0b, unsigned int) /* Read IRQ rate */
42 #define RTC_IRQP_SET32 _IOW('p', 0x0c, unsigned int) /* Set IRQ rate */
43 #define RTC_EPOCH_READ32 _IOR('p', 0x0d, unsigned) /* Read epoch */
44 #define RTC_EPOCH_SET32 _IOW('p', 0x0e, unsigned) /* Set epoch */
46 static int rtc32_ioctl(unsigned fd, unsigned cmd, unsigned long arg)
49 mm_segment_t oldfs = get_fs();
55 ret = sys_ioctl(fd, RTC_IRQP_READ, (unsigned long)&val);
58 ret = put_user(val, (unsigned int*) arg);
65 case RTC_EPOCH_READ32:
67 ret = sys_ioctl(fd, RTC_EPOCH_READ, (unsigned long) &val);
70 ret = put_user(val, (unsigned int*) arg);
77 return sys_ioctl(fd,cmd,arg);
80 /* /proc/mtrr ioctls */
85 compat_ulong_t base; /* Base address */
86 compat_uint_t size; /* Size of region */
87 compat_uint_t type; /* Type of region */
92 compat_ulong_t regnum; /* Register number */
93 compat_uint_t base; /* Base address */
94 compat_uint_t size; /* Size of region */
95 compat_uint_t type; /* Type of region */
98 #define MTRR_IOCTL_BASE 'M'
100 #define MTRRIOC32_ADD_ENTRY _IOW(MTRR_IOCTL_BASE, 0, struct mtrr_sentry32)
101 #define MTRRIOC32_SET_ENTRY _IOW(MTRR_IOCTL_BASE, 1, struct mtrr_sentry32)
102 #define MTRRIOC32_DEL_ENTRY _IOW(MTRR_IOCTL_BASE, 2, struct mtrr_sentry32)
103 #define MTRRIOC32_GET_ENTRY _IOWR(MTRR_IOCTL_BASE, 3, struct mtrr_gentry32)
104 #define MTRRIOC32_KILL_ENTRY _IOW(MTRR_IOCTL_BASE, 4, struct mtrr_sentry32)
105 #define MTRRIOC32_ADD_PAGE_ENTRY _IOW(MTRR_IOCTL_BASE, 5, struct mtrr_sentry32)
106 #define MTRRIOC32_SET_PAGE_ENTRY _IOW(MTRR_IOCTL_BASE, 6, struct mtrr_sentry32)
107 #define MTRRIOC32_DEL_PAGE_ENTRY _IOW(MTRR_IOCTL_BASE, 7, struct mtrr_sentry32)
108 #define MTRRIOC32_GET_PAGE_ENTRY _IOWR(MTRR_IOCTL_BASE, 8, struct mtrr_gentry32)
109 #define MTRRIOC32_KILL_PAGE_ENTRY _IOW(MTRR_IOCTL_BASE, 9, struct mtrr_sentry32)
112 static int mtrr_ioctl32(unsigned int fd, unsigned int cmd, unsigned long arg)
114 struct mtrr_gentry g;
115 struct mtrr_sentry s;
116 int get = 0, err = 0;
117 struct mtrr_gentry32 *g32 = (struct mtrr_gentry32 *)arg;
118 mm_segment_t oldfs = get_fs();
121 #define SET(x) case MTRRIOC32_ ## x ## _ENTRY: cmd = MTRRIOC_ ## x ## _ENTRY; break
122 #define GET(x) case MTRRIOC32_ ## x ## _ENTRY: cmd = MTRRIOC_ ## x ## _ENTRY; get=1; break
136 err = get_user(g.regnum, &g32->regnum);
137 err |= get_user(g.base, &g32->base);
138 err |= get_user(g.size, &g32->size);
139 err |= get_user(g.type, &g32->type);
141 arg = (unsigned long)&g;
143 struct mtrr_sentry32 *s32 = (struct mtrr_sentry32 *)arg;
144 err = get_user(s.base, &s32->base);
145 err |= get_user(s.size, &s32->size);
146 err |= get_user(s.type, &s32->type);
148 arg = (unsigned long)&s;
153 err = sys_ioctl(fd, cmd, arg);
157 err = put_user(g.base, &g32->base);
158 err |= put_user(g.size, &g32->size);
159 err |= put_user(g.regnum, &g32->regnum);
160 err |= put_user(g.type, &g32->type);
165 #define HANDLE_IOCTL(cmd,handler) { (cmd), (ioctl_trans_handler_t)(handler) },
166 #define COMPATIBLE_IOCTL(cmd) HANDLE_IOCTL(cmd,sys_ioctl)
168 struct ioctl_trans ioctl_start[] = {
169 #include <linux/compat_ioctl.h>
171 #include "compat_ioctl.c"
172 COMPATIBLE_IOCTL(HDIO_SET_KEEPSETTINGS)
173 COMPATIBLE_IOCTL(HDIO_SCAN_HWIF)
174 COMPATIBLE_IOCTL(BLKRASET)
175 COMPATIBLE_IOCTL(BLKFRASET)
176 COMPATIBLE_IOCTL(0x4B50) /* KDGHWCLK - not in the kernel, but don't complain */
177 COMPATIBLE_IOCTL(0x4B51) /* KDSHWCLK - not in the kernel, but don't complain */
178 #ifdef CONFIG_AUTOFS_FS
179 COMPATIBLE_IOCTL(AUTOFS_IOC_READY)
180 COMPATIBLE_IOCTL(AUTOFS_IOC_FAIL)
181 COMPATIBLE_IOCTL(AUTOFS_IOC_CATATONIC)
182 COMPATIBLE_IOCTL(AUTOFS_IOC_PROTOVER)
183 COMPATIBLE_IOCTL(AUTOFS_IOC_SETTIMEOUT)
184 COMPATIBLE_IOCTL(AUTOFS_IOC_EXPIRE)
185 COMPATIBLE_IOCTL(AUTOFS_IOC_EXPIRE_MULTI)
188 COMPATIBLE_IOCTL(RTC_AIE_ON)
189 COMPATIBLE_IOCTL(RTC_AIE_OFF)
190 COMPATIBLE_IOCTL(RTC_UIE_ON)
191 COMPATIBLE_IOCTL(RTC_UIE_OFF)
192 COMPATIBLE_IOCTL(RTC_PIE_ON)
193 COMPATIBLE_IOCTL(RTC_PIE_OFF)
194 COMPATIBLE_IOCTL(RTC_WIE_ON)
195 COMPATIBLE_IOCTL(RTC_WIE_OFF)
196 COMPATIBLE_IOCTL(RTC_ALM_SET)
197 COMPATIBLE_IOCTL(RTC_ALM_READ)
198 COMPATIBLE_IOCTL(RTC_RD_TIME)
199 COMPATIBLE_IOCTL(RTC_SET_TIME)
200 COMPATIBLE_IOCTL(RTC_WKALM_SET)
201 COMPATIBLE_IOCTL(RTC_WKALM_RD)
203 COMPATIBLE_IOCTL(HCIUARTSETPROTO)
204 COMPATIBLE_IOCTL(HCIUARTGETPROTO)
205 COMPATIBLE_IOCTL(RFCOMMCREATEDEV)
206 COMPATIBLE_IOCTL(RFCOMMRELEASEDEV)
207 COMPATIBLE_IOCTL(RFCOMMGETDEVLIST)
208 COMPATIBLE_IOCTL(RFCOMMGETDEVINFO)
209 COMPATIBLE_IOCTL(RFCOMMSTEALDLC)
210 COMPATIBLE_IOCTL(BNEPCONNADD)
211 COMPATIBLE_IOCTL(BNEPCONNDEL)
212 COMPATIBLE_IOCTL(BNEPGETCONNLIST)
213 COMPATIBLE_IOCTL(BNEPGETCONNINFO)
214 COMPATIBLE_IOCTL(FIOQSIZE)
216 /* And these ioctls need translation */
217 HANDLE_IOCTL(TIOCGDEV, tiocgdev)
218 /* realtime device */
219 HANDLE_IOCTL(RTC_IRQP_READ, rtc32_ioctl)
220 HANDLE_IOCTL(RTC_IRQP_READ32,rtc32_ioctl)
221 HANDLE_IOCTL(RTC_IRQP_SET32, rtc32_ioctl)
222 HANDLE_IOCTL(RTC_EPOCH_READ32, rtc32_ioctl)
223 HANDLE_IOCTL(RTC_EPOCH_SET32, rtc32_ioctl)
224 /* take care of sizeof(sizeof()) breakage */
226 HANDLE_IOCTL(MTRRIOC32_ADD_ENTRY, mtrr_ioctl32)
227 HANDLE_IOCTL(MTRRIOC32_SET_ENTRY, mtrr_ioctl32)
228 HANDLE_IOCTL(MTRRIOC32_DEL_ENTRY, mtrr_ioctl32)
229 HANDLE_IOCTL(MTRRIOC32_GET_ENTRY, mtrr_ioctl32)
230 HANDLE_IOCTL(MTRRIOC32_KILL_ENTRY, mtrr_ioctl32)
231 HANDLE_IOCTL(MTRRIOC32_ADD_PAGE_ENTRY, mtrr_ioctl32)
232 HANDLE_IOCTL(MTRRIOC32_SET_PAGE_ENTRY, mtrr_ioctl32)
233 HANDLE_IOCTL(MTRRIOC32_DEL_PAGE_ENTRY, mtrr_ioctl32)
234 HANDLE_IOCTL(MTRRIOC32_GET_PAGE_ENTRY, mtrr_ioctl32)
235 HANDLE_IOCTL(MTRRIOC32_KILL_PAGE_ENTRY, mtrr_ioctl32)
238 int ioctl_table_size = ARRAY_SIZE(ioctl_start);