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 #ifdef MAJOR_NR
55
56
57
58
59
60
61 #if (MAJOR_NR == 1)
62
63 #define DEVICE_NAME "ramdisk"
64 #define DEVICE_REQUEST do_rd_request
65 #define DEVICE_NR(device) ((device) & 7)
66 #define DEVICE_ON(device)
67 #define DEVICE_OFF(device)
68
69 #elif (MAJOR_NR == 2)
70
71 #define DEVICE_NAME "floppy"
72 #define DEVICE_INTR do_floppy
73 #define DEVICE_REQUEST do_fd_request
74 #define DEVICE_NR(device) ((device) & 3)
75 #define DEVICE_ON(device) floppy_on(DEVICE_NR(device))
76 #define DEVICE_OFF(device) floppy_off(DEVICE_NR(device))
77
78 #elif (MAJOR_NR == 3)
79
80 #define DEVICE_NAME "harddisk"
81 #define DEVICE_INTR do_hd
82 #define DEVICE_REQUEST do_hd_request
83 #define DEVICE_NR(device) (MINOR(device)/5)
84 #define DEVICE_ON(device)
85 #define DEVICE_OFF(device)
86
87 #elif
88
89 #error "unknown blk device"
90
91 #endif
92
93 #define CURRENT (blk_dev[MAJOR_NR].current_request)
94 #define CURRENT_DEV DEVICE_NR(CURRENT->dev)
95
96 #ifdef DEVICE_INTR
97 void (*DEVICE_INTR)(void) = NULL;
98 #endif
99 static void (DEVICE_REQUEST)(void);
100
101 extern inline void unlock_buffer(struct buffer_head * bh)
102 {
103 if (!bh->b_lock)
104 printk(DEVICE_NAME ": free buffer being unlocked\n");
105 bh->b_lock=0;
106 wake_up(&bh->b_wait);
107 }
108
109 extern inline void end_request(int uptodate)
110 {
111 DEVICE_OFF(CURRENT->dev);
112 if (CURRENT->bh) {
113 CURRENT->bh->b_uptodate = uptodate;
114 unlock_buffer(CURRENT->bh);
115 }
116 if (!uptodate) {
117 printk(DEVICE_NAME " I/O error\n\r");
118 printk("dev %04x, block %d\n\r",CURRENT->dev,
119 CURRENT->bh->b_blocknr);
120 }
121 wake_up(&CURRENT->waiting);
122 wake_up(&wait_for_request);
123 CURRENT->dev = -1;
124 CURRENT = CURRENT->next;
125 }
126
127 #define INIT_REQUEST \
128 repeat: \
129 if (!CURRENT) \
130 return; \
131 if (MAJOR(CURRENT->dev) != MAJOR_NR) \
132 panic(DEVICE_NAME ": request list destroyed"); \
133 if (CURRENT->bh) { \
134 if (!CURRENT->bh->b_lock) \
135 panic(DEVICE_NAME ": block not locked"); \
136 }
137
138 #endif
139
140 #endif