2005-01-05 22:34:37 +00:00
|
|
|
/*-
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
* Copyright (c) 1994 Christos Zoulas
|
|
|
|
* Copyright (c) 1995 Frank van der Linden
|
|
|
|
* Copyright (c) 1995 Scott Bartram
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. The name of the author may not be used to endorse or promote products
|
|
|
|
* derived from this software without specific prior written permission
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
* from: svr4_util.c,v 1.5 1995/01/22 23:44:50 christos Exp
|
|
|
|
*/
|
|
|
|
|
2003-06-10 21:29:12 +00:00
|
|
|
#include <sys/cdefs.h>
|
|
|
|
__FBSDID("$FreeBSD$");
|
|
|
|
|
Add the linux 2.6.x stuff (not used by default!):
- TLS - complete
- pid/tid mangling - complete
- thread area - complete
- futexes - complete with issues
- clone() extension - complete with some possible minor issues
- mq*/timer*/clock* stuff - complete but untested and the mq* stuff is
disabled when not build as part of the kernel with native FreeBSD mq*
support (module support for this will come later)
Tested with:
- linux-firefox - works, tested
- linux-opera - works, tested
- linux-realplay - doesnt work, issue with futexes
- linux-skype - doesnt work, issue with futexes
- linux-rt2-demo - works, tested
- linux-acroread - doesnt work, unknown reason (coredump) and sometimes
issue with futexes
- various unix utilities in linux-base-gentoo3 and linux-base-fc4:
everything tried worked
On amd64 not everything is supported like on i386, the catchup is planned for
later when the remaining bugs in the new functions are fixed.
To test this new stuff, you have to run
sysctl compat.linux.osrelease=2.6.16
to switch back use
sysctl compat.linux.osrelease=2.4.2
Don't switch while running a linux program, strange things may or may not
happen.
Sponsored by: Google SoC 2006
Submitted by: rdivacky
Some suggestions/help by: jhb, kib, manu@NetBSD.org, netchild
2006-08-15 12:54:30 +00:00
|
|
|
#include "opt_compat.h"
|
2012-05-05 19:42:38 +00:00
|
|
|
#include "opt_kdtrace.h"
|
Add the linux 2.6.x stuff (not used by default!):
- TLS - complete
- pid/tid mangling - complete
- thread area - complete
- futexes - complete with issues
- clone() extension - complete with some possible minor issues
- mq*/timer*/clock* stuff - complete but untested and the mq* stuff is
disabled when not build as part of the kernel with native FreeBSD mq*
support (module support for this will come later)
Tested with:
- linux-firefox - works, tested
- linux-opera - works, tested
- linux-realplay - doesnt work, issue with futexes
- linux-skype - doesnt work, issue with futexes
- linux-rt2-demo - works, tested
- linux-acroread - doesnt work, unknown reason (coredump) and sometimes
issue with futexes
- various unix utilities in linux-base-gentoo3 and linux-base-fc4:
everything tried worked
On amd64 not everything is supported like on i386, the catchup is planned for
later when the remaining bugs in the new functions are fixed.
To test this new stuff, you have to run
sysctl compat.linux.osrelease=2.6.16
to switch back use
sysctl compat.linux.osrelease=2.4.2
Don't switch while running a linux program, strange things may or may not
happen.
Sponsored by: Google SoC 2006
Submitted by: rdivacky
Some suggestions/help by: jhb, kib, manu@NetBSD.org, netchild
2006-08-15 12:54:30 +00:00
|
|
|
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
#include <sys/param.h>
|
2006-05-05 16:10:45 +00:00
|
|
|
#include <sys/bus.h>
|
2008-03-31 12:01:21 +00:00
|
|
|
#include <sys/fcntl.h>
|
2004-06-23 06:35:43 +00:00
|
|
|
#include <sys/lock.h>
|
|
|
|
#include <sys/malloc.h>
|
2012-05-05 19:42:38 +00:00
|
|
|
#include <sys/kernel.h>
|
2006-05-05 16:10:45 +00:00
|
|
|
#include <sys/linker_set.h>
|
2004-06-23 06:35:43 +00:00
|
|
|
#include <sys/mutex.h>
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
#include <sys/namei.h>
|
|
|
|
#include <sys/proc.h>
|
2012-05-05 19:42:38 +00:00
|
|
|
#include <sys/sdt.h>
|
2005-02-07 18:46:05 +00:00
|
|
|
#include <sys/syscallsubr.h>
|
2004-06-23 06:35:43 +00:00
|
|
|
#include <sys/systm.h>
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
#include <sys/vnode.h>
|
|
|
|
|
2003-01-02 02:19:10 +00:00
|
|
|
#include <machine/stdarg.h>
|
|
|
|
|
2000-08-22 01:51:54 +00:00
|
|
|
#include <compat/linux/linux_util.h>
|
Add the linux 2.6.x stuff (not used by default!):
- TLS - complete
- pid/tid mangling - complete
- thread area - complete
- futexes - complete with issues
- clone() extension - complete with some possible minor issues
- mq*/timer*/clock* stuff - complete but untested and the mq* stuff is
disabled when not build as part of the kernel with native FreeBSD mq*
support (module support for this will come later)
Tested with:
- linux-firefox - works, tested
- linux-opera - works, tested
- linux-realplay - doesnt work, issue with futexes
- linux-skype - doesnt work, issue with futexes
- linux-rt2-demo - works, tested
- linux-acroread - doesnt work, unknown reason (coredump) and sometimes
issue with futexes
- various unix utilities in linux-base-gentoo3 and linux-base-fc4:
everything tried worked
On amd64 not everything is supported like on i386, the catchup is planned for
later when the remaining bugs in the new functions are fixed.
To test this new stuff, you have to run
sysctl compat.linux.osrelease=2.6.16
to switch back use
sysctl compat.linux.osrelease=2.4.2
Don't switch while running a linux program, strange things may or may not
happen.
Sponsored by: Google SoC 2006
Submitted by: rdivacky
Some suggestions/help by: jhb, kib, manu@NetBSD.org, netchild
2006-08-15 12:54:30 +00:00
|
|
|
#ifdef COMPAT_LINUX32
|
|
|
|
#include <machine/../linux32/linux.h>
|
|
|
|
#else
|
|
|
|
#include <machine/../linux/linux.h>
|
|
|
|
#endif
|
1999-12-15 23:02:35 +00:00
|
|
|
|
2012-05-05 19:42:38 +00:00
|
|
|
#include <compat/linux/linux_dtrace.h>
|
|
|
|
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
const char linux_emul_path[] = "/compat/linux";
|
|
|
|
|
2012-05-05 19:42:38 +00:00
|
|
|
/* DTrace init */
|
|
|
|
LIN_SDT_PROVIDER_DECLARE(LINUX_DTRACE);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* DTrace probes in this module.
|
|
|
|
*/
|
|
|
|
LIN_SDT_PROBE_DEFINE5(util, linux_emul_convpath, entry, "const char *",
|
|
|
|
"enum uio_seg", "char **", "int", "int");
|
|
|
|
LIN_SDT_PROBE_DEFINE1(util, linux_emul_convpath, return, "int");
|
|
|
|
LIN_SDT_PROBE_DEFINE1(util, linux_msg, entry, "const char *");
|
|
|
|
LIN_SDT_PROBE_DEFINE0(util, linux_msg, return);
|
|
|
|
LIN_SDT_PROBE_DEFINE2(util, linux_driver_get_name_dev, entry, "device_t",
|
|
|
|
"const char *");
|
|
|
|
LIN_SDT_PROBE_DEFINE0(util, linux_driver_get_name_dev, nullcall);
|
|
|
|
LIN_SDT_PROBE_DEFINE1(util, linux_driver_get_name_dev, return, "char *");
|
|
|
|
LIN_SDT_PROBE_DEFINE3(util, linux_driver_get_major_minor, entry, "char *",
|
|
|
|
"int *", "int *");
|
|
|
|
LIN_SDT_PROBE_DEFINE0(util, linux_driver_get_major_minor, nullcall);
|
|
|
|
LIN_SDT_PROBE_DEFINE1(util, linux_driver_get_major_minor, notfound, "char *");
|
|
|
|
LIN_SDT_PROBE_DEFINE3(util, linux_driver_get_major_minor, return, "int",
|
|
|
|
"int", "int");
|
|
|
|
LIN_SDT_PROBE_DEFINE0(util, linux_get_char_devices, entry);
|
|
|
|
LIN_SDT_PROBE_DEFINE1(util, linux_get_char_devices, return, "char *");
|
|
|
|
LIN_SDT_PROBE_DEFINE1(util, linux_free_get_char_devices, entry, "char *");
|
|
|
|
LIN_SDT_PROBE_DEFINE0(util, linux_free_get_char_devices, return);
|
|
|
|
LIN_SDT_PROBE_DEFINE1(util, linux_device_register_handler, entry,
|
|
|
|
"struct linux_device_handler *");
|
|
|
|
LIN_SDT_PROBE_DEFINE1(util, linux_device_register_handler, return, "int");
|
|
|
|
LIN_SDT_PROBE_DEFINE1(util, linux_device_unregister_handler, entry,
|
|
|
|
"struct linux_device_handler *");
|
|
|
|
LIN_SDT_PROBE_DEFINE1(util, linux_device_unregister_handler, return, "int");
|
|
|
|
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
/*
|
2007-02-24 16:49:25 +00:00
|
|
|
* Search an alternate path before passing pathname arguments on to
|
|
|
|
* system calls. Useful for keeping a separate 'emulation tree'.
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
*
|
2007-02-24 16:49:25 +00:00
|
|
|
* If cflag is set, we check if an attempt can be made to create the
|
|
|
|
* named file, i.e. we check if the directory it should be in exists.
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
*/
|
2002-09-01 21:15:37 +00:00
|
|
|
int
|
2012-05-05 19:42:38 +00:00
|
|
|
linux_emul_convpath(struct thread *td, const char *path, enum uio_seg pathseg,
|
|
|
|
char **pbuf, int cflag, int dfd)
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
{
|
2012-05-05 19:42:38 +00:00
|
|
|
int retval;
|
|
|
|
|
|
|
|
LIN_SDT_PROBE5(util, linux_emul_convpath, entry, path, pathseg, pbuf,
|
|
|
|
cflag, dfd);
|
|
|
|
|
|
|
|
retval = kern_alternate_path(td, linux_emul_path, path, pathseg, pbuf,
|
|
|
|
cflag, dfd);
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
|
2012-05-05 19:42:38 +00:00
|
|
|
LIN_SDT_PROBE1(util, linux_emul_convpath, return, retval);
|
|
|
|
return (retval);
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
}
|
2003-01-02 02:19:10 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
linux_msg(const struct thread *td, const char *fmt, ...)
|
|
|
|
{
|
|
|
|
va_list ap;
|
|
|
|
struct proc *p;
|
|
|
|
|
2012-05-05 19:42:38 +00:00
|
|
|
LIN_SDT_PROBE1(util, linux_msg, entry, fmt);
|
|
|
|
|
2003-01-02 02:19:10 +00:00
|
|
|
p = td->td_proc;
|
|
|
|
printf("linux: pid %d (%s): ", (int)p->p_pid, p->p_comm);
|
|
|
|
va_start(ap, fmt);
|
|
|
|
vprintf(fmt, ap);
|
|
|
|
va_end(ap);
|
|
|
|
printf("\n");
|
2012-05-05 19:42:38 +00:00
|
|
|
|
|
|
|
LIN_SDT_PROBE0(util, linux_msg, return);
|
2003-01-02 02:19:10 +00:00
|
|
|
}
|
2006-05-05 16:10:45 +00:00
|
|
|
|
|
|
|
struct device_element
|
|
|
|
{
|
|
|
|
TAILQ_ENTRY(device_element) list;
|
|
|
|
struct linux_device_handler entry;
|
|
|
|
};
|
|
|
|
|
|
|
|
static TAILQ_HEAD(, device_element) devices =
|
|
|
|
TAILQ_HEAD_INITIALIZER(devices);
|
|
|
|
|
|
|
|
static struct linux_device_handler null_handler =
|
|
|
|
{ "mem", "mem", "null", "null", 1, 3, 1};
|
|
|
|
|
|
|
|
DATA_SET(linux_device_handler_set, null_handler);
|
|
|
|
|
|
|
|
char *
|
|
|
|
linux_driver_get_name_dev(device_t dev)
|
|
|
|
{
|
|
|
|
struct device_element *de;
|
|
|
|
const char *device_name = device_get_name(dev);
|
|
|
|
|
2012-05-05 19:42:38 +00:00
|
|
|
LIN_SDT_PROBE2(util, linux_driver_get_name_dev, entry, dev,
|
|
|
|
device_name);
|
|
|
|
|
|
|
|
if (device_name == NULL) {
|
|
|
|
LIN_SDT_PROBE0(util, linux_driver_get_name_dev, nullcall);
|
|
|
|
LIN_SDT_PROBE1(util, linux_driver_get_name_dev, return, NULL);
|
2006-05-05 16:10:45 +00:00
|
|
|
return NULL;
|
2012-05-05 19:42:38 +00:00
|
|
|
}
|
2006-05-05 16:10:45 +00:00
|
|
|
TAILQ_FOREACH(de, &devices, list) {
|
2012-05-05 19:42:38 +00:00
|
|
|
if (strcmp(device_name, de->entry.bsd_driver_name) == 0) {
|
|
|
|
LIN_SDT_PROBE1(util, linux_driver_get_name_dev, return,
|
|
|
|
de->entry.linux_driver_name);
|
2006-05-05 16:10:45 +00:00
|
|
|
return (de->entry.linux_driver_name);
|
2012-05-05 19:42:38 +00:00
|
|
|
}
|
2006-05-05 16:10:45 +00:00
|
|
|
}
|
|
|
|
|
2012-05-05 19:42:38 +00:00
|
|
|
LIN_SDT_PROBE1(util, linux_driver_get_name_dev, return, NULL);
|
2006-05-05 16:10:45 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2012-02-10 12:35:57 +00:00
|
|
|
linux_driver_get_major_minor(const char *node, int *major, int *minor)
|
2006-05-05 16:10:45 +00:00
|
|
|
{
|
|
|
|
struct device_element *de;
|
|
|
|
|
2012-05-05 19:42:38 +00:00
|
|
|
LIN_SDT_PROBE3(util, linux_driver_get_major_minor, entry, node, major,
|
|
|
|
minor);
|
|
|
|
|
|
|
|
if (node == NULL || major == NULL || minor == NULL) {
|
|
|
|
LIN_SDT_PROBE0(util, linux_driver_get_major_minor, nullcall);
|
|
|
|
LIN_SDT_PROBE3(util, linux_driver_get_major_minor, return, 1,
|
|
|
|
0, 0);
|
2006-05-05 16:10:45 +00:00
|
|
|
return 1;
|
2012-05-05 19:42:38 +00:00
|
|
|
}
|
2008-06-02 08:40:06 +00:00
|
|
|
|
|
|
|
if (strlen(node) > strlen("pts/") &&
|
|
|
|
strncmp(node, "pts/", strlen("pts/")) == 0) {
|
|
|
|
unsigned long devno;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Linux checks major and minors of the slave device
|
|
|
|
* to make sure it's a pty device, so let's make him
|
|
|
|
* believe it is.
|
|
|
|
*/
|
|
|
|
devno = strtoul(node + strlen("pts/"), NULL, 10);
|
|
|
|
*major = 136 + (devno / 256);
|
|
|
|
*minor = devno % 256;
|
2012-05-05 19:42:38 +00:00
|
|
|
|
|
|
|
LIN_SDT_PROBE3(util, linux_driver_get_major_minor, return, 0,
|
|
|
|
*major, *minor);
|
2008-06-02 08:40:06 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-05-05 16:10:45 +00:00
|
|
|
TAILQ_FOREACH(de, &devices, list) {
|
|
|
|
if (strcmp(node, de->entry.bsd_device_name) == 0) {
|
|
|
|
*major = de->entry.linux_major;
|
|
|
|
*minor = de->entry.linux_minor;
|
2012-05-05 19:42:38 +00:00
|
|
|
|
|
|
|
LIN_SDT_PROBE3(util, linux_driver_get_major_minor,
|
|
|
|
return, 0, *major, *minor);
|
2006-05-05 16:10:45 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-05 19:42:38 +00:00
|
|
|
LIN_SDT_PROBE1(util, linux_driver_get_major_minor, notfound, node);
|
|
|
|
LIN_SDT_PROBE3(util, linux_driver_get_major_minor, return, 1, 0, 0);
|
2006-05-05 16:10:45 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
char *
|
|
|
|
linux_get_char_devices()
|
|
|
|
{
|
|
|
|
struct device_element *de;
|
|
|
|
char *temp, *string, *last;
|
|
|
|
char formated[256];
|
|
|
|
int current_size = 0, string_size = 1024;
|
|
|
|
|
2012-05-05 19:42:38 +00:00
|
|
|
LIN_SDT_PROBE0(util, linux_get_char_devices, entry);
|
|
|
|
|
2008-10-23 15:53:51 +00:00
|
|
|
string = malloc(string_size, M_LINUX, M_WAITOK);
|
2006-05-05 16:10:45 +00:00
|
|
|
string[0] = '\000';
|
|
|
|
last = "";
|
|
|
|
TAILQ_FOREACH(de, &devices, list) {
|
|
|
|
if (!de->entry.linux_char_device)
|
|
|
|
continue;
|
|
|
|
temp = string;
|
|
|
|
if (strcmp(last, de->entry.bsd_driver_name) != 0) {
|
|
|
|
last = de->entry.bsd_driver_name;
|
|
|
|
|
|
|
|
snprintf(formated, sizeof(formated), "%3d %s\n",
|
|
|
|
de->entry.linux_major,
|
|
|
|
de->entry.linux_device_name);
|
|
|
|
if (strlen(formated) + current_size
|
|
|
|
>= string_size) {
|
|
|
|
string_size *= 2;
|
2008-10-23 15:53:51 +00:00
|
|
|
string = malloc(string_size,
|
2006-05-05 16:10:45 +00:00
|
|
|
M_LINUX, M_WAITOK);
|
|
|
|
bcopy(temp, string, current_size);
|
2008-10-23 15:53:51 +00:00
|
|
|
free(temp, M_LINUX);
|
2006-05-05 16:10:45 +00:00
|
|
|
}
|
|
|
|
strcat(string, formated);
|
|
|
|
current_size = strlen(string);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-05 19:42:38 +00:00
|
|
|
LIN_SDT_PROBE1(util, linux_get_char_devices, return, string);
|
2006-05-05 16:10:45 +00:00
|
|
|
return string;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
linux_free_get_char_devices(char *string)
|
|
|
|
{
|
2012-05-05 19:42:38 +00:00
|
|
|
|
|
|
|
LIN_SDT_PROBE1(util, linux_get_char_devices, entry, string);
|
|
|
|
|
2008-10-23 15:53:51 +00:00
|
|
|
free(string, M_LINUX);
|
2012-05-05 19:42:38 +00:00
|
|
|
|
|
|
|
LIN_SDT_PROBE0(util, linux_get_char_devices, return);
|
2006-05-05 16:10:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int linux_major_starting = 200;
|
|
|
|
|
|
|
|
int
|
|
|
|
linux_device_register_handler(struct linux_device_handler *d)
|
|
|
|
{
|
|
|
|
struct device_element *de;
|
|
|
|
|
2012-05-05 19:42:38 +00:00
|
|
|
LIN_SDT_PROBE1(util, linux_device_register_handler, entry, d);
|
|
|
|
|
|
|
|
if (d == NULL) {
|
|
|
|
LIN_SDT_PROBE1(util, linux_device_register_handler, return,
|
|
|
|
EINVAL);
|
2006-05-05 16:10:45 +00:00
|
|
|
return (EINVAL);
|
2012-05-05 19:42:38 +00:00
|
|
|
}
|
2006-05-05 16:10:45 +00:00
|
|
|
|
2012-05-05 19:42:38 +00:00
|
|
|
de = malloc(sizeof(*de), M_LINUX, M_WAITOK);
|
2006-05-05 16:10:45 +00:00
|
|
|
if (d->linux_major < 0) {
|
|
|
|
d->linux_major = linux_major_starting++;
|
|
|
|
}
|
|
|
|
bcopy(d, &de->entry, sizeof(*d));
|
|
|
|
|
|
|
|
/* Add the element to the list, sorted on span. */
|
|
|
|
TAILQ_INSERT_TAIL(&devices, de, list);
|
|
|
|
|
2012-05-05 19:42:38 +00:00
|
|
|
LIN_SDT_PROBE1(util, linux_device_register_handler, return, 0);
|
2006-05-05 16:10:45 +00:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
linux_device_unregister_handler(struct linux_device_handler *d)
|
|
|
|
{
|
|
|
|
struct device_element *de;
|
|
|
|
|
2012-05-05 19:42:38 +00:00
|
|
|
LIN_SDT_PROBE1(util, linux_device_unregister_handler, entry, d);
|
|
|
|
|
|
|
|
if (d == NULL) {
|
|
|
|
LIN_SDT_PROBE1(util, linux_device_unregister_handler, return,
|
|
|
|
EINVAL);
|
2006-05-05 16:10:45 +00:00
|
|
|
return (EINVAL);
|
2012-05-05 19:42:38 +00:00
|
|
|
}
|
2006-05-05 16:10:45 +00:00
|
|
|
|
|
|
|
TAILQ_FOREACH(de, &devices, list) {
|
|
|
|
if (bcmp(d, &de->entry, sizeof(*d)) == 0) {
|
|
|
|
TAILQ_REMOVE(&devices, de, list);
|
2008-10-23 15:53:51 +00:00
|
|
|
free(de, M_LINUX);
|
2012-05-05 19:42:38 +00:00
|
|
|
|
|
|
|
LIN_SDT_PROBE1(util, linux_device_unregister_handler,
|
|
|
|
return, 0);
|
2006-05-05 16:10:45 +00:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-05 19:42:38 +00:00
|
|
|
LIN_SDT_PROBE1(util, linux_device_unregister_handler, return, EINVAL);
|
2006-05-05 16:10:45 +00:00
|
|
|
return (EINVAL);
|
|
|
|
}
|