Commit | Line | Data |
---|---|---|
9c66bb97 KT |
1 | /* |
2 | * Each buffer in the pool is usually doubly linked into 2 lists: | |
3 | * the device with which it is currently associated (always) | |
4 | * and also on a list of blocks available for allocation | |
5 | * for other use (usually). | |
6 | * The latter list is kept in last-used order, and the two | |
7 | * lists are doubly linked to make it easy to remove | |
8 | * a buffer from one list when it was found by | |
9 | * looking through the other. | |
10 | * A buffer is on the available list, and is liable | |
11 | * to be reassigned to another disk block, if and only | |
12 | * if it is not marked BUSY. When a buffer is busy, the | |
13 | * available-list pointers can be used for other purposes. | |
14 | * Most drivers use the forward ptr as a link in their I/O | |
15 | * active queue. | |
16 | * A buffer header contains all the information required | |
17 | * to perform I/O. | |
18 | * Most of the routines which manipulate these things | |
19 | * are in bio.c. | |
20 | */ | |
21 | struct buf | |
22 | { | |
23 | int b_flags; /* see defines below */ | |
24 | struct buf *b_forw; /* headed by devtab of b_dev */ | |
25 | struct buf *b_back; /* " */ | |
26 | struct buf *av_forw; /* position on free list, */ | |
27 | struct buf *av_back; /* if not BUSY*/ | |
28 | int b_dev; /* major+minor device name */ | |
29 | int b_wcount; /* transfer count (usu. words) */ | |
30 | char *b_addr; /* low order core address */ | |
31 | char *b_xmem; /* high order core address */ | |
32 | char *b_blkno; /* block # on device */ | |
33 | char b_error; /* returned after I/O */ | |
34 | char *b_resid; /* words not transferred after error */ | |
35 | } buf[NBUF]; | |
36 | ||
37 | /* | |
38 | * Each block device has a devtab, which contains private state stuff | |
39 | * and 2 list heads: the b_forw/b_back list, which is doubly linked | |
40 | * and has all the buffers currently associated with that major | |
41 | * device; and the d_actf/d_actl list, which is private to the | |
42 | * device but in fact is always used for the head and tail | |
43 | * of the I/O queue for the device. | |
44 | * Various routines in bio.c look at b_forw/b_back | |
45 | * (notice they are the same as in the buf structure) | |
46 | * but the rest is private to each device driver. | |
47 | */ | |
48 | struct devtab | |
49 | { | |
50 | char d_active; /* busy flag */ | |
51 | char d_errcnt; /* error count (for recovery) */ | |
52 | struct buf *b_forw; /* first buffer for this dev */ | |
53 | struct buf *b_back; /* last buffer for this dev */ | |
54 | struct buf *d_actf; /* head of I/O queue */ | |
55 | struct buf *d_actl; /* tail of I/O queue */ | |
56 | }; | |
57 | ||
58 | /* | |
59 | * This is the head of the queue of available | |
60 | * buffers-- all unused except for the 2 list heads. | |
61 | */ | |
62 | struct buf bfreelist; | |
63 | ||
64 | /* | |
65 | * These flags are kept in b_flags. | |
66 | */ | |
67 | #define B_WRITE 0 /* non-read pseudo-flag */ | |
68 | #define B_READ 01 /* read when I/O occurs */ | |
69 | #define B_DONE 02 /* transaction finished */ | |
70 | #define B_ERROR 04 /* transaction aborted */ | |
71 | #define B_BUSY 010 /* not on av_forw/back list */ | |
72 | #define B_PHYS 020 /* Physical IO potentially using UNIBUS map */ | |
73 | #define B_MAP 040 /* This block has the UNIBUS map allocated */ | |
74 | #define B_WANTED 0100 /* issue wakeup when BUSY goes off */ | |
75 | #define B_RELOC 0200 /* no longer used */ | |
76 | #define B_ASYNC 0400 /* don't wait for I/O completion */ | |
77 | #define B_DELWRI 01000 /* don't write till block leaves available list */ |