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

Subversion Repositories or1k_old

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

powered by: WebSVN 2.1.0

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