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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [hal/] [mips/] [arch/] [v2_0/] [include/] [arch.inc] - Blame information for rev 638

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

Line No. Rev Author Line
1 27 unneback
#ifndef CYGONCE_HAL_ARCH_INC
2
#define CYGONCE_HAL_ARCH_INC
3
##=============================================================================
4
##
5
##      arch.inc
6
##
7
##      MIPS assembler header file
8
##
9
##=============================================================================
10
#####ECOSGPLCOPYRIGHTBEGIN####
11
## -------------------------------------------
12
## This file is part of eCos, the Embedded Configurable Operating System.
13
## Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
14
##
15
## eCos is free software; you can redistribute it and/or modify it under
16
## the terms of the GNU General Public License as published by the Free
17
## Software Foundation; either version 2 or (at your option) any later version.
18
##
19
## eCos is distributed in the hope that it will be useful, but WITHOUT ANY
20
## WARRANTY; without even the implied warranty of MERCHANTABILITY or
21
## FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
22
## for more details.
23
##
24
## You should have received a copy of the GNU General Public License along
25
## with eCos; if not, write to the Free Software Foundation, Inc.,
26
## 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
27
##
28
## As a special exception, if other files instantiate templates or use macros
29
## or inline functions from this file, or you compile this file and link it
30
## with other works to produce a work based on this file, this file does not
31
## by itself cause the resulting work to be covered by the GNU General Public
32
## License. However the source code for this file must still be made available
33
## in accordance with section (3) of the GNU General Public License.
34
##
35
## This exception does not invalidate any other reasons why a work based on
36
## this file might be covered by the GNU General Public License.
37
##
38
## Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
39
## at http://sources.redhat.com/ecos/ecos-license/
40
## -------------------------------------------
41
#####ECOSGPLCOPYRIGHTEND####
42
##=============================================================================
43
#######DESCRIPTIONBEGIN####
44
##
45
## Author(s):   nickg
46
## Contributors:        nickg, dmoseley
47
## Date:        1997-10-16
48
## Purpose:     Architecture definitions.
49
## Description: This file contains various definitions and macros that are
50
##              useful for writing assembly code for the MIPS CPU family.
51
## Usage:
52
##              #include 
53
##              ...
54
##
55
##
56
######DESCRIPTIONEND####
57
##
58
##=============================================================================
59
 
60
#include 
61
 
62
#include 
63
 
64
##-----------------------------------------------------------------------------
65
## Set up the value for the initial status register
66
 
67
 
68
# Either the variant or platform may define an INITIAL_SR of its
69
#own. If not then provide a default value here.
70
 
71
#ifndef INITIAL_SR
72
 
73
# Both the variant and platform HALs have the option to add some bits
74
# to the default status register. If they do not choose to do so,
75
# supply default zeroes here.
76
 
77
# ifndef INITIAL_SR_VAR
78
#  define INITIAL_SR_VAR 0x00000000
79
# endif
80
# ifndef INITIAL_SR_PLF
81
#  define INITIAL_SR_PLF 0x00000000
82
# endif
83
 
84
#if defined(CYG_HAL_STARTUP_RAM) || defined(CYG_HAL_STARTUP_ROMRAM)
85
# if defined(CYGPKG_HAL_MIPS_SIM) || !defined(CYGSEM_HAL_USE_ROM_MONITOR)
86
#  define INITIAL_SR_ARCH       0x1000ff00 /* CP0 usable, Ints enabled, master interrupt disable */
87
# else
88
#  define INITIAL_SR_ARCH       0x1040ff00      /* as above + ROM vectors used  */
89
# endif
90
#elif defined(CYG_HAL_STARTUP_ROM)
91
# define INITIAL_SR_ARCH        0x1040ff00      /* as above + ROM vectors used  */
92
#endif
93
 
94
#define INITIAL_SR      (INITIAL_SR_ARCH|INITIAL_SR_VAR|INITIAL_SR_PLF)
95
 
96
#endif
97
 
98
##-----------------------------------------------------------------------------
99
## Setup the initial value for the config0 register
100
 
101
#ifndef INITIAL_CONFIG0
102
 
