This source file includes following definitions.
- unlock_buffer
- end_request
1 #ifndef _BLK_H
2 #define _BLK_H
3
4 #define NR_BLK_DEV 7
5
6
7
8
9
10
11
12
13
14
15 #define NR_REQUEST 32
16
17
18
19
20
21
22
23 struct request {
24 int dev;
25 int cmd;
26 int errors;
27 unsigned long sector;
28 unsigned long nr_sectors;
29 char * buffer;
30 struct task_struct * waiting;
31 struct buffer_head * bh;
32 struct request * next;
33 };
34
35
36
37
38
39
40 #define IN_ORDER(s1,s2) \
41 ((s1)->cmd<(s2)->cmd || ((s1)->cmd==(s2)->cmd && \
42 ((s1)->dev < (s2)->dev || (((s1)->dev == (s2)->dev && \
43 (s1)->sector < (s2)->sector)))))
44
45 struct blk_dev_struct {
46 void (*request_fn)(void);
47 struct request * current_request;
48 };
49
50 extern struct blk_dev_struct blk_dev[NR_BLK_DEV];
51 extern struct request request[NR_REQUEST];
52 extern struct task_struct * wait_for_request;
53
54 extern int * blk_size[NR_BLK_DEV];
55
56 #ifdef MAJOR_NR
57
58
59
60
61
62
63 #if (MAJOR_NR == 1)
64
65 #define DEVICE_NAME "ramdisk"
66 #define DEVICE_REQUEST do_rd_request
67 #define DEVICE_NR(device) ((device) & 7)
68 #define DEVICE_ON(device)
69 #define DEVICE_OFF(device)
70
71 #elif (MAJOR_NR == 2)
72
73 #define DEVICE_NAME "floppy"
74 #define DEVICE_INTR do_floppy
75 #define DEVICE_REQUEST do_fd_request
76 #define DEVICE_NR(device) ((device) & 3)
77 #define DEVICE_ON(device) floppy_on(DEVICE_NR(device))
78 #define DEVICE_OFF(device) floppy_off(DEVICE_NR(device))
79
80 #elif (MAJOR_NR == 3)
81
82 #define DEVICE_NAME "harddisk"
83 #define DEVICE_INTR do_hd
84 #define DEVICE_TIMEOUT HD_TIMER
85 #define TIMEOUT_VALUE 600
86 #define DEVICE_REQUEST do_hd_request
87 #define DEVICE_NR(device) (MINOR(device)>>6)
88 #define DEVICE_ON(device)
89 #define DEVICE_OFF(device)
90
91 #elif
92
93 #error "unknown blk device"
94
95 #endif
96
97 #define CURRENT (blk_dev[MAJOR_NR].current_request)
98 #define CURRENT_DEV DEVICE_NR(CURRENT->dev)
99
100 #ifdef DEVICE_INTR
101 void (*DEVICE_INTR)(void) = NULL;
102 #endif
103 #ifdef DEVICE_TIMEOUT
104
105 #define SET_TIMER \
106 ((timer_table[DEVICE_TIMEOUT].expires = jiffies + TIMEOUT_VALUE), \
107 (timer_active |= 1<<DEVICE_TIMEOUT))
108
109 #define CLEAR_TIMER \
110 timer_active &= ~(1<<DEVICE_TIMEOUT)
111
112 #define SET_INTR(x) \
113 if (DEVICE_INTR = (x)) \
114 SET_TIMER; \
115 else \
116 CLEAR_TIMER;
117
118 #else
119
120 #define SET_INTR(x) (DEVICE_INTR = (x))
121
122 #endif
123 static void (DEVICE_REQUEST)(void);
124
125 extern inline void unlock_buffer(struct buffer_head * bh)
126 {
127 if (!bh->b_lock)
128 printk(DEVICE_NAME ": free buffer being unlocked\n");
129 bh->b_lock=0;
130 wake_up(&bh->b_wait);
131 }
132
133 extern inline void end_request(int uptodate)
134 {
135 DEVICE_OFF(CURRENT->dev);
136 if (CURRENT->bh) {
137 CURRENT->bh->b_uptodate = uptodate;
138 unlock_buffer(CURRENT->bh);
139 }
140 if (!uptodate) {
141 printk(DEVICE_NAME " I/O error\n\r");
142 printk("dev %04x, block %d\n\r",CURRENT->dev,
143 CURRENT->bh->b_blocknr);
144 }
145 wake_up(&CURRENT->waiting);
146 wake_up(&wait_for_request);
147 CURRENT->dev = -1;
148 CURRENT = CURRENT->next;
149 }
150
151 #ifdef DEVICE_INTR
152 #define CLEAR_INTR SET_INTR(NULL)
153 #else
154 #define CLEAR_INTR
155 #endif
156
157 #define INIT_REQUEST \
158 repeat: \
159 if (!CURRENT) {\
160 CLEAR_INTR; \
161 return; \
162 } \
163 if (MAJOR(CURRENT->dev) != MAJOR_NR) \
164 panic(DEVICE_NAME ": request list destroyed"); \
165 if (CURRENT->bh) { \
166 if (!CURRENT->bh->b_lock) \
167 panic(DEVICE_NAME ": block not locked"); \
168 }
169
170 #endif
171
172 #endif