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

Subversion Repositories openrisc_me

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 27 unneback
#ifndef CYGONCE_HAL_VARIANT_INC
2
#define CYGONCE_HAL_VARIANT_INC
3
//#=============================================================================
4
//#
5
//#     variant.inc
6
//#
7
//#     UPD985XX 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):  hmt, nickg
46
//# Contributors:       nickg
47
//# Date:       2001-05-24
48
//# Purpose:    UPD985XX definitions.
49
//# Description:        This file contains various definitions and macros that are
50
//#              useful for writing assembly code for the UPD985XX CPU.
51
//# Usage:
52
//#             #include 
53
//#             ...
54
//#
55
//#
56
//#####DESCRIPTIONEND####
57
//#
58
//#=============================================================================
59
 
60
        .set    mips3
61
 
62
#include 
63
 
64
#include 
65
 
66
#include 
67
 
68
#include CYGBLD_HAL_PLATFORM_H
69
 
70
#include 
71
 
72
#include 
73
#include 
74
 
75
// ------------------------------------------------------------------------
76
// Basic LED and poke-uart level debugging stuff.
77
 
78
#if 0
79
        .macro DELAY dd
80
        la      k0,\dd
81
98:     addiu   k0,k0,-1
82
        bnez    k0,98b
83
         nop
84
        .endm
85
 
86
        .macro LED nn
87
        la      k1,0xb0000000
88
        la      k0,0xfdff
89
        sw      k0,0x20(k1)
90
        nop
91
        nop
92
        nop
93
        la      t0,\nn
94
99:
95
        la      k0,0x100
96
        sw      k0,0x24(k1)
97
 
98
        DELAY 0x40000
99
 
100
        la      k0,0x000
101
        sw      k0,0x24(k1)
102
 
103
        DELAY 0x30000
104
 
105
        addi    t0,t0,-1
106
        bnez    t0,99b
107
         nop
108
 
109
        DELAY 0xd0000
110
 
111
        .endm
112
 
113
        .macro PRINT nn
114
        la      k1,0xb0000000
115
        DELAY 0x10000
116
        la      k0, '.'
117
        sw      k0,0x80(k1)
118
        DELAY 0x10000
119
        la      k0, 0xf & ((\nn) >> 4)
120
        addi    k0,k0,'0'
121
        sw      k0,0x80(k1)
122
        DELAY 0x10000
123
        la      k0, 0xf & ((\nn))
124
        addi    k0,k0,'0'
125
        sw      k0,0x80(k1)
126
        DELAY 0x10000
127
        la      k0, '.'
128
        sw      k0,0x80(k1)
129
        .endm
130
 
131
        .macro DEBUG nn
132
        #LED \nn
133
        PRINT \nn
134
        .endm
135
 
136
#else
137
 
138
        .macro DEBUG nn
139
        .endm
140
 
141
#endif
142
 
143
##-----------------------------------------------------------------------------
144
## configure the architecture HAL to define the right things.
145
 
146
## ISR tables are larger than the defaults defined in vectors.S
147
## We define our own in var_misc.c
148
#define CYG_HAL_MIPS_ISR_TABLES_DEFINED
149
 
150
## VSR table is at a fixed RAM address defined by the linker script
151
#define CYG_HAL_MIPS_VSR_TABLE_DEFINED
152
 
153
//------------------------------------------------------------------------------
154
// Set up initial value for config register. Sets endian mode and
155
// disables the cache on kseg0.
156
 
157
#if defined(CYGPKG_HAL_MIPS_MSBFIRST)
158
# define        INITIAL_CONFIG0 ***!!!Nope, it should be little-endian!!!***
159
#elif defined(CYGPKG_HAL_MIPS_LSBFIRST)
160
# define        INITIAL_CONFIG0 0x00000002
161
#else
162
# error MIPS endianness not set by configuration
163
#endif
164
 
165
//------------------------------------------------------------------------------
166
// Initial SR value for use standalone and with GDB_stubs:
167
// CP0 usable
168
// Vectors to RAM
169
// All hw ints disabled
170
 
171
#define INITIAL_SR      0x10000000
172
 
173
#------------------------------------------------------------------------------
174
# Cache macros.
175
 
176
 
177
#ifndef CYGPKG_HAL_MIPS_CACHE_DEFINED
178
 
179
        .macro  hal_cache_init
180
 
181
        mfc0    v0,config0              # disable Kseg0 caching in config0 register
182
        nop
183
        nop
184
        la      v1,0xfffffff8
185
        and     v0,v0,v1
186
        ori     v0,v0,2
