summaryrefslogtreecommitdiff
path: root/i386/i386at/if_de6s.S
blob: cc697a23770720bb9510d4cfaccaf5ee476f583a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
/* 
 * Mach Operating System
 * Copyright (c) 1992 Carnegie Mellon University
 * All Rights Reserved.
 * 
 * Permission to use, copy, modify and distribute this software and its
 * documentation is hereby granted, provided that both the copyright
 * notice and this permission notice appear in all copies of the
 * software, derivative works or modified versions, and any portions
 * thereof, and that both notices appear in supporting documentation.
 * 
 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
 * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
 * 
 * Carnegie Mellon requests users of this software to return to
 * 
 *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
 *  School of Computer Science
 *  Carnegie Mellon University
 *  Pittsburgh PA 15213-3890
 * 
 * any improvements or extensions that they make and grant Carnegie Mellon
 * the rights to redistribute these changes.
 */

/* 
 * HISTORY
 * $Log: if_de6s.S,v $
 * Revision 1.1.1.1  1996/10/30 01:39:26  thomas
 * Imported from UK22
 *
# Revision 1.3  1995/04/26  19:22:12  baford
# got alignment working right for both ELF and a.out
#
# Revision 1.2  1995/04/25  16:13:28  baford
# got kernel working with ELF build tools
#
# Revision 1.1  1994/11/08  20:47:25  baford
# merged in CMU's MK83-MK83a diffs
#
 * Revision 2.2  93/11/17  18:33:19  dbg
 * 	Moved source into kernel/i386at/DLINK/if_de6c.c, since we
 * 	can't release it but don't want to lose it.
 * 	[93/11/17            dbg]
 * 
 * Revision 2.2.2.1  93/09/21  21:00:39  dbg
 * 	<no changes>
 * 
 * Revision 2.2.1.1  93/09/03  15:06:26  dbg
 * 	Created.
 * 	[92/08/13            rvb]
 * 
 *
 *	File:	if_de6s.s
 *	Author: Robert V. Baron
 */

#include <mach/machine/asm.h>
#undef DATA

#include <i386at/if_de6c.h>

	P2ALIGN(2)
de6csetmemaddr:
	movl	8(%ebp), %ebx		/* addr */
	movb 	%bl, %al		/* low byte; low nibble */
	salb	$4, %al
	orb	$(RW_ADR), %al
	outb	%al, %dx
	  movl	%edi, %ecx
0:	  loop	0b

	movb	%bl, %al		/* low byte; high nibble */
	andb	$0xf0, %al
	orb	$(RW_ADR|STROBE), %al
	outb	%al, %dx
	  movl	%edi, %ecx
0:	  loop	0b

	movb	%bh, %al		/* high byte; low nibble */
	salb	$4, %al
	orb	$(RW_ADR), %al
	outb	%al, %dx
	  movl	%edi, %ecx
0:	  loop	0b

	movb	%bh, %al		/* high byte; high nibble */
	andb	$0xf0, %al
	orb	$(RW_ADR|STROBE), %al
	outb	%al, %dx
	  movl	%edi, %ecx
0:	  loop	0b
	ret

/* de6cwriteasm(address, buf, len, port, delay) */
ENTRY(de6cwriteasm)
	pushl	%ebp
	movl	%esp, %ebp
	pushl	%edi
	pushl	%esi
	pushl	%ebx
	movl	20(%ebp), %edx		/* port */
	movl	24(%ebp), %edi		/* delay */

	call	de6csetmemaddr

	cld
	movl	16(%ebp), %ecx		/* cnt */
	movl	12(%ebp), %esi		/* source */

	cmpl	$1, %edi		/* no delay/latency */
	je	2f
1:	lodsb				/* leave delay/latency */
	  pushl	%ecx
	  movb	%al, %bl		/* high byte; low nibble */
	  salb	$4, %al
	  outb	%al, %dx
	    movl  %edi, %ecx
0:	    loop  0b

	  movb	%bl, %al		/* high byte; high nibble */
	  andb	$0xf0, %al
	  orb	$(WRITE|STROBE), %al	/* NB: WRITE == 0 */
	  outb	%al, %dx
	    movl  %edi, %ecx
0:	    loop  0b
	  popl	%ecx
	loop	1b

	popl	%ebx
	popl	%esi
	popl	%edi
	leave
	ret
					/* edi and ebx free */
