OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [uclinux/] [uClinux-2.0.x/] [arch/] [armnommu/] [lib/] [io-acorn.S] - Blame information for rev 1775

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 199 simons
/*
2
 * linux/arch/arm/lib/io.S
3
 *
4
 * Copyright (C) 1995, 1996 Russell King
5
 */
6
#include 
7
#include 
8
#include 
9
 
10
                .text
11
                .align
12
 
13
#define OUT(reg)                                                \
14
                mov     r8, reg, lsl $16                        ;\
15
                orr     r8, r8, r8, lsr $16                     ;\
16
                str     r8, [r3, r0, lsl $2]                    ;\
17
                mov     r8, reg, lsr $16                        ;\
18
                orr     r8, r8, r8, lsl $16                     ;\
19
                str     r8, [r3, r0, lsl $2]
20
 
21
#define IN(reg)                                                 \
22
                ldr     reg, [r0]                               ;\
23
                and     reg, reg, ip                            ;\
24
                ldr     lr, [r0]                                ;\
25
                orr     reg, reg, lr, lsl $16
26
 
27
#if (IO_BASE == (PCIO_BASE & 0xff000000))
28
#define ADDR(off,reg)                                           \
29
                tst     off, $0x80000000                        ;\
30
                mov     reg, $IO_BASE                           ;\
31
                orreq   reg, reg, $(PCIO_BASE & 0x00ff0000)
32
#else
33
#define ADDR(off,reg)                                           \
34
                tst     off, $0x80000000                        ;\
35
                movne   reg, $IO_BASE                           ;\
36
                moveq   reg, $(PCIO_BASE & 0xff000000)		;\
37
                orreq   reg, reg, $(PCIO_BASE & 0x00ff0000)
38
#endif
39
 
40
@ purpose: read a byte from a hardware register.
41
@ Proto  : unsigned char inb(int address);
42
 
43
                .global ___inb
44
                .global ___inb_p
45
                .global ___inbc
46
                .global ___inbc_p
47
___inb:
48
___inb_p:
49
___inbc:
50
___inbc_p:
51
                ADDR(r0,r2)