103
#define INITIAL_CONFIG0 0x00000002
104
 
105
#endif
106
 
107
##-----------------------------------------------------------------------------
108
## MIPS thread and interrupt saved state. This must match the layout of the
109
## HAL_SavedRegisters in hal_arch.h. Do not change this without changing the
110
## layout there, or viceversa.
111
 
112
# Size of registers that change size between 32 and 64 bit implementations
113
#ifdef CYGHWR_HAL_MIPS_64BIT
114
# define mips_regsize   8
115
#else
116
# define mips_regsize   4
117
#endif
118
 
119
# Size of registers that stay the same size in all implementations
120
# define mips_regsize32 4
121
 
122
# Size of FPU registers.
123
#if defined(CYGHWR_HAL_MIPS_FPU)
124
# if defined(CYGHWR_HAL_MIPS_FPU_64BIT)
125
#  define mips_fpuregsize 8
126
# elif defined(CYGHWR_HAL_MIPS_FPU_32BIT)
127
#  define mips_fpuregsize 4
128
# else
129
#  error MIPS FPU register size not defined
130
# endif
131
#endif
132
 
133
 
134
#define mipsreg_regs    0
135
#define mipsreg_hi      (mips_regsize*32)
136
#define mipsreg_lo      (mipsreg_hi+mips_regsize)
137
#ifdef CYGHWR_HAL_MIPS_FPU
138
# define mipsreg_fpureg (mipsreg_lo+mips_regsize)
139
# define mipsreg_fcr31  (mipsreg_fpureg+(mips_fpuregsize*32))
140
# define mipsreg_fppad  (mipsreg_fcr31+mips_regsize32)
141
# define mipsreg_vector (mipsreg_fppad+mips_regsize32)
142
#else
143
# define mipsreg_vector (mipsreg_lo+mips_regsize)
144
#endif
145
#define mipsreg_sr      (mipsreg_vector+mips_regsize32)
146
#define mipsreg_pc      (mipsreg_sr+mips_regsize32)
147
#define mipsreg_cachectrl (mipsreg_pc+mips_regsize)
148
#define mipsreg_cause   (mipsreg_cachectrl+mips_regsize32)
149
#define mipsreg_badvr   (mipsreg_cause+mips_regsize32)
150
#define mipsreg_prid    (mipsreg_badvr+mips_regsize)
151
#define mipsreg_config  (mipsreg_prid+mips_regsize32)
152
#define mipsreg_size    (mipsreg_config+mips_regsize32)
153
 
154
# The following expression ensures that the decrement is always a
155
# multiple of 16 bytes. This is a requirement of the MEABI used in
156
# MIPS32/64 targets.
157
 
158
#define mips_exception_decrement        ((mipsreg_size*2)&~0xF)
159
 
160
##-----------------------------------------------------------------------------
161
## Minimal stack frame size uses to call functions from asm.
162
 
163
#define mips_stack_frame_size           32      // 4 (64 bit) args worth
164
 
165
##-----------------------------------------------------------------------------
166
## Load Address and Relocate. This macro is used in code that may be linked
167
## to execute out of RAM but is actually executed from ROM. If that is the
168
## case a suitable version of this macro will have been defined elsewhere.
169
## This is just a default version for use when that does not happen.
170
 
171
#ifndef CYGPKG_HAL_MIPS_LAR_DEFINED
172
 
173
        .macro  lar     reg,addr
174
        la      \reg,\addr
175
        .endm
176
 
177
#define CYGPKG_HAL_MIPS_LAR_DEFINED
178
 
179
#endif
180
 
181
##-----------------------------------------------------------------------------
182
## CPU specific macros. These provide a common assembler interface to
183
## operations that may have CPU specific implementations on different
184
## variants of the architecture.
185
 
186
        # Initialize CPU
187
        .macro  hal_cpu_init
188
 
189
#if defined(CYGPKG_HAL_MIPS_MIPS32) || defined(CYGPKG_HAL_MIPS_MIPS64)
190
        # Initialize/clear watchpoint registers
191
        mvatc0  zero, C0_WATCHLO
192
        nop
