1 |
786 |
skrzyp |
#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) 2003, 2006, 2008 Free Software Foundation, 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
|
18 |
|
|
// version.
|
19 |
|
|
//
|
20 |
|
|
// eCos is distributed in the hope that it will be useful, but WITHOUT
|
21 |
|
|
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
22 |
|
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
23 |
|
|
// for more details.
|
24 |
|
|
//
|
25 |
|
|
// You should have received a copy of the GNU General Public License
|
26 |
|
|
// along with eCos; if not, write to the Free Software Foundation, Inc.,
|
27 |
|
|
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
28 |
|
|
//
|
29 |
|
|
// As a special exception, if other files instantiate templates or use
|
30 |
|
|
// macros or inline functions from this file, or you compile this file
|
31 |
|
|
// and link it with other works to produce a work based on this file,
|
32 |
|
|
// this file does not by itself cause the resulting work to be covered by
|
33 |
|
|
// the GNU General Public License. However the source code for this file
|
34 |
|
|
// must still be made available in accordance with section (3) of the GNU
|
35 |
|
|
// General Public License v2.
|
36 |
|
|
//
|
37 |
|
|
// This exception does not invalidate any other reasons why a work based
|
38 |
|
|
// on this file might be covered by the GNU General Public License.
|
39 |
|
|
// -------------------------------------------
|
40 |
|
|
// ####ECOSGPLCOPYRIGHTEND####
|
41 |
|
|
//=============================================================================
|
42 |
|
|
//#####DESCRIPTIONBEGIN####
|
43 |
|
|
//
|
44 |
|
|
// Author(s): bartv
|
45 |
|
|
// Date: 2003-06-04
|
46 |
|
|
//
|
47 |
|
|
//####DESCRIPTIONEND####
|
48 |
|
|
//=============================================================================
|
49 |
|
|
|
50 |
|
|
#include <pkgconf/hal.h>
|
51 |
|
|
#include <pkgconf/hal_m68k_mcfxxxx.h>
|
52 |
|
|
#include <cyg/infra/cyg_type.h>
|
53 |
|
|
#include <cyg/hal/proc_arch.h>
|
54 |
|
|
|
55 |
|
|
// ----------------------------------------------------------------------------
|
56 |
|
|
// Context support. ColdFire exceptions/interrupts are simpler than the
|
57 |
|
|
// 68000 variants, with a much more regular exception frame. Usually the
|
58 |
|
|
// hardware simply pushes two longs on to the stack. The program counter
|
59 |
|
|
// is at the top. Then the 16-bit status register. Then some extra
|
60 |
|
|
// information identifying the exception number etc. If the stack was not
|
61 |
|
|
// aligned when the exception occurred) (which should not happen for
|
62 |
|
|
// eCos code) then the hardware will do some extra stack alignment and
|
63 |
|
|
// store this information in a fmt field. That possibility is ignored
|
64 |
|
|
// for now.
|
65 |
|
|
|
66 |
|
|
#define HAL_CONTEXT_PCSR \
|
67 |
|
|
cyg_uint32 sr_vec; \
|
68 |
|
|
CYG_ADDRESS pc;
|
69 |
|
|
|
70 |
|
|
// An exception aligns the stack to a 32-bit boundary, and the fmt part
|
71 |
|
|
// of the exception frame encodes how much adjustment was done. The
|
72 |
|
|
// 0x40000000 specifies 0 bytes adjustment since the code should be
|
73 |
|
|
// running with stacks always aligned.
|
74 |
|
|
#define HAL_CONTEXT_PCSR_INIT(_regs_, _entry_, _sr_) \
|
75 |
|
|
CYG_MACRO_START \
|
76 |
|
|
(_regs_)->sr_vec = 0x40000000 | (cyg_uint32)(_sr_); \
|
77 |
|
|
(_regs_)->pc = (CYG_ADDRESS)(_entry_); \
|
78 |
|
|
CYG_MACRO_END
|
79 |
|
|
|
80 |
|
|
#define HAL_CONTEXT_PCSR_GET_SR(_regs_, _sr_) \
|
81 |
|
|
CYG_MACRO_START \
|
82 |
|
|
_sr_ = (_regs_)->sr_vec & 0x0000FFFF; \
|
83 |
|
|
CYG_MACRO_END
|
84 |
|
|
|
85 |
|
|
#define HAL_CONTEXT_PCSR_GET_PC(_regs_, _pc_) \
|
86 |
|
|
CYG_MACRO_START \
|
87 |
|
|
_pc_ = (_regs_)->pc; \
|
88 |
|
|
CYG_MACRO_END
|
89 |
|
|
|
90 |
|
|
#define HAL_CONTEXT_PCSR_SET_SR(_regs_, _sr_) \
|
91 |
|
|
CYG_MACRO_START \
|
92 |
|
|
(_regs_)->sr_vec = ((_regs_)->sr_vec & 0xFFFF0000) | (_sr_); \
|
93 |
|
|
CYG_MACRO_END
|
94 |
|
|
|
95 |
|
|
#define HAL_CONTEXT_PCSR_SET_PC(_regs_, _pc_) \
|
96 |
|
|
CYG_MACRO_START \
|
97 |
|
|
(_regs_)->pc = (CYG_ADDRESS)(_pc_); \
|
98 |
|
|
CYG_MACRO_END
|
99 |
|
|
|
100 |
|
|
#define HAL_CONTEXT_PCSR_GET_EXCEPTION(_regs_, _code_) \
|
101 |
|
|
CYG_MACRO_START \
|
102 |
|
|
(_code_) = (((_regs_)->sr_vec) >> 18) & 0x000000FF; \
|
103 |
|
|
CYG_MACRO_END
|
104 |
|
|
|
105 |
|
|
// ----------------------------------------------------------------------------
|
106 |
|
|
// LSBIT/MSBIT. Most ColdFires have ff1 and bitrev instructions which
|
107 |
|
|
// allow for more efficient implementations than the default ones in
|
108 |
|
|
// the architectural HAL.
|
109 |
|
|
#ifndef _HAL_M68K_MCFxxxx_NO_FF1_
|
110 |
|
|
# define HAL_LSBIT_INDEX(_index_, _mask_) \
|
111 |
|
|
CYG_MACRO_START \
|
112 |
|
|
cyg_uint32 _tmp_ = (_mask_); \
|
113 |
|
|
int _idx_; \
|
114 |
|
|
if (0 == _tmp_) { \
|
115 |
|
|
_idx_ = -1; \
|
116 |
|
|
} else { \
|
117 |
|
|
__asm__ volatile ( \
|
118 |
|
|
"move.l %1, %0 ; \n" \
|
119 |
|
|
"bitrev.l %0 ; \n" \
|
120 |
|
|
"ff1.l %0 ; \n" \
|
121 |
|
|
: "=d" (_idx_) \
|
122 |
|
|
: "d" (_mask_) \
|
123 |
|
|
); \
|
124 |
|
|
} \
|
125 |
|
|
_index_ = _idx_; \
|
126 |
|
|
CYG_MACRO_END
|
127 |
|
|
|
128 |
|
|
# define HAL_MSBIT_INDEX(_index_, _mask_) \
|
129 |
|
|
CYG_MACRO_START \
|
130 |
|
|
cyg_uint32 _tmp_ = (_mask_); \
|
131 |
|
|
int _idx_; \
|
132 |
|
|
__asm__ volatile ( \
|
133 |
|
|
"move.l %1, %0 ; \n" \
|
134 |
|
|
"ff1.l %0\n" \
|
135 |
|
|
: "=d" (_idx_) \
|
136 |
|
|
: "d" (_tmp_) \
|
137 |
|
|
); \
|
138 |
|
|
_index_ = 31 - _idx_; \
|
139 |
|
|
CYG_MACRO_END
|
140 |
|
|
|
141 |
|
|
#endif
|
142 |
|
|
|
143 |
|
|
//-----------------------------------------------------------------------------
|
144 |
|
|
#endif // CYGONCE_HAL_VAR_ARCH_H
|
145 |
|
|
|