Deleted Added
full compact
freebsd32_misc.c (113859) freebsd32_misc.c (114987)
1/*-
2 * Copyright (c) 2002 Doug Rabson
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 9 unchanged lines hidden (view full) ---

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
1/*-
2 * Copyright (c) 2002 Doug Rabson
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 9 unchanged lines hidden (view full) ---

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 * $FreeBSD: head/sys/compat/freebsd32/freebsd32_misc.c 113859 2003-04-22 18:23:49Z jhb $
26 * $FreeBSD: head/sys/compat/freebsd32/freebsd32_misc.c 114987 2003-05-14 04:10:49Z peter $
27 */
28
29#include "opt_compat.h"
30
31#include <sys/param.h>
32#include <sys/systm.h>
33#include <sys/bus.h>
34#include <sys/exec.h>

--- 34 unchanged lines hidden (view full) ---

69#include <vm/vm.h>
70#include <vm/vm_kern.h>
71#include <vm/vm_param.h>
72#include <vm/pmap.h>
73#include <vm/vm_map.h>
74#include <vm/vm_object.h>
75#include <vm/vm_extern.h>
76
27 */
28
29#include "opt_compat.h"
30
31#include <sys/param.h>
32#include <sys/systm.h>
33#include <sys/bus.h>
34#include <sys/exec.h>

--- 34 unchanged lines hidden (view full) ---

69#include <vm/vm.h>
70#include <vm/vm_kern.h>
71#include <vm/vm_param.h>
72#include <vm/pmap.h>
73#include <vm/vm_map.h>
74#include <vm/vm_object.h>
75#include <vm/vm_extern.h>
76
77#include <ia64/ia32/ia32_util.h>
78#include <ia64/ia32/ia32.h>
79#include <ia64/ia32/ia32_proto.h>
77#include <amd64/ia32/ia32_util.h>
78#include <amd64/ia32/ia32.h>
79#include <amd64/ia32/ia32_proto.h>
80
81static const char ia32_emul_path[] = "/compat/ia32";
82/*
83 * [ taken from the linux emulator ]
84 * Search an alternate path before passing pathname arguments on
85 * to system calls. Useful for keeping a separate 'emulation tree'.
86 *
87 * If cflag is set, we check if an attempt can be made to create

--- 346 unchanged lines hidden (view full) ---

434 return error;
435 *p++ = PTRIN(arg);
436 } while (arg != 0);
437 }
438
439 return execve(td, &ap);
440}
441
80
81static const char ia32_emul_path[] = "/compat/ia32";
82/*
83 * [ taken from the linux emulator ]
84 * Search an alternate path before passing pathname arguments on
85 * to system calls. Useful for keeping a separate 'emulation tree'.
86 *
87 * If cflag is set, we check if an attempt can be made to create

--- 346 unchanged lines hidden (view full) ---

434 return error;
435 *p++ = PTRIN(arg);
436 } while (arg != 0);
437 }
438
439 return execve(td, &ap);
440}
441
442#ifdef __ia64__
442static int
443ia32_mmap_partial(struct thread *td, vm_offset_t start, vm_offset_t end,
444 int prot, int fd, off_t pos)
445{
446 vm_map_t map;
447 vm_map_entry_t entry;
448 int rv;
449

--- 30 unchanged lines hidden (view full) ---

480 } else {
481 while (start < end) {
482 subyte((void *) start, 0);
483 start++;
484 }
485 return (0);
486 }
487}
443static int
444ia32_mmap_partial(struct thread *td, vm_offset_t start, vm_offset_t end,
445 int prot, int fd, off_t pos)
446{
447 vm_map_t map;
448 vm_map_entry_t entry;
449 int rv;
450

--- 30 unchanged lines hidden (view full) ---

481 } else {
482 while (start < end) {
483 subyte((void *) start, 0);
484 start++;
485 }
486 return (0);
487 }
488}
489#endif
488
489int
490ia32_mmap(struct thread *td, struct ia32_mmap_args *uap)
491{
492 struct mmap_args ap;
493 vm_offset_t addr = (vm_offset_t) uap->addr;
494 vm_size_t len = uap->len;
495 int prot = uap->prot;
496 int flags = uap->flags;
497 int fd = uap->fd;
498 off_t pos = (uap->poslo
499 | ((off_t)uap->poshi << 32));
490
491int
492ia32_mmap(struct thread *td, struct ia32_mmap_args *uap)
493{
494 struct mmap_args ap;
495 vm_offset_t addr = (vm_offset_t) uap->addr;
496 vm_size_t len = uap->len;
497 int prot = uap->prot;
498 int flags = uap->flags;
499 int fd = uap->fd;
500 off_t pos = (uap->poslo
501 | ((off_t)uap->poshi << 32));
502#ifdef __ia64__
500 vm_size_t pageoff;
501 int error;
502
503 /*
504 * Attempt to handle page size hassles.
505 */
506 pageoff = (pos & PAGE_MASK);
507 if (flags & MAP_FIXED) {

--- 54 unchanged lines hidden (view full) ---

562 * might be none left.
563 */
564 td->td_retval[0] = addr;
565 return (0);
566 }
567 addr = start;
568 len = end - start;
569 }
503 vm_size_t pageoff;
504 int error;
505
506 /*
507 * Attempt to handle page size hassles.
508 */
509 pageoff = (pos & PAGE_MASK);
510 if (flags & MAP_FIXED) {

--- 54 unchanged lines hidden (view full) ---

565 * might be none left.
566 */
567 td->td_retval[0] = addr;
568 return (0);
569 }
570 addr = start;
571 len = end - start;
572 }
573#endif
570
571 ap.addr = (void *) addr;
572 ap.len = len;
573 ap.prot = prot;
574 ap.flags = flags;
575 ap.fd = fd;
576 ap.pos = pos;
577

