From owner-p4-projects@FreeBSD.ORG Sat Jul 8 11:42:28 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 1311516A4DE; Sat, 8 Jul 2006 11:42:28 +0000 (UTC) X-Original-To: perforce@FreeBSD.org Delivered-To: perforce@FreeBSD.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B274E16A4DA for ; Sat, 8 Jul 2006 11:42:27 +0000 (UTC) (envelope-from rdivacky@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 775AF43D45 for ; Sat, 8 Jul 2006 11:42:27 +0000 (GMT) (envelope-from rdivacky@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.6/8.13.6) with ESMTP id k68BgRbV039023 for ; Sat, 8 Jul 2006 11:42:27 GMT (envelope-from rdivacky@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id k68BgROX039017 for perforce@freebsd.org; Sat, 8 Jul 2006 11:42:27 GMT (envelope-from rdivacky@FreeBSD.org) Date: Sat, 8 Jul 2006 11:42:27 GMT Message-Id: <200607081142.k68BgROX039017@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to rdivacky@FreeBSD.org using -f From: Roman Divacky To: Perforce Change Reviews Cc: Subject: PERFORCE change 100979 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 08 Jul 2006 11:42:28 -0000 http://perforce.freebsd.org/chv.cgi?CH=100979 Change 100979 by rdivacky@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) {