187
        mtc0    v0,config0
188
        nop
189
        nop
190
        nop
191
 
192
        // If we invalidate the caches in RAM startup, this destroys
193
        // network debugging == the network device.
194
        // Don~t fully understand why, but this exclusion fixes it.
195
        // Invalidating caches could destroy other RedBoot state so we
196
        // shouldn~t do it anyway.
197
#ifndef CYG_HAL_STARTUP_RAM
198
 
199
        .set mips3                      # Set ISA to MIPS 3 to allow cache insns
200
 
201
        // Now ensure the caches are invalidated. The caches are NOT cleared or
202
        // invalidated on non-power-up resets and may come up in a random state
203
        // on power-up. Hence they may contain stale or randomly bogus data.
204
        // Here we use the index-store-tag cache operation to clear all the cache
205
        // tags and states to zero. This will render them all invalid on the
206
        // VR4300.
207
 
208
        # D-cache:
209
        la      t0,0x80000000
210
        addi    t1,t0,0x2000
211
1:
212
        mtc0    zero,$28
213
        mtc0    zero,$29
214
        cache   0x09,0(t0)
215
        addi    t0,t0,0x10
216
        sub     v0,t1,t0
217
        bgez    v0,1b
218
         nop
219
 
220
        # I-cache:
221
        la      a0,0x80000000
222
        addi    a1,a0,0x4000
223
1:
224
        mtc0    zero,$28
225
        mtc0    zero,$29
226
        cache   0x08,0(a0)
227
        addi    a0,a0,0x20
228
        sub     v0,a1,a0
229
        bgez    v0,1b
230
         nop
231
 
232
        .set mips0                      # reset ISA to default
233
 
234
#endif
235
 
236
        .endm
237
 
238
#define CYGPKG_HAL_MIPS_CACHE_DEFINED
239
 
240
#endif
241
 
242
//-----------------------------------------------------------------------------
243
// Load Address and Relocate. This macro is used in code that may be
244
// linked to execute out of RAM but is actually executed from ROM. The
245
// code that initializes the memory controller and copies the ROM
246
// contents to RAM must work in this way, for example. This macro is used
247
// in place of an "la" macro instruction when loading code and data
248
// addresses.  There are two versions of the macro here. The first
249
// assumes that we are executing in the ROM space at 0xbfc00000 and are
250
// linked to run in the RAM space at 0x80000000.  It simply adds the
251
// difference between the two to the loaded address.  The second is more
252
// code, but will execute correctly at either location since it
253
// calculates the difference at runtime.  The second variant is enabled
254
// by default.
255
 
256
 
257
#ifdef CYG_HAL_STARTUP_ROMRAM
258
 
259
#if 0
260
        .macro  lar     reg,addr
261
        .set    noat
262
        la      \reg,\addr
263
        la      $at,0x3fc00000
264
        addu    \reg,\reg,$at
265
        .set    at
266
        .endm
267
#else
268
        .macro  lar     reg,addr
269
        .set    noat
270
        move    $at,ra                  # save ra
271
        la      \reg,\addr              # get address into register
272
        la      ra,x\@                  # get linked address of label
273
        subiu   \reg,\reg,ra            # subtract it from value
274
        bal     x\@                     # branch and link to label
275
        nop                             #  to get current actual address
276
x\@:
277
        addiu   \reg,\reg,ra            # add actual address
278
        move    ra,$at                  # restore ra
279
        .set    at
280
        .endm
281
 
282
#endif
283
 
284
#define CYGPKG_HAL_MIPS_LAR_DEFINED
285
 
286
#endif
287
 
288
//----------------------------------------------------------------------------
289
// MMU macros.
290
// The MMU must be set up on this board before we can access any external devices,
291
// including the memory controller, so we have no RAM to work with yet.
292
// Since the setup code must work only in registers, we do not do a subroutine
293
// linkage here, instead the setup code knows to jump back here when finished.
294
 
295
#if defined(CYG_HAL_STARTUP_ROM) || defined(CYG_HAL_STARTUP_ROMRAM)
296
 
297
// There is none.  We can access all areas via kseg[01] so we are happy
298
// with no MMU setup.
299
 
300
// NO #define CYGPKG_HAL_MIPS_MMU_DEFINED
301
 
302
#endif
303
 
304
//----------------------------------------------------------------------------
305
// MEMC macros.
306
//
307
        .macro  hal_memc_init
308
 
309
#if defined(CYG_HAL_STARTUP_ROM) || defined(CYG_HAL_STARTUP_ROMRAM)
310
 
311
        .extern hal_memc_setup
