1 |
27 |
unneback |
#ifndef CYGONCE_HAL_VAR_ARCH_H
|
2 |
|
|
#define CYGONCE_HAL_VAR_ARCH_H
|
3 |
|
|
//=============================================================================
|
4 |
|
|
//
|
5 |
|
|
// var_arch.h
|
6 |
|
|
//
|
7 |
|
|
// Architecture variant specific abstractions
|
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 |
|
|
|
44 |
|
|
#include <pkgconf/hal.h>
|
45 |
|
|
#include <cyg/infra/cyg_type.h>
|
46 |
|
|
|
47 |
|
|
#include <cyg/hal/proc_arch.h>
|
48 |
|
|
|
49 |
|
|
// The ColdFire family of processors has a simplified exception stack
|
50 |
|
|
// frame that looks like the following:
|
51 |
|
|
//
|
52 |
|
|
// 3322222222221111 111111
|
53 |
|
|
// 1098765432109876 5432109876543210
|
54 |
|
|
// 8 +----------------+----------------+
|
55 |
|
|
// | Program Counter |
|
56 |
|
|
// 4 +----------------+----------------+
|
57 |
|
|
// |Fmt/FS/Vector/FS| SR |
|
58 |
|
|
// SP --> 0 +----------------+----------------+
|
59 |
|
|
//
|
60 |
|
|
// The stack self-aligns to a 4-byte boundary at an exception, with
|
61 |
|
|
// the Fmt/FS/Vector/FS field indicating the size of the adjustment
|
62 |
|
|
// (SP += 0,1,2,3 bytes).
|
63 |
|
|
|
64 |
|
|
// Define the Fmt/FS/Vector/FS word.
|
65 |
|
|
// The first four bits are the format word which tells the
|
66 |
|
|
// RTI instruction how to align the stack.
|
67 |
|
|
#define HAL_MCF52XX_RD_SF_FORMAT_MSK ((CYG_WORD16)0xF000)
|
68 |
|
|
// These bits are the vector number of the exception.
|
69 |
|
|
#define HAL_MCF52XX_RD_SF_VECTOR_MSK ((CYG_WORD16)0x03FC)
|
70 |
|
|
// These are bits 3-2, and 1-0 of the fault status used
|
71 |
|
|
// for bus and address errors.
|
72 |
|
|
#define HAL_MCF52XX_RD_SF_FS32_MSK ((CYG_WORD16)0x0C00)
|
73 |
|
|
#define HAL_MCF52XX_RD_SF_FS10_MSK ((CYG_WORD16)0x0003)
|
74 |
|
|
|
75 |
|
|
// Macros to access fields in the format vector word.
|
76 |
|
|
|
77 |
|
|
#define HAL_MCF52XX_RD_SF_FORMAT(_fmt_vec_word_) \
|
78 |
|
|
((((CYG_WORD16)(_fmt_vec_word_)) & HAL_MCF52XX_RD_SF_FORMAT_MSK) >> 12)
|
79 |
|
|
|
80 |
|
|
#define HAL_MCF52XX_RD_SF_VECTOR(_fmt_vec_word_) \
|
81 |
|
|
((((CYG_WORD16)(_fmt_vec_word_)) & HAL_MCF52XX_RD_SF_VECTOR_MSK) >> 2)
|
82 |
|
|
|
83 |
|
|
#define HAL_MCF52XX_RD_SF_FS(_fmt_vec_word_) \
|
84 |
|
|
(((((CYG_WORD16)(_fmt_vec_word_)) & HAL_MCF52XX_RD_SF_FS32_MSK) >> 8) \
|
85 |
|
|
| (((CYG_WORD16)(_fmt_vec_word_)) & HAL_MCF52XX_RD_SF_FS10_MSK))
|
86 |
|
|
|
87 |
|
|
/*****************************************************************************
|
88 |
|
|
Exception handler saved context. Some exceptions contain extra
|
89 |
|
|
information following this common exception handler context.
|
90 |
|
|
*****************************************************************************/
|
91 |
|
|
typedef struct
|
92 |
|
|
{
|
93 |
|
|
|
94 |
|
|
// Data regs D0-D7
|
95 |
|
|
|
96 |
|
|
#define HAL_EXC_NUM_D_REGS 8
|
97 |
|
|
CYG_WORD32 d[HAL_EXC_NUM_D_REGS];
|
98 |
|
|
|
99 |
|
|
// Address regs A0-A6
|
100 |
|
|
|
101 |
|
|
#define HAL_EXC_NUM_A_REGS 7
|
102 |
|
|
CYG_ADDRESS a[HAL_EXC_NUM_A_REGS];
|
103 |
|
|
|
104 |
|
|
// Stack Pointer
|
105 |
|
|
|
106 |
|
|
CYG_ADDRESS sp;
|
107 |
|
|
|
108 |
|
|
// 16-bit format/vector word
|
109 |
|
|
|
110 |
|
|
CYG_WORD16 fmt_vec_word;
|
111 |
|
|
|
112 |
|
|
// Status Reg
|
113 |
|
|
|
114 |
|
|
CYG_WORD16 sr;
|
115 |
|
|
|
116 |
|
|
// Program Counter
|
117 |
|
|
|
118 |
|
|
CYG_ADDRESS pc;
|
119 |
|
|
|
120 |
|
|
} __attribute__ ((aligned, packed)) HAL_SavedRegisters_exception;
|
121 |
|
|
|
122 |
|
|
#ifndef HAL_GENERIC_SAVED_CONTEXT
|
123 |
|
|
/*****************************************************************************
|
124 |
|
|
HAL_GENERIC_SAVED_CONTEXT -- Generic saved context structure
|
125 |
|
|
|
126 |
|
|
This structure could contain a normal saved context or an exception
|
127 |
|
|
context.
|
128 |
|
|
|
129 |
|
|
*****************************************************************************/
|
130 |
|
|
#define HAL_GENERIC_SAVED_CONTEXT \
|
131 |
|
|
typedef union \
|
132 |
|
|
{ \
|
133 |
|
|
HAL_SavedRegisters_normal normal; \
|
134 |
|
|
HAL_SavedRegisters_exception exception; \
|
135 |
|
|
} __attribute__ ((aligned, packed)) HAL_SavedRegisters;
|
136 |
|
|
#endif // HAL_GENERIC_SAVED_CONTEXT
|
137 |
|
|
|
138 |
|
|
//-----------------------------------------------------------------------------
|
139 |
|
|
// Thread register state manipulation for GDB support.
|
140 |
|
|
|
141 |
|
|
// Translate a stack pointer as saved by the thread context macros above into
|
142 |
|
|
// a pointer to a HAL_SavedRegisters structure.
|
143 |
|
|
#define HAL_THREAD_GET_SAVED_REGISTERS( _sp_, _regs_ ) \
|
144 |
|
|
(_regs_) = (HAL_SavedRegisters *)(_sp_)
|
145 |
|
|
|
146 |
|
|
// Copy a set of registers from a HAL_SavedRegisters structure into a
|
147 |
|
|
// GDB ordered array.
|
148 |
|
|
|
149 |
|
|
/* there are 180 bytes of registers on a 68020 w/68881 */
|
150 |
|
|
/* many of the fpa registers are 12 byte (96 bit) registers */
|
151 |
|
|
/*
|
152 |
|
|
#define NUMREGBYTES 180
|
153 |
|
|
enum regnames {D0,D1,D2,D3,D4,D5,D6,D7,
|
154 |
|
|
A0,A1,A2,A3,A4,A5,A6,A7,
|
155 |
|
|
PS,PC,
|
156 |
|
|
FP0,FP1,FP2,FP3,FP4,FP5,FP6,FP7,
|
157 |
|
|
FPCONTROL,FPSTATUS,FPIADDR
|
158 |
|
|
};
|
159 |
|
|
*/
|
160 |
|
|
|
161 |
|
|
#define HAL_GET_GDB_REGISTERS( _aregval_, _regs_ ) \
|
162 |
|
|
CYG_MACRO_START \
|
163 |
|
|
CYG_ADDRWORD *_regval_ = (CYG_ADDRWORD *)(_aregval_); \
|
164 |
|
|
int _i_; \
|
165 |
|
|
\
|
166 |
|
|
for( _i_ = 0; _i_ < HAL_NUM_D_REGS; _i_++ ) \
|
167 |
|
|
*_regval_++ = (_regs_)->nml_ctxt.d[_i_]; \
|
168 |
|
|
\
|
169 |
|
|
for( _i_ = 0; _i_ < HAL_NUM_A_REGS; _i_++ ) \
|
170 |
|
|
*_regval_++ = (_regs_)->nml_ctxt.a[_i_]; \
|
171 |
|
|
\
|
172 |
|
|
*_regval_++ = (_regs_)->nml_ctxt.sp; \
|
173 |
|
|
*_regval_++ = (CYG_ADDRWORD) ((_regs_)->nml_ctxt.sr); \
|
174 |
|
|
*_regval_++ = (_regs_)->nml_ctxt.pc; \
|
175 |
|
|
/* Undefined registers */ \
|
176 |
|
|
for ( _i_ = 0; _i_ < 8; _i_++ ) \
|
177 |
|
|
{ \
|
178 |
|
|
*((CYG_WORD16*)_regval_)++ = _i_; \
|
179 |
|
|
*((CYG_WORD16*)_regval_)++ = _i_; \
|
180 |
|
|
*((CYG_WORD16*)_regval_)++ = _i_; \
|
181 |
|
|
} \
|
182 |
|
|
*_regval_++ = 0xBADC0DE0; \
|
183 |
|
|
*_regval_++ = 0xBADC0DE1; \
|
184 |
|
|
*_regval_++ = 0xBADC0DE2; \
|
185 |
|
|
CYG_MACRO_END
|
186 |
|
|
|
187 |
|
|
// Copy a GDB ordered array into a HAL_SavedRegisters structure.
|
188 |
|
|
#define HAL_SET_GDB_REGISTERS( _regs_ , _aregval_ ) \
|
189 |
|
|
CYG_MACRO_START \
|
190 |
|
|
CYG_ADDRWORD *_regval_ = (CYG_ADDRWORD *)(_aregval_); \
|
191 |
|
|
int _i_; \
|
192 |
|
|
\
|
193 |
|
|
for( _i_ = 0; _i_ < HAL_NUM_D_REGS; _i_++ ) \
|
194 |
|
|
(_regs_)->nml_ctxt.d[_i_] = *_regval_++; \
|
195 |
|
|
\
|
196 |
|
|
for( _i_ = 0; _i_ < HAL_NUM_A_REGS; _i_++ ) \
|
197 |
|
|
(_regs_)->nml_ctxt.a[_i_] = *_regval_++; \
|
198 |
|
|
\
|
199 |
|
|
(_regs_)->nml_ctxt.sp = *_regval_++; \
|
200 |
|
|
(_regs_)->nml_ctxt.sr = (CYG_WORD16) (*_regval_++); \
|
201 |
|
|
(_regs_)->nml_ctxt.pc = *_regval_++; \
|
202 |
|
|
CYG_MACRO_END
|
203 |
|
|
|
204 |
|
|
/* ************************************************************************ */
|
205 |
|
|
/* These routines write to the special purpose registers in the ColdFire */
|
206 |
|
|
/* core. Since these registers are write-only in the supervisor model, no */
|
207 |
|
|
/* corresponding read routines exist. */
|
208 |
|
|
|
209 |
|
|
externC void mcf52xx_wr_vbr(CYG_WORD32);
|
210 |
|
|
externC void mcf52xx_wr_cacr(CYG_WORD32);
|
211 |
|
|
externC void mcf52xx_wr_acr0(CYG_WORD32);
|
212 |
|
|
externC void mcf52xx_wr_acr1(CYG_WORD32);
|
213 |
|
|
externC void mcf52xx_wr_rambar(CYG_WORD32);
|
214 |
|
|
|
215 |
|
|
//-----------------------------------------------------------------------------
|
216 |
|
|
#endif // CYGONCE_HAL_VAR_ARCH_H
|
217 |
|
|
|