[16] | 1 | /*************************************************************************** |
---|
| 2 | * |
---|
| 3 | * Copyright (C) 2001 International Business Machines |
---|
| 4 | * All rights reserved. |
---|
| 5 | * |
---|
| 6 | * This file is part of the GPFS mmfslinux kernel module. |
---|
| 7 | * |
---|
| 8 | * Redistribution and use in source and binary forms, with or without |
---|
| 9 | * modification, are permitted provided that the following conditions |
---|
| 10 | * are met: |
---|
| 11 | * |
---|
| 12 | * 1. Redistributions of source code must retain the above copyright notice, |
---|
| 13 | * this list of conditions and the following disclaimer. |
---|
| 14 | * 2. Redistributions in binary form must reproduce the above copyright |
---|
| 15 | * notice, this list of conditions and the following disclaimer in the |
---|
| 16 | * documentation and/or other materials provided with the distribution. |
---|
| 17 | * 3. The name of the author may not be used to endorse or promote products |
---|
| 18 | * derived from this software without specific prior written |
---|
| 19 | * permission. |
---|
| 20 | * |
---|
| 21 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
---|
| 22 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
---|
| 23 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
---|
| 24 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
---|
| 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
---|
| 26 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; |
---|
| 27 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
---|
| 28 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
---|
| 29 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
---|
| 30 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
---|
| 31 | * |
---|
| 32 | *************************************************************************** */ |
---|
| 33 | /* @(#)27 1.5 src/avs/fs/mmfs/ts/kernext/gpl-linux/ppc64/ss_ppc64.c, mmfs, avs_rgpfs24, rgpfs240610b 9/15/04 23:29:27 */ |
---|
| 34 | |
---|
| 35 | /* |
---|
| 36 | * Implementation of shared segment for GPFS daemon and GPFS kernel code. |
---|
| 37 | * |
---|
| 38 | */ |
---|
| 39 | |
---|
| 40 | #include <Shark-gpl.h> |
---|
| 41 | #include <cxiSystem.h> |
---|
| 42 | #include <cxiSharedSeg.h> |
---|
| 43 | |
---|
| 44 | #include <linux/types.h> |
---|
| 45 | #include <linux/version.h> |
---|
| 46 | #include <linux/kernel.h> |
---|
| 47 | #include <linux/module.h> |
---|
| 48 | #include <linux/sched.h> |
---|
| 49 | #include <linux/types.h> |
---|
| 50 | #if LINUX_KERNEL_VERSION < 2060000 |
---|
| 51 | #include <linux/compatmac.h> |
---|
| 52 | #endif |
---|
| 53 | |
---|
| 54 | #include <verdep.h> |
---|
| 55 | |
---|
| 56 | int |
---|
| 57 | kxSaveThreadInfo(int tid, void* regP) |
---|
| 58 | { |
---|
| 59 | struct task_struct *g, *t; |
---|
| 60 | int rc = ENOENT; |
---|
| 61 | unsigned long sp; |
---|
| 62 | |
---|
| 63 | read_lock(&tasklist_lock); |
---|
| 64 | DO_EACH_THREAD(g,t) |
---|
| 65 | { |
---|
| 66 | if (t->pid != tid) |
---|
| 67 | continue; |
---|
| 68 | |
---|
| 69 | rc = 0; |
---|
| 70 | goto found_it; |
---|
| 71 | } WHILE_EACH_THREAD(g,t); |
---|
| 72 | found_it: |
---|
| 73 | read_unlock(&tasklist_lock); |
---|
| 74 | if (rc == 0) |
---|
| 75 | { |
---|
| 76 | if (t->thread.regs != NULL) |
---|
| 77 | copy_to_user(regP, t->thread.regs, sizeof(struct pt_regs)); |
---|
| 78 | else |
---|
| 79 | { |
---|
| 80 | #if LINUX_KERNEL_VERSION < 2060000 |
---|
| 81 | sp = (unsigned long)t + sizeof(union task_union); |
---|
| 82 | #else |
---|
| 83 | /* ??? */ |
---|
| 84 | sp = (unsigned long)t->thread_info + THREAD_SIZE; |
---|
| 85 | #endif |
---|
| 86 | sp -= sizeof(struct pt_regs); |
---|
| 87 | copy_to_user(regP, (void*)sp, sizeof(struct pt_regs)); |
---|
| 88 | } |
---|
| 89 | } |
---|
| 90 | return rc; |
---|
| 91 | } |
---|