312
        lar     k0,hal_memc_setup
313
        jalr    k0
314
        nop
315
 
316
#endif
317
 
318
#if defined(CYG_HAL_STARTUP_ROMRAM)
319
 
320
        # Having got the RAM working, we must now relocate the Entire
321
        # ROM into it and then continue execution from RAM.
322
 
323
        la      t0,0x80000000           # dest addr
324
        la      t1,0xbfc00000           # source addr
325
        la      t3,__ram_data_end       # end dest addr
326
1:
327
        lw      v0,0(t1)                # get word
328
        addiu   t1,t1,4
329
        sw      v0,0(t0)                # write word
330
        addiu   t0,t0,4
331
        bne     t0,t3,1b
332
        nop
333
 
334
        la      v0,2f                   # RAM address to go to
335
        jr      v0
336
        nop
337
2:
338
        # We are now executing out of RAM!
339
 
340
#endif
341
 
342
        .endm
343
 
344
#define CYGPKG_HAL_MIPS_MEMC_DEFINED
345
 
346
#------------------------------------------------------------------------------
347
# Interrupt controller initialization.
348
 
349
#ifndef CYGPKG_HAL_MIPS_INTC_DEFINED
350
 
351
#ifndef CYGPKG_HAL_MIPS_INTC_INIT_DEFINED
352
        # initialize all interrupts to disabled
353
        .macro  hal_intc_init
354
        mfc0    v0,status
355
        nop
356
        lui     v1,0xFFFF
357
        ori     v1,v1,0x00FF
358
        and     v0,v0,v1                # clear the IntMask bits
359
        mtc0    v0,status
360
        nop
361
        nop
362
        nop
363
        .endm
364
#endif
365
 
366
#ifndef CYGPKG_HAL_MIPS_INTC_DECODE_DEFINED
367
        .macro  hal_intc_decode vnum
368
        mfc0    v1,status               # get status register (interrupt mask)
369
        nop                             # delay slot
370
        mfc0    v0,cause                # get cause register
371
        nop                             # delay slot
372
        and     v0,v0,v1                # apply interrupt mask
373
        andi    v1,v0,0x0300            # test for soft interrupt bits
374
        beqz    v1, 43f                 # neither of them
375
         srl    v1,v1,8                 # shift interrupt bits down
376
        addi    v1,v1,-1                # now have 1,2,3 in v1 -> 0,1,2
377
        andi    \vnum,v1,1              # -> 0,1,0 is the right answer
378
        b       44f
379
         nop
380
43:
381
        srl     v0,v0,10                # shift interrupt bits down
382
        andi    v0,v0,0x3f              # isolate 6 interrupt bits
383
        la      v1,hal_intc_translation_table
384
        add     v0,v0,v1                # index into table
385
        lb      \vnum,0(v0)             # pick up vector number
386
        addi    \vnum,\vnum,2           # offset soft intrs
387
44:     nop
388
        .endm
389
#endif
390
 
391
#ifndef CYGPKG_HAL_MIPS_INTC_TRANSLATE_DEFINED
392
#ifdef CYGIMP_HAL_COMMON_INTERRUPTS_CHAIN
393
        .macro  hal_intc_translate inum,vnum
394
        move    \vnum,zero                      # Just vector zero is supported
395
        .endm
396
#else
397
        .macro  hal_intc_translate inum,vnum
398
        move    \vnum,\inum                     # Vector == interrupt number
399
        .endm
400
#endif
401
#endif
402
 
403
        .macro  hal_intc_decode_data
404
hal_intc_translation_table:
405
        .byte   0, 0, 1, 0
406
        .byte   2, 0, 1, 0
407
        .byte   3, 0, 1, 0
408
        .byte   2, 0, 1, 0
409
        .byte   4, 0, 1, 0
410
        .byte   2, 0, 1, 0
411
        .byte   3, 0, 1, 0
412
        .byte   2, 0, 1, 0
413
        .byte   5, 0, 1, 0
414
        .byte   2, 0, 1, 0
415
        .byte   3, 0, 1, 0
416
        .byte   2, 0, 1, 0
417
        .byte   4, 0, 1, 0
418
        .byte   2, 0, 1, 0
419
        .byte   3, 0, 1, 0
420
        .byte   2, 0, 1, 0
421
        .endm
422
 
423
#define CYGPKG_HAL_MIPS_INTC_DEFINED
424
 
425
#endif // CYGPKG_HAL_MIPS_INTC_DEFINED
426
 
427
 
428
#------------------------------------------------------------------------------
429
# Monitor initialization.
430
 
