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

Subversion Repositories test_project

[/] [test_project/] [trunk/] [linux_sd_driver/] [arch/] [or32/] [kernel/] [misc.S] - Blame information for rev 79

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

Line No. Rev Author Line
1 62 marcus.erl
/*
2
 *  linux/arch/or32/kernel/misc.S
3
 *
4
 *  or32 version
5
 *    author(s): Simon Srot (srot@opencores.org)
6
 *
7
 *  derived from cris, i386, m68k, ppc, sh ports.
8
 *
9
 *  changes:
10
 *  18. 11. 2003: Matjaz Breskvar (phoenix@bsemi.com)
11
 *    initial port to or32 architecture
12
 *
13
 */
14
#include 
15
#include 
16
#include 
17
 
18
/* defined in  */
19
#define CLONE_VM  0x00000100
20
 
21
        /*
22
         * we could avoid saving of some registers
23
         * if we could guarantee certian functions to be inlined
24
         */
25
 
26
        .text
27
/*
28
 * Enable interrupts
29
 *      sti()
30
 */
31
        .global ___sti
32
___sti:
33
        l.addi  r1,r1,-0x4
34
        l.sw    0x0(r1),r3
35
 
36
        l.mfspr r3,r0,SPR_SR
37
        l.ori   r3,r3,(SPR_SR_IEE | SPR_SR_TEE)
38
        l.mtspr r0,r3,SPR_SR
39
        l.lwz   r3,0x0(r1)
40
        l.jr    r9
41
        l.addi  r1,r1,0x4
42
 
43
/*
44
 * Disable interrupts
45
 *      cli()
46
 */
47
        .global ___cli
48
___cli:
49
        l.addi  r1,r1,-0x8
50
        l.sw    0x0(r1),r4
51
        l.sw    0x4(r1),r3
52
 
53
//      l.sw    -0x4(r1),r4
54
        l.addi  r4,r0,-1
55
        l.xori  r4,r4,(SPR_SR_IEE | SPR_SR_TEE)
56
        l.mfspr r3,r0,SPR_SR
57
        l.and   r3,r3,r4
58
        l.mtspr r0,r3,SPR_SR
59
 
60
        l.lwz   r4,0x0(r1)
61
        l.lwz   r3,0x4(r1)
62
        l.jr    r9
63
        l.addi  r1,r1,0x8
64
//      l.lwz   r4,-0x4(r1)
65
 
66
/*
67
 * Get 'flags' (aka status register)
68
 *      save_flags(long *ptr)
69
 */
70
        .global ___save_flags
71
___save_flags:
72
        l.addi  r1,r1,-0x4
73
        l.sw    0x0(r1),r4
74
 
75
//      l.sw    -0x4(r1),r4
76
        l.mfspr r4,r0,SPR_SR
77
        l.sw    0(r3),r4
78
 
79
        l.lwz   r4,0x0(r1)
80
        l.jr    r9
81
        l.addi  r1,r1,0x4
82
//      l.lwz   r4,-0x4(r1)
83
 
84
/*
85
 * Get 'flags' and disable interrupts
86
 *      save_and_cli(long *ptr)
87
 */
88
        .global ___save_and_cli
89
___save_and_cli:
90
        l.addi  r1,r1,-0x8
91
        l.sw    0x0(r1),r4
92
        l.sw    0x4(r1),r3
93
 
94
//      l.sw    -0x4(r1),r4
95
        l.mfspr r4,r0,SPR_SR
96
        l.sw    0(r3),r4
97
        l.addi  r4,r0,-1
98
        l.xori  r4,r4,(SPR_SR_IEE | SPR_SR_TEE)
99
        l.mfspr r3,r0,SPR_SR
100
        l.and   r3,r3,r4
101
        l.mtspr r0,r3,SPR_SR
102
 
103
        l.lwz   r4,0x0(r1)
104
        l.lwz   r3,0x4(r1)
105
        l.jr    r9
106
        l.addi  r1,r1,0x8
107
//      l.lwz   r4,-0x4(r1)
108
 
109
/*
110
 * Restore 'flags'
111
 *      restore_flags(long val)
112
 */
113
        .global ___restore_flags
114
___restore_flags:
115
        l.mtspr r0,r3,SPR_SR