193
        nop
194
        nop
195
        mtc0    zero, C0_WATCHHI
196
        nop
197
        nop
198
        nop
199
#endif /* CYGPKG_HAL_MIPS_MIPS32 || CYGPKG_HAL_MIPS_MIPS64 */
200
        mtc0    zero,cause              # zero cause reg
201
        nop
202
#if !defined(CYGSEM_HAL_USE_ROM_MONITOR)
203
        la      v0,INITIAL_SR           # initialize status register
204
        mtc0    v0,status
205
        nop
206
        nop
207
        nop
208
        la      v0,INITIAL_CONFIG0
209
        mtc0    v0,config0
210
        nop
211
        nop
212
        nop
213
#endif
214
        .endm
215
 
216
        # Enable interrupts
217
#ifdef CYG_HAL_MIPS_R3900
218
        .macro hal_cpu_int_enable
219
        mfc0    v0,status
220
        nop
221
        nop
222
        ori     v0,v0,0x0001            # set IE bit
223
        mtc0    v0,status
224
        nop
225
        nop
226
        nop
227
        .endm
228
#else
229
        .macro hal_cpu_int_enable
230
        mfc0    v0,status
231
        la      v1,0xFFFFFFF9
232
        and     v0,v0,v1                # clear EXL and ERL bits
233
        ori     v0,v0,0x0001            # set IE bit
234
        mtc0    v0,status
235
        nop
236
        nop
237
        nop
238
        .endm
239
#endif
240
 
241
 
242
        # Disable interrupts
243
        .macro hal_cpu_int_disable
244
        mfc0    v0,status
245
        la      v1,0xFFFFFFFE
246
        and     v0,v0,v1
247
        mtc0    v0,status
248
        nop
249
        nop
250
        nop
251
        .endm
252
 
253
        # Merge the interrupt enable state of the status register in
254
        # \sr with the current sr.
255
#ifdef CYG_HAL_MIPS_R3900
256
#define HAL_SR_INT_MASK 0x00000001              // IEc only
257
#else
258
#define HAL_SR_INT_MASK 0x00000007              // IE, EXL, ERL
259
#endif
260
        .macro  hal_cpu_int_merge sr
261
        mfc0    v0,status                       # V0 = current SR
262
        la      v1,HAL_SR_INT_MASK              # V1 = SR interrupt bits mask
263
        and     \sr,\sr,v1                      # Isolate interrupt bits of \sr
264
        nor     v1,v1,zero                      # Invert mask
265
        and     v0,v0,v1                        # V0 = current SR except int bits
266
        or      v0,v0,\sr                       # V0 = New SR
267
        mtc0    v0,status                       # Return to SR
268
        .endm
269
 
270
        # Enable further exception processing, and disable
271
        # interrupt processing.
272
#ifdef CYG_HAL_MIPS_R3900
273
        .macro hal_cpu_except_enable
274
        hal_cpu_int_disable
275
        .endm
276
#else
277
        .macro hal_cpu_except_enable
278
        mfc0    v0,status
279
        la      v1,0xFFFFFFF0
280
        and     v0,v0,v1                # clear EXL, ERL and IE bits
281
        mtc0    v0,status
282
        nop
283
        nop
284
        nop
285
        .endm
286
#endif
287
 
288
        # Return from exception.
289
#ifdef CYG_HAL_MIPS_R3900
290
        .macro  hal_cpu_eret pc,sr
291
        mtc0    \sr,status                      # Load status register
292
        nop
293
        nop
294
        nop
295
        sync                                    # settle things down
296
        jr      \pc                             # jump back to interrupted code
297
        rfe                                     # restore state (delay slot)
298
        .endm
299
#else
300
        .macro  hal_cpu_eret pc,sr
301
        .set mips3
302
        ori     \sr,\sr,2                       # prevent interrupts until eret
303
        mtc0    \sr,status                      # put SR back
304
        nop
305
        nop
306
        nop
307
        mvatc0  \pc,epc                         # put PC in EPC
308
        nop
309
        nop
310
        nop
311
        sync                                    # settle things down
312
        eret                                    # return
