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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [hal/] [i386/] [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_HAL_IO_H
2
#define CYGONCE_HAL_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
46
// Contributors: Fabrice Gautier
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
//####DESCRIPTIONEND####
57
//
58
//=============================================================================
59
 
60
#include <cyg/infra/cyg_type.h>
61
 
62
#include <cyg/hal/plf_io.h>
63
 
64
 
65
//-----------------------------------------------------------------------------
66
// IO Register address.
67
// This type is for recording the address of an IO register.
68
 
69
typedef volatile CYG_ADDRWORD HAL_IO_REGISTER;
70
 
71
//-----------------------------------------------------------------------------
72
// BYTE Register access.
73
// Individual and vectorized access to 8 bit registers.
74
 
75
#define HAL_READ_UINT8( _register_, _value_ )   \
76
CYG_MACRO_START                                 \
77
{                                               \
78
    asm volatile ( "xor %%eax,%%eax ;"          \
79
                   "inb %%dx, %%al"             \
80
                   : "=a" (_value_)             \
81
                   :  "d"(_register_)           \
82
        );                                      \
83
}                                               \
84
CYG_MACRO_END
85
 
86
#define HAL_WRITE_UINT8( _register_, _value_ )          \
87
CYG_MACRO_START                                         \
88
{                                                       \
89
    asm volatile ( "outb %%al,%%dx"                     \
90
                   :                                    \
91
                   : "a" (_value_), "d"(_register_) \
92
        );                                              \
93
}                                                       \
94
CYG_MACRO_END
95
 
96
#define HAL_READ_UINT8_VECTOR( _register_, _buf_, _count_, _step_ )     \
97
CYG_MACRO_START                                                         \
98
    ! Not supported MACRO !                                             \
99
CYG_MACRO_END
100
 
101
#define HAL_WRITE_UINT8_VECTOR( _register_, _buf_, _count_, _step_ )    \
102
CYG_MACRO_START                                                         \
103
    ! Not supported MACRO !                                             \
104
CYG_MACRO_END
105
 
106
#define HAL_READ_UINT8_STRING( _register_, _buf_, _count_)      \
107
CYG_MACRO_START                                                 \
108
    asm volatile ( "insb"                                       \
109
                   :                                            \
110
                   : "c" (_count_), "d"(_register_), "D"(_buf_) \
111
        );                                                      \
112
CYG_MACRO_END
113
 
114
#define HAL_WRITE_UINT8_STRING( _register_, _buf_, _count_)     \
115
CYG_MACRO_START                                                 \
116
    asm volatile ( "outsb"                                      \
117
                   :                                            \
118
                   : "c" (_count_), "d"(_register_), "S"(_buf_) \
119
        );                                                      \
120
CYG_MACRO_END
121
 
122
 
123
//-----------------------------------------------------------------------------
124
// 16 bit access.
125
// Individual and vectorized access to 16 bit registers.
126
 
127
#define HAL_READ_UINT16( _register_, _value_ )  \
128
CYG_MACRO_START                                 \
129
{                                               \
130
    asm volatile ( "xor %%eax,%%eax ;"          \
131
                   "inw %%dx, %%ax"             \
132
                   : "=a" (_value_)             \
133
                   :  "d"(_register_)           \
134
        );                                      \
135
}                                               \
136
CYG_MACRO_END
137
 
138
#define HAL_WRITE_UINT16( _register_, _value_ )         \
139
CYG_MACRO_START                                         \
140
{                                                       \
141
    asm volatile ( "outw %%ax,%%dx"                     \
142
                   :                                    \
143
                   : "a" (_value_), "d"(_register_) \
144
        );                                              \
145
}                                                       \
146
CYG_MACRO_END
147
 
148
#define HAL_READ_UINT16_VECTOR( _register_, _buf_, _count_, _step_ )    \
149
    CYG_MACRO_START                                                     \
150
    ! Not supported MACRO !                                             \
151
    CYG_MACRO_END
152
 
153
 
154
#define HAL_WRITE_UINT16_VECTOR( _register_, _buf_, _count_, _step_ )   \
155
    CYG_MACRO_START                                                     \
156
    ! Not supported MACRO !                                             \
157
    CYG_MACRO_END
158
 
159
#define HAL_READ_UINT16_STRING( _register_, _buf_, _count_)             \
160
    CYG_MACRO_START                                                     \
161
    asm volatile ( "insw"                                               \
162
                   :                                                    \
163
                   : "c" (_count_), "d"(_register_), "D"(_buf_)         \
164
        );                                                              \
165
    CYG_MACRO_END
166
 
167
#define HAL_WRITE_UINT16_STRING( _register_, _buf_, _count_)            \
168
    CYG_MACRO_START                                                     \
169
    asm volatile ( "outsw"                                              \
170
                   :                                                    \
171
                   : "c" (_count_), "d"(_register_), "S"(_buf_)         \
172
        );                                                              \
173
    CYG_MACRO_END
174
 
175
 
176
 
177
//-----------------------------------------------------------------------------
178
// 32 bit access.
179
// Individual and vectorized access to 32 bit registers.
180
 
181
#define HAL_READ_UINT32( _register_, _value_ )  \
182
CYG_MACRO_START                                 \
183
{                                               \
184
    asm volatile ( "inl %%dx, %%eax"            \
185
                   : "=a" (_value_)             \
186
                   :  "d"(_register_)           \
187
        );                                      \
188
}                                               \
189
CYG_MACRO_END
190
 
191
#define HAL_WRITE_UINT32( _register_, _value_ )         \
192
CYG_MACRO_START                                         \
193
{                                                       \
194
    asm volatile ( "outl %%eax,%%dx"                    \
195
                   :                                    \
196
                   : "a" (_value_), "d"(_register_)     \
197
        );                                              \
198
}                                                       \
199
CYG_MACRO_END
200
 
201
#define HAL_READ_UINT32_VECTOR( _register_, _buf_, _count_, _step_ )    \
202
    CYG_MACRO_START                                                     \
203
    ! Not supported MACRO !                                             \
204
    CYG_MACRO_END
205
 
206
#define HAL_WRITE_UINT32_VECTOR( _register_, _buf_, _count_, _step_ )   \
207
    CYG_MACRO_START                                                     \
208
    ! Not supported MACRO !                                             \
209
    CYG_MACRO_END
210
 
211
#define HAL_READ_UINT32_STRING( _register_, _buf_, _count_)             \
212
    CYG_MACRO_START                                                     \
213
    asm volatile ( "insl"                                               \
214
                   :                                                    \
215
                   : "c" (_count_), "d"(_register_), "D"(_buf_)         \
216
        );                                                              \
217
    CYG_MACRO_END
218
 
219
#define HAL_WRITE_UINT32_STRING( _register_, _buf_, _count_)            \
220
    CYG_MACRO_START                                                     \
221
    asm volatile ( "outsl"                                              \
222
                   :                                                    \
223
                   : "c" (_count_), "d"(_register_), "S"(_buf_)         \
224
        );                                                              \
225
    CYG_MACRO_END
226
 
227
 
228
//-----------------------------------------------------------------------------
229
 
230
// Macros for acessing shared memory structures
231
 
232
#define HAL_READMEM_UINT8(   _reg_, _val_ ) ((_val_) = *((volatile CYG_BYTE *)(_reg_)))
233
#define HAL_WRITEMEM_UINT8(  _reg_, _val_ ) (*((volatile CYG_BYTE *)(_reg_)) = (_val_))
234
 
235
#define HAL_READMEM_UINT16(  _reg_, _val_ ) ((_val_) = *((volatile CYG_WORD16 *)(_reg_)))
236
#define HAL_WRITEMEM_UINT16( _reg_, _val_ ) (*((volatile CYG_WORD16 *)(_reg_)) = (_val_))
237
 
238
#define HAL_READMEM_UINT32(  _reg_, _val_ ) ((_val_) = *((volatile CYG_WORD32 *)(_reg_)))
239
#define HAL_WRITEMEM_UINT32( _reg_, _val_ ) (*((volatile CYG_WORD32 *)(_reg_)) = (_val_))
240
 
241
//-----------------------------------------------------------------------------
242
#endif // ifndef CYGONCE_HAL_HAL_IO_H
243
// 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.