--- 70 unchanged lines hidden (view full) ---

648 return (error);
649 }
650 /*
651 * XXX big-endian needs to convert the fd_sets too.
652 */
653 return (select(td, (struct select_args *) uap));
654}
655
574
575 ap.addr = (void *) addr;
576 ap.len = len;
577 ap.prot = prot;
578 ap.flags = flags;
579 ap.fd = fd;
580 ap.pos = pos;
581

--- 70 unchanged lines hidden (view full) ---

652 return (error);
653 }
654 /*
655 * XXX big-endian needs to convert the fd_sets too.
656 */
657 return (select(td, (struct select_args *) uap));
658}
659
660struct kevent32 {
661 u_int32_t ident; /* identifier for this event */
662 short filter; /* filter for event */
663 u_short flags;
664 u_int fflags;
665 int32_t data;
666 u_int32_t udata; /* opaque user data identifier */
667};
668
656int
669int
670ia32_kevent(struct thread *td, struct ia32_kevent_args *uap)
671{
672 int error;
673 caddr_t sg;
674 struct timespec32 ts32;
675 struct timespec ts;
676 struct kevent32 ks32;
677 struct kevent *ks;
678 struct kevent_args a;
679 int i;
680
681 sg = stackgap_init();
682
683 a.fd = uap->fd;
684 a.changelist = uap->changelist;
685 a.nchanges = uap->nchanges;
686 a.eventlist = uap->eventlist;
687 a.nevents = uap->nevents;
688 a.timeout = NULL;
689
690 if (uap->timeout) {
691 a.timeout = stackgap_alloc(&sg, sizeof(struct timespec));
692 error = copyin(uap->timeout, &ts32, sizeof(ts32));
693 if (error)
694 return (error);
695 CP(ts32, ts, tv_sec);
696 CP(ts32, ts, tv_nsec);
697 error = copyout(&ts, (void *)(uintptr_t)a.timeout, sizeof(ts));
698 if (error)
699 return (error);
700 }
701 if (uap->changelist) {
702 a.changelist = (struct kevent *)stackgap_alloc(&sg, uap->nchanges * sizeof(struct kevent));
703 for (i = 0; i < uap->nchanges; i++) {
704 error = copyin(&uap->changelist[i], &ks32, sizeof(ks32));
705 if (error)
706 return (error);
707 ks = (struct kevent *)(uintptr_t)&a.changelist[i];
708 CP(ks32, *ks, ident);
709 CP(ks32, *ks, filter);
710 CP(ks32, *ks, flags);
711 CP(ks32, *ks, fflags);
712 CP(ks32, *ks, data);
713 PTRIN_CP(ks32, *ks, udata);
714 }
715 }
716 if (uap->eventlist) {
717 a.eventlist = stackgap_alloc(&sg, uap->nevents * sizeof(struct kevent));
718 }
719 error = kevent(td, &a);
720 if (uap->eventlist && error > 0) {
721 for (i = 0; i < error; i++) {
722 ks = &a.eventlist[i];
723 CP(*ks, ks32, ident);
724 CP(*ks, ks32, filter);
725 CP(*ks, ks32, flags);
726 CP(*ks, ks32, fflags);
727 CP(*ks, ks32, data);
728 PTROUT_CP(*ks, ks32, udata);
729 error = copyout(&ks32, &uap->eventlist[i], sizeof(ks32));
730 if (error)
731 return (error);
732 }
733 }
734 return error;
735}
736
737int
657ia32_gettimeofday(struct thread *td, struct ia32_gettimeofday_args *uap)
658{
659 int error;
660 caddr_t sg;
661 struct timeval32 *p32, s32;
662 struct timeval *p = NULL, s;
663
664 p32 = uap->tp;

--- 617 unchanged lines hidden (view full) ---

1282 s32.sa_u = PTROUT(osa.sa_handler);
1283 CP(osa, s32, sa_flags);
1284 CP(osa, s32, sa_mask);
1285 error = copyout(&s32, uap->oact, sizeof(s32));
1286 }
1287 return (error);
1288}
1289
738ia32_gettimeofday(struct thread *td, struct ia32_gettimeofday_args *uap)
739{
740 int error;
741 caddr_t sg;
742 struct timeval32 *p32, s32;
743 struct timeval *p = NULL, s;
744
745 p32 = uap->tp;

--- 617 unchanged lines hidden (view full) ---

1363 s32.sa_u = PTROUT(osa.sa_handler);
1364 CP(osa, s32, sa_flags);
1365 CP(osa, s32, sa_mask);
1366 error = copyout(&s32, uap->oact, sizeof(s32));
1367 }
1368 return (error);
1369}
1370
1371#ifdef COMPAT_FREEBSD4
1372int
1373freebsd4_ia32_sigaction(struct thread *td, struct freebsd4_ia32_sigaction_args *uap)
1374{
1375 struct sigaction32 s32;
1376 struct sigaction sa, osa, *sap;
1377 int error;
1378
1379 if (uap->act) {
1380 error = copyin(uap->act, &s32, sizeof(s32));
1381 if (error)
1382 return (error);
1383 sa.sa_handler = PTRIN(s32.sa_u);
1384 CP(s32, sa, sa_flags);
1385 CP(s32, sa, sa_mask);
1386 sap = &sa;
1387 } else
1388 sap = NULL;
1389 error = kern_sigaction(td, uap->sig, sap, &osa, KSA_FREEBSD4);
1390 if (error != 0 && uap->oact != NULL) {
1391 s32.sa_u = PTROUT(osa.sa_handler);
1392 CP(osa, s32, sa_flags);
1393 CP(osa, s32, sa_mask);
1394 error = copyout(&s32, uap->oact, sizeof(s32));
1395 }
1396 return (error);
1397}
1398#endif
1399
1290#if 0
1291
1292int
1293ia32_xxx(struct thread *td, struct ia32_xxx_args *uap)
1294{
1295 int error;
1296 caddr_t sg;
1297 struct yyy32 *p32, s32;

--- 29 unchanged lines hidden ---
1400#if 0
1401
1402int
1403ia32_xxx(struct thread *td, struct ia32_xxx_args *uap)
1404{
1405 int error;
1406 caddr_t sg;
1407 struct yyy32 *p32, s32;

--- 29 unchanged lines hidden ---