Diff for /src/sys/kern/kern_xio.c between versions 1.4 and 1.5

version 1.4, 2004/04/03 08:20:10 version 1.5, 2004/05/13 17:40:15
Line 65 Line 65
  * Initialize an XIO given a userspace buffer.  0 is returned on success,   * Initialize an XIO given a userspace buffer.  0 is returned on success,
  * an error code on failure.  The actual number of bytes that could be   * an error code on failure.  The actual number of bytes that could be
  * accomodated in the XIO will be stored in xio_bytes.   * accomodated in the XIO will be stored in xio_bytes.
    *
    * Note that you cannot legally accessed a previously cached linmap with 
    * a newly initialized xio until after calling xio_linmap().
  */   */
 int  int
 xio_init_ubuf(xio_t xio, void *ubase, size_t ubytes, int flags)  xio_init_ubuf(xio_t xio, void *ubase, size_t ubytes, int flags)
Line 74  xio_init_ubuf(xio_t xio, void *ubase, si Line 77  xio_init_ubuf(xio_t xio, void *ubase, si
     vm_page_t m;      vm_page_t m;
     int i;      int i;
     int n;      int n;
       int s;
     int vmprot;      int vmprot;
   
     addr = trunc_page((vm_offset_t)ubase);      addr = trunc_page((vm_offset_t)ubase);
Line 94  xio_init_ubuf(xio_t xio, void *ubase, si Line 98  xio_init_ubuf(xio_t xio, void *ubase, si
                 break;                  break;
             if ((paddr = pmap_kextract(addr)) == 0)              if ((paddr = pmap_kextract(addr)) == 0)
                 break;                  break;
               s = splvm();
             m = PHYS_TO_VM_PAGE(paddr);              m = PHYS_TO_VM_PAGE(paddr);
             vm_page_hold(m);              vm_page_hold(m);
               splx(s);
             xio->xio_pages[i] = m;              xio->xio_pages[i] = m;
             ubytes -= n;              ubytes -= n;
             xio->xio_bytes += n;              xio->xio_bytes += n;
Line 123  xio_init_ubuf(xio_t xio, void *ubase, si Line 129  xio_init_ubuf(xio_t xio, void *ubase, si
  * accomodated in the XIO will be stored in xio_bytes.   * accomodated in the XIO will be stored in xio_bytes.
  *   *
  * vmprot is usually either VM_PROT_READ or VM_PROT_WRITE.   * vmprot is usually either VM_PROT_READ or VM_PROT_WRITE.
    *
    * Note that you cannot legally accessed a previously cached linmap with 
    * a newly initialized xio until after calling xio_linmap().
  */   */
 int  int
 xio_init_kbuf(xio_t xio, void *kbase, size_t kbytes)  xio_init_kbuf(xio_t xio, void *kbase, size_t kbytes)
Line 132  xio_init_kbuf(xio_t xio, void *kbase, si Line 141  xio_init_kbuf(xio_t xio, void *kbase, si
     vm_page_t m;      vm_page_t m;
     int i;      int i;
     int n;      int n;
       int s;
   
     addr = trunc_page((vm_offset_t)kbase);      addr = trunc_page((vm_offset_t)kbase);
     xio->xio_flags = 0;      xio->xio_flags = 0;
Line 144  xio_init_kbuf(xio_t xio, void *kbase, si Line 154  xio_init_kbuf(xio_t xio, void *kbase, si
     for (i = 0; n && i < XIO_INTERNAL_PAGES; ++i) {      for (i = 0; n && i < XIO_INTERNAL_PAGES; ++i) {
         if ((paddr = pmap_kextract(addr)) == 0)          if ((paddr = pmap_kextract(addr)) == 0)
             break;              break;
           s = splvm();
         m = PHYS_TO_VM_PAGE(paddr);          m = PHYS_TO_VM_PAGE(paddr);
         vm_page_hold(m);          vm_page_hold(m);
           splx(s);
         xio->xio_pages[i] = m;          xio->xio_pages[i] = m;
         kbytes -= n;          kbytes -= n;
         xio->xio_bytes += n;          xio->xio_bytes += n;
Line 166  xio_init_kbuf(xio_t xio, void *kbase, si Line 178  xio_init_kbuf(xio_t xio, void *kbase, si
     return(xio->xio_error);      return(xio->xio_error);
 }  }
   
   /*
    * Cleanup an XIO so it can be destroyed.  The pages associated with the
    * XIO are released.  If a linear mapping buffer is active, it will be
    * unlocked but the mappings will be left intact for optimal reconstitution
    * in a later xio_linmap() call.
    *
    * Note that you cannot legally accessed the linmap on a released XIO.
    */
 void  void
 xio_release(xio_t xio)  xio_release(xio_t xio)
 {  {
     int i;      int i;
       int s;
     vm_page_t m;      vm_page_t m;
   
       s = splvm();
     for (i = 0; i < xio->xio_npages; ++i) {      for (i = 0; i < xio->xio_npages; ++i) {
         m = xio->xio_pages[i];          m = xio->xio_pages[i];
         vm_page_unhold(m);          vm_page_unhold(m);
     }      }
       splx(s);
       if (xio->xio_flags & XIOF_LINMAP) {
           xio->xio_flags &= ~XIOF_LINMAP;
           /* XXX */
       }
     xio->xio_offset = 0;      xio->xio_offset = 0;
     xio->xio_npages = 0;      xio->xio_npages = 0;
     xio->xio_bytes = 0;      xio->xio_bytes = 0;

Removed from v.1.4  
changed lines
  Added in v.1.5