1 /* $Id: misc.c,v 1.36 2002/02/09 19:49:31 davem Exp $
2 * misc.c: Miscellaneous syscall emulation for Solaris
4 * Copyright (C) 1997,1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
7 #include <linux/module.h>
8 #include <linux/types.h>
9 #include <linux/smp_lock.h>
10 #include <linux/utsname.h>
11 #include <linux/limits.h>
13 #include <linux/smp.h>
14 #include <linux/tty.h>
15 #include <linux/mman.h>
16 #include <linux/file.h>
17 #include <linux/timex.h>
18 #include <linux/major.h>
19 #include <linux/compat.h>
21 #include <asm/uaccess.h>
22 #include <asm/string.h>
23 #include <asm/oplib.h>
24 #include <asm/idprom.h>
30 /* Conversion from Linux to Solaris errnos. 0-34 are identity mapped.
31 Some Linux errnos (EPROCLIM, EDOTDOT, ERREMOTE, EUCLEAN, ENOTNAM,
32 ENAVAIL, EISNAM, EREMOTEIO, ENOMEDIUM, EMEDIUMTYPE) have no Solaris
33 equivalents. I return EINVAL in that case, which is very wrong. If
34 someone suggest a better value for them, you're welcomed.
35 On the other side, Solaris ECANCELED and ENOTSUP have no Linux equivalents,
36 but that doesn't matter here. --jj */
37 int solaris_err_table[] = {
38 /* 0 */ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
39 /* 10 */ 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
40 /* 20 */ 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
41 /* 30 */ 30, 31, 32, 33, 34, 22, 150, 149, 95, 96,
42 /* 40 */ 97, 98, 99, 120, 121, 122, 123, 124, 125, 126,
43 /* 50 */ 127, 128, 129, 130, 131, 132, 133, 134, 143, 144,
44 /* 60 */ 145, 146, 90, 78, 147, 148, 93, 22, 94, 49,
45 /* 70 */ 151, 66, 60, 62, 63, 35, 77, 36, 45, 46,
46 /* 80 */ 64, 22, 67, 68, 69, 70, 71, 74, 22, 82,
47 /* 90 */ 89, 92, 79, 81, 37, 38, 39, 40, 41, 42,
48 /* 100 */ 43, 44, 50, 51, 52, 53, 54, 55, 56, 57,
49 /* 110 */ 87, 61, 84, 65, 83, 80, 91, 22, 22, 22,
50 /* 120 */ 22, 22, 88, 86, 85, 22, 22,
53 #define SOLARIS_NR_OPEN 256
55 static u32 do_solaris_mmap(u32 addr, u32 len, u32 prot, u32 flags, u32 fd, u64 off)
57 struct file *file = NULL;
58 unsigned long retval, ret_type;
60 /* Do we need it here? */
61 set_personality(PER_SVR4);
62 if (flags & MAP_NORESERVE) {
66 printk("%s: unimplemented Solaris MAP_NORESERVE mmap() flag\n",
70 flags &= ~MAP_NORESERVE;
73 if(!(flags & MAP_ANONYMOUS)) {
74 if(fd >= SOLARIS_NR_OPEN)
80 struct inode * inode = file->f_path.dentry->d_inode;
81 if(imajor(inode) == MEM_MAJOR &&
83 flags |= MAP_ANONYMOUS;
91 len = PAGE_ALIGN(len);
92 if(!(flags & MAP_FIXED))
94 else if (len > STACK_TOP32 || addr > STACK_TOP32 - len)
96 ret_type = flags & _MAP_NEW;
99 down_write(¤t->mm->mmap_sem);
100 flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
101 retval = do_mmap(file,
102 (unsigned long) addr, (unsigned long) len,
103 (unsigned long) prot, (unsigned long) flags, off);
104 up_write(¤t->mm->mmap_sem);
106 retval = ((retval < STACK_TOP32) ? 0 : retval);
115 asmlinkage u32 solaris_mmap(u32 addr, u32 len, u32 prot, u32 flags, u32 fd, u32 off)
117 return do_solaris_mmap(addr, len, prot, flags, fd, (u64) off);
120 asmlinkage u32 solaris_mmap64(struct pt_regs *regs, u32 len, u32 prot, u32 flags, u32 fd, u32 offhi)
124 if (regs->u_regs[UREG_G1]) {
125 if (get_user (offlo, (u32 __user *)(long)((u32)regs->u_regs[UREG_I6] + 0x5c)))
128 if (get_user (offlo, (u32 __user *)(long)((u32)regs->u_regs[UREG_I6] + 0x60)))
131 return do_solaris_mmap((u32)regs->u_regs[UREG_I0], len, prot, flags, fd, (((u64)offhi)<<32)|offlo);
134 asmlinkage int solaris_brk(u32 brk)
136 int (*sunos_brk)(u32) = (int (*)(u32))SUNOS(17);
138 return sunos_brk(brk);
141 static int __set_utsfield(char __user *to, int to_size,
142 const char *from, int from_size,
143 int dotchop, int countfrom)
145 int len = countfrom ? (to_size > from_size ?
146 from_size : to_size) : to_size;
149 if (copy_to_user(to, from, len))
152 off = len < to_size? len: len - 1;
154 const char *p = strnchr(from, len, '.');
155 if (p) off = p - from;
158 if (__put_user('\0', to + off))
164 #define set_utsfield(to, from, dotchop, countfrom) \
165 __set_utsfield((to), sizeof(to), \
166 (from), sizeof(from), \
167 (dotchop), (countfrom))
185 static char *machine(void)
187 switch (sparc_cpu_model) {
188 case sun4: return "sun4";
189 case sun4c: return "sun4c";
190 case sun4e: return "sun4e";
191 case sun4m: return "sun4m";
192 case sun4d: return "sun4d";
193 case sun4u: return "sun4u";
194 default: return "sparc";
198 static char *platform(char *buffer, int sz)
200 struct device_node *dp = of_find_node_by_path("/");
204 len = strlen(dp->name);
207 memcpy(buffer, dp->name, len);
212 for (p = buffer; *p; p++)
213 if (*p == '/' || *p == ' ') *p = '_';
220 static char *serial(char *buffer, int sz)
222 struct device_node *dp = of_find_node_by_path("/options");
228 of_get_property(dp, "system-board-serial#", &len);
230 if (val && len > 0) {
233 memcpy(buffer, val, len);
238 return "4512348717234";
243 asmlinkage int solaris_utssys(u32 buf, u32 flags, int which, u32 buf2)
245 struct sol_uname __user *v = A(buf);
249 case 0: /* old uname */
251 err = set_utsfield(v->sysname, "SunOS", 1, 0);
253 err |= set_utsfield(v->nodename, utsname()->nodename,
256 err |= set_utsfield(v->release, "2.6", 0, 0);
257 err |= set_utsfield(v->version, "Generic", 0, 0);
258 err |= set_utsfield(v->machine, machine(), 0, 0);
259 return (err ? -EFAULT : 0);
269 asmlinkage int solaris_utsname(u32 buf)
271 struct sol_utsname __user *v = A(buf);
274 /* Why should we not lie a bit? */
276 err = set_utsfield(v->sysname, "SunOS", 0, 0);
277 err |= set_utsfield(v->nodename, utsname()->nodename, 1, 1);
278 err |= set_utsfield(v->release, "5.6", 0, 0);
279 err |= set_utsfield(v->version, "Generic", 0, 0);
280 err |= set_utsfield(v->machine, machine(), 0, 0);
283 return (err ? -EFAULT : 0);
286 #define SI_SYSNAME 1 /* return name of operating system */
287 #define SI_HOSTNAME 2 /* return name of node */
288 #define SI_RELEASE 3 /* return release of operating system */
289 #define SI_VERSION 4 /* return version field of utsname */
290 #define SI_MACHINE 5 /* return kind of machine */
291 #define SI_ARCHITECTURE 6 /* return instruction set arch */
292 #define SI_HW_SERIAL 7 /* return hardware serial number */
293 #define SI_HW_PROVIDER 8 /* return hardware manufacturer */
294 #define SI_SRPC_DOMAIN 9 /* return secure RPC domain */
295 #define SI_PLATFORM 513 /* return platform identifier */
297 asmlinkage int solaris_sysinfo(int cmd, u32 buf, s32 count)
303 /* Again, we cheat :)) */
305 case SI_SYSNAME: r = "SunOS"; break;
309 for (p = utsname()->nodename, q = buffer;
310 q < r && *p && *p != '.'; *q++ = *p++);
315 case SI_RELEASE: r = "5.6"; break;
316 case SI_MACHINE: r = machine(); break;
317 case SI_ARCHITECTURE: r = "sparc"; break;
318 case SI_HW_PROVIDER: r = "Sun_Microsystems"; break;
319 case SI_HW_SERIAL: r = serial(buffer, sizeof(buffer)); break;
320 case SI_PLATFORM: r = platform(buffer, sizeof(buffer)); break;
321 case SI_SRPC_DOMAIN: r = ""; break;
322 case SI_VERSION: r = "Generic"; break;
323 default: return -EINVAL;
327 if (copy_to_user(A(buf), r, count - 1) ||
328 __put_user(0, (char __user *)A(buf) + count - 1))
331 if (copy_to_user(A(buf), r, len))
337 #define SOLARIS_CONFIG_NGROUPS 2
338 #define SOLARIS_CONFIG_CHILD_MAX 3
339 #define SOLARIS_CONFIG_OPEN_FILES 4
340 #define SOLARIS_CONFIG_POSIX_VER 5
341 #define SOLARIS_CONFIG_PAGESIZE 6
342 #define SOLARIS_CONFIG_CLK_TCK 7
343 #define SOLARIS_CONFIG_XOPEN_VER 8
344 #define SOLARIS_CONFIG_PROF_TCK 10
345 #define SOLARIS_CONFIG_NPROC_CONF 11
346 #define SOLARIS_CONFIG_NPROC_ONLN 12
347 #define SOLARIS_CONFIG_AIO_LISTIO_MAX 13
348 #define SOLARIS_CONFIG_AIO_MAX 14
349 #define SOLARIS_CONFIG_AIO_PRIO_DELTA_MAX 15
350 #define SOLARIS_CONFIG_DELAYTIMER_MAX 16
351 #define SOLARIS_CONFIG_MQ_OPEN_MAX 17
352 #define SOLARIS_CONFIG_MQ_PRIO_MAX 18
353 #define SOLARIS_CONFIG_RTSIG_MAX 19
354 #define SOLARIS_CONFIG_SEM_NSEMS_MAX 20
355 #define SOLARIS_CONFIG_SEM_VALUE_MAX 21
356 #define SOLARIS_CONFIG_SIGQUEUE_MAX 22
357 #define SOLARIS_CONFIG_SIGRT_MIN 23
358 #define SOLARIS_CONFIG_SIGRT_MAX 24
359 #define SOLARIS_CONFIG_TIMER_MAX 25
360 #define SOLARIS_CONFIG_PHYS_PAGES 26
361 #define SOLARIS_CONFIG_AVPHYS_PAGES 27
363 asmlinkage int solaris_sysconf(int id)
366 case SOLARIS_CONFIG_NGROUPS: return NGROUPS_MAX;
367 case SOLARIS_CONFIG_CHILD_MAX:
368 return current->signal->rlim[RLIMIT_NPROC].rlim_cur;
369 case SOLARIS_CONFIG_OPEN_FILES:
370 return current->signal->rlim[RLIMIT_NOFILE].rlim_cur;
371 case SOLARIS_CONFIG_POSIX_VER: return 199309;
372 case SOLARIS_CONFIG_PAGESIZE: return PAGE_SIZE;
373 case SOLARIS_CONFIG_XOPEN_VER: return 3;
374 case SOLARIS_CONFIG_CLK_TCK:
375 case SOLARIS_CONFIG_PROF_TCK:
376 return sparc64_get_clock_tick(smp_processor_id());
378 case SOLARIS_CONFIG_NPROC_CONF: return NR_CPUS;
379 case SOLARIS_CONFIG_NPROC_ONLN: return num_online_cpus();
381 case SOLARIS_CONFIG_NPROC_CONF: return 1;
382 case SOLARIS_CONFIG_NPROC_ONLN: return 1;
384 case SOLARIS_CONFIG_SIGRT_MIN: return 37;
385 case SOLARIS_CONFIG_SIGRT_MAX: return 44;
386 case SOLARIS_CONFIG_PHYS_PAGES:
387 case SOLARIS_CONFIG_AVPHYS_PAGES:
392 if (id == SOLARIS_CONFIG_PHYS_PAGES)
393 return s.totalram >>= PAGE_SHIFT;
395 return s.freeram >>= PAGE_SHIFT;
397 /* XXX support these as well -jj */
398 case SOLARIS_CONFIG_AIO_LISTIO_MAX: return -EINVAL;
399 case SOLARIS_CONFIG_AIO_MAX: return -EINVAL;
400 case SOLARIS_CONFIG_AIO_PRIO_DELTA_MAX: return -EINVAL;
401 case SOLARIS_CONFIG_DELAYTIMER_MAX: return -EINVAL;
402 case SOLARIS_CONFIG_MQ_OPEN_MAX: return -EINVAL;
403 case SOLARIS_CONFIG_MQ_PRIO_MAX: return -EINVAL;
404 case SOLARIS_CONFIG_RTSIG_MAX: return -EINVAL;
405 case SOLARIS_CONFIG_SEM_NSEMS_MAX: return -EINVAL;
406 case SOLARIS_CONFIG_SEM_VALUE_MAX: return -EINVAL;
407 case SOLARIS_CONFIG_SIGQUEUE_MAX: return -EINVAL;
408 case SOLARIS_CONFIG_TIMER_MAX: return -EINVAL;
409 default: return -EINVAL;
413 asmlinkage int solaris_procids(int cmd, s32 pid, s32 pgid)
418 case 0: /* getpgrp */
419 return process_group(current);
420 case 1: /* setpgrp */
422 int (*sys_setpgid)(pid_t,pid_t) =
423 (int (*)(pid_t,pid_t))SYS(setpgid);
425 /* can anyone explain me the difference between
426 Solaris setpgrp and setsid? */
427 ret = sys_setpgid(0, 0);
429 proc_clear_tty(current);
430 return process_group(current);
434 int (*sys_getsid)(pid_t) = (int (*)(pid_t))SYS(getsid);
435 return sys_getsid(pid);
439 int (*sys_setsid)(void) = (int (*)(void))SYS(setsid);
442 case 4: /* getpgid */
444 int (*sys_getpgid)(pid_t) = (int (*)(pid_t))SYS(getpgid);
445 return sys_getpgid(pid);
447 case 5: /* setpgid */
449 int (*sys_setpgid)(pid_t,pid_t) =
450 (int (*)(pid_t,pid_t))SYS(setpgid);
451 return sys_setpgid(pid,pgid);
457 asmlinkage int solaris_gettimeofday(u32 tim)
459 int (*sys_gettimeofday)(struct timeval *, struct timezone *) =
460 (int (*)(struct timeval *, struct timezone *))SYS(gettimeofday);
462 return sys_gettimeofday((struct timeval *)(u64)tim, NULL);
465 #define RLIM_SOL_INFINITY32 0x7fffffff
466 #define RLIM_SOL_SAVED_MAX32 0x7ffffffe
467 #define RLIM_SOL_SAVED_CUR32 0x7ffffffd
468 #define RLIM_SOL_INFINITY ((u64)-3)
469 #define RLIM_SOL_SAVED_MAX ((u64)-2)
470 #define RLIM_SOL_SAVED_CUR ((u64)-1)
471 #define RESOURCE32(x) ((x > RLIM_INFINITY32) ? RLIM_INFINITY32 : x)
472 #define RLIMIT_SOL_NOFILE 5
473 #define RLIMIT_SOL_VMEM 6
480 asmlinkage int solaris_getrlimit(unsigned int resource, struct rlimit32 __user *rlim)
484 mm_segment_t old_fs = get_fs ();
485 int (*sys_getrlimit)(unsigned int, struct rlimit *) =
486 (int (*)(unsigned int, struct rlimit *))SYS(getrlimit);
488 if (resource > RLIMIT_SOL_VMEM)
491 case RLIMIT_SOL_NOFILE: resource = RLIMIT_NOFILE; break;
492 case RLIMIT_SOL_VMEM: resource = RLIMIT_AS; break;
496 ret = sys_getrlimit(resource, &r);
499 if (r.rlim_cur == RLIM_INFINITY)
500 r.rlim_cur = RLIM_SOL_INFINITY32;
501 else if ((u64)r.rlim_cur > RLIM_SOL_INFINITY32)
502 r.rlim_cur = RLIM_SOL_SAVED_CUR32;
503 if (r.rlim_max == RLIM_INFINITY)
504 r.rlim_max = RLIM_SOL_INFINITY32;
505 else if ((u64)r.rlim_max > RLIM_SOL_INFINITY32)
506 r.rlim_max = RLIM_SOL_SAVED_MAX32;
507 ret = put_user (r.rlim_cur, &rlim->rlim_cur);
508 ret |= __put_user (r.rlim_max, &rlim->rlim_max);
513 asmlinkage int solaris_setrlimit(unsigned int resource, struct rlimit32 __user *rlim)
515 struct rlimit r, rold;
517 mm_segment_t old_fs = get_fs ();
518 int (*sys_getrlimit)(unsigned int, struct rlimit __user *) =
519 (int (*)(unsigned int, struct rlimit __user *))SYS(getrlimit);
520 int (*sys_setrlimit)(unsigned int, struct rlimit __user *) =
521 (int (*)(unsigned int, struct rlimit __user *))SYS(setrlimit);
523 if (resource > RLIMIT_SOL_VMEM)
526 case RLIMIT_SOL_NOFILE: resource = RLIMIT_NOFILE; break;
527 case RLIMIT_SOL_VMEM: resource = RLIMIT_AS; break;
530 if (get_user (r.rlim_cur, &rlim->rlim_cur) ||
531 __get_user (r.rlim_max, &rlim->rlim_max))
534 ret = sys_getrlimit(resource, &rold);
536 if (r.rlim_cur == RLIM_SOL_INFINITY32)
537 r.rlim_cur = RLIM_INFINITY;
538 else if (r.rlim_cur == RLIM_SOL_SAVED_CUR32)
539 r.rlim_cur = rold.rlim_cur;
540 else if (r.rlim_cur == RLIM_SOL_SAVED_MAX32)
541 r.rlim_cur = rold.rlim_max;
542 if (r.rlim_max == RLIM_SOL_INFINITY32)
543 r.rlim_max = RLIM_INFINITY;
544 else if (r.rlim_max == RLIM_SOL_SAVED_CUR32)
545 r.rlim_max = rold.rlim_cur;
546 else if (r.rlim_max == RLIM_SOL_SAVED_MAX32)
547 r.rlim_max = rold.rlim_max;
548 ret = sys_setrlimit(resource, &r);
554 asmlinkage int solaris_getrlimit64(unsigned int resource, struct rlimit __user *rlim)
558 mm_segment_t old_fs = get_fs ();
559 int (*sys_getrlimit)(unsigned int, struct rlimit __user *) =
560 (int (*)(unsigned int, struct rlimit __user *))SYS(getrlimit);
562 if (resource > RLIMIT_SOL_VMEM)
565 case RLIMIT_SOL_NOFILE: resource = RLIMIT_NOFILE; break;
566 case RLIMIT_SOL_VMEM: resource = RLIMIT_AS; break;
570 ret = sys_getrlimit(resource, &r);
573 if (r.rlim_cur == RLIM_INFINITY)
574 r.rlim_cur = RLIM_SOL_INFINITY;
575 if (r.rlim_max == RLIM_INFINITY)
576 r.rlim_max = RLIM_SOL_INFINITY;
577 ret = put_user (r.rlim_cur, &rlim->rlim_cur);
578 ret |= __put_user (r.rlim_max, &rlim->rlim_max);
583 asmlinkage int solaris_setrlimit64(unsigned int resource, struct rlimit __user *rlim)
585 struct rlimit r, rold;
587 mm_segment_t old_fs = get_fs ();
588 int (*sys_getrlimit)(unsigned int, struct rlimit __user *) =
589 (int (*)(unsigned int, struct rlimit __user *))SYS(getrlimit);
590 int (*sys_setrlimit)(unsigned int, struct rlimit __user *) =
591 (int (*)(unsigned int, struct rlimit __user *))SYS(setrlimit);
593 if (resource > RLIMIT_SOL_VMEM)
596 case RLIMIT_SOL_NOFILE: resource = RLIMIT_NOFILE; break;
597 case RLIMIT_SOL_VMEM: resource = RLIMIT_AS; break;
600 if (get_user (r.rlim_cur, &rlim->rlim_cur) ||
601 __get_user (r.rlim_max, &rlim->rlim_max))
604 ret = sys_getrlimit(resource, &rold);
606 if (r.rlim_cur == RLIM_SOL_INFINITY)
607 r.rlim_cur = RLIM_INFINITY;
608 else if (r.rlim_cur == RLIM_SOL_SAVED_CUR)
609 r.rlim_cur = rold.rlim_cur;
610 else if (r.rlim_cur == RLIM_SOL_SAVED_MAX)
611 r.rlim_cur = rold.rlim_max;
612 if (r.rlim_max == RLIM_SOL_INFINITY)
613 r.rlim_max = RLIM_INFINITY;
614 else if (r.rlim_max == RLIM_SOL_SAVED_CUR)
615 r.rlim_max = rold.rlim_cur;
616 else if (r.rlim_max == RLIM_SOL_SAVED_MAX)
617 r.rlim_max = rold.rlim_max;
618 ret = sys_setrlimit(resource, &r);
624 struct sol_ntptimeval {
625 struct compat_timeval time;
650 asmlinkage int solaris_ntp_gettime(struct sol_ntptimeval __user *ntp)
652 int (*sys_adjtimex)(struct timex __user *) =
653 (int (*)(struct timex __user *))SYS(adjtimex);
656 mm_segment_t old_fs = get_fs();
660 ret = sys_adjtimex(&t);
664 ret = put_user (t.time.tv_sec, &ntp->time.tv_sec);
665 ret |= __put_user (t.time.tv_usec, &ntp->time.tv_usec);
666 ret |= __put_user (t.maxerror, &ntp->maxerror);
667 ret |= __put_user (t.esterror, &ntp->esterror);
671 asmlinkage int solaris_ntp_adjtime(struct sol_timex __user *txp)
673 int (*sys_adjtimex)(struct timex __user *) =
674 (int (*)(struct timex __user *))SYS(adjtimex);
677 mm_segment_t old_fs = get_fs();
679 ret = get_user (t.modes, &txp->modes);
680 ret |= __get_user (t.offset, &txp->offset);
681 ret |= __get_user (t.freq, &txp->freq);
682 ret |= __get_user (t.maxerror, &txp->maxerror);
683 ret |= __get_user (t.esterror, &txp->esterror);
684 ret |= __get_user (t.status, &txp->status);
685 ret |= __get_user (t.constant, &txp->constant);
687 ret = sys_adjtimex(&t);
691 err = put_user (t.offset, &txp->offset);
692 err |= __put_user (t.freq, &txp->freq);
693 err |= __put_user (t.maxerror, &txp->maxerror);
694 err |= __put_user (t.esterror, &txp->esterror);
695 err |= __put_user (t.status, &txp->status);
696 err |= __put_user (t.constant, &txp->constant);
697 err |= __put_user (t.precision, &txp->precision);
698 err |= __put_user (t.tolerance, &txp->tolerance);
699 err |= __put_user (t.ppsfreq, &txp->ppsfreq);
700 err |= __put_user (t.jitter, &txp->jitter);
701 err |= __put_user (t.shift, &txp->shift);
702 err |= __put_user (t.stabil, &txp->stabil);
703 err |= __put_user (t.jitcnt, &txp->jitcnt);
704 err |= __put_user (t.calcnt, &txp->calcnt);
705 err |= __put_user (t.errcnt, &txp->errcnt);
706 err |= __put_user (t.stbcnt, &txp->stbcnt);
712 asmlinkage int do_sol_unimplemented(struct pt_regs *regs)
714 printk ("Unimplemented Solaris syscall %d %08x %08x %08x %08x\n",
715 (int)regs->u_regs[UREG_G1],
716 (int)regs->u_regs[UREG_I0],
717 (int)regs->u_regs[UREG_I1],
718 (int)regs->u_regs[UREG_I2],
719 (int)regs->u_regs[UREG_I3]);
723 asmlinkage void solaris_register(void)
725 set_personality(PER_SVR4);
728 extern long solaris_to_linux_signals[], linux_to_solaris_signals[];
730 struct exec_domain solaris_exec_domain = {
733 .pers_low = 1, /* PER_SVR4 personality */
735 .signal_map = solaris_to_linux_signals,
736 .signal_invmap =linux_to_solaris_signals,
737 .module = THIS_MODULE,
741 extern int init_socksys(void);
743 MODULE_AUTHOR("Jakub Jelinek (jj@ultra.linux.cz), Patrik Rak (prak3264@ss1000.ms.mff.cuni.cz)");
744 MODULE_DESCRIPTION("Solaris binary emulation module");
745 MODULE_LICENSE("GPL");
747 extern u32 tl0_solaris[8];
748 #define update_ttable(x) \
749 tl0_solaris[3] = (((long)(x) - (long)tl0_solaris - 3) >> 2) | 0x40000000; \
751 __asm__ __volatile__ ("flush %0" : : "r" (&tl0_solaris[3]))
753 extern u32 solaris_sparc_syscall[];
754 extern u32 solaris_syscall[];
755 extern void cleanup_socksys(void);
757 extern u32 entry64_personality_patch;
759 static int __init solaris_init(void)
763 SOLDD(("Solaris module at %p\n", solaris_sparc_syscall));
764 register_exec_domain(&solaris_exec_domain);
765 if ((ret = init_socksys())) {
766 unregister_exec_domain(&solaris_exec_domain);
769 update_ttable(solaris_sparc_syscall);
770 entry64_personality_patch |=
771 (offsetof(struct task_struct, personality) +
772 (sizeof(unsigned long) - 1));
774 __asm__ __volatile__("flush %0"
775 : : "r" (&entry64_personality_patch));
779 static void __exit solaris_exit(void)
781 update_ttable(solaris_syscall);
783 unregister_exec_domain(&solaris_exec_domain);
786 module_init(solaris_init);
787 module_exit(solaris_exit);