summaryrefslogtreecommitdiffstats
path: root/sys/i386/linux/linux.h
diff options
context:
space:
mode:
authornetchild <netchild@FreeBSD.org>2006-08-15 12:54:30 +0000
committernetchild <netchild@FreeBSD.org>2006-08-15 12:54:30 +0000
commitec2ba5d85d7c127eef674f77e45cc0bea81d8850 (patch)
treeeefd61a061ceacbae59d210a958f6ea28f9d2b34 /sys/i386/linux/linux.h
parente8cb5b55782d998cb82d772021c355c69edfaf5e (diff)
downloadFreeBSD-src-ec2ba5d85d7c127eef674f77e45cc0bea81d8850.zip
FreeBSD-src-ec2ba5d85d7c127eef674f77e45cc0bea81d8850.tar.gz
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
Diffstat (limited to 'sys/i386/linux/linux.h')
-rw-r--r--sys/i386/linux/linux.h99
1 files changed, 99 insertions, 0 deletions
diff --git a/sys/i386/linux/linux.h b/sys/i386/linux/linux.h
index 08a76f3..4bbf303 100644
--- a/sys/i386/linux/linux.h
+++ b/sys/i386/linux/linux.h
@@ -32,6 +32,10 @@
#define _I386_LINUX_LINUX_H_
#include <sys/signal.h> /* for sigval union */
+#include <sys/param.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+#include <sys/sx.h>
#include <i386/linux/linux_syscall.h>
@@ -706,4 +710,99 @@ struct l_pollfd {
l_short revents;
};
+struct l_user_desc {
+ l_uint entry_number;
+ l_uint base_addr;
+ l_uint limit;
+ l_uint seg_32bit:1;
+ l_uint contents:2;
+ l_uint read_exec_only:1;
+ l_uint limit_in_pages:1;
+ l_uint seg_not_present:1;
+ l_uint useable:1;
+};
+
+struct l_desc_struct {
+ unsigned long a,b;
+};
+
+
+#define LINUX_LOWERWORD 0x0000ffff
+
+/* macros which does the same thing as those in linux include/asm-um/ldt-i386.h
+ * these convert linux user-space descriptor to machine one
+ */
+#define LDT_entry_a(info) \
+ ((((info)->base_addr & LINUX_LOWERWORD) << 16) | ((info)->limit & LINUX_LOWERWORD))
+
+#define ENTRY_B_READ_EXEC_ONLY 9
+#define ENTRY_B_CONTENTS 10
+#define ENTRY_B_SEG_NOT_PRESENT 15
+#define ENTRY_B_BASE_ADDR 16
+#define ENTRY_B_USEABLE 20
+#define ENTRY_B_SEG32BIT 22
+#define ENTRY_B_LIMIT 23
+
+#define LDT_entry_b(info) \
+ (((info)->base_addr & 0xff000000) | \
+ ((info)->limit & 0xf0000) | \
+ ((info)->contents << ENTRY_B_CONTENTS) | \
+ (((info)->seg_not_present == 0) << ENTRY_B_SEG_NOT_PRESENT) | \
+ (((info)->base_addr & 0x00ff0000) >> ENTRY_B_BASE_ADDR) | \
+ (((info)->read_exec_only == 0) << ENTRY_B_READ_EXEC_ONLY) | \
+ ((info)->seg_32bit << ENTRY_B_SEG32BIT) | \
+ ((info)->useable << ENTRY_B_USEABLE) | \
+ ((info)->limit_in_pages << ENTRY_B_LIMIT) | 0x7000)
+
+#define LDT_empty(info) (\
+ (info)->base_addr == 0 && \
+ (info)->limit == 0 && \
+ (info)->contents == 0 && \
+ (info)->seg_not_present == 1 && \
+ (info)->read_exec_only == 1 && \
+ (info)->seg_32bit == 0 && \
+ (info)->limit_in_pages == 0 && \
+ (info)->useable == 0 )
+
+/* macros for converting segments, they do the same as those in arch/i386/kernel/process.c */
+#define GET_BASE(desc) ( \
+ (((desc)->a >> 16) & LINUX_LOWERWORD) | \
+ (((desc)->b << 16) & 0x00ff0000) | \
+ ( (desc)->b & 0xff000000) )
+
+#define GET_LIMIT(desc) ( \
+ ((desc)->a & LINUX_LOWERWORD) | \
+ ((desc)->b & 0xf0000) )
+
+#define GET_32BIT(desc) (((desc)->b >> ENTRY_B_SEG32BIT) & 1)
+#define GET_CONTENTS(desc) (((desc)->b >> ENTRY_B_CONTENTS) & 3)
+#define GET_WRITABLE(desc) (((desc)->b >> ENTRY_B_READ_EXEC_ONLY) & 1)
+#define GET_LIMIT_PAGES(desc) (((desc)->b >> ENTRY_B_LIMIT) & 1)
+#define GET_PRESENT(desc) (((desc)->b >> ENTRY_B_SEG_NOT_PRESENT) & 1)
+#define GET_USEABLE(desc) (((desc)->b >> ENTRY_B_USEABLE) & 1)
+
+#define LINUX_CLOCK_REALTIME 0
+#define LINUX_CLOCK_MONOTONIC 1
+#define LINUX_CLOCK_PROCESS_CPUTIME_ID 2
+#define LINUX_CLOCK_THREAD_CPUTIME_ID 3
+#define LINUX_CLOCK_REALTIME_HR 4
+#define LINUX_CLOCK_MONOTONIC_HR 5
+
+typedef int l_timer_t;
+typedef int l_mqd_t;
+
+#define CLONE_VM 0x100
+#define CLONE_FS 0x200
+#define CLONE_FILES 0x400
+#define CLONE_SIGHAND 0x800
+#define CLONE_PID 0x1000 /* this flag does not exist in linux anymore */
+#define CLONE_PARENT 0x00008000
+#define CLONE_THREAD 0x10000
+#define CLONE_SETTLS 0x80000
+#define CLONE_CHILD_CLEARTID 0x00200000
+#define CLONE_CHILD_SETTID 0x01000000
+#define CLONE_PARENT_SETTID 0x00100000
+
+#define THREADING_FLAGS (CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND)
+
#endif /* !_I386_LINUX_LINUX_H_ */
OpenPOWER on IntegriCloud