2:	lodsb
	  movb	%al, %bl		/* high byte; low nibble */
	  salb	$4, %al
	  outb	%al, %dx

	  movb	%bl, %al		/* high byte; high nibble */
	  andb	$0xf0, %al
	  orb	$(WRITE|STROBE), %al	/* NB: WRITE == 0 */
	  outb	%al, %dx
	loop	2b

6:	popl	%ebx
	popl	%esi
	popl	%edi
	leave
	ret


/* de6creadasm(address, buf, len, port, delay) */
ENTRY(de6creadasm)
	pushl	%ebp
	movl	%esp, %ebp
	pushl	%edi
	pushl	%esi
	pushl	%ebx
	movl	20(%ebp), %edx		/* port */
	movl	24(%ebp), %edi		/* delay for desetmemaddr*/
	movl	%edi, %esi		/* delay; cause edi used by stosl */

	call	de6csetmemaddr

	cld
	movl	16(%ebp), %ecx		/* cnt */
	movl	12(%ebp), %edi		/* destination */
	movw	$0x0901, %bx		/* bl = 1 = READ; bh = READ|STROBE */

#ifdef	out_in
	cmpl	$1, %esi		/* no delay/latency */
	je	2f
#endif	/* out_in */
1:	xorw	%ax, %ax		/* leave delay/latency */
	pushl	%ecx
	  movb	%bl, %al
	  outb	%al, %dx
	    movl  %esi, %ecx
0:	    loop  0b
	   incw	%dx			/* inb from STAT == port + 1 */
	   inb	%dx, %al		/* first byte high nibble goes into */
	   decw	%dx
	  salw	$4, %ax			/* ... low nibble formed byte */

	  movb	%bh, %al
	  outb	%al, %dx
	    movl  %esi, %ecx
0:	    loop  0b
	   incw	%dx			/* inb from STAT == port + 1 */
	   inb	%dx, %al		/* second byte high nibble goes into */
	   decw	%dx
	  andb	$0xf0, %al		/* ... high nibble formed byte */
	  orb	%ah, %al
	stosb
	popl	%ecx
	loop	1b

	popl	%ebx
	popl	%esi
	popl	%edi
	leave
	ret

2:	xorw	%ax, %ax		/* leave delay/latency */
	  movb	%bl, %al
	  outb	%al, %dx
	   incw	%dx			/* inb from STAT == port + 1 */
	   inb	%dx, %al		/* high nibble goes into low nibble */
	   decw	%dx
	  salw	$4, %ax

	  movb	%bh, %al
	  outb	%al, %dx
	   incw	%dx			/* inb from STAT == port + 1 */
	   inb	%dx, %al
	   decw	%dx
	  andb	$0xf0, %al
	  orb	%ah, %al
	stosb
	loop	2b

	popl	%ebx
	popl	%esi
	popl	%edi
	leave
	ret


#ifdef	unroll_wins
	unrolled loop for write iff no delay
2:	lodsl
	  movl	%eax, %ebx		/* byte one; low nibble */
	  salb	$4, %al
	  outb	%al, %dx

	  movb	%bl, %al		/* byte one; high nibble */
	  andb	$0xf0, %al
	  orb	$8, %al
	  outb	%al, %dx
loop	3f
jmp	6f
3:	  sarl	$8, %ebx
	  movb	%bl, %al		/* byte two; low nibble */
	  salb	$4, %al
	  outb	%al, %dx

	  movb	%bl, %al		/* byte two; high nibble */
	  andb	$0xf0, %al
	  orb	$8, %al
	  outb	%al, %dx
loop	4f
jmp	6f
4:	  sarl	$8, %ebx
	  movb	%bl, %al		/* byte three; low nibble */
	  salb	$4, %al
	  outb	%al, %dx

	  movb	%bl, %al		/* byte three; high nibble */
	  andb	$0xf0, %al
	  orb	$8, %al
	  outb	%al, %dx
loop	5f
jmp	6f
5:	  sarl	$8, %ebx
	  movb	%bl, %al		/* byte three; low nibble */
	  salb	$4, %al
	  outb	%al, %dx

	  movb	%bl, %al		/* byte four; high nibble */
	  andb	$0xf0, %al
	  orb	$8, %al
	  outb	%al, %dx
	loop	2b
#endif	/* unroll_wins */