Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

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

Media Vault

Software Library

Restoration Projects

Artifacts Sought



     DB_ALLOC(K)               UNIX System V               DB_ALLOC(K)



     Name
          db_alloc, db_free - allocates and frees physically
          contiguous memory

     Syntax
          int
          db_alloc(dv)
          struct devbuf *dv;

          int
          db_free(dv)
          struct devbuf *dv;

     Description
          The db_alloc routine allocates one block of physically
          contiguous memory. Contiguous memory is necessary for
          performing DMA transfers. Memory for all other uses should
          be allocated using standard memory allocation routines for
          your machine.  dv points to an instance of the devbuf
          structure.  Set the size field in the devbuf structure to
          the block size before calling db_alloc.

          db_free releases the previously allocated memory.

          The devbuf structure is:

          Type      Field     Description
          paddr_t   bufptr;   /* pointer to start of buffer   */
          paddr_t   bufend;   /* pointer to end of buffer     */
          long      size;     /* size of buffer               */
          paddr_t   head;     /* put buffer data here         */
          paddr_t   tail;     /* get buffer data here         */

          Except for size, all other fields in the devbuf structure
          are read-only.

     Warning
          db_alloc must not be used during the driver's initialization
          routine. The memget(K) routine can be called to obtain
          contiguous memory during driver initialization.  Reading
          from and writing to memory areas allocated using db_alloc(K)
          must be performed using the db_read(K) and db_write(K)
          routines only.

     Return Value
          For db_alloc, zero (0) is returned if no memory is
          available; otherwise, 1 is returned.  db_free always returns
          zero (0).  for normal completion.

     Examples
          The following example allocates a single 120K buffer:

                  struct devbuf dv;
                  dv.size = (long) (120 * 1024);  /* 120 times 1K */
                  if (db_alloc(&dv) == 0) {
                          cmn_err(CE_NOTE, "db_alloc failed");
                          return(-1);
                  }


          The following example releases previously allocated memory:

                  struct devbuf dv;
                  db_free(&dv);

     See Also
          db_read(K), db_write(K)

                                                      (printed 7/6/89)



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