313
        nop                                     # just to be safe
314
        .set mips0
315
        .endm
316
#endif
317
 
318
##-----------------------------------------------------------------------------
319
# Default MIPS interrupt decoding macros. This uses the basic interrupt
320
# support provided by CP0 in the cause and status registers. If there is
321
# a more complex external interrupt controller, or the default stuff is
322
# interpreted differently (as in the TX3904) then these macros will be
323
# overridden and CYGPKG_HAL_MIPS_INTC_DEFINED will be defined.
324
 
325
#ifndef CYGPKG_HAL_MIPS_INTC_DEFINED
326
 
327
#ifndef CYGPKG_HAL_MIPS_INTC_INIT_DEFINED
328
        # initialize all interrupts to disabled
329
        .macro  hal_intc_init
330
        mfc0    v0,status
331
        nop
332
        lui     v1,0xFFFF
333
        ori     v1,v1,0x00FF
334
        and     v0,v0,v1                # clear the IntMask bits
335
        mtc0    v0,status
336
        nop
337
        nop
338
        nop
339
        .endm
340
#endif
341
 
342
#ifndef CYGPKG_HAL_MIPS_INTC_DECODE_DEFINED
343
        .macro  hal_intc_decode vnum
344
        mfc0    v1,status               # get status register (interrupt mask)
345
        nop                             # delay slot
346
        mfc0    v0,cause                # get cause register
347
        nop                             # delay slot
348
        and     v0,v0,v1                # apply interrupt mask
349
        srl     v0,v0,10                # shift interrupt bits down
350
        andi    v0,v0,0x7f              # isolate 6 interrupt bits
351
        la      v1,hal_intc_translation_table
352
        add     v0,v0,v1                # index into table
353
        lb      \vnum,0(v0)             # pick up vector number
354
        .endm
355
#endif
356
 
357
#ifndef CYGPKG_HAL_MIPS_INTC_TRANSLATE_DEFINED
358
#ifdef CYGIMP_HAL_COMMON_INTERRUPTS_CHAIN
359
        .macro  hal_intc_translate inum,vnum
360
        move    \vnum,zero                      # Just vector zero is supported
361
        .endm
362
#else
363
        .macro  hal_intc_translate inum,vnum
364
        move    \vnum,\inum                     # Vector == interrupt number
365
        .endm
366
#endif
367
#endif
368
 
369
        .macro  hal_intc_decode_data
370
hal_intc_translation_table:
371
        .byte   0, 0, 1, 0
372
        .byte   2, 0, 1, 0
373
        .byte   3, 0, 1, 0
374
        .byte   2, 0, 1, 0
375
        .byte   4, 0, 1, 0
376
        .byte   2, 0, 1, 0
377
        .byte   3, 0, 1, 0
378
        .byte   2, 0, 1, 0
379
        .byte   5, 0, 1, 0
380
        .byte   2, 0, 1, 0
381
        .byte   3, 0, 1, 0
382
        .byte   2, 0, 1, 0
383
        .byte   4, 0, 1, 0
384
        .byte   2, 0, 1, 0
385
        .byte   3, 0, 1, 0
386
        .byte   2, 0, 1, 0
387
        .endm
388
#endif
389
 
390
#------------------------------------------------------------------------------
391
# Register save and restore macros. These expect a pointer to a CPU save state
392
# area in the register \ptr. The GPR indicated by \reg will be saved into its
393
# slot in that structure.
394
 
395
#ifdef CYGHWR_HAL_MIPS_64BIT
396
 
397
        .macro sgpr reg,ptr
398
        sd      $\reg,(mipsreg_regs+\reg*mips_regsize)(\ptr)
399
        .endm
400
 
401
        .macro lgpr reg,ptr
402
        ld      $\reg,(mipsreg_regs+\reg*mips_regsize)(\ptr)
403
        .endm
404
 
405
        .macro slo reg,ptr
406
        sd      \reg,(mipsreg_lo)(\ptr)
407
        .endm
408
 
409
        .macro shi reg,ptr
410
        sd      \reg,(mipsreg_hi)(\ptr)
411
        .endm
412
 
