00001 /* 00002 * Shared memory. 00003 * 00004 * Original RTAI/x86 layer implementation: 00005 * Copyright (c) 2000 Paolo Mantegazza (mantegazza@aero.polimi.it) 00006 * Copyright (c) 2000 Steve Papacharalambous (stevep@zentropix.com) 00007 * Copyright (c) 2000 Stuart Hughes 00008 * and others. 00009 * 00010 * RTAI/x86 rewrite over Adeos: 00011 * Copyright (c) 2002 Philippe Gerum (rpm@xenomai.org) 00012 * 00013 * Original RTAI/ARM RTHAL implementation: 00014 * Copyright (c) 2000 Pierre Cloutier (pcloutier@poseidoncontrols.com) 00015 * Copyright (c) 2001 Alex Züpke, SYSGO RTS GmbH (azu@sysgo.de) 00016 * Copyright (c) 2002 Guennadi Liakhovetski DSA GmbH (gl@dsa-ac.de) 00017 * Copyright (c) 2002 Steve Papacharalambous (stevep@zentropix.com) 00018 * Copyright (c) 2002 Wolfgang Müller (wolfgang.mueller@dsa-ac.de) 00019 * Copyright (c) 2003 Bernard Haible, Marconi Communications 00020 * Copyright (c) 2003 Thomas Gleixner (tglx@linutronix.de) 00021 * Copyright (c) 2003 Philippe Gerum (rpm@xenomai.org) 00022 * 00023 * RTAI/ARM over Adeos rewrite: 00024 * Copyright (c) 2004-2005 Michael Neuhauser, Firmix Software GmbH (mike@firmix.at) 00025 * 00026 * 00027 * This program is free software; you can redistribute it and/or modify it under 00028 * the terms of the GNU General Public License as published by the Free Software 00029 * Foundation, Inc., 675 Mass Ave, Cambridge MA 02139, USA; either version 2 of 00030 * the License, or (at your option) any later version. 00031 * 00032 * This program is distributed in the hope that it will be useful, but WITHOUT 00033 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00034 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 00035 * details. 00036 * 00037 * You should have received a copy of the GNU General Public License along with 00038 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple 00039 * Place - Suite 330, Boston, MA 02111-1307, USA. 00040 */ 00041 #ifndef _RTAI_ASM_ARM_SHM_H 00042 #define _RTAI_ASM_ARM_SHM_H 00043 00044 #undef __SHM_USE_VECTOR /* not yet implemented for arm ... */ 00045 00046 #ifdef __KERNEL__ 00047 00048 #define RTAI_SHM_HANDLER shm_handler 00049 #define DEFINE_SHM_HANDLER 00050 00051 #else /* !__KERNEL__ */ 00052 00053 #ifdef __SHM_USE_VECTOR 00054 #include <asm/rtai_vectors.h> 00055 #define rtai_shmrq(srq, whatever) rtai_do_swi((srq)|(RTAI_SHM_VECTOR << 24), whatever) 00056 #endif 00057 00058 #endif /* __KERNEL__ */ 00059 00060 /* convert virtual user memory address to physical address */ 00061 /* (virt_to_phys only works for kmalloced kernel memory) */ 00062 00063 static inline unsigned long uvirt_to_kva(pgd_t *pgd, unsigned long adr) 00064 { 00065 unsigned long ret = 0UL; 00066 pmd_t *pmd; 00067 pte_t *ptep, pte; 00068 00069 if(!pgd_none(*pgd)) { 00070 pmd = pmd_offset(pgd, adr); 00071 if (!pmd_none(*pmd)) { 00072 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) 00073 ptep = pte_offset(pmd, adr); 00074 #else /* >= 2.6.0 */ 00075 ptep = pte_offset_kernel(pmd, adr); 00076 #endif /* < 2.6.0 */ 00077 pte = *ptep; 00078 if(pte_present(pte)){ 00079 ret = (unsigned long) page_address(pte_page(pte)); 00080 ret |= (adr&(PAGE_SIZE-1)); 00081 } 00082 } 00083 } 00084 return ret; 00085 } 00086 00087 #ifndef VMALLOC_VMADDR 00088 #define VMALLOC_VMADDR(x) ((unsigned long)(x)) 00089 #endif 00090 00091 static inline unsigned long kvirt_to_pa(unsigned long adr) 00092 { 00093 unsigned long va, kva, ret; 00094 00095 va = VMALLOC_VMADDR(adr); 00096 kva = uvirt_to_kva(pgd_offset_k(va), va); 00097 ret = __pa(kva); 00098 00099 return ret; 00100 } 00101 00102 #endif /* _RTAI_ASM_ARM_SHM_H */