]> git.saurik.com Git - apple/xnu.git/blobdiff - bsd/kern/kern_subr.c
xnu-517.9.5.tar.gz
[apple/xnu.git] / bsd / kern / kern_subr.c
index 7e94acb9c9aa474a6b7f08854207997f50862e5f..cc5b4382e55c59c8da39739b8bda7e80eaa3f0fd 100644 (file)
@@ -3,22 +3,19 @@
  *
  * @APPLE_LICENSE_HEADER_START@
  * 
- * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
+ * The contents of this file constitute Original Code as defined in and
+ * are subject to the Apple Public Source License Version 1.1 (the
+ * "License").  You may not use this file except in compliance with the
+ * License.  Please obtain a copy of the License at
+ * http://www.apple.com/publicsource and read it before using this file.
  * 
- * This file contains Original Code and/or Modifications of Original Code
- * as defined in and that are subject to the Apple Public Source License
- * Version 2.0 (the 'License'). You may not use this file except in
- * compliance with the License. Please obtain a copy of the License at
- * http://www.opensource.apple.com/apsl/ and read it before using this
- * file.
- * 
- * The Original Code and all software distributed under the License are
- * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This Original Code and all software distributed under the License are
+ * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
- * Please see the License for the specific language governing rights and
- * limitations under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
+ * License for the specific language governing rights and limitations
+ * under the License.
  * 
  * @APPLE_LICENSE_HEADER_END@
  */
@@ -76,6 +73,7 @@
 #define DBG_UIO_COPYOUT 16
 #define DBG_UIO_COPYIN  17
 
+
 int
 uiomove(cp, n, uio)
        register caddr_t cp;
@@ -116,22 +114,22 @@ uiomove64(addr64_t cp, int n, struct uio *uio)
                        if (uio->uio_rw == UIO_READ)
                          {
                                KERNEL_DEBUG((FSDBG_CODE(DBG_FSRW, DBG_UIO_COPYOUT)) | DBG_FUNC_START,
-                                        (caddr_t)cp, iov->iov_base, cnt, 0,0);
+                                        (int)cp, (int)iov->iov_base, cnt, 0,0);
 
-                               error = copyout((caddr_t)cp, iov->iov_base, cnt);
+                               error = copyout( CAST_DOWN(caddr_t, cp), iov->iov_base, cnt );
 
                                KERNEL_DEBUG((FSDBG_CODE(DBG_FSRW, DBG_UIO_COPYOUT)) | DBG_FUNC_END,
-                                        (caddr_t)cp, iov->iov_base, cnt, 0,0);
+                                        (int)cp, (int)iov->iov_base, cnt, 0,0);
                          }
                        else
                          {
                                KERNEL_DEBUG((FSDBG_CODE(DBG_FSRW, DBG_UIO_COPYIN)) | DBG_FUNC_START,
-                                        iov->iov_base, (caddr_t)cp, cnt, 0,0);
+                                        (int)iov->iov_base, (int)cp, cnt, 0,0);
 
-                               error = copyin(iov->iov_base, (caddr_t)cp, cnt);
+                               error = copyin(iov->iov_base, CAST_DOWN(caddr_t, cp), cnt);
 
                                KERNEL_DEBUG((FSDBG_CODE(DBG_FSRW, DBG_UIO_COPYIN)) | DBG_FUNC_END,
-                                        iov->iov_base, (caddr_t)cp, cnt, 0,0);
+                                        (int)iov->iov_base, (int)cp, cnt, 0,0);
                          }
                        if (error)
                                return (error);
@@ -139,10 +137,10 @@ uiomove64(addr64_t cp, int n, struct uio *uio)
 
                case UIO_SYSSPACE:
                        if (uio->uio_rw == UIO_READ)