413
        .macro llo reg,ptr
414
        ld      \reg,(mipsreg_lo)(\ptr)
415
        .endm
416
 
417
        .macro lhi reg,ptr
418
        ld      \reg,(mipsreg_hi)(\ptr)
419
        .endm
420
 
421
        .macro ssp reg,ptr
422
        sd      \reg,(mipsreg_regs+29*mips_regsize)(\ptr)
423
        .endm
424
 
425
        .macro lsp reg,ptr
426
        ld      \reg,(mipsreg_regs+29*mips_regsize)(\ptr)
427
        .endm
428
 
429
        .macro sva reg,val
430
        sd      \reg,\val
431
        .endm
432
 
433
        .macro lva reg,val
434
        ld      \reg,\val
435
        .endm
436
 
437
        .macro mvafc0 gpr,cpr
438
        dmfc0   \gpr,\cpr
439
        .endm
440
 
441
        .macro mvatc0 gpr,cpr
442
        dmtc0   \gpr,\cpr
443
        .endm
444
 
445
        .macro lpc reg,ptr
446
        ld      \reg,(mipsreg_pc)(\ptr)
447
        .endm
448
 
449
        .macro spc reg,ptr
450
        sd      \reg,(mipsreg_pc)(\ptr)
451
        .endm
452
 
453
#else
454
 
455
        .macro sgpr reg,ptr
456
        sw      $\reg,(mipsreg_regs+\reg*mips_regsize)(\ptr)
457
        .endm
458
 
459
        .macro lgpr reg,ptr
460
        lw      $\reg,(mipsreg_regs+\reg*mips_regsize)(\ptr)
461
        .endm
462
 
463
        .macro slo reg,ptr
464
        sw      \reg,(mipsreg_lo)(\ptr)
465
        .endm
466
 
467
        .macro shi reg,ptr
468
        sw      \reg,(mipsreg_hi)(\ptr)
469
        .endm
470
 
471
        .macro llo reg,ptr
472
        lw      \reg,(mipsreg_lo)(\ptr)
473
        .endm
474
 
475
        .macro lhi reg,ptr
476
        lw      \reg,(mipsreg_hi)(\ptr)
477
        .endm
478
 
479
        .macro ssp reg,ptr
480
        sw      \reg,(mipsreg_regs+29*mips_regsize)(\ptr)
481
        .endm
482
 
483
        .macro lsp reg,ptr
484
        lw      \reg,(mipsreg_regs+29*mips_regsize)(\ptr)
485
        .endm
486
 
487
        .macro sva reg,val
488
        sw      \reg,\val
489
        .endm
490
 
491
        .macro lva reg,val
492
        lw      \reg,\val
493
        .endm
494
 
495
        .macro mvafc0 gpr,cpr
496
        mfc0    \gpr,\cpr
497
        .endm
498
 
499
        .macro mvatc0 gpr,cpr
500
        mtc0    \gpr,\cpr
501
        .endm
502
 
503
        .macro lpc reg,ptr
504
        lw      \reg,(mipsreg_pc)(\ptr)
505
        .endm
506
 
507
        .macro spc reg,ptr
508
        sw      \reg,(mipsreg_pc)(\ptr)
509
        .endm
510
#endif
511
 
512
#------------------------------------------------------------------------------
513
# FPU macros.
514
# The MIPS floating point unit essentially operates in two modes. In the first
515
# it supplies 32 32bit FP registers that may be paired into 16 64 bit registers.
516
# In the second it supplies 32 64bit registers. Which mode is to be used depends
517
# not only on the specific implementation in use, but also on the setting of the
518
# FR bit in the status register (if it is implemented) and on the expectations of
519
# the toolchain.
520
 
521
#ifndef CYGPKG_HAL_MIPS_FPU_DEFINED
522
 
523
#ifdef CYGHWR_HAL_MIPS_FPU
524
 
