PERFORCE change 100979 for review

Roman Divacky rdivacky at FreeBSD.org
Sat Jul 8 11:42:28 UTC 2006


http://perforce.freebsd.org/chv.cgi?CH=100979

Change 100979 by rdivacky at rdivacky_witten on 2006/07/08 11:41:48

	Implement get_thread_area() which I forgot when I was doing the TLS stuff. Its not
	necessary but its good to have it for being complete.

Affected files ...

.. //depot/projects/soc2006/rdivacky_linuxolator/i386/linux/linux.h#8 edit
.. //depot/projects/soc2006/rdivacky_linuxolator/i386/linux/linux_machdep.c#11 edit

Differences ...

==== //depot/projects/soc2006/rdivacky_linuxolator/i386/linux/linux.h#8 (text+ko) ====

@@ -721,6 +721,11 @@
 	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 
@@ -758,6 +763,23 @@
         (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)
+
 /* modeled after similar structure in NetBSD 
  * this will be extended as we need more functionality
  */

==== //depot/projects/soc2006/rdivacky_linuxolator/i386/linux/linux_machdep.c#11 (text+ko) ====

@@ -1032,6 +1032,48 @@
 }
 
 int
+linux_get_thread_area(struct thread *td, struct linux_get_thread_area_args *args)
+{
+   	
+	struct l_user_desc info;
+	int error;
+	int idx;
+	struct l_desc_struct desc;
+	struct segment_descriptor sd;
+
+	error = copyin(args->desc, &info, sizeof(struct l_user_desc));
+	if (error)
+		return (error);
+
+	idx = info.entry_number;
+	/* XXX: I am not sure if we want 3 to be allowed too. */
+	if (idx != 6 && idx != 3)
+		return (EINVAL);
+
+	memset(&info, 0, sizeof(info));
+
+	sd = PCPU_GET(fsgs_gdt)[1];
+
+	memcpy(&desc, &sd, sizeof(desc));
+
+	info.entry_number = idx;
+	info.base_addr = GET_BASE(&desc);
+	info.limit = GET_LIMIT(&desc);
+	info.seg_32bit = GET_32BIT(&desc);
+	info.contents = GET_CONTENTS(&desc);
+	info.read_exec_only = !GET_WRITABLE(&desc);
+	info.limit_in_pages = GET_LIMIT_PAGES(&desc);
+	info.seg_not_present = !GET_PRESENT(&desc);
+	info.useable = GET_USEABLE(&desc);
+
+	error = copyout(&info, args->desc, sizeof(struct l_user_desc));
+	if (error)
+	   	return (EFAULT);
+
+	return (0);
+}
+
+int
 linux_gettid(struct thread *td, struct linux_gettid_args *args)
 {
 


More information about the p4-projects mailing list