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

Subversion Repositories or1k_old

[/] [or1k_old/] [trunk/] [rc203soc/] [sw/] [uClinux/] [arch/] [armnommu/] [mm/] [proc-arm2,3.S] - Blame information for rev 1782

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1622 jcastillo
/*
2
 * linux/arch/arm/mm/arm2,3.S: MMU functions for ARM2,3
3
 *
4
 * (C) 1997 Russell King
5
 *
6
 * These are the low level assembler for performing cache
7
 * and memory functions on ARM2, ARM250 and ARM3 processors.
8
 */
9
 
10
#include 
11
#include "../lib/constants.h"
12
 
13
/*
14
 * Code common to all processors - MEMC specific not processor
15
 * specific!
16
 */
17
 
18
LC1:            .word   _page_nr
19
/*
20
 * Function: arm2_3_update_map (struct task_struct *tsk)
21
 *
22
 * Params  : tsk        Task structure to be updated
23
 *
24
 * Purpose : Re-generate memc maps for task from its pseudo page tables
25
 */
26
_arm2_3_update_map:
27
                mov     ip, sp
28
                stmfd   sp!, {r4 - r6, fp, ip, lr, pc}
29
                sub     fp, ip, #4
30
                add     r1, r0, #TSS_MEMCMAP
31
                ldr     r2, LC1
32
                ldr     r2, [r2]
33
                mov     r3, #0x03f00000
34
                orr     r3, r3, #0x00000f00
35
                orr     r4, r3, #1
36
                orr     r5, r3, #2
37
                orr     r6, r3, #3
38
1:              stmia   r1!, {r3, r4, r5, r6}           @ Default mapping (null mapping)
39
                add     r3, r3, #4
40
                add     r4, r4, #4
41
                add     r5, r5, #4
42
                add     r6, r6, #4
43
                stmia   r1!, {r3, r4, r5, r6}           @ Default mapping (null mapping)
44
                add     r3, r3, #4
45
                add     r4, r4, #4
46
                add     r5, r5, #4
47
                add     r6, r6, #4
48
                subs    r2, r2, #8
49
                bhi     1b
50
 
51
                adr     r2, Lphystomemc32               @ r2 = conversion table to logical page number
