Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ vas(K) — System V/386 Software Development System 3.2.2b

Media Vault

Software Library

Restoration Projects

Artifacts Sought



     VAS(K)                    UNIX System V                    VAS(K)



     Name
          vas: vasbind, vasmalloc, vasmapped, vasunbind - virtual
          address space memory routines

     Syntax
          int
          vasbind(paddr, vaddr, nbytes)
          paddr_t paddr;
          caddr_t vaddr;
          unsigned int nbytes;

          caddr_t
          vasmalloc(paddr, nbytes)
          paddr_t paddr;
          unsigned int nbytes;

          caddr_t
          vasmapped(paddr, nbytes)
          paddr_t paddr;
          unsigned int nbytes;

          int
          vasunbind(vaddr, nbytes)
          caddr_t vaddr;
          unsigned int nbytes;

     Description
          These routines allow a driver to map physical memory so that
          it can be read from or written to by both a driver and a
          calling user process.  These routines are generally used to
          allow user processes to directly access video adapter
          memory.  Memory that has been mapped using these routines is
          visible to the kernel and to a calling process.  However,
          the mapping is not globally visible to all processes.

          vasmalloc allocates virtual memory.  Use this routine to
          obtain virtual address space that is not currently in use.
          vasmalloc can only allocate four megabytes of virtual
          address space on each call.  Requests less than this amount
          are rounded up to four megabytes; requests larger than this
          amount cause an error to occur.  vasmalloc returns an
          address to virtual user memory; no actual physical memory is
          allocated by this routine.  The nbytes argument can be
          specified as 1 to allocate four megabytes, but 0 (zero) or
          not specifying this argument is not permissible.

          vasbind binds a specified virtual address to a physical
          address.  This routine ensures that a problem will not occur
          with the bound memory being swapped out and causing a page
          fault and panic in the kernel.  Before using vasbind, call
          vasmapped to determine if memory has already been mapped for
          the calling process.

          The physical address supplied to vasbind may be the address
          of an I/O address space, for example, a memory-mapped I/O
          address.  Or specify -1 to request that the memory be
          allocated from the kernel free memory pool.

          When vasbind completes, the driver must pass the virtual
          address back to the user process using copyout(K) or another
          similar routine.  Calls to vasbind must not specify an
          address in the text, data, or shared data segments of a user
          process.

          The upper limit for user virtual memory is set in the KVBASE
          constant (defined in sys/immu.h); above KVBASE is the kernel
          virtual address space.  The virtual address supplied to
          vasbind must be in user virtual memory (below KVBASE), and
          must not be in use by the current process.

          vasmapped determines if a mapping is already in place.

          vasunbind undoes a mapping.

     Notes
          These routines cannot be called from a driver's interrupt
          routine (xxintr).

     Parameters
               nbytes         number of bytes of memory to allocate,
                              bind, or unbind.  For vasmalloc, nbytes
                              can be specified as 1 to allocate four
                              megabytes, but 0 (zero) or not
                              specifying this argument is not
                              permissible.

               paddr          Physical address at which the specified
                              virtual address is to be bound.  When
                              calling vasbind, paddr can be set to -1
                              to indicate that the requested user
                              virtual memory is to be allocated.

               vaddr          Virtual address to bind or unbind to or
                              from physical memory

     Return Value
          vasbind returns -1 if an error occurs or if an error is
          found in u.u_error.  vasmalloc returns a virtual address.
          vasunbind returns -1 if an error is found in u.u_error, or
          if the virtual address couldn't be found.  vasmapped returns
          the virtual address at which the supplied physical address
          is bound, or 0 (zero) is physical address is not bound.

     See Also
          sptalloc(K), copyout(K)

                                                      (printed 7/6/89)



Typewritten Software • bear@typewritten.org • Edmonds, WA 98026