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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [hal/] [i386/] [arch/] [v2_0/] [include/] [hal_io.h] - Blame information for rev 174

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 27 unneback
#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 Red Hat, 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 version.
19
//
20
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
21
// 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 along
26
// with eCos; if not, write to the Free Software Foundation, Inc.,
27
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
28
//
29
// As a special exception, if other files instantiate templates or use macros
30
// or inline functions from this file, or you compile this file and link it
31
// with other works to produce a work based on this file, this file does not
32
// by itself cause the resulting work to be covered by the GNU General Public
33
// License. However the source code for this file must still be made available
34
// in accordance with section (3) of the GNU General Public License.
35
//
36
// This exception does not invalidate any other reasons why a work based on
37
// this file might be covered by the GNU General Public License.
38
//
39
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
40
// at http://sources.redhat.com/ecos/ecos-license/
41
// -------------------------------------------
42
//####ECOSGPLCOPYRIGHTEND####
43
//=============================================================================
44
//#####DESCRIPTIONBEGIN####
45
//
46
// Author(s):    nickg
47
// Contributors: Fabrice Gautier
48
// Date:         1998-02-17
49
// Purpose:      Define IO register support
50
// Description:  The macros defined here provide the HAL APIs for handling
51
//               device IO control registers.
52
//              
53
// Usage:
54
//               #include <cyg/hal/hal_io.h>
55
//               ...
56
//
57
//####DESCRIPTIONEND####
58
//
59
//=============================================================================
60
 
61
#include <cyg/infra/cyg_type.h>
62
 
63
#include <cyg/hal/plf_io.h>
64
 
65
 
66
//-----------------------------------------------------------------------------
67
// IO Register address.
68
// This type is for recording the address of an IO register.
69
 
70
typedef volatile CYG_ADDRWORD HAL_IO_REGISTER;
71
 
72
//-----------------------------------------------------------------------------
73
// BYTE Register access.
74
// Individual and vectorized access to 8 bit registers.
75
 
76
#define HAL_READ_UINT8( _register_, _value_ )   \
77
CYG_MACRO_START                                 \
78
{                                               \
79
    asm volatile ( "xor %%eax,%%eax ;"          \
80
                   "inb %%dx, %%al"             \
81
                   : "=a" (_value_)             \
82
                   :  "d"(_register_)           \
83
        );                                      \
84
}                                               \
85
CYG_MACRO_END
86
 
87
#define HAL_WRITE_UINT8( _register_, _value_ )          \
88
CYG_MACRO_START                                         \
89
{                                                       \
90
    asm volatile ( "outb %%al,%%dx"                     \
91
                   :                                    \
92
                   : "a" (_value_), "d"(_register_) \
93
        );                                              \
94
}                                                       \
95
CYG_MACRO_END
96
 
97
#define HAL_READ_UINT8_VECTOR( _register_, _buf_, _count_, _step_ )     \
98
CYG_MACRO_START                                                         \
99
    ! Not supported MACRO !                                             \
100
CYG_MACRO_END
101
 
102
#define HAL_WRITE_UINT8_VECTOR( _register_, _buf_, _count_, _step_ )    \
103
CYG_MACRO_START                                                         \
104
    ! Not supported MACRO !                                             \
105
CYG_MACRO_END
106
 
107
#define HAL_READ_UINT8_STRING( _register_, _buf_, _count_)      \
108
CYG_MACRO_START                                                 \
109
    asm volatile ( "insb"                                       \
110
                   :                                            \
111
                   : "c" (_count_), "d"(_register_), "D"(_buf_) \
112
        );                                                      \
113
CYG_MACRO_END
114
 
115
#define HAL_WRITE_UINT8_STRING( _register_, _buf_, _count_)     \
116
CYG_MACRO_START                                                 \
117
    asm volatile ( "outsb"                                      \
118
                   :                                            \
119
                   : "c" (_count_), "d"(_register_), "S"(_buf_) \
120
        );                                                      \
121
CYG_MACRO_END
122
 
123
 
124
//-----------------------------------------------------------------------------
125
// 16 bit access.
126
// Individual and vectorized access to 16 bit registers.
127
 
128
#define HAL_READ_UINT16( _register_, _value_ )  \
129
CYG_MACRO_START                                 \
130
{                                               \
131
    asm volatile ( "xor %%eax,%%eax ;"          \
132
                   "inw %%dx, %%ax"             \
133
                   : "=a" (_value_)             \
134
                   :  "d"(_register_)           \
135
        );                                      \
136
}                                               \
137
CYG_MACRO_END
138
 
139
#define HAL_WRITE_UINT16( _register_, _value_ )         \
140
CYG_MACRO_START                                         \
141
{                                                       \
142
    asm volatile ( "outw %%ax,%%dx"                     \
143
                   :                                    \
144
                   : "a" (_value_), "d"(_register_) \
145
        );                                              \
146
}                                                       \
147
CYG_MACRO_END
148
 