116
        l.jr    r9
117
        l.nop
118
 
119
/*
120
 * Create a kernel thread
121
 *   kernel_thread(fn, arg, flags)
122
 */
123
  .global _kernel_thread
124
_kernel_thread:
125
        l.addi  r1,r1,-8
126
        l.sw    0x0(r1),r6
127
        l.sw    0x4(r1),r3
128
 
129
        /* __PHX__ do we need to save the stat ??? */
130
        l.add   r6,r0,r3                /* function */
131
        l.ori   r3,r5,CLONE_VM          /* flags */
132
        /* __PHX__ needs also CLONE_UNTRACED */
133
        l.addi  r11,r0,__NR_clone
134
        l.sys   1
135
        l.sfeqi r11,0                   /* parent or child? */
136
        l.bnf   1f                      /* return if parent */
137
        l.nop
138
        l.addi  r1,r1,-16               /* make top-level stack frame */
139
        l.sw    0(r1),r0
140
        l.jalr  r6                      /* load arg and call fn */
141
        l.add   r3,r0,r4
142
        l.add   r3,r3,r11
143
        l.addi  r11,r0,__NR_exit        /* exit after child exits */
144
        l.sys   1
145
1:
146
        l.lwz   r6,0x0(r1)
147
        l.lwz   r3,0x4(r1)
148
        l.jr    r9
149
        l.addi  r1,r1,8
150
 
151
#if 0
152
 
153
/*
154
 * Instruction cache enable
155
 *      ic_enable()
156
 */
157
        .global ___ic_enable
158
___ic_enable:
159
        /* Disable IC */
160
        l.mfspr r13,r0,SPR_SR
161
        l.addi  r11,r0,-1
162
        l.xori  r11,r11,SPR_SR_ICE
163
        l.and   r11,r13,r11
164
        l.mtspr r0,r11,SPR_SR
165
 
166
        /* Invalidate IC */
167
        l.addi  r13,r0,0
168
        l.addi  r11,r0,IC_SIZE
169
1:
170
        l.mtspr r0,r13,SPR_ICBIR
171
        l.sfne  r13,r11
172
        l.bf    1b
173
        l.addi  r13,r13,IC_LINE
174
 
175
        /* Enable IC */
176
        l.mfspr r13,r0,SPR_SR
177
        l.ori   r13,r13,SPR_SR_ICE
178
        l.mtspr r0,r13,SPR_SR
179
        l.nop
180
        l.nop
181
        l.nop
182
        l.nop
183
        l.nop
184
 
185
        l.jr    r9
186
        l.nop
187
 
188
/*
189
 * Instruction cache disable
190
 *      ic_disable()
191
 */
192
        .global ___ic_disable
193
___ic_disable:
194
        /* Disable IC */
195
        l.mfspr r13,r0,SPR_SR
196
        l.addi  r11,r0,-1
197
        l.xori  r11,r11,SPR_SR_ICE
198
        l.and   r11,r13,r11
199
        l.mtspr r0,r11,SPR_SR
200
 
201
        l.jr    r9
202
        l.nop
203
 
204
/*
205
 * Instruction cache invalidate
206
 *      ic_flush()
207
 */
208
        .global ___ic_invalidate
209
___ic_invalidate:
210
        /* Disable IC */
211
        l.mfspr r13,r0,SPR_SR
212
        l.addi  r11,r0,-1
213
        l.xori  r11,r11,SPR_SR_ICE
214
        l.and   r11,r13,r11
215
        l.mtspr r0,r11,SPR_SR
216
 
217
        /* Invalidate IC */
218
        l.addi  r13,r0,0
219
        l.addi  r11,r0,IC_SIZE
220
1:
221
        l.mtspr r0,r13,SPR_ICBIR
222
        l.sfne  r13,r11
223
        l.bf    1b
224
        l.addi  r13,r13,IC_LINE
225
 
226
        /* Enable IC */
227
        l.mfspr r13,r0,SPR_SR
228
        l.ori   r13,r13,SPR_SR_ICE
229
        l.mtspr r0,r13,SPR_SR
230
        l.nop
231
        l.nop
232
        l.nop
233
        l.nop
234
        l.nop
235
 
236
        l.jr    r9
