1 #ifndef CYGONCE_HAL_VARIANT_INC
2 #define CYGONCE_HAL_VARIANT_INC
3 ##=============================================================================
7 ## IDT32334 family assembler header file
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.
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.
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
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.
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.
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.
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####
45 ## Author(s): tmichals
46 ## Contributors: nickg
48 ## Purpose: MIPS IDT32334 family definitions.
49 ## Description: This file contains various definitions and macros that are
50 ## useful for writing assembly code for the MIPS IDT32334 CPU family.
52 ## #include <cyg/hal/variant.inc>
56 ######DESCRIPTIONEND####
58 ##=============================================================================
60 #include <pkgconf/hal.h>
61 #include <cyg/hal/mips.inc>
62 #include <cyg/hal/platform.inc>
64 #define CYGARC_HAL_COMMON_EXPORT_CPU_MACROS
68 //#include <cyg/hal/mips-regs.h>
70 #define CYGARC_ADDRESS_REG_UNCACHED(reg) \
71 and reg, reg, ~CYGARC_KSEG_MASK; \
72 or reg, reg, CYGARC_KSEG_UNCACHED
74 #define CYGARC_KSEG_MASK (0xE0000000)
75 #define CYGARC_KSEG_CACHED (0x80000000)
76 #define CYGARC_KSEG_UNCACHED (0xA0000000)
77 #define CYGARC_KSEG_CACHED_BASE (0x80000000)
78 #define CYGARC_KSEG_UNCACHED_BASE (0xA0000000)
82 //-----------------------------------------------------------------------------
83 // Load Address and Relocate. This macro is used in code that may be
84 // linked to execute out of RAM but is actually executed from ROM. The
85 // code that initializes the memory controller and copies the ROM
86 // contents to RAM must work in this way, for example. This macro is used
87 // in place of an "la" macro instruction when loading code and data
88 // addresses. There are two versions of the macro here. The first
89 // assumes that we are executing in the ROM space at 0xbfc00000 and are
90 // linked to run in the RAM space at 0x80000000. It simply adds the
91 // difference between the two to the loaded address. The second is more
92 // code, but will execute correctly at either location since it
93 // calculates the difference at runtime. The second variant is enabled
97 #ifdef CYG_HAL_STARTUP_ROMRAM
101 move $at,ra # save ra
102 la \reg,\addr # get address into register
103 la ra,x\@ # get linked address of label
104 sub \reg,\reg,ra # subtract it from value
105 bal x\@ # branch and link to label
106 nop # to get current actual address
108 add \reg,\reg,ra # add actual address
109 move ra,$at # restore ra
113 #define CYGPKG_HAL_MIPS_LAR_DEFINED
118 #------------------------------------------------------------------------------
121 #ifndef CYGPKG_HAL_MIPS_CACHE_DEFINED
123 .macro hal_cache_init
125 # Setup a temporary stack pointer for running C code.
126 la a0,__interrupt_stack
128 CYGARC_ADDRESS_REG_UNCACHED(sp)
130 # Read the CONFIG1 register into a0
136 # Jump to C-code to initialize caches (uncached)
137 lar k0, hal_c_cache_init
138 CYGARC_ADDRESS_REG_UNCACHED(k0)
143 #define CYGPKG_HAL_MIPS_CACHE_DEFINED
148 ##-----------------------------------------------------------------------------
149 ## Define CPU variant for architecture HAL.
152 ##-----------------------------------------------------------------------------
153 ## Indicate that the ISR tables are defined in variant.S
155 #define CYG_HAL_MIPS_ISR_TABLES_DEFINED
157 ##-----------------------------------------------------------------------------
160 #ifndef CYGPKG_HAL_MIPS_MEMC_DEFINED
162 ## ROM timing characteristics are dependent on the clock speed.
170 #define CYGPKG_HAL_MIPS_MEMC_DEFINED
174 ##-----------------------------------------------------------------------------
175 ## IDT32334 interrupt handling.
177 #ifndef CYGPKG_HAL_MIPS_INTC_DEFINED
181 # Set all ILRX registers to 0, masking all external interrupts.
185 .macro hal_intc_decode vnum
192 srl v1,v1,11 # shift IP bits to ls bits
193 andi v1,v1,0x7F # isolate IP bits
195 la v0,hal_intc_translation_table # address of translation table
196 add v0,v0,v1 # offset of index byte
197 lb \vnum,0(v0) # load it
200 #ifndef CYGPKG_HAL_MIPS_INTC_TRANSLATE_DEFINED
201 #ifdef CYGIMP_HAL_COMMON_INTERRUPTS_CHAIN
202 .macro hal_intc_translate inum,vnum
203 move \vnum,zero # Just vector zero is supported
206 .macro hal_intc_translate inum,vnum
207 move \vnum,\inum # Vector == interrupt number
212 # This table translates from the 6 bit value supplied in the IP bits
213 # of the cause register into a 0..16 offset into the ISR tables.
214 .macro hal_intc_decode_data
215 hal_intc_translation_table:
217 .byte 0,1,0,0,3,3,0,0
218 .byte 0,0,0,0,0,0,0,0
219 .byte 5,5,0,0,3,5,0,0
220 .byte 0,0,0,0,0,0,0,0
221 .byte 0,0,0,0,0,0,0,0
222 .byte 0,0,0,0,0,0,0,0
223 .byte 0,0,0,0,0,0,0,0
224 .byte 0,0,0,0,0,0,0,0
228 #define CYGPKG_HAL_MIPS_INTC_DEFINED
232 #------------------------------------------------------------------------------
233 # Diagnostics macros.
236 #ifndef CYGPKG_HAL_MIPS_DIAG_DEFINED
238 # Set up PIO0 for debugging output
242 #define CYGPKG_HAL_MIPS_DIAG_DEFINED
247 #------------------------------------------------------------------------------
248 #endif // ifndef CYGONCE_HAL_VARIANT_INC