149
#define HAL_READ_UINT16_VECTOR( _register_, _buf_, _count_, _step_ )    \
150
    CYG_MACRO_START                                                     \
151
    ! Not supported MACRO !                                             \
152
    CYG_MACRO_END
153
 
154
 
155
#define HAL_WRITE_UINT16_VECTOR( _register_, _buf_, _count_, _step_ )   \
156
    CYG_MACRO_START                                                     \
157
    ! Not supported MACRO !                                             \
158
    CYG_MACRO_END
159
 
160
#define HAL_READ_UINT16_STRING( _register_, _buf_, _count_)             \
161
    CYG_MACRO_START                                                     \
162
    asm volatile ( "insw"                                               \
163
                   :                                                    \
164
                   : "c" (_count_), "d"(_register_), "D"(_buf_)         \
165
        );                                                              \
166
    CYG_MACRO_END
167
 
168
#define HAL_WRITE_UINT16_STRING( _register_, _buf_, _count_)            \
169
    CYG_MACRO_START                                                     \
170
    asm volatile ( "outsw"                                              \
171
                   :                                                    \
172
                   : "c" (_count_), "d"(_register_), "S"(_buf_)         \
173
        );                                                              \
174
    CYG_MACRO_END
175
 
176
 
177
 
178
//-----------------------------------------------------------------------------
179
// 32 bit access.
180
// Individual and vectorized access to 32 bit registers.
181
 
182
#define HAL_READ_UINT32( _register_, _value_ )  \
183
CYG_MACRO_START                                 \
184
{                                               \
185
    asm volatile ( "inl %%dx, %%eax"            \
186
                   : "=a" (_value_)             \
187
                   :  "d"(_register_)           \
188
        );                                      \
189
}                                               \
190
CYG_MACRO_END
191
 
192
#define HAL_WRITE_UINT32( _register_, _value_ )         \
193
CYG_MACRO_START                                         \
194
{                                                       \
195
    asm volatile ( "outl %%eax,%%dx"                    \
196
                   :                                    \
197
                   : "a" (_value_), "d"(_register_)     \
198
        );                                              \
199
}                                                       \
200
CYG_MACRO_END
201
 
202
#define HAL_READ_UINT32_VECTOR( _register_, _buf_, _count_, _step_ )    \
203
    CYG_MACRO_START                                                     \
204
    ! Not supported MACRO !                                             \
205
    CYG_MACRO_END
206
 
207
#define HAL_WRITE_UINT32_VECTOR( _register_, _buf_, _count_, _step_ )   \
208
    CYG_MACRO_START                                                     \
209
    ! Not supported MACRO !                                             \
210
    CYG_MACRO_END
211
 
212
#define HAL_READ_UINT32_STRING( _register_, _buf_, _count_)             \
213
    CYG_MACRO_START                                                     \
214
    asm volatile ( "insl"                                               \
215
                   :                                                    \
216
                   : "c" (_count_), "d"(_register_), "D"(_buf_)         \
217
        );                                                              \
218
    CYG_MACRO_END
219
 
220
#define HAL_WRITE_UINT32_STRING( _register_, _buf_, _count_)            \
221
    CYG_MACRO_START                                                     \
222
    asm volatile ( "outsl"                                              \
223
                   :                                                    \
224
                   : "c" (_count_), "d"(_register_), "S"(_buf_)         \
225
        );                                                              \
226
    CYG_MACRO_END
227
 
228
 
229
//-----------------------------------------------------------------------------
230
 
231
// Macros for acessing shared memory structures
232
 
233
#define HAL_READMEM_UINT8(   _reg_, _val_ ) ((_val_) = *((volatile CYG_BYTE *)(_reg_)))
234
#define HAL_WRITEMEM_UINT8(  _reg_, _val_ ) (*((volatile CYG_BYTE *)(_reg_)) = (_val_))
235
 
236
#define HAL_READMEM_UINT16(  _reg_, _val_ ) ((_val_) = *((volatile CYG_WORD16 *)(_reg_)))
237
#define HAL_WRITEMEM_UINT16( _reg_, _val_ ) (*((volatile CYG_WORD16 *)(_reg_)) = (_val_))
238
 
239
#define HAL_READMEM_UINT32(  _reg_, _val_ ) ((_val_) = *((volatile CYG_WORD32 *)(_reg_)))
240
#define HAL_WRITEMEM_UINT32( _reg_, _val_ ) (*((volatile CYG_WORD32 *)(_reg_)) = (_val_))
241
 
242
//-----------------------------------------------------------------------------
243
#endif // ifndef CYGONCE_HAL_HAL_IO_H
244
// 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.