431
 
432
# Macro for copying vectors to RAM if necessary.
433
#if !defined(CYGSEM_HAL_USE_ROM_MONITOR)
434
 
435
        .macro  hal_vectors_init
436
 
437
        # If we don~t play nice with a ROM monitor, copy the required
438
        # vectors into the proper location.
439
        la      t0,0x80000000           # dest addr
440
        la      t1,utlb_vector          # source addr
441
        la      t3,utlb_vector_end      # end dest addr
442
1:
443
        lw      v0,0(t1)                # get word
444
        addi    t1,t1,4
445
        sw      v0,0x0000(t0)           # write word to utlb vec
446
        sw      v0,0x0080(t0)           # and also to xtlb vector (64-bit)
447
        addi    t0,t0,4                 #         (no harm done)
448
        bne     t1,t3,1b
449
         nop
450
 
451
        la      t0,0x80000000           # dest addr page base
452
        la      t1,other_vector         # source addr
453
        la      t3,other_vector_end     # end dest addr
454
1:
455
        lw      v0,0(t1)                # get word
456
        addi    t1,t1,4
457
        sw      v0,0x0180(t0)           # write word to other vector
458
        addi    t0,t0,4
459
        bne     t1,t3,1b
460
         nop
461
 
462
        // We are running uncached here anyhow, so no need to flush caches
463
 
464
        .endm
465
 
466
#else
467
 
468
        .macro  hal_vectors_init
469
        .endm
470
 
471
#endif
472
 
473
 
474
#ifndef CYGPKG_HAL_MIPS_MON_DEFINED
475
 
476
#if     defined(CYG_HAL_STARTUP_ROM) ||                 \
477
        (       defined(CYG_HAL_STARTUP_RAM) &&         \
478
                !defined(CYGSEM_HAL_USE_ROM_MONITOR))
479
 
480
        # If we are starting up from ROM, or we are starting in
481
        # RAM and NOT using a ROM monitor, initialize the VSR table.
482
 
483
        .macro  hal_mon_init
484
 
485
        hal_vectors_init
486
 
487
        # Set default exception VSR for all vectors
488
        ori     a0,zero,64 // not CYGNUM_HAL_VSR_COUNT at all
489
        la      a1,__default_exception_vsr
490
        la      a2,hal_vsr_table
491
1:      sw      a1,0(a2)
492
        addi    a2,a2,4
493
        addi    a0,a0,-1
494
        bne     a0,zero,1b
495
         nop
496
 
497
        # Now set special VSRs
498
 
499
        # FIXME: Should use proper definitions
500
 
501
        la      a0,hal_vsr_table
502
        # Set interrupt VSR
503
        la      a1,__default_interrupt_vsr
504
        sw      a1,0*4(a0) // CYGNUM_HAL_VECTOR_INTERRUPT
505
        # Add special handler on breakpoint vector to allow GDB and
506
        # GCC to both use 'break' without conflicts.
507
        la      a1,__break_vsr_springboard
508
        sw      a1,9*4(a0) // CYGNUM_HAL_VECTOR_BREAKPOINT
509
 
510
        # Set exception handler on special vectors
511
// but these are already set up above:
512
//        la    a1,__default_exception_vsr
513
//        sw    a1,32*4(a0)             # debug
514
//        sw    a1,33*4(a0)             # utlb
515
//        sw    a1,34*4(a0)             # nmi
516
        .endm
517
 
518
#elif defined(CYG_HAL_STARTUP_RAM) && defined(CYGSEM_HAL_USE_ROM_MONITOR)
519
 
520
        # Initialize the VSR table entries
521
        # We only take control of the interrupt vector,
522
        # the rest are left to the ROM for now...
523
 
524
        .macro  hal_mon_init
525
        hal_vectors_init
526
        # Set interrupt VSR
527
        la      a0,hal_vsr_table
528
        la      a1,__default_interrupt_vsr
529
        sw      a1,0*4(a0) // CYGNUM_HAL_VECTOR_INTERRUPT
530
        .endm
531
 
532
#else
533
 
534
        .macro  hal_mon_init
535
        hal_vectors_init
536
        .endm
537
 
538
#endif
539
 
540
#define CYGPKG_HAL_MIPS_MON_DEFINED
541
#endif
542
 
543
#------------------------------------------------------------------------------
544
# Diagnostic macros
545
 
546
 
547
#------------------------------------------------------------------------------
548
#endif // ifndef CYGONCE_HAL_VARIANT_INC
549
# end of variant.inc

powered by: WebSVN 2.1.0

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