The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/kernel/system/do_vcopy.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /* The kernel call implemented in this file:
    2  *   m_type:    SYS_VIRVCOPY, SYS_PHYSVCOPY 
    3  *
    4  * The parameters for this kernel call are:
    5  *    m1_i3:    VCP_VEC_SIZE            size of copy request vector 
    6  *    m1_p1:    VCP_VEC_ADDR            address of vector at caller 
    7  *    m1_i2:    VCP_NR_OK               number of successfull copies    
    8  */
    9 
   10 #include "../system.h"
   11 #include <minix/type.h>
   12 
   13 #if (USE_VIRVCOPY || USE_PHYSVCOPY)
   14 
   15 /* Buffer to hold copy request vector from user. */
   16 PRIVATE struct vir_cp_req vir_cp_req[VCOPY_VEC_SIZE];
   17 
   18 /*===========================================================================*
   19  *                              do_vcopy                                             *
   20  *===========================================================================*/
   21 PUBLIC int do_vcopy(m_ptr)
   22 register message *m_ptr;        /* pointer to request message */
   23 {
   24 /* Handle sys_virvcopy() and sys_physvcopy() that pass a vector with copy
   25  * requests. Although a single handler function is used, there are two
   26  * different kernel calls so that permissions can be checked.
   27  */
   28   int nr_req;
   29   int caller_pid;
   30   vir_bytes caller_vir;
   31   phys_bytes caller_phys;
   32   phys_bytes kernel_phys;
   33   phys_bytes bytes;
   34   int i,s;
   35   struct vir_cp_req *req;
   36 
   37   /* Check if request vector size is ok. */
   38   nr_req = (unsigned) m_ptr->VCP_VEC_SIZE;
   39   if (nr_req > VCOPY_VEC_SIZE) return(EINVAL);
   40   bytes = nr_req * sizeof(struct vir_cp_req);
   41 
   42   /* Calculate physical addresses and copy (port,value)-pairs from user. */
   43   caller_pid = (int) m_ptr->m_source; 
   44   caller_vir = (vir_bytes) m_ptr->VCP_VEC_ADDR;
   45   caller_phys = umap_local(proc_addr(caller_pid), D, caller_vir, bytes);
   46   if (0 == caller_phys) return(EFAULT);
   47   kernel_phys = vir2phys(vir_cp_req);
   48   phys_copy(caller_phys, kernel_phys, (phys_bytes) bytes);
   49 
   50   /* Assume vector with requests is correct. Try to copy everything. */
   51   m_ptr->VCP_NR_OK = 0;
   52   for (i=0; i<nr_req; i++) {
   53 
   54       req = &vir_cp_req[i];
   55 
   56       /* Check if physical addressing is used without SYS_PHYSVCOPY. */
   57       if (((req->src.segment | req->dst.segment) & PHYS_SEG) &&
   58               m_ptr->m_type != SYS_PHYSVCOPY) return(EPERM);
   59       if ((s=virtual_copy(&req->src, &req->dst, req->count)) != OK) 
   60           return(s);
   61       m_ptr->VCP_NR_OK ++;
   62   }
   63   return(OK);
   64 }
   65 
   66 #endif /* (USE_VIRVCOPY || USE_PHYSVCOPY) */
   67 

Cache object: 016b05c81b35b625219c3d377f3c8398


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.