525
#if defined(CYGHWR_HAL_MIPS_FPU_64BIT)
526
#define sfpr    sdc1
527
#define lfpr    ldc1
528
#define CYG_HAL_MIPS_FPU_SR_INIT        0x24000000
529
#elif defined(CYGHWR_HAL_MIPS_FPU_32BIT)
530
#define sfpr    swc1
531
#define lfpr    lwc1
532
#define CYG_HAL_MIPS_FPU_SR_INIT        0x20000000
533
#else
534
#error MIPS FPU register size not defined
535
#endif
536
 
537
#ifndef CYG_HAL_MIPS_FCSR_INIT
538
#define CYG_HAL_MIPS_FCSR_INIT 0
539
#endif
540
 
541
        .macro  hal_fpu_init
542
        mfc0    v0,status                       # Get sr
543
        la      v1,0xDBFFFFFF                   # Clear bits to be changed
544
        and     v0,v0,v1
545
        la      v1,CYG_HAL_MIPS_FPU_SR_INIT     # Set the bits we want
546
        or      v0,v0,v1                        # Set sr to required value
547
        mtc0    v0,status                       # return to sr
548
        nop
549
        nop
550
        nop
551
        la      v0,CYG_HAL_MIPS_FCSR_INIT       # Get initial value for FCR31
552
        ctc1    v0,$31                          # set Fp control reg
553
        nop
554
        .endm
555
 
556
        # Save the caller-saved registers as defined by the ABI.
557
        # These only really need saving during interrupts.
558
        .macro  hal_fpu_save_caller regs
559
        cfc1    v0,$31
560
        sw      v0,mipsreg_fcr31(\regs)
561
        sfpr    f0,(mipsreg_fpureg+0*mips_fpuregsize)(\regs)
562
        sfpr    f1,(mipsreg_fpureg+1*mips_fpuregsize)(\regs)
563
        sfpr    f2,(mipsreg_fpureg+2*mips_fpuregsize)(\regs)
564
        sfpr    f3,(mipsreg_fpureg+3*mips_fpuregsize)(\regs)
565
        sfpr    f4,(mipsreg_fpureg+4*mips_fpuregsize)(\regs)
566
        sfpr    f5,(mipsreg_fpureg+5*mips_fpuregsize)(\regs)
567
        sfpr    f6,(mipsreg_fpureg+6*mips_fpuregsize)(\regs)
568
        sfpr    f7,(mipsreg_fpureg+7*mips_fpuregsize)(\regs)
569
        sfpr    f8,(mipsreg_fpureg+8*mips_fpuregsize)(\regs)
570
        sfpr    f9,(mipsreg_fpureg+9*mips_fpuregsize)(\regs)
571
        sfpr    f10,(mipsreg_fpureg+10*mips_fpuregsize)(\regs)
572
        sfpr    f11,(mipsreg_fpureg+11*mips_fpuregsize)(\regs)
573
        sfpr    f12,(mipsreg_fpureg+12*mips_fpuregsize)(\regs)
574
        sfpr    f13,(mipsreg_fpureg+13*mips_fpuregsize)(\regs)
575
        sfpr    f14,(mipsreg_fpureg+14*mips_fpuregsize)(\regs)
576
        sfpr    f15,(mipsreg_fpureg+15*mips_fpuregsize)(\regs)
577
        sfpr    f16,(mipsreg_fpureg+16*mips_fpuregsize)(\regs)
578
        sfpr    f17,(mipsreg_fpureg+17*mips_fpuregsize)(\regs)
579
        sfpr    f18,(mipsreg_fpureg+18*mips_fpuregsize)(\regs)
580
        sfpr    f19,(mipsreg_fpureg+19*mips_fpuregsize)(\regs)
581
        sfpr    f31,(mipsreg_fpureg+31*mips_fpuregsize)(\regs)
582
        .endm
583
 
584
        # Save the callee-saved registers as defined by the ABI.
585
        # These are the only registers that need to be saved
586
        # across thread switches.
587
        .macro  hal_fpu_save_callee regs
588
        sfpr    f20,(mipsreg_fpureg+20*mips_fpuregsize)(\regs)
589
        sfpr    f21,(mipsreg_fpureg+21*mips_fpuregsize)(\regs)
590
        sfpr    f22,(mipsreg_fpureg+22*mips_fpuregsize)(\regs)
