home *** CD-ROM | disk | FTP | other *** search
/ Jason Aller Floppy Collection / 202.img / SCO386N2.TD0 / usr / include / sys / devbuf.h < prev    next >
Encoding:
C/C++ Source or Header  |  1988-11-03  |  1.6 KB  |  59 lines

  1. /*
  2.  *    @(#) devbuf.h 1.1 88/11/03 
  3.  *
  4.  *    Copyright (C) The Santa Cruz Operation, 1985, 1986, 1987, 1988.
  5.  *    This Module contains Proprietary Information of
  6.  *    The Santa Cruz Operation and should be treated as Confidential.
  7.  *
  8.  */
  9.  
  10. /*    devbuf - device buffer managment routines
  11.  *
  12.  *    These routines provide large core memory buffers for tape drives
  13.  *    and other devices that need huge amounts of memory for buffers
  14.  */
  15.  
  16. #define MAXDBREQ    30    /* Max # of chunks in single devbuf request */
  17.  
  18. struct devbuf {
  19.     int    bufptr;        /* pointer to beginning of core block */
  20.     int    bufend;        /* pointer to end of core block */
  21.     int    size;        /* size of core buf in device blocks */
  22.     int    head;        /* where to put data to the buffer */
  23.     int    tail;        /* where to get data from the buffer */
  24.     int    sel;        /* selector storage & in use flag */
  25.     int    ldbs;        /* shift for MMU size <-> block size */
  26.     int    debug;        /* debug flag */
  27. };
  28.  
  29. /*  ldbs (log of delta between block sizes) is used to shift left/right
  30.  *  when converting device block sizes to/from MMU page sizes
  31.  */
  32.  
  33. #define    dstoms(x)    ((x) >> dbptr->ldbs)
  34. #define    mstods(x)    ((x) << dbptr->ldbs)
  35.  
  36. /*  compute the amount of data in the buffer in device block units
  37.  */
  38.  
  39. #define    db_amtdata(b)    \
  40.     ((b.head-b.tail)>=0 ? b.head-b.tail : b.size-(b.tail-b.head))
  41.  
  42. /*  compute the amount of free space in the buffer in device block units
  43.  */
  44.  
  45. #define    db_amtfree(b)    \
  46.     ((b.head-b.tail)>=0 ? b.size-(b.head-b.tail)-1 : b.tail-b.head-1)
  47.  
  48. /*  increment the head/tail pointer
  49.  */
  50.  
  51. #define    db_inc(b,p)                \
  52. if (1) {                    \
  53.     register int i;                \
  54.     i = b.p + 1 ;                \
  55.     if (i == b.bufend) i = b.bufptr;    \
  56.     b.p = i;                \
  57. } else
  58.  
  59.