home *** CD-ROM | disk | FTP | other *** search
/ Jason Aller Floppy Collection / 202.img / SCO386N2.TD0 / usr / include / sys / buf.h < prev    next >
Encoding:
C/C++ Source or Header  |  1988-05-18  |  4.0 KB  |  132 lines

  1. /*
  2.  *    @(#) buf.h 2.1 88/05/18 
  3.  *
  4.  *    Copyright (C) The Santa Cruz Operation, 1984, 1985, 1986, 1987.
  5.  *    Copyright (C) Microsoft Corporation, 1984, 1985, 1986, 1987.
  6.  *    This Module contains Proprietary Information of
  7.  *    The Santa Cruz Operation, Microsoft Corporation
  8.  *    and AT&T, and should be treated as Confidential.
  9.  */
  10.  
  11. /*
  12.  * THIS FILE CONTAINS CODE WHICH IS DESIGNED TO BE
  13.  * PORTABLE BETWEEN DIFFERENT MACHINE ARCHITECTURES
  14.  * AND CONFIGURATIONS. IT SHOULD NOT REQUIRE ANY
  15.  * MODIFICATIONS WHEN ADAPTING XENIX TO NEW HARDWARE.
  16.  */
  17.  
  18.  
  19.  
  20. /*
  21.  * Each buffer in the pool is usually doubly linked into 2 lists:
  22.  * the device with which it is currently associated (always)
  23.  * and also on a list of blocks available for allocation
  24.  * for other use (usually).
  25.  * The latter list is kept in last-used order, and the two
  26.  * lists are doubly linked to make it easy to remove
  27.  * a buffer from one list when it was found by
  28.  * looking through the other.
  29.  * A buffer is on the available list, and is liable
  30.  * to be reassigned to another disk block, if and only
  31.  * if it is not marked BUSY.  When a buffer is busy, the
  32.  * available-list pointers can be used for other purposes.
  33.  * Most drivers use the forward ptr as a link in their I/O active queue.
  34.  * A buffer header contains all the information required to perform I/O.
  35.  * Most of the routines which manipulate these things are in bio.c.
  36.  */
  37. struct buf
  38. {
  39.     int    b_flags;        /* see defines below */
  40.     struct    buf *b_forw;        /* headed by d_tab of conf.c */
  41.     struct    buf *b_back;        /*  "  */
  42.     struct    buf *av_forw;        /* position on free list, */
  43.     struct    buf *av_back;        /*     if not BUSY*/
  44.     dev_t    b_dev;            /* major+minor device name */
  45.     unsigned b_bcount;        /* transfer count */
  46.     paddr_t    b_paddr;        /* physical address */
  47. #define    paddr(X)    X->b_paddr
  48.     daddr_t    b_blkno;        /* block # on device */
  49.     char    b_error;        /* returned after I/O */
  50.     char    b_res;            /* reserved field to word align */
  51.     unsigned int b_resid;        /* words not transferred after error */
  52.     ushort  b_cylin;                /* cylinder number for disk i/o queue */
  53. };
  54.  
  55. #ifndef M_I386
  56. extern struct buf buf[];        /* The buffer pool itself */
  57. extern char sabuf[][BSIZE];
  58. #endif
  59. extern struct buf bfreelist;        /* head of available list */
  60.  
  61. #ifdef M_I386
  62. extern struct buf pbuf[];        /* Physio header pool */
  63. struct pfree {
  64.     int    b_flags;
  65.     struct    buf *av_forw;
  66. };
  67. extern struct pfree pfreelist;        /* head of physio pool */
  68. #endif
  69.  
  70. #ifdef BUFMAPOUT
  71. long    bigetl();
  72. #else
  73. #define bigetc(bp,cp) (*(char *)(bp->b_paddr+cp))
  74. #define biget(bp,cp) (*(short *)(bp->b_paddr+cp))
  75. #define bigetl(bp,cp) (*(long *)(bp->b_paddr+cp))
  76. #define biputc(bp,cp,c) (*(char *)(bp->b_paddr+cp)=c)
  77. #define biput(bp,cp,c) (*(short *)(bp->b_paddr+cp)=c)
  78. #define biputl(bp,cp,c) (*(long *)(bp->b_paddr+cp)=c)
  79. #endif
  80.  
  81. paddr_t    bufbase;
  82.  
  83. /*
  84.  * These flags are kept in b_flags.
  85.  */
  86. #define    B_WRITE      0        /* non-read pseudo-flag */
  87. #define    B_READ      01        /* read when I/O occurs */
  88. #define    B_DONE      02        /* transaction finished */
  89. #define    B_ERROR      04        /* transaction aborted */
  90. #define    B_BUSY      010        /* not on av_forw/back list */
  91. #define    B_PHYS      020        /* Physical IO potentially using UNIBUS map */
  92. #define    B_MAP      040        /* This block has the UNIBUS map allocated */
  93. #define    B_WANTED  0100        /* issue wakeup when BUSY goes off */
  94. #define    B_AGE      0200        /* delayed write for correct aging */
  95. #define    B_ASYNC      0400        /* don't wait for I/O completion */
  96. #define    B_DELWRI  01000        /* don't write til block leaves available list*/
  97. #define    B_OPEN      02000        /* open routine called */
  98. #define    B_STALE   04000
  99. #define B_NOCROSS 010000    /* transfer cannot cross 64k boundary */
  100. #define B_FLUSH   020000    /* write queued by bflush */
  101.  
  102. /*
  103.  * Fast access to buffers in cache by hashing.
  104.  */
  105.  
  106. #define    bhash(d,b)    ((struct buf *)&hbuf[((int)d+(int)b)&v.v_hmask])
  107.  
  108. struct hbuf
  109. {
  110.     int    b_flags;
  111.     struct    buf *b_forw;
  112.     struct    buf *b_back;
  113. };
  114.  
  115. extern struct hbuf hbuf[];
  116.  
  117. #ifdef M_KERNEL
  118.  
  119. #ifdef M_I386
  120. #define    bimap(bp)    (ptok(paddr(bp)))
  121. #endif
  122.  
  123. #ifdef M_I286
  124. extern faddr_t bimap();
  125. #endif
  126.  
  127. #ifdef M_I8086
  128. extern char far *bimap();
  129. #endif
  130.  
  131. #endif
  132.