52
                ldr     r4, [r0, #TSS_MEMMAP]           @ r4 = active mem map
53
                add     r5, r4, #32 << 2                @ r5 = end of active mem map
54
                add     r0, r0, #TSS_MEMCMAP            @ r0 = memc map
55
 
56
                mov     r6, #0
57
2:              ldmia   r4!, {r1, r3}
58
                tst     r1, #PAGE_PRESENT
59
                blne    update_map_pgd
60
                add     r6, r6, #32 << 2
61
                tst     r3, #PAGE_PRESENT
62
                blne    update_map_pgd3
63
                add     r6, r6, #32 << 2
64
                cmp     r4, r5
65
                blt     2b
66
                ldmea   fp, {r4 - r6, fp, sp, pc}^
67
 
68
@ r0,r2,r3,r4,r5 = preserve
69
@ r1,ip = available
70
@ r0 = memc map
71
@ r1 = pgd entry
72
@ r2 = conversion table
73
@ r6 = logical page no << 2
74
 
75
update_map_pgd3:
76
                mov     r1, r3
77
update_map_pgd: stmfd   sp!, {r3, r4, r5, lr}
78
                bic     r4, r1, #3                      @ r4 = page table
79
                sub     r5, r6, #1 << 2
80
                add     ip, r4, #32 << 2                @ ip = end of page table
81
 
82
1:              ldr     r1, [r4], #4                    @ get entry
83
                add     r5, r5, #1 << 2
84
                tst     r1, #PAGE_PRESENT               @ page present?
85
                blne    Lconvertmemc                    @ yes
86
                ldr     r1, [r4], #4                    @ get entry
87
                add     r5, r5, #1 << 2
88
                tst     r1, #PAGE_PRESENT               @ page present?
89
                blne    Lconvertmemc                    @ yes
90
                ldr     r1, [r4], #4                    @ get entry
91
                add     r5, r5, #1 << 2
92
                tst     r1, #PAGE_PRESENT               @ page present?
93
                blne    Lconvertmemc                    @ yes
94
                ldr     r1, [r4], #4                    @ get entry
95
                add     r5, r5, #1 << 2
96
                tst     r1, #PAGE_PRESENT               @ page present?
97
                blne    Lconvertmemc                    @ yes
98
                cmp     r4, ip
99
                blt     1b
100
                ldmfd   sp!, {r3, r4, r5, pc}^
101
 
102
Lconvertmemc:   mov     r3, r1, lsr #13                 @
103
                and     r3, r3, #0x3fc                  @ Convert to memc physical page no
104
                ldr     r3, [r2, r3]                    @
105
 
106
                tst     r1, #PAGE_OLD|PAGE_NOT_USER     @ check for MEMC read
107
                biceq   r3, r3, #0x200                  @
108
                tsteq   r1, #PAGE_READONLY|PAGE_CLEAN   @ check for MEMC write
109
                biceq   r3, r3, #0x300                  @
110
 
111
                orr     r3, r3, r5, lsl #13
112
                and     r1, r5, #0x01800000 >> 13
113
                orr     r3, r3, r1
114
 
115
                and     r1, r3, #255
116
                str     r3, [r0, r1, lsl #2]
117
                movs    pc, lr
118
 
119
/*
120
 * Function: arm2_3_update_cache (struct task_struct *tsk, unsigned long addr, pte_t pte)
121
 * Params  : tsk      Task to update
122
 *           address  Address of fault.
123
 *           pte      New PTE at address
124
 * Purpose : Update the mapping for this address.
125
 * Notes   : does the ARM3 run faster if you dont use the result in the next instruction?
126
 */
127
_arm2_3_update_cache:
128
                tst     r2, #PAGE_PRESENT
129
                moveqs  pc, lr
130
                mov     r3, r2, lsr #13                 @ Physical page no.
131
                adr     ip, Lphystomemc32               @ Convert to logical page number
132
                and     r3, r3, #0x3fc
133
                mov     r1, r1, lsr #15
134
                ldr     r3, [ip, r3]                    @ Convert to memc phys page no.
135
                tst     r2, #PAGE_OLD|PAGE_NOT_USER
136
                biceq   r3, r3, #0x200
137
                tsteq   r2, #PAGE_READONLY|PAGE_CLEAN
138
                biceq   r3, r3, #0x300
139
                ldr     ip, [pc, #LC0 - . - 8]
140
                orr     r3, r3, r1, lsl #15
141
                and     r1, r1, #0x300
142
                ldr     ip, [ip]
143
                orr     r3, r3, r1, lsl #2
144
                teq     ip, r0
145
                and     r2, r3, #255
146
                add     r0, r0, #TSS_MEMCMAP
147
                streqb  r3, [r3]
148
                str     r3, [r0, r2, lsl #2]
149
                movs    pc, lr
150
 
151
#define PCD(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, aa, ab, ac, ad, ae, af) \
152
                .long   a0| 0x03800300; .long   a1| 0x03800300;\
153
                .long   a2| 0x03800300; .long   a3| 0x03800300;\
154
                .long   a4| 0x03800300; .long   a5| 0x03800300;\
155
                .long   a6| 0x03800300; .long   a7| 0x03800300;\
156
                .long   a8| 0x03800300; .long   a9| 0x03800300;\
157
                .long   aa| 0x03800300; .long   ab| 0x03800300;\
158
                .long   ac| 0x03800300; .long   ad| 0x03800300;\
159
                .long   ae| 0x03800300; .long   af| 0x03800300
160
 
161
@ Table to map from page number to vidc page number
162
Lphystomemc32:  PCD(0x00,0x08,0x10,0x18,0x20,0x28,0x30,0x38,0x40,0x48,0x50,0x58,0x60,0x68,0x70,0x78)
163
                PCD(0x01,0x09,0x11,0x19,0x21,0x29,0x31,0x39,0x41,0x49,0x51,0x59,0x61,0x69,0x71,0x79)
164
                PCD(0x04,0x0C,0x14,0x1C,0x24,0x2C,0x34,0x3C,0x44,0x4C,0x54,0x5C,0x64,0x6C,0x74,0x7C)
165
                PCD(0x05,0x0D,0x15,0x1D,0x25,0x2D,0x35,0x3D,0x45,0x4D,0x55,0x5D,0x65,0x6D,0x75,0x7D)
166
                PCD(0x02,0x0A,0x12,0x1A,0x22,0x2A,0x32,0x3A,0x42,0x4A,0x52,0x5A,0x62,0x6A,0x72,0x7A)
167
                PCD(0x03,0x0B,0x13,0x1B,0x23,0x2B,0x33,0x3B,0x43,0x4B,0x53,0x5B,0x63,0x6B,0x73,0x7B)
168
                PCD(0x06,0x0E,0x16,0x1E,0x26,0x2E,0x36,0x3E,0x46,0x4E,0x56,0x5E,0x66,0x6E,0x76,0x7E)
169
                PCD(0x07,0x0F,0x17,0x1F,0x27,0x2F,0x37,0x3F,0x47,0x4F,0x57,0x5F,0x67,0x6F,0x77,0x7F)
170
                PCD(0x80,0x88,0x90,0x98,0xA0,0xA8,0xB0,0xB8,0xC0,0xC8,0xD0,0xD8,0xE0,0xE8,0xF0,0xF8)
171
                PCD(0x81,0x89,0x91,0x99,0xA1,0xA9,0xB1,0xB9,0xC1,0xC9,0xD1,0xD9,0xE1,0xE9,0xF1,0xF9)
172
                PCD(0x84,0x8C,0x94,0x9C,0xA4,0xAC,0xB4,0xBC,0xC4,0xCC,0xD4,0xDC,0xE4,0xEC,0xF4,0xFC)
173
                PCD(0x85,0x8D,0x95,0x9D,0xA5,0xAD,0xB5,0xBD,0xC5,0xCD,0xD5,0xDD,0xE5,0xED,0xF5,0xFD)
174
                PCD(0x82,0x8A,0x92,0x9A,0xA2,0xAA,0xB2,0xBA,0xC2,0xCA,0xD2,0xDA,0xE2,0xEA,0xF2,0xFA)
175
                PCD(0x83,0x8B,0x93,0x9B,0xA3,0xAB,0xB3,0xBB,0xC3,0xCB,0xD3,0xDB,0xE3,0xEB,0xF3,0xFB)
176
                PCD(0x86,0x8E,0x96,0x9E,0xA6,0xAE,0xB6,0xBE,0xC6,0xCE,0xD6,0xDE,0xE6,0xEE,0xF6,0xFE)
177
                PCD(0x87,0x8F,0x97,0x9F,0xA7,0xAF,0xB7,0xBF,0xC7,0xCF,0xD7,0xDF,0xE7,0xEF,0xF7,0xFF)
178
 
179
/*
180
 * Function: arm2_3_data_abort ()
181
 *
182
 * Params  : r0 = address of aborted instruction
183
 *
184
 * Purpose :
185
 *
186
 * Returns : r0 = address of abort
187
 *         : r1 = FSR
188
 *         : r2 != 0 if writing
189
 */
190
 
191
_arm2_3_data_abort:
192
                movs    pc, lr
193
 
194
_arm2_3_check_bugs:
195
                movs    pc, lr
196
 
197
/*
198
 * Processor specific - ARM2
199
 */
200
 
201
LC0:            .word   _current
202
                .word   _page_nr
203
/*
204
 * Function: arm2_switch_to (struct task_struct *prev, struct task_struct *next)
205
 *
206
 * Params  : prev       Old task structure
207
 *         : next       New task structure for process to run
208
 *
209
 * Purpose : Perform a task switch, saving the old processes state, and restoring
210
 *           the new.
211
 *
212
 * Notes   : We don't fiddle with the FP registers here - we postpone this until
213
 *           the new task actually uses FP.  This way, we don't swap FP for tasks
214
 *           that do not require it.
215
 */
216
_arm2_switch_to:
217
                stmfd   sp!, {r4 - r9, fp, lr}          @ Store most regs on stack
218
                str     sp, [r0, #TSS_SAVE]             @ Save sp_SVC
219
                ldr     r2, LC0
220
                str     r1, [r2]
221
                ldr     sp, [r1, #TSS_SAVE]             @ Get saved sp_SVC
222
                mov     r4, r1
223
                add     r0, r1, #TSS_MEMCMAP            @ Remap MEMC
224
                ldr     r1, LC0 + 4
225
                ldr     r1, [r1]
226
1:              ldmia   r0!, {r2, r3, r5, r6}
227
                strb    r2, [r2]
228
                strb    r3, [r3]
229
                strb    r5, [r5]
230
                strb    r6, [r6]
231
                ldmia   r0!, {r2, r3, r5, r6}
232
                strb    r2, [r2]
233
                strb    r3, [r3]
234
                strb    r5, [r5]
235
                strb    r6, [r6]
236
                subs    r1, r1, #8
237
                bhi     1b
238
                ldmfd   sp!, {r4 - r9, fp, pc}^         @ Load all regs saved previously
239
 
240
/*
241
 * Function: arm2_remap_memc (struct task_struct *tsk)
242
 *
243
 * Params  : tsk        Task structure specifing the new mapping structure
244
 *
245
 * Purpose : remap MEMC tables
246
 */
247
_arm2_remap_memc:
248
                stmfd   sp!, {lr}
249
                add     r0, r0, #TSS_MEMCMAP
250
                ldr     r1, LC0 + 4
251
                ldr     r1, [r1]
252
1:              ldmia   r0!, {r2, r3, ip, lr}
253
                strb    r2, [r2]
254
                strb    r3, [r3]
255
                strb    ip, [ip]
256
                strb    lr, [lr]
257
                ldmia   r0!, {r2, r3, ip, lr}
258
                strb    r2, [r2]
259
                strb    r3, [r3]
260
                strb    ip, [ip]
261
                strb    lr, [lr]
262
                subs    r1, r1, #8
263
                bhi     1b
264
                ldmfd   sp!, {pc}^
265
 
266
/*
267
 * Function: arm2_xchg_1 (int new, volatile void *ptr)
268
 *
269
 * Params  : new        New value to store at...
270
 *         : ptr        pointer to byte-wide location
271
 *
272
 * Purpose : Performs an exchange operation
273
 *
274
 * Returns : Original byte data at 'ptr'
275
 *
276
 * Notes   : This will have to be changed if we ever use multi-processing using these
277
 *           processors, but that is very unlikely...
278
 */
279
_arm2_xchg_1:   mov     r2, pc
280
                orr     r2, r2, #I_BIT
281
                teqp    r2, #0
282
                ldrb    r2, [r1]
283
                strb    r0, [r1]
284
                mov     r0, r2
285
                movs    pc, lr
286
 
287
/*
288
 * Function: arm2_xchg_4 (int new, volatile void *ptr)
289
 *
290
 * Params  : new        New value to store at...
291
 *         : ptr        pointer to word-wide location
292
 *
293
 * Purpose : Performs an exchange operation
294
 *
295
 * Returns : Original word data at 'ptr'
296
 *
297
 * Notes   : This will have to be changed if we ever use multi-processing using these
298
 *           processors, but that is very unlikely...
299
 */
300
_arm2_xchg_4:   mov     r2, pc
301
                orr     r2, r2, #I_BIT
302
                teqp    r2, #0
303
                ldr     r2, [r1]
304
                str     r0, [r1]
305
                mov     r0, r2
306
/*
307
 * fall through
308
 */
309
/*
310
 * Function: arm2_proc_init (void)
311
 *         : arm2_proc_fin (void)
312
 *
313
 * Purpose : Initialise / finalise processor specifics (none required)
314
 */
315
_arm2_proc_init:
316
_arm2_proc_fin: movs    pc, lr
317
/*
318
 * Function: arm3_switch_to (struct task_struct *prev, struct task_struct *next)
319
 *
320
 * Params  : prev       Old task structure
321
 *         : next       New task structure for process to run
322
 *
323
 * Purpose : Perform a task switch, saving the old processes state, and restoring
324
 *           the new.
325
 *
326
 * Notes   : We don't fiddle with the FP registers here - we postpone this until
327
 *           the new task actually uses FP.  This way, we don't swap FP for tasks
328
 *           that do not require it.
329
 */
330
_arm3_switch_to:
331
                stmfd   sp!, {r4 - r9, fp, lr}          @ Store most regs on stack
332
                str     sp, [r0, #TSS_SAVE]             @ Save sp_SVC
333
                ldr     r2, LC0
334
                str     r1, [r2]
335
                ldr     sp, [r1, #TSS_SAVE]             @ Get saved sp_SVC
336
                mov     r4, r1
337
                add     r0, r1, #TSS_MEMCMAP            @ Remap MEMC
338
                ldr     r1, LC0 + 4
339
                ldr     r1, [r1]
340
1:              ldmia   r0!, {r2, r3, r5, r6}
341
                strb    r2, [r2]
342
                strb    r3, [r3]
343
                strb    r5, [r5]
344
                strb    r6, [r6]
345
                ldmia   r0!, {r2, r3, r5, r6}
346
                strb    r2, [r2]
347
                strb    r3, [r3]
348
                strb    r5, [r5]
349
                strb    r6, [r6]
350
                subs    r1, r1, #8
351
                bhi     1b
352
                mcr     p15, 0, r0, c1, c0, 0           @ flush cache
353
                ldmfd   sp!, {r4 - r9, fp, pc}^         @ Load all regs saved previously
354
/*
355
 * Function: arm2_remap_memc (struct task_struct *tsk)
356
 *
357
 * Params  : tsk        Task structure specifing the new mapping structure
358
 *
359
 * Purpose : remap MEMC tables
360
 */
361
_arm3_remap_memc:
362
                stmfd   sp!, {lr}
363
                add     r0, r0, #TSS_MEMCMAP
364
                ldr     r1, LC0 + 4
365
                ldr     r1, [r1]
366
1:              ldmia   r0!, {r2, r3, ip, lr}
367
                strb    r2, [r2]
368
                strb    r3, [r3]
369
                strb    ip, [ip]
370
                strb    lr, [lr]
371
                ldmia   r0!, {r2, r3, ip, lr}
372
                strb    r2, [r2]
373
                strb    r3, [r3]
374
                strb    ip, [ip]
375
                strb    lr, [lr]
376
                subs    r1, r1, #8
377
                bhi     1b
378
                mcr     p15, 0, r0, c1, c0, 0           @ flush cache
379
                ldmfd   sp!, {pc}^
380
 
381
/*
382
 * Function: arm3_proc_init (void)
383
 *
384
 * Purpose : Initialise the cache control registers
385
 */
386
_arm3_proc_init:
387
                mov     r0, #0x001f0000
388
                orr     r0, r0, #0x0000ff00
389
                orr     r0, r0, #0x000000ff
390
                mcr     p15, 0, r0, c3, c0
391
                mcr     p15, 0, r0, c4, c0
392
                mov     r0, #0
393
                mcr     p15, 0, r0, c5, c0
394
                mov     r0, #3
395
                mcr     p15, 0, r0, c1, c0
396
                mcr     p15, 0, r0, c2, c0
397
                movs    pc, lr
398
 
399
/*
400
 * Function: arm3_proc_fin (void)
401
 *
402
 * Purpose : Finalise processor (disable caches)
403
 */
404
_arm3_proc_fin: mov     r0, #2
405
                mcr     p15, 0, r0, c2, c0
406
                movs    pc, lr
407
 
408
/*
409
 * Function: arm3_xchg_1 (int new, volatile void *ptr)
410
 *
411
 * Params  : new        New value to store at...
412
 *         : ptr        pointer to byte-wide location
413
 *
414
 * Purpose : Performs an exchange operation
415
 *
416
 * Returns : Original byte data at 'ptr'
417
 */
418
_arm3_xchg_1:   swpb    r0, r0, [r1]
419
                movs    pc, lr
420
 
421
/*
422
 * Function: arm3_xchg_4 (int new, volatile void *ptr)
423
 *
424
 * Params  : new        New value to store at...
425
 *         : ptr        pointer to word-wide location
426
 *
427
 * Purpose : Performs an exchange operation
428
 *
429
 * Returns : Original word data at 'ptr'
430
 */
431
_arm3_xchg_4:   swp     r0, r0, [r1]
432
                movs    pc, lr
433
 
434
 
435
/*
436
 * Purpose : Function pointers used to access above functions - all calls
437
 *           come through these
438
 */
439
_arm2_name:
440
                .ascii  "arm2\0"
441
                .align
442
 
443
                .globl  _arm2_processor_functions
444
_arm2_processor_functions:
445
                .word   _arm2_name                      @  0
446
                .word   _arm2_switch_to                 @  4
447
                .word   _arm2_3_data_abort              @  8
448
                .word   _arm2_3_check_bugs              @ 12
449
                .word   _arm2_proc_init                 @ 16
450
                .word   _arm2_proc_fin                  @ 20
451
 
452
                .word   _arm2_remap_memc                @ 24
453
                .word   _arm2_3_update_map              @ 28
454
                .word   _arm2_3_update_cache            @ 32
455
                .word   _arm2_xchg_1                    @ 36
456
                .word   _abort                          @ 40
457
                .word   _arm2_xchg_4                    @ 44
458
 
459
_arm250_name:
460
                .ascii  "arm250\0"
461
                .align
462
 
463
                .globl  _arm250_processor_functions
464
_arm250_processor_functions:
465
                .word   _arm250_name                    @  0
466
                .word   _arm2_switch_to                 @  4
467
                .word   _arm2_3_data_abort              @  8
468
                .word   _arm2_3_check_bugs              @ 12
469
                .word   _arm2_proc_init                 @ 16
470
                .word   _arm2_proc_fin                  @ 20
471
 
472
                .word   _arm2_remap_memc                @ 24
473
                .word   _arm2_3_update_map              @ 28
474
                .word   _arm2_3_update_cache            @ 32
475
                .word   _arm3_xchg_1                    @ 36
476
                .word   _abort                          @ 40
477
                .word   _arm3_xchg_4                    @ 44
478
 
479
_arm3_name:
480
                .ascii  "arm3\0"
481
                .align
482
 
483
                .globl  _arm3_processor_functions
484
_arm3_processor_functions:
485
                .word   _arm3_name                      @  0
486
                .word   _arm3_switch_to                 @  4
487
                .word   _arm2_3_data_abort              @  8
488
                .word   _arm2_3_check_bugs              @ 12
489
                .word   _arm3_proc_init                 @ 16
490
                .word   _arm3_proc_fin                  @ 20
491
 
492
                .word   _arm3_remap_memc                @ 24
493
                .word   _arm2_3_update_map              @ 28
494
                .word   _arm2_3_update_cache            @ 32
495
                .word   _arm3_xchg_1                    @ 36
496
                .word   _abort                          @ 40
497
                .word   _arm3_xchg_4                    @ 44
498
 

powered by: WebSVN 2.1.0

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