1 |
786 |
skrzyp |
#ifndef CYGONCE_PLF_IO_H
|
2 |
|
|
#define CYGONCE_PLF_IO_H
|
3 |
|
|
|
4 |
|
|
//=============================================================================
|
5 |
|
|
//
|
6 |
|
|
// plf_io.h
|
7 |
|
|
//
|
8 |
|
|
// HAL platform device IO register support.
|
9 |
|
|
//
|
10 |
|
|
//=============================================================================
|
11 |
|
|
// ####ECOSGPLCOPYRIGHTBEGIN####
|
12 |
|
|
// -------------------------------------------
|
13 |
|
|
// This file is part of eCos, the Embedded Configurable Operating System.
|
14 |
|
|
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
|
15 |
|
|
//
|
16 |
|
|
// eCos is free software; you can redistribute it and/or modify it under
|
17 |
|
|
// the terms of the GNU General Public License as published by the Free
|
18 |
|
|
// Software Foundation; either version 2 or (at your option) any later
|
19 |
|
|
// version.
|
20 |
|
|
//
|
21 |
|
|
// eCos is distributed in the hope that it will be useful, but WITHOUT
|
22 |
|
|
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
23 |
|
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
24 |
|
|
// for more details.
|
25 |
|
|
//
|
26 |
|
|
// You should have received a copy of the GNU General Public License
|
27 |
|
|
// along with eCos; if not, write to the Free Software Foundation, Inc.,
|
28 |
|
|
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
29 |
|
|
//
|
30 |
|
|
// As a special exception, if other files instantiate templates or use
|
31 |
|
|
// macros or inline functions from this file, or you compile this file
|
32 |
|
|
// and link it with other works to produce a work based on this file,
|
33 |
|
|
// this file does not by itself cause the resulting work to be covered by
|
34 |
|
|
// the GNU General Public License. However the source code for this file
|
35 |
|
|
// must still be made available in accordance with section (3) of the GNU
|
36 |
|
|
// General Public License v2.
|
37 |
|
|
//
|
38 |
|
|
// This exception does not invalidate any other reasons why a work based
|
39 |
|
|
// on this file might be covered by the GNU General Public License.
|
40 |
|
|
// -------------------------------------------
|
41 |
|
|
// ####ECOSGPLCOPYRIGHTEND####
|
42 |
|
|
//=============================================================================
|
43 |
|
|
//#####DESCRIPTIONBEGIN####
|
44 |
|
|
//
|
45 |
|
|
// Author(s): nickg
|
46 |
|
|
// Contributors:nickg, jskov
|
47 |
|
|
// Date: 2000-05-18
|
48 |
|
|
// Purpose: Define IO register support
|
49 |
|
|
// Description: The macros defined here provide the HAL APIs for handling
|
50 |
|
|
// device IO control registers.
|
51 |
|
|
//
|
52 |
|
|
// Usage:
|
53 |
|
|
// #include <cyg/hal/plf_io.h>
|
54 |
|
|
// ...
|
55 |
|
|
//
|
56 |
|
|
//
|
57 |
|
|
//####DESCRIPTIONEND####
|
58 |
|
|
//
|
59 |
|
|
//=============================================================================
|
60 |
|
|
|
61 |
|
|
#include <pkgconf/hal.h>
|
62 |
|
|
|
63 |
|
|
//-----------------------------------------------------------------------------
|
64 |
|
|
// BYTE Register access.
|
65 |
|
|
// Individual and vectorized access to 8 bit registers.
|
66 |
|
|
|
67 |
|
|
// Little-endian version
|
68 |
|
|
#if (CYG_BYTEORDER == CYG_LSBFIRST)
|
69 |
|
|
|
70 |
|
|
#define HAL_READ_UINT8( _register_, _value_ ) \
|
71 |
|
|
((_value_) = *((volatile CYG_BYTE *)(_register_)))
|
72 |
|
|
|
73 |
|
|
#define HAL_WRITE_UINT8( _register_, _value_ ) \
|
74 |
|
|
(*((volatile CYG_BYTE *)(_register_)) = (_value_))
|
75 |
|
|
|
76 |
|
|
#define HAL_READ_UINT8_VECTOR( _register_, _buf_, _count_, _step_ ) \
|
77 |
|
|
CYG_MACRO_START \
|
78 |
|
|
cyg_count32 _i_,_j_; \
|
79 |
|
|
for( _i_ = 0, _j_ = 0; _i_ < (_count_); _i_++, _j_ += (_step_)) \
|
80 |
|
|
(_buf_)[_i_] = ((volatile CYG_BYTE *)(_register_))[_j_]; \
|
81 |
|
|
CYG_MACRO_END
|
82 |
|
|
|
83 |
|
|
#define HAL_WRITE_UINT8_VECTOR( _register_, _buf_, _count_, _step_ ) \
|
84 |
|
|
CYG_MACRO_START \
|
85 |
|
|
cyg_count32 _i_,_j_; \
|
86 |
|
|
for( _i_ = 0, _j_ = 0; _i_ < (_count_); _i_++, _j_ += (_step_)) \
|
87 |
|
|
((volatile CYG_BYTE *)(_register_))[_j_] = (_buf_)[_i_]; \
|
88 |
|
|
CYG_MACRO_END
|
89 |
|
|
|
90 |
|
|
#else // Big-endian version
|
91 |
|
|
|
92 |
|
|
#define HAL_READ_UINT8( _register_, _value_ ) \
|
93 |
|
|
((_value_) = *((volatile CYG_BYTE *)((CYG_ADDRWORD)(_register_)^3)))
|
94 |
|
|
|
95 |
|
|
#define HAL_WRITE_UINT8( _register_, _value_ ) \
|
96 |
|
|
(*((volatile CYG_BYTE *)((CYG_ADDRWORD)(_register_)^3)) = (_value_))
|
97 |
|
|
|
98 |
|
|
#define HAL_READ_UINT8_VECTOR( _register_, _buf_, _count_, _step_ ) \
|
99 |
|
|
CYG_MACRO_START \
|
100 |
|
|
cyg_count32 _i_,_j_; \
|
101 |
|
|
volatile CYG_BYTE* _r_ = ((CYG_ADDRWORD)(_register_)^3); \
|
102 |
|
|
for( _i_ = 0, _j_ = 0; _i_ < (_count_); _i_++, _j_ += (_step_)) \
|
103 |
|
|
(_buf_)[_i_] = _r_[_j_]; \
|
104 |
|
|
CYG_MACRO_END
|
105 |
|
|
|
106 |
|
|
#define HAL_WRITE_UINT8_VECTOR( _register_, _buf_, _count_, _step_ ) \
|
107 |
|
|
CYG_MACRO_START \
|
108 |
|
|
cyg_count32 _i_,_j_; \
|
109 |
|
|
volatile CYG_BYTE* _r_ = ((CYG_ADDRWORD)(_register_)^3); \
|
110 |
|
|
for( _i_ = 0, _j_ = 0; _i_ < (_count_); _i_++, _j_ += (_step_)) \
|
111 |
|
|
_r_[_j_] = (_buf_)[_i_]; \
|
112 |
|
|
CYG_MACRO_END
|
113 |
|
|
|
114 |
|
|
#endif // Big-endian
|
115 |
|
|
|
116 |
|
|
//-----------------------------------------------------------------------------
|
117 |
|
|
// 16 bit access.
|
118 |
|
|
// Individual and vectorized access to 16 bit registers.
|
119 |
|
|
|
120 |
|
|
// Little-endian version
|
121 |
|
|
#if (CYG_BYTEORDER == CYG_LSBFIRST)
|
122 |
|
|
|
123 |
|
|
#define HAL_READ_UINT16( _register_, _value_ ) \
|
124 |
|
|
((_value_) = *((volatile CYG_WORD16 *)(_register_)))
|
125 |
|
|
|
126 |
|
|
#define HAL_WRITE_UINT16( _register_, _value_ ) \
|
127 |
|
|
(*((volatile CYG_WORD16 *)(_register_)) = (_value_))
|
128 |
|
|
|
129 |
|
|
#define HAL_READ_UINT16_VECTOR( _register_, _buf_, _count_, _step_ ) \
|
130 |
|
|
CYG_MACRO_START \
|
131 |
|
|
cyg_count32 _i_,_j_; \
|
132 |
|
|
for( _i_ = 0, _j_ = 0; _i_ < (_count_); _i_++, _j_ += (_step_)) \
|
133 |
|
|
(_buf_)[_i_] = ((volatile CYG_WORD16 *)(_register_))[_j_]; \
|
134 |
|
|
CYG_MACRO_END
|
135 |
|
|
|
136 |
|
|
#define HAL_WRITE_UINT16_VECTOR( _register_, _buf_, _count_, _step_ ) \
|
137 |
|
|
CYG_MACRO_START \
|
138 |
|
|
cyg_count32 _i_,_j_; \
|
139 |
|
|
for( _i_ = 0, _j_ = 0; _i_ < (_count_); _i_++, _j_ += (_step_)) \
|
140 |
|
|
((volatile CYG_WORD16 *)(_register_))[_j_] = (_buf_)[_i_]; \
|
141 |
|
|
CYG_MACRO_END
|
142 |
|
|
|
143 |
|
|
#else // Big-endian version
|
144 |
|
|
|
145 |
|
|
#define HAL_READ_UINT16( _register_, _value_ ) \
|
146 |
|
|
((_value_) = *((volatile CYG_WORD16 *)((CYG_ADDRWORD)(_register_)^3)))
|
147 |
|
|
|
148 |
|
|
#define HAL_WRITE_UINT16( _register_, _value_ ) \
|
149 |
|
|
(*((volatile CYG_WORD16 *)((CYG_ADDRWORD)(_register_)^3)) = (_value_))
|
150 |
|
|
|
151 |
|
|
#define HAL_READ_UINT16_VECTOR( _register_, _buf_, _count_, _step_ ) \
|
152 |
|
|
CYG_MACRO_START \
|
153 |
|
|
cyg_count32 _i_,_j_; \
|
154 |
|
|
volatile CYG_WORD16* _r_ = ((CYG_ADDRWORD)(_register_)^3); \
|
155 |
|
|
for( _i_ = 0, _j_ = 0; _i_ < (_count_); _i_++, _j_ += (_step_)) \
|
156 |
|
|
(_buf_)[_i_] = _r_[_j_]; \
|
157 |
|
|
CYG_MACRO_END
|
158 |
|
|
|
159 |
|
|
#define HAL_WRITE_UINT16_VECTOR( _register_, _buf_, _count_, _step_ ) \
|
160 |
|
|
CYG_MACRO_START \
|
161 |
|
|
cyg_count32 _i_,_j_; \
|
162 |
|
|
volatile CYG_WORD16* _r_ = ((CYG_ADDRWORD)(_register_)^3); \
|
163 |
|
|
for( _i_ = 0, _j_ = 0; _i_ < (_count_); _i_++, _j_ += (_step_)) \
|
164 |
|
|
_r_[_j_] = (_buf_)[_i_]; \
|
165 |
|
|
CYG_MACRO_END
|
166 |
|
|
|
167 |
|
|
#endif // Big-endian
|
168 |
|
|
|
169 |
|
|
//-----------------------------------------------------------------------------
|
170 |
|
|
// 32 bit access.
|
171 |
|
|
// Individual and vectorized access to 32 bit registers.
|
172 |
|
|
|
173 |
|
|
// Note: same macros for little- and big-endian systems.
|
174 |
|
|
|
175 |
|
|
#define HAL_READ_UINT32( _register_, _value_ ) \
|
176 |
|
|
((_value_) = *((volatile CYG_WORD32 *)(_register_)))
|
177 |
|
|
|
178 |
|
|
#define HAL_WRITE_UINT32( _register_, _value_ ) \
|
179 |
|
|
(*((volatile CYG_WORD32 *)(_register_)) = (_value_))
|
180 |
|
|
|
181 |
|
|
#define HAL_READ_UINT32_VECTOR( _register_, _buf_, _count_, _step_ ) \
|
182 |
|
|
{ \
|
183 |
|
|
cyg_count32 _i_,_j_; \
|
184 |
|
|
for( _i_ = 0, _j_ = 0; _i_ < (_count_); _i_++, _j_ += (_step_)) \
|
185 |
|
|
(_buf_)[_i_] = ((volatile CYG_WORD32 *)(_register_))[_j_]; \
|
186 |
|
|
}
|
187 |
|
|
|
188 |
|
|
#define HAL_WRITE_UINT32_VECTOR( _register_, _buf_, _count_, _step_ ) \
|
189 |
|
|
{ \
|
190 |
|
|
cyg_count32 _i_,_j_; \
|
191 |
|
|
for( _i_ = 0, _j_ = 0; _i_ < (_count_); _i_++, _j_ += (_step_)) \
|
192 |
|
|
((volatile CYG_WORD32 *)(_register_))[_j_] = (_buf_)[_i_]; \
|
193 |
|
|
}
|
194 |
|
|
|
195 |
|
|
#define HAL_IO_MACROS_DEFINED
|
196 |
|
|
|
197 |
|
|
//-----------------------------------------------------------------------------
|
198 |
|
|
#endif // ifndef CYGONCE_HAL_PLF_IO_H
|
199 |
|
|
// End of plf_io.h
|