52
                ldrb    r0, [r2, r0, lsl#2]
53
                RETINSTR(mov,pc,lr)
54
 
55
@ purpose: read a short word from a hardware register.
56
@ Proto  : unsigned short inw(int address);
57
 
58
                .global ___inw
59
___inw:         ADDR(r0,r2)
60
                ldr     r0, [r2, r0, lsl#2]
61
                bic     r0, r0, #0xff000000
62
                bic     r0, r0, #0x00ff0000
63
                RETINSTR(mov,pc,lr)
64
 
65
@ Purpose: write a byte to a hardware register.
66
@ Proto  : outb(unsigned char c,int address);
67
 
68
                .global ___outb
69
                .global ___outb_p
70
                .global ___outbc
71
                .global ___outbc_p
72
___outb:
73
___outb_p:
74
___outbc:
75
___outbc_p:
76
                ADDR(r1,r2)
77
                strb    r0,[r2,r1,LSL#2]
78
                RETINSTR(mov,pc,lr)
79
 
80
@ Purpose: write a short to a hardware register.
81
@ Proto  : outw(unsigned short c,int address);
82
 
83
                .global ___outw
84
___outw:        ADDR(r1,r2)
85
                orr     r0, r0, r0, lsl#16
86
                str     r0, [r2, r1, lsl#2]
87
                RETINSTR(mov,pc,lr)
88
 
89
@ Purpose: read a block of data from a hardware register to memory.
90
@ Proto  : insw(int from_port, void *to, int len_in_words);
91
@ Proto  : inswb(int from_port, void *to, int len_in_bytes);
92
@ Notes  : increment to
93
 
94
                .global _insw
95
                .global _inswb
96
_insw:          mov     r2, r2, lsl#1
97
_inswb:         mov     ip, sp
98
                stmfd   sp!, {r4 - r10 ,fp ,ip ,lr ,pc}
99
                sub     fp, ip, #4
100
                ADDR(r0,r3)
101
                add     r0, r3, r0, lsl #2
102
                tst     r1, #3
103
                beq     Linswok
104
                tst     r1, #1
105
                bne     Linsw_notaligned
106
                cmp     r2, #1
107
                ldrge   r4, [r0]
108
                strgeb  r4, [r1], #1
109
                movgt   r4, r4, LSR#8
110
                strgtb  r4, [r1], #1
111
                ldmleea fp, {r4 - r10, fp, sp, pc}^
112
                sub     r2, r2, #2
113
Linswok:        mov     ip, #0xFF
114
                orr     ip, ip, ip, lsl #8
115
Linswlp:        subs    r2, r2, #64
116
                bmi     Linsw_toosmall
117
                IN(r3)
118
                IN(r4)
119
                IN(r5)
120
                IN(r6)
121
                IN(r7)
122
                IN(r8)
123
                IN(r9)
124
                IN(r10)
125
                stmia   r1!, {r3 - r10}
126
                IN(r3)
127
                IN(r4)
128
                IN(r5)
129
                IN(r6)
130
                IN(r7)
131
                IN(r8)
132
                IN(r9)
133
                IN(r10)
134
                stmia   r1!, {r3 - r10}
135
                bne     Linswlp
136
                LOADREGS(ea, fp, {r4 - r10, fp, sp, pc})
137
Linsw_toosmall:
138
                adds    r2, r2, #32
139
                bmi     Linsw_toosmall2
140
Linsw2lp:       IN(r3)
141
                IN(r4)
142
                IN(r5)
143
                IN(r6)
144
                IN(r7)
145
                IN(r8)
146
                IN(r9)
147
                IN(r10)
148
                stmia   r1!, {r3 - r10}
149
                LOADREGS(eqea, fp, {r4 - r10, fp, sp, pc})
150
                b       Linsw_notaligned
151
Linsw_toosmall2:
152
                add     r2, r2, #32
153
Linsw_notaligned:
154
                cmp     r2, #1
155
                LOADREGS(ltea, fp, {r4 - r10, fp, sp, pc})
156
                ldr     r4, [r0]
157
                strb    r4, [r1], #1
158
                movgt   r4, r4, LSR#8
159
                strgtb  r4, [r1], #1
160
                subs    r2, r2, #2
161
                bgt     Linsw_notaligned
162
                LOADREGS(ea, fp, {r4 - r10, fp, sp, pc})
163
 
164
@ Purpose: write a block of data from memory to a hardware register.
165
@ Proto  : outsw(int to_reg, void *from, int len_in_words);
166
@ Proto  : outswb(int to_reg, void *from, int len_in_bytes);
167
@ Notes  : increments from
168
 
169
                .global _outsw
170
                .global _outswb
171
_outsw:         mov     r2, r2, LSL#1
172
_outswb:        mov     ip, sp
173
                stmfd   sp!, {r4 - r8, fp, ip, lr, pc}
174
                sub     fp, ip, #4
175
                ADDR(r0,r3)
176
                tst     r1, #2
177
                beq     Loutsw32lp
178
                ldr     r4, [r1], #2
179
                mov     r4, r4, lsl #16
180
                orr     r4, r4, r4, lsr #16
181
                str     r4, [r3, r0, lsl #2]
182
                sub     r2, r2, #2
183
                teq     r2, #0
184
                LOADREGS(eqea, fp, {r4 - r8, fp, sp, pc})
185
Loutsw32lp:     subs    r2,r2,#32
186
                blt     Loutsw_toosmall
187
                ldmia   r1!,{r4,r5,r6,r7}
188
                OUT(r4)
189
                OUT(r5)
190
                OUT(r6)
191
                OUT(r7)
192
                ldmia   r1!,{r4,r5,r6,r7}
193
                OUT(r4)
194
                OUT(r5)
195
                OUT(r6)
196
                OUT(r7)
197
                LOADREGS(eqea, fp, {r4 - r8, fp, sp, pc})
198
                b       Loutsw32lp
199
Loutsw_toosmall:
200
                adds    r2,r2,#32
201
                LOADREGS(eqea, fp, {r4 - r8, fp, sp, pc})
202
Llpx:           ldr     r4,[r1],#2
203
                mov     r4,r4,LSL#16
204
                orr     r4,r4,r4,LSR#16
205
                str     r4,[r3,r0,LSL#2]
206
                subs    r2,r2,#2
207
                bgt     Llpx
208
                LOADREGS(ea, fp, {r4 - r8, fp, sp, pc})
209
 
210
@ Purpose: write a memc register
211
@ Proto  : void memc_write(int register, int value);
212
@ Returns: nothing
213
 
214
#ifndef CONFIG_ARCH_RPC
215
                .globl  _memc_write
216
_memc_write:    cmp     r0, #7
217
                RETINSTR(movgt,pc,lr)
218
                mov     r0, r0, lsl #17
219
                mov     r1, r1, lsl #15
220
                mov     r1, r1, lsr #17
221
                orr     r0, r0, r1, lsl #2
222
                add     r0, r0, #0x03600000
223
                strb    r0, [r0]
224
                RETINSTR(mov,pc,lr)
225
#define CPSR2SPSR(rt)
226
#else
227
#define CPSR2SPSR(rt) \
228
                mrs     rt, cpsr; \
229
                msr     spsr, rt
230
#endif
231
 
232
@ Purpose: call an expansion card loader to read bytes.
233
@ Proto  : char read_loader(int offset, char *card_base, char *loader);
234
@ Returns: byte read
235
 
236
                .global _ecard_loader_read
237
_ecard_loader_read:
238
                stmfd   sp!, {r4 - r12, lr}
239
                mov     r11, r1
240
                mov     r1, r0
241
                CPSR2SPSR(r0)
242
                mov     lr, pc
243
                mov     pc, r2
244
                LOADREGS(fd, sp!, {r4 - r12, pc})
245
 
246
@ Purpose: call an expansion card loader to reset the card
247
@ Proto  : void read_loader(int card_base, char *loader);
248
@ Returns: byte read
249
 
250
                .global _ecard_loader_reset
251
_ecard_loader_reset:
252
                stmfd   sp!, {r4 - r12, lr}
253
                mov     r11, r0
254
                CPSR2SPSR(r0)
255
                mov     lr, pc
256
                add     pc, r1, #8
257
                LOADREGS(fd, sp!, {r4 - r12, pc})

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.