-                               error = copywithin((caddr_t)cp, iov->iov_base,
+                               error = copywithin(CAST_DOWN(caddr_t, cp), iov->iov_base,
                                                   cnt);
                        else
-                               error = copywithin(iov->iov_base, (caddr_t)cp,
+                               error = copywithin(iov->iov_base, CAST_DOWN(caddr_t, cp),
                                                   cnt);
                        break;
 
@@ -150,24 +148,51 @@ uiomove64(addr64_t cp, int n, struct uio *uio)
                        if (uio->uio_rw == UIO_READ)
                          {
                                KERNEL_DEBUG((FSDBG_CODE(DBG_FSRW, DBG_UIO_COPYOUT)) | DBG_FUNC_START,
-                                        cp, iov->iov_base, cnt, 1,0);
+                                        (int)cp, (int)iov->iov_base, cnt, 1,0);
 
                                if (error = copypv((addr64_t)cp, (addr64_t)((unsigned int)iov->iov_base), cnt, cppvPsrc | cppvNoRefSrc))        /* Copy physical to virtual */
                                        error = EFAULT;
 
                                KERNEL_DEBUG((FSDBG_CODE(DBG_FSRW, DBG_UIO_COPYOUT)) | DBG_FUNC_END,
-                                        cp, iov->iov_base, cnt, 1,0);
+                                        (int)cp, (int)iov->iov_base, cnt, 1,0);
                          }
                        else
                          {
                                KERNEL_DEBUG((FSDBG_CODE(DBG_FSRW, DBG_UIO_COPYIN)) | DBG_FUNC_START,
-                                        iov->iov_base, cp, cnt, 1,0);
+                                        (int)iov->iov_base, (int)cp, cnt, 1,0);
 
                                if (error = copypv((addr64_t)((unsigned int)iov->iov_base), (addr64_t)cp, cnt, cppvPsnk | cppvNoRefSrc | cppvNoModSnk)) /* Copy virtual to physical */
                                        error = EFAULT;
 
                                KERNEL_DEBUG((FSDBG_CODE(DBG_FSRW, DBG_UIO_COPYIN)) | DBG_FUNC_END,
-                                        iov->iov_base, cp, cnt, 1,0);
+                                        (int)iov->iov_base, (int)cp, cnt, 1,0);
+                         }
+                       if (error)
+                               return (error);
+                       break;
+
+               case UIO_PHYS_SYSSPACE:
+                       if (uio->uio_rw == UIO_READ)
+                         {
+                               KERNEL_DEBUG((FSDBG_CODE(DBG_FSRW, DBG_UIO_COPYOUT)) | DBG_FUNC_START,
+                                        (int)cp, (int)iov->iov_base, cnt, 2,0);
+
+                               if (error = copypv((addr64_t)cp, (addr64_t)((unsigned int)iov->iov_base), cnt, cppvKmap | cppvPsrc | cppvNoRefSrc))     /* Copy physical to virtual */
+                                       error = EFAULT;
+
+                               KERNEL_DEBUG((FSDBG_CODE(DBG_FSRW, DBG_UIO_COPYOUT)) | DBG_FUNC_END,
+                                        (int)cp, (int)iov->iov_base, cnt, 2,0);
+                         }
+                       else
+                         {
+                               KERNEL_DEBUG((FSDBG_CODE(DBG_FSRW, DBG_UIO_COPYIN)) | DBG_FUNC_START,
+                                        (int)iov->iov_base, (int)cp, cnt, 2,0);
+
+                               if (error = copypv((addr64_t)((unsigned int)iov->iov_base), (addr64_t)cp, cnt, cppvKmap | cppvPsnk | cppvNoRefSrc | cppvNoModSnk))      /* Copy virtual to physical */
+                                       error = EFAULT;
+
+                               KERNEL_DEBUG((FSDBG_CODE(DBG_FSRW, DBG_UIO_COPYIN)) | DBG_FUNC_END,
+                                        (int)iov->iov_base, (int)cp, cnt, 2,0);
                          }
                        if (error)
                                return (error);