591
        sfpr    f23,(mipsreg_fpureg+23*mips_fpuregsize)(\regs)
592
        sfpr    f24,(mipsreg_fpureg+24*mips_fpuregsize)(\regs)
593
        sfpr    f25,(mipsreg_fpureg+25*mips_fpuregsize)(\regs)
594
        sfpr    f26,(mipsreg_fpureg+26*mips_fpuregsize)(\regs)
595
        sfpr    f27,(mipsreg_fpureg+27*mips_fpuregsize)(\regs)
596
        sfpr    f28,(mipsreg_fpureg+28*mips_fpuregsize)(\regs)
597
        sfpr    f29,(mipsreg_fpureg+29*mips_fpuregsize)(\regs)
598
        sfpr    f30,(mipsreg_fpureg+30*mips_fpuregsize)(\regs)
599
        .endm
600
 
601
        # General macro to save everything
602
        .macro  hal_fpu_save regs
603
        hal_fpu_save_caller \regs
604
        hal_fpu_save_callee \regs
605
        .endm
606
 
607
        # Reload the caller-saved registers.
608
        .macro  hal_fpu_load_caller regs
609
        lfpr    f0,(mipsreg_fpureg+0*mips_fpuregsize)(\regs)
610
        lfpr    f1,(mipsreg_fpureg+1*mips_fpuregsize)(\regs)
611
        lfpr    f2,(mipsreg_fpureg+2*mips_fpuregsize)(\regs)
612
        lfpr    f3,(mipsreg_fpureg+3*mips_fpuregsize)(\regs)
613
        lfpr    f4,(mipsreg_fpureg+4*mips_fpuregsize)(\regs)
614
        lfpr    f5,(mipsreg_fpureg+5*mips_fpuregsize)(\regs)
615
        lfpr    f6,(mipsreg_fpureg+6*mips_fpuregsize)(\regs)
616
        lfpr    f7,(mipsreg_fpureg+7*mips_fpuregsize)(\regs)
617
        lfpr    f8,(mipsreg_fpureg+8*mips_fpuregsize)(\regs)
618
        lfpr    f9,(mipsreg_fpureg+9*mips_fpuregsize)(\regs)
619
        lfpr    f10,(mipsreg_fpureg+10*mips_fpuregsize)(\regs)
620
        lfpr    f11,(mipsreg_fpureg+11*mips_fpuregsize)(\regs)
621
        lfpr    f12,(mipsreg_fpureg+12*mips_fpuregsize)(\regs)
622
        lfpr    f13,(mipsreg_fpureg+13*mips_fpuregsize)(\regs)
623
        lfpr    f14,(mipsreg_fpureg+14*mips_fpuregsize)(\regs)
624
        lfpr    f15,(mipsreg_fpureg+15*mips_fpuregsize)(\regs)
625
        lfpr    f16,(mipsreg_fpureg+16*mips_fpuregsize)(\regs)
626
        lfpr    f17,(mipsreg_fpureg+17*mips_fpuregsize)(\regs)
627
        lfpr    f18,(mipsreg_fpureg+18*mips_fpuregsize)(\regs)
628
        lfpr    f19,(mipsreg_fpureg+19*mips_fpuregsize)(\regs)
629
        lfpr    f31,(mipsreg_fpureg+31*mips_fpuregsize)(\regs)
630
        lw      v0,mipsreg_fcr31(\regs)
631
        ctc1    v0,$31
632
        .endm
633
 
634
        # Reload the callee-saved registers.
635
        .macro  hal_fpu_load_callee regs
636
        lfpr    f20,(mipsreg_fpureg+20*mips_fpuregsize)(\regs)
637
        lfpr    f21,(mipsreg_fpureg+21*mips_fpuregsize)(\regs)
638
        lfpr    f22,(mipsreg_fpureg+22*mips_fpuregsize)(\regs)
639
        lfpr    f23,(mipsreg_fpureg+23*mips_fpuregsize)(\regs)
640
        lfpr    f24,(mipsreg_fpureg+24*mips_fpuregsize)(\regs)
641
        lfpr    f25,(mipsreg_fpureg+25*mips_fpuregsize)(\regs)
