PERFORCE change 103770 for review
Roman Divacky
rdivacky at FreeBSD.org
Sun Aug 13 14:52:00 UTC 2006
http://perforce.freebsd.org/chv.cgi?CH=103770
Change 103770 by rdivacky at rdivacky_witten on 2006/08/13 14:51:27
o make amd64 compile
o add linux_emul.c and linux_futex.c to files.arch
o sync linux.h in amd64 with i386 version
o make FUTEX_WAKE_OP temporarily i386 only
Affected files ...
.. //depot/projects/soc2006/rdivacky_linuxolator/amd64/linux32/linux.h#2 edit
.. //depot/projects/soc2006/rdivacky_linuxolator/amd64/linux32/linux32_machdep.c#3 edit
.. //depot/projects/soc2006/rdivacky_linuxolator/compat/linux/linux_emul.c#2 edit
.. //depot/projects/soc2006/rdivacky_linuxolator/compat/linux/linux_futex.c#21 edit
.. //depot/projects/soc2006/rdivacky_linuxolator/compat/linux/linux_util.c#7 edit
.. //depot/projects/soc2006/rdivacky_linuxolator/conf/files.amd64#4 edit
.. //depot/projects/soc2006/rdivacky_linuxolator/conf/files.i386#4 edit
Differences ...
==== //depot/projects/soc2006/rdivacky_linuxolator/amd64/linux32/linux.h#2 (text+ko) ====
@@ -34,6 +34,10 @@
#define _AMD64_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 <amd64/linux32/linux32_syscall.h>
@@ -495,6 +499,7 @@
extern int bsd_to_linux_signal[];
extern int linux_to_bsd_signal[];
+extern struct sysentvec elf_linux_sysvec;
/*
* Pluggable ioctl handlers
@@ -527,6 +532,11 @@
#define LINUX_O_NDELAY LINUX_O_NONBLOCK
#define LINUX_O_SYNC 010000
#define LINUX_FASYNC 020000
+#define LINUX_O_DIRECT 040000 /* direct disk access hint */
+#define LINUX_O_LARGEFILE 0100000
+#define LINUX_O_DIRECTORY 0200000 /* must be a directory */
+#define LINUX_O_NOFOLLOW 0400000 /* don't follow links */
+#define LINUX_O_NOATIME 01000000
#define LINUX_F_DUPFD 0
#define LINUX_F_GETFD 1
@@ -737,4 +747,99 @@
l_short revents;
} __packed;
+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 */
+#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 /* !_AMD64_LINUX_LINUX_H_ */
==== //depot/projects/soc2006/rdivacky_linuxolator/amd64/linux32/linux32_machdep.c#3 (text+ko) ====
@@ -35,6 +35,7 @@
#include <sys/kernel.h>
#include <sys/systm.h>
#include <sys/imgact.h>
+#include <sys/limit.h>
#include <sys/lock.h>
#include <sys/malloc.h>
#include <sys/mman.h>
==== //depot/projects/soc2006/rdivacky_linuxolator/compat/linux/linux_emul.c#2 (text+ko) ====
@@ -26,6 +26,8 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include "opt_compat.h"
+
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/imgact.h>
==== //depot/projects/soc2006/rdivacky_linuxolator/compat/linux/linux_futex.c#21 (text+ko) ====
@@ -34,6 +34,8 @@
#include <sys/cdefs.h>
/* __KERNEL_RCSID(1, "$NetBSD: linux_futex.c,v 1.5 2005/11/23 16:14:57 manu Exp $"); */
+#include "opt_compat.h"
+
#include <sys/param.h>
#include <sys/types.h>
#include <sys/time.h>
@@ -83,7 +85,9 @@
static void futex_put(struct futex *);
static int futex_sleep(struct futex *, struct thread *, unsigned long);
static int futex_wake(struct futex *, int, struct futex *);
+#ifdef __i386__
static int futex_atomic_op(struct thread *td, int encoded_op, caddr_t uaddr);
+#endif
/* support.s */
int futex_xchgl(int oparg, caddr_t uaddr, int *oldval);
@@ -99,11 +103,14 @@
int ret;
struct l_timespec timeout = { 0, 0 };
int error = 0;
- struct futex *f, *f2;
+ struct futex *f;
struct futex *newf;
int timeout_hz;
struct timeval tv = {0, 0};
+#ifdef __i386__
+ struct futex *f2;
int op_ret;
+#endif
#ifdef DEBUG
if (ldebug(sys_futex))
@@ -256,6 +263,7 @@
break;
case LINUX_FUTEX_WAKE_OP:
+#ifdef __i386__
FUTEX_SYSTEM_LOCK;
#ifdef DEBUG
if (ldebug(sys_futex))
@@ -297,6 +305,9 @@
td->td_retval[0] = ret;
FUTEX_SYSTEM_UNLOCK;
+#else
+ printf("linux_sys_futex: wake_op not implemented");
+#endif
break;
default:
@@ -412,6 +423,7 @@
return count;
}
+#ifdef __i386__
static int
futex_atomic_op(struct thread *td, int encoded_op, caddr_t uaddr)
{
@@ -479,3 +491,4 @@
return (ret);
}
+#endif
==== //depot/projects/soc2006/rdivacky_linuxolator/compat/linux/linux_util.c#7 (text+ko) ====
@@ -32,6 +32,8 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: src/sys/compat/linux/linux_util.c,v 1.30 2006/05/05 16:10:45 ambrisko Exp $");
+#include "opt_compat.h"
+
#include <sys/param.h>
#include <sys/bus.h>
#include <sys/lock.h>
==== //depot/projects/soc2006/rdivacky_linuxolator/conf/files.amd64#4 (text+ko) ====
@@ -233,7 +233,9 @@
amd64/linux32/linux32_machdep.c optional compat_linux32
amd64/linux32/linux32_sysent.c optional compat_linux32
amd64/linux32/linux32_sysvec.c optional compat_linux32
+compat/linux/linux_emul.c optional compat_linux32
compat/linux/linux_file.c optional compat_linux32
+compat/linux/linux_futex.c optional compat_linux32
compat/linux/linux_getcwd.c optional compat_linux32
compat/linux/linux_ioctl.c optional compat_linux32
compat/linux/linux_ipc.c optional compat_linux32
==== //depot/projects/soc2006/rdivacky_linuxolator/conf/files.i386#4 (text+ko) ====
@@ -85,7 +85,9 @@
#
compat/linprocfs/linprocfs.c optional linprocfs
compat/linsysfs/linsysfs.c optional linsysfs
+compat/linux/linux_emul.c optional compat_linux
compat/linux/linux_file.c optional compat_linux
+compat/linux/linux_futex.c optional compat_linux
compat/linux/linux_getcwd.c optional compat_linux
compat/linux/linux_ioctl.c optional compat_linux
compat/linux/linux_ipc.c optional compat_linux
More information about the p4-projects
mailing list