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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [hal/] [sparc/] [arch/] [current/] [include/] [hal_io.h] - Blame information for rev 786

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
#ifndef CYGONCE_HAL_IO_H
2
#define CYGONCE_HAL_IO_H
3
 
4
//=============================================================================
5
//
6
//      hal_io.h
7
//
8
//      HAL 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, hmt
46
// Contributors:        nickg, hmt
47
// Date:        1998-02-17
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/hal_io.h>
54
//              ...
55
//              
56
//
57
//####DESCRIPTIONEND####
58
//
59
//=============================================================================
60
 
61
#include <pkgconf/system.h>
62
 
63
#include <cyg/infra/cyg_type.h>
64
 
65
//-----------------------------------------------------------------------------
66
// Enforce in-order IO for all HAL reads/writes using this macro.
67
#define HAL_IO_BARRIER()                        \
68
    asm volatile ( "" : : : "memory" )
69
 
70
//-----------------------------------------------------------------------------
71
// IO Register address.
72
// This type is for recording the address of an IO register.
73
 
74
typedef volatile CYG_ADDRWORD HAL_IO_REGISTER;
75
 
76
//-----------------------------------------------------------------------------
77
// BYTE Register access.
78
// Individual and vectorized access to 8 bit registers.
79
 
80
#define HAL_READ_UINT8( _register_, _value_ )           \
81
    CYG_MACRO_START                                     \
82
    ((_value_) = *((volatile CYG_BYTE *)(_register_))); \
83
    HAL_IO_BARRIER ();                                  \
84
    CYG_MACRO_END
85
 
86
#define HAL_WRITE_UINT8( _register_, _value_ )          \
87
    CYG_MACRO_START                                     \
88
    (*((volatile CYG_BYTE *)(_register_)) = (_value_)); \
89
    HAL_IO_BARRIER ();                                  \
90
    CYG_MACRO_END
91
 
92
#define HAL_READ_UINT8_VECTOR( _register_, _buf_, _count_, _step_ )     \
93
    CYG_MACRO_START                                                     \
94
    cyg_count32 _i_,_j_;                                                \
95
    for( _i_ = 0, _j_ = 0; _i_ < (_count_); _i_++, _j_ += (_step_)) {   \
96
        (_buf_)[_i_] = ((volatile CYG_BYTE *)(_register_))[_j_];        \
97
        HAL_IO_BARRIER ();                                              \
98
    }                                                                   \
99
    CYG_MACRO_END
100
 
101
#define HAL_WRITE_UINT8_VECTOR( _register_, _buf_, _count_, _step_ )    \
102
    CYG_MACRO_START                                                     \
103
    cyg_count32 _i_,_j_;                                                \
104
    for( _i_ = 0, _j_ = 0; _i_ < (_count_); _i_++, _j_ += (_step_)) {   \
105
        ((volatile CYG_BYTE *)(_register_))[_j_] = (_buf_)[_i_];        \
106
        HAL_IO_BARRIER ();                                              \
107
    }                                                                   \
108
    CYG_MACRO_END
109
 
110
 
111
//-----------------------------------------------------------------------------
112
// 16 bit access.
113
// Individual and vectorized access to 16 bit registers.
114
 
115
#define HAL_READ_UINT16( _register_, _value_ )                  \
116
    CYG_MACRO_START                                             \
117
    ((_value_) = *((volatile CYG_WORD16 *)(_register_)));       \
118
    HAL_IO_BARRIER ();                                          \
119
    CYG_MACRO_END
120
 
121
#define HAL_WRITE_UINT16( _register_, _value_ )                 \
122
    CYG_MACRO_START                                             \
123
    (*((volatile CYG_WORD16 *)(_register_)) = (_value_));       \
124
    HAL_IO_BARRIER ();                                          \
125
    CYG_MACRO_END
126
 
127
#define HAL_READ_UINT16_VECTOR( _register_, _buf_, _count_, _step_ )    \
128
    CYG_MACRO_START                                                     \
129
    cyg_count32 _i_,_j_;                                                \
130
    for( _i_ = 0, _j_ = 0; _i_ < (_count_); _i_++, _j_ += (_step_)) {   \
131
        (_buf_)[_i_] = ((volatile CYG_WORD16 *)(_register_))[_j_];      \
132
        HAL_IO_BARRIER ();                                              \
133
    }                                                                   \
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
        HAL_IO_BARRIER ();                                              \
142
    }                                                                   \
143
    CYG_MACRO_END
144
 
145
//-----------------------------------------------------------------------------
146
// 32 bit access.
147
// Individual and vectorized access to 32 bit registers.
148
 
149
#define HAL_READ_UINT32( _register_, _value_ )                  \
150
    CYG_MACRO_START                                             \
151
    ((_value_) = *((volatile CYG_WORD32 *)(_register_)));       \
152
    HAL_IO_BARRIER ();                                          \
153
    CYG_MACRO_END
154
 
155
#define HAL_WRITE_UINT32( _register_, _value_ )                 \
156
    CYG_MACRO_START                                             \
157
    (*((volatile CYG_WORD32 *)(_register_)) = (_value_));       \
158
    HAL_IO_BARRIER ();                                          \
159
    CYG_MACRO_END
160
 
161
#define HAL_READ_UINT32_VECTOR( _register_, _buf_, _count_, _step_ )    \
162
    CYG_MACRO_START                                                     \
163
    cyg_count32 _i_,_j_;                                                \
164
    for( _i_ = 0, _j_ = 0; _i_ < (_count_); _i_++, _j_ += (_step_)) {   \
165
        (_buf_)[_i_] = ((volatile CYG_WORD32 *)(_register_))[_j_];      \
166
        HAL_IO_BARRIER ();                                              \
167
    }                                                                   \
168
    CYG_MACRO_END
169
 
170
#define HAL_WRITE_UINT32_VECTOR( _register_, _buf_, _count_, _step_ )   \
171
    CYG_MACRO_START                                                     \
172
    cyg_count32 _i_,_j_;                                                \
173
    for( _i_ = 0, _j_ = 0; _i_ < (_count_); _i_++, _j_ += (_step_)) {   \
174
        ((volatile CYG_WORD32 *)(_register_))[_j_] = (_buf_)[_i_];      \
175
        HAL_IO_BARRIER ();                                              \
176
    }                                                                   \
177
    CYG_MACRO_END
178
 
179
//-----------------------------------------------------------------------------
180
 
181
#endif // ifndef CYGONCE_HAL_IO_H
182
// End of hal_io.h

powered by: WebSVN 2.1.0

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