237
        l.nop
238
 
239
/*
240
 * Data cache enable
241
 *      dc_enable()
242
 */
243
        .global ___dc_enable
244
___dc_enable:
245
  /* Disable DC */
246
        l.mfspr r13,r0,SPR_SR
247
        l.addi  r11,r0,-1
248
        l.xori  r11,r11,SPR_SR_DCE
249
        l.and   r11,r13,r11
250
        l.mtspr r0,r11,SPR_SR
251
 
252
        /* Flush DC */
253
        l.addi  r13,r0,0
254
        l.addi  r11,r0,DC_SIZE
255
1:
256
        l.mtspr r0,r13,SPR_DCBIR
257
        l.sfne  r13,r11
258
        l.bf    1b
259
        l.addi  r13,r13,DC_LINE
260
 
261
        /* Enable DC */
262
        l.mfspr r13,r0,SPR_SR
263
        l.ori   r13,r13,SPR_SR_DCE
264
        l.mtspr r0,r13,SPR_SR
265
 
266
        l.jr    r9
267
        l.nop
268
 
269
/*
270
 * Data cache disable
271
 *      dc_disable()
272
 */
273
        .global ___dc_disable
274
___dc_disable:
275
        /* Disable DC */
276
        l.mfspr r13,r0,SPR_SR
277
        l.addi  r11,r0,-1
278
        l.xori  r11,r11,SPR_SR_DCE
279
        l.and   r11,r13,r11
280
        l.mtspr r0,r11,SPR_SR
281
 
282
        l.jr    r9
283
        l.nop
284
 
285
/*
286
 * Invalidate data cache line
287
 *      dc_line_invalidate(long ph_add)
288
 */
289
        .global ___dc_line_invalidate
290
___dc_line_invalidate:
291
  l.mfspr r4,r0,SPR_SR
292
  l.addi  r5,r0,-1
293
  l.xori  r5,r5,SPR_SR_DCE
294
  l.and   r5,r4,r5
295
  l.mtspr r0,r5,SPR_SR
296
  l.mtspr r0,r3,SPR_DCBIR
297
  l.mtspr r0,r4,SPR_SR
298
  l.jr    r9
299
  l.nop
300
 
301
/*
302
 * Data MMU enable
303
 *      dmmu_enable()
304
 */
305
        .global ___dmmu_enable
306
___dmmu_enable:
307
  /* Invalidate all sets */
308
  l.addi  r11,r0,DMMU_SET_NB
309
  l.addi  r13,r0,0
310
1:
311
  l.mtspr r13,r0,SPR_DTLBMR_BASE(0)
312
  l.addi  r11,r11,-1
313
  l.sfeqi r11,0
314
  l.bnf   1b
315
  l.addi  r13,r13,1
316
  l.mfspr r11,r0,SPR_SR
317
  l.ori   r11,r11,SPR_SR_DME
318
  l.mtspr r0,r11,SPR_SR
319
  l.jr    r9
320
  l.nop
321
 
322
/*
323
 * Instruction MMU enable
324
 *      immu_enable()
325
 */
326
        .global ___immu_enable
327
___immu_enable:
328
  /* Invalidate all sets */
329
  l.addi  r11,r0,IMMU_SET_NB
330
  l.addi  r13,r0,0
331
1:
332
  l.mtspr r13,r0,SPR_ITLBMR_BASE(0)
333
  l.addi  r11,r11,-1
334
  l.sfeqi r11,0
335
  l.bnf   1b
336
  l.addi  r13,r13,1
337
  l.mfspr r11,r0,SPR_SR
338
  l.ori   r11,r11,SPR_SR_IME
339
  l.mtspr r0,r11,SPR_SR
340
  l.nop
341
  l.nop
342
  l.nop
343
  l.nop
344
  l.jr    r9
345
  l.nop
346
#endif
347
 
348
 /*
349
 * Print utility
350
 *      print(const char *fmt, ...)
351
 */
352
        .global ___print
353
___print:
354
        l.lwz   r3,0(r1)
355
        l.addi  r4,r1,4
356
#       l.sys   202
357
  l.nop 3
358
        l.jr    r9
359
        l.nop
360
 

powered by: WebSVN 2.1.0

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