642
        lfpr    f26,(mipsreg_fpureg+26*mips_fpuregsize)(\regs)
643
        lfpr    f27,(mipsreg_fpureg+27*mips_fpuregsize)(\regs)
644
        lfpr    f28,(mipsreg_fpureg+28*mips_fpuregsize)(\regs)
645
        lfpr    f29,(mipsreg_fpureg+29*mips_fpuregsize)(\regs)
646
        lfpr    f30,(mipsreg_fpureg+30*mips_fpuregsize)(\regs)
647
        .endm
648
 
649
        # Reload everything.
650
        .macro  hal_fpu_load regs
651
        hal_fpu_load_caller \regs
652
        hal_fpu_load_callee \regs
653
        .endm
654
#else
655
 
656
        # Default macros for non-fpu implementations
657
 
658
        .macro  hal_fpu_init
659
        .endm
660
 
661
        .macro  hal_fpu_save regs
662
        .endm
663
 
664
        .macro  hal_fpu_save_caller regs
665
        .endm
666
 
667
        .macro  hal_fpu_save_callee regs
668
        .endm
669
 
670
        .macro  hal_fpu_load_caller regs
671
        .endm
672
 
673
        .macro  hal_fpu_load_callee regs
674
        .endm
675
 
676
        .macro  hal_fpu_load regs
677
        .endm
678
 
679
#endif
680
 
681
#endif
682
 
683
#------------------------------------------------------------------------------
684
# MMU macros.
685
 
686
#ifndef CYGPKG_HAL_MIPS_MMU_DEFINED
687
 
688
        .macro  hal_mmu_init
689
        .endm
690
 
691
#endif
692
 
693
#------------------------------------------------------------------------------
694
# MEMC macros.
695
 
696
#ifndef CYGPKG_HAL_MIPS_MEMC_DEFINED
697
 
698
        .macro  hal_memc_init
699
        .endm
700
 
701
#endif
702
 
703
#------------------------------------------------------------------------------
704
# Cache macros.
705
 
706
#ifndef CYGPKG_HAL_MIPS_CACHE_DEFINED
707
 
708
#ifdef CYG_HAL_MIPS_R3900
709
        .macro  hal_cache_init
710
        mfc0    v0,config               # disable cache in config register
711
        nop
712
        nop
713
        la      v1,0xffffffcf
714
        and     v0,v0,v1
715
        mtc0    v0,config
716
        nop
717
        nop
718
        nop
719
        .endm
720
#else
721
        .macro  hal_cache_init
722
 
723
        mfc0    v0,config0              # disable Kseg0 caching in config0 register
724
        nop
725
        nop
726
        la      v1,0xfffffff8
727
        and     v0,v0,v1
728
        ori     v0,v0,2
729
        mtc0    v0,config0
730
        nop
731
        nop
732
        nop
733
 
734
        .endm
735
#endif
736
 
737
#endif
738
 
739
#------------------------------------------------------------------------------
740
# Diagnostics macros.
741
 
742
#ifndef CYGPKG_HAL_MIPS_DIAG_DEFINED
743
 
744
        .macro  hal_diag_init
745
        .endm
746
 
747
        .macro  hal_diag_excpt_start
748
        .endm
749
 
750
        .macro  hal_diag_intr_start
751
        .endm
752
 
753
        .macro  hal_diag_restore
754
        .endm
755
#endif
756
 
757
#------------------------------------------------------------------------------
758
# Timer initialization.
759
 
760
#ifndef CYGPKG_HAL_MIPS_TIMER_DEFINED
761
 
762
        .macro  hal_timer_init
763
        .endm
764
 
765
#endif
766
 
767
#------------------------------------------------------------------------------
768
# Monitor initialization.
769
 
770
#ifndef CYGPKG_HAL_MIPS_MON_DEFINED
771
 
772
        .macro  hal_mon_init
773
        .endm
774
 
775
#endif
776
 
777
#------------------------------------------------------------------------------
778
#endif // ifndef CYGONCE_HAL_ARCH_INC
779
# end of arch.inc

powered by: WebSVN 2.1.0

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