This source file includes following definitions.
- big_endianize_driveid
1 #ifndef _M68K_IDE_H
2 #define _M68K_IDE_H
3
4
5
6
7 #include <linux/config.h>
8
9 #ifdef CONFIG_AMIGA
10 #include <asm/amigahw.h>
11 #include <asm/amihdreg.h>
12 #include <asm/amigaints.h>
13 #endif
14
15 #ifdef CONFIG_ATARI
16 #include <asm/atarihw.h>
17 #include <asm/atarihdreg.h>
18 #include <asm/atariints.h>
19 #include <asm/atari_stdma.h>
20 #endif
21
22 #include <asm/bootinfo.h>
23
24 struct hd_regs_struct {
25 unsigned int hd_error,
26 hd_nsector,
27 hd_sector,
28 hd_lcyl,
29 hd_hcyl,
30 hd_select,
31 hd_status;
32 };
33
34 static struct hd_regs_struct hd_regs;
35 static void probe_m68k_ide (void);
36
37
38 #undef IDE_ERROR_OFFSET
39 #undef IDE_NSECTOR_OFFSET
40 #undef IDE_SECTOR_OFFSET
41 #undef IDE_LCYL_OFFSET
42 #undef IDE_HCYL_OFFSET
43 #undef IDE_SELECT_OFFSET
44 #undef IDE_STATUS_OFFSET
45 #undef IDE_FEATURE_OFFSET
46 #undef IDE_COMMAND_OFFSET
47 #undef SELECT_DRIVE
48
49 #define IDE_ERROR_OFFSET hd_regs.hd_error
50 #define IDE_NSECTOR_OFFSET hd_regs.hd_nsector
51 #define IDE_SECTOR_OFFSET hd_regs.hd_sector
52 #define IDE_LCYL_OFFSET hd_regs.hd_lcyl
53 #define IDE_HCYL_OFFSET hd_regs.hd_hcyl
54 #define IDE_SELECT_OFFSET hd_regs.hd_select
55 #define IDE_STATUS_OFFSET hd_regs.hd_status
56 #define IDE_FEATURE_OFFSET IDE_ERROR_OFFSET
57 #define IDE_COMMAND_OFFSET IDE_STATUS_OFFSET
58
59 #undef SUPPORT_VLB_SYNC
60 #define SUPPORT_VLB_SYNC 0
61
62 #undef HD_DATA
63 #define HD_DATA NULL
64
65 #define SELECT_DRIVE(hwif,drive) OUT_BYTE((drive)->select.all, hwif->io_base+IDE_SELECT_OFFSET);
66
67 #define insl(data_reg, buffer, wcount) insw(data_reg, buffer, wcount<<1)
68 #define outsl(data_reg, buffer, wcount) outsw(data_reg, buffer, wcount<<1)
69
70 #define insw(port, buf, nr) \
71 if (nr % 16) \
72 __asm__ __volatile__ \
73 ("movel %0,%/a0; \
74 movel %1,%/a1; \
75 movel %2,%/d6; \
76 subql #1,%/d6; \
77 1:movew %/a0@,%/a1@+; \
78 dbra %/d6,1b" : \
79 : "g" (port), "g" (buf), "g" (nr) \
80 : "a0", "a1", "d6"); \
81 else \
82 __asm__ __volatile__ \
83 ("movel %0,%/a0; \
84 movel %1,%/a1; \
85 movel %2,%/d6; \
86 lsrl #4,%/d6; \
87 subql #1,%/d6; \
88 1:movew %/a0@,%/a1@+; \
89 movew %/a0@,%/a1@+; \
90 movew %/a0@,%/a1@+; \
91 movew %/a0@,%/a1@+; \
92 movew %/a0@,%/a1@+; \
93 movew %/a0@,%/a1@+; \
94 movew %/a0@,%/a1@+; \
95 movew %/a0@,%/a1@+; \
96 movew %/a0@,%/a1@+; \
97 movew %/a0@,%/a1@+; \
98 movew %/a0@,%/a1@+; \
99 movew %/a0@,%/a1@+; \
100 movew %/a0@,%/a1@+; \
101 movew %/a0@,%/a1@+; \
102 movew %/a0@,%/a1@+; \
103 movew %/a0@,%/a1@+; \
104 dbra %/d6,1b" : \
105 : "g" (port), "g" (buf), "g" (nr) \
106 : "a0", "a1", "d6");
107
108 #define outsw(port, buf, nr) \
109 if (nr % 16) \
110 __asm__ __volatile__ \
111 ("movel %0,%/a0; \
112 movel %1,%/a1; \
113 movel %2,%/d6; \
114 subql #1,%/d6; \
115 1:movew %/a1@+,%/a0@; \
116 dbra %/d6,1b" : \
117 : "g" (port), "g" (buf), "g" (nr) \
118 : "a0", "a1", "d6"); \
119 else \
120 __asm__ __volatile__ \
121 ("movel %0,%/a0; \
122 movel %1,%/a1; \
123 movel %2,%/d6; \
124 lsrl #4,%/d6; \
125 subql #1,%/d6; \
126 1:movew %/a1@+,%/a0@; \
127 movew %/a1@+,%/a0@; \
128 movew %/a1@+,%/a0@; \
129 movew %/a1@+,%/a0@; \
130 movew %/a1@+,%/a0@; \
131 movew %/a1@+,%/a0@; \
132 movew %/a1@+,%/a0@; \
133 movew %/a1@+,%/a0@; \
134 movew %/a1@+,%/a0@; \
135 movew %/a1@+,%/a0@; \
136 movew %/a1@+,%/a0@; \
137 movew %/a1@+,%/a0@; \
138 movew %/a1@+,%/a0@; \
139 movew %/a1@+,%/a0@; \
140 movew %/a1@+,%/a0@; \
141 movew %/a1@+,%/a0@; \
142 dbra %/d6,1b" : \
143 : "g" (port), "g" (buf), "g" (nr) \
144 : "a0", "a1", "d6");
145
146 #define T_CHAR (0x0000)
147 #define T_SHORT (0x4000)
148 #define T_INT (0x8000)
149 #define T_TEXT (0xc000)
150
151 #define T_MASK_TYPE (0xc000)
152 #define T_MASK_COUNT (0x3fff)
153
154 #define D_CHAR(cnt) (T_CHAR | (cnt))
155 #define D_SHORT(cnt) (T_SHORT | (cnt))
156 #define D_INT(cnt) (T_INT | (cnt))
157 #define D_TEXT(cnt) (T_TEXT | (cnt))
158
159 static u_short driveid_types[] = {
160 D_SHORT(10),
161 D_TEXT(20),
162 D_SHORT(3),
163 D_TEXT(48),
164 D_CHAR(2),
165 D_SHORT(1),
166 D_CHAR(2),
167 D_SHORT(1),
168 D_CHAR(4),
169 D_SHORT(4),
170 D_INT(1),
171 D_CHAR(2),
172 D_INT(1),
173 D_SHORT(194)
174 };
175
176 #define num_driveid_types (sizeof(driveid_types)/sizeof(*driveid_types))
177
178 static __inline__ void big_endianize_driveid(struct hd_driveid *id)
179 {
180 u_char *p = (u_char *)id;
181 int i, j, cnt;
182 u_char t;
183
184 for (i = 0; i < num_driveid_types; i++) {
185 cnt = driveid_types[i] & T_MASK_COUNT;
186 switch (driveid_types[i] & T_MASK_TYPE) {
187 case T_CHAR:
188 p += cnt;
189 break;
190 case T_SHORT:
191 for (j = 0; j < cnt; j++) {
192 t = p[0];
193 p[0] = p[1];
194 p[1] = t;
195 p += 2;
196 }
197 break;
198 case T_INT:
199 for (j = 0; j < cnt; j++) {
200 t = p[0];
201 p[0] = p[3];
202 p[3] = t;
203 t = p[1];
204 p[1] = p[2];
205 p[2] = t;
206 p += 4;
207 }
208 break;
209 case T_TEXT:
210 for (j = 0; j < cnt; j += 2) {
211 t = p[0];
212 p[0] = p[1];
213 p[1] = t;
214 p += 2;
215 }
216 break;
217 }
218 }
219 }
220
221 #endif