1 |
5 |
quickwayne |
/* $Id: xio.h,v 1.1 2006-06-23 18:59:00 quickwayne Exp $ */
|
2 |
|
|
/******************************************************************************
|
3 |
|
|
*
|
4 |
|
|
* XILINX IS PROVIDING THIS DESIGN, CODE, OR INFORMATION "AS IS"
|
5 |
|
|
* AS A COURTESY TO YOU, SOLELY FOR USE IN DEVELOPING PROGRAMS AND
|
6 |
|
|
* SOLUTIONS FOR XILINX DEVICES. BY PROVIDING THIS DESIGN, CODE,
|
7 |
|
|
* OR INFORMATION AS ONE POSSIBLE IMPLEMENTATION OF THIS FEATURE,
|
8 |
|
|
* APPLICATION OR STANDARD, XILINX IS MAKING NO REPRESENTATION
|
9 |
|
|
* THAT THIS IMPLEMENTATION IS FREE FROM ANY CLAIMS OF INFRINGEMENT,
|
10 |
|
|
* AND YOU ARE RESPONSIBLE FOR OBTAINING ANY RIGHTS YOU MAY REQUIRE
|
11 |
|
|
* FOR YOUR IMPLEMENTATION. XILINX EXPRESSLY DISCLAIMS ANY
|
12 |
|
|
* WARRANTY WHATSOEVER WITH RESPECT TO THE ADEQUACY OF THE
|
13 |
|
|
* IMPLEMENTATION, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OR
|
14 |
|
|
* REPRESENTATIONS THAT THIS IMPLEMENTATION IS FREE FROM CLAIMS OF
|
15 |
|
|
* INFRINGEMENT, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
16 |
|
|
* FOR A PARTICULAR PURPOSE.
|
17 |
|
|
*
|
18 |
|
|
* (c) Copyright 2002-2003 Xilinx Inc.
|
19 |
|
|
* All rights reserved.
|
20 |
|
|
*
|
21 |
|
|
******************************************************************************/
|
22 |
|
|
/*****************************************************************************/
|
23 |
|
|
/**
|
24 |
|
|
*
|
25 |
|
|
* @file xio.h
|
26 |
|
|
*
|
27 |
|
|
* This file contains the interface for the XIo component, which encapsulates
|
28 |
|
|
* the Input/Output functions for processors that do not require any special
|
29 |
|
|
* I/O handling.
|
30 |
|
|
*
|
31 |
|
|
* <pre>
|
32 |
|
|
* MODIFICATION HISTORY:
|
33 |
|
|
*
|
34 |
|
|
* Ver Who Date Changes
|
35 |
|
|
* ----- ---- -------- -------------------------------------------------------
|
36 |
|
|
* 1.00a rpm 11/07/03 Added InSwap/OutSwap routines for endian conversion
|
37 |
|
|
* 1.00a xd 11/04/04 Improved support for doxygen
|
38 |
|
|
* </pre>
|
39 |
|
|
*
|
40 |
|
|
* @note
|
41 |
|
|
*
|
42 |
|
|
* This file may contain architecture-dependent items (memory-mapped or
|
43 |
|
|
* non-memory-mapped I/O).
|
44 |
|
|
*
|
45 |
|
|
******************************************************************************/
|
46 |
|
|
|
47 |
|
|
#ifndef XIO_H /* prevent circular inclusions */
|
48 |
|
|
#define XIO_H /* by using protection macros */
|
49 |
|
|
|
50 |
|
|
/***************************** Include Files *********************************/
|
51 |
|
|
|
52 |
|
|
#include "xbasic_types.h"
|
53 |
|
|
|
54 |
|
|
/************************** Constant Definitions *****************************/
|
55 |
|
|
|
56 |
|
|
|
57 |
|
|
/**************************** Type Definitions *******************************/
|
58 |
|
|
|
59 |
|
|
/**
|
60 |
|
|
* Typedef for an I/O address. Typically correlates to the width of the
|
61 |
|
|
* address bus.
|
62 |
|
|
*/
|
63 |
|
|
typedef Xuint32 XIo_Address;
|
64 |
|
|
|
65 |
|
|
/***************** Macros (Inline Functions) Definitions *********************/
|
66 |
|
|
|
67 |
|
|
/*
|
68 |
|
|
* The following macros allow optimized I/O operations for memory mapped I/O.
|
69 |
|
|
* It should be noted that macros cannot be used if synchronization of the I/O
|
70 |
|
|
* operation is needed as it will likely break some code.
|
71 |
|
|
*/
|
72 |
|
|
|
73 |
|
|
/*****************************************************************************/
|
74 |
|
|
/**
|
75 |
|
|
*
|
76 |
|
|
* Performs an input operation for an 8-bit memory location by reading from the
|
77 |
|
|
* specified address and returning the value read from that address.
|
78 |
|
|
*
|
79 |
|
|
* @param InputPtr contains the address to perform the input operation at.
|
80 |
|
|
*
|
81 |
|
|
* @return The value read from the specified input address.
|
82 |
|
|
*
|
83 |
|
|
******************************************************************************/
|
84 |
|
|
#define XIo_In8(InputPtr) (*(volatile Xuint8 *)(InputPtr))
|
85 |
|
|
|
86 |
|
|
/*****************************************************************************/
|
87 |
|
|
/**
|
88 |
|
|
*
|
89 |
|
|
* Performs an input operation for a 16-bit memory location by reading from the
|
90 |
|
|
* specified address and returning the value read from that address.
|
91 |
|
|
*
|
92 |
|
|
* @param InputPtr contains the address to perform the input operation at.
|
93 |
|
|
*
|
94 |
|
|
* @return The value read from the specified input address.
|
95 |
|
|
*
|
96 |
|
|
******************************************************************************/
|
97 |
|
|
#define XIo_In16(InputPtr) (*(volatile Xuint16 *)(InputPtr))
|
98 |
|
|
|
99 |
|
|
/*****************************************************************************/
|
100 |
|
|
/**
|
101 |
|
|
*
|
102 |
|
|
* Performs an input operation for a 32-bit memory location by reading from the
|
103 |
|
|
* specified address and returning the value read from that address.
|
104 |
|
|
*
|
105 |
|
|
* @param InputPtr contains the address to perform the input operation at.
|
106 |
|
|
*
|
107 |
|
|
* @return The value read from the specified input address.
|
108 |
|
|
*
|
109 |
|
|
******************************************************************************/
|
110 |
|
|
#define XIo_In32(InputPtr) (*(volatile Xuint32 *)(InputPtr))
|
111 |
|
|
|
112 |
|
|
|
113 |
|
|
/*****************************************************************************/
|
114 |
|
|
/**
|
115 |
|
|
*
|
116 |
|
|
* Performs an output operation for an 8-bit memory location by writing the
|
117 |
|
|
* specified value to the the specified address.
|
118 |
|
|
*
|
119 |
|
|
* @param OutputPtr contains the address to perform the output operation at.
|
120 |
|
|
* @param Value contains the value to be output at the specified address.
|
121 |
|
|
*
|
122 |
|
|
* @return None.
|
123 |
|
|
*
|
124 |
|
|
******************************************************************************/
|
125 |
|
|
#define XIo_Out8(OutputPtr, Value) \
|
126 |
|
|
{ (*(volatile Xuint8 *)(OutputPtr) = Value); }
|
127 |
|
|
|
128 |
|
|
/*****************************************************************************/
|
129 |
|
|
/**
|
130 |
|
|
*
|
131 |
|
|
* Performs an output operation for a 16-bit memory location by writing the
|
132 |
|
|
* specified value to the the specified address.
|
133 |
|
|
*
|
134 |
|
|
* @param OutputPtr contains the address to perform the output operation at.
|
135 |
|
|
* @param Value contains the value to be output at the specified address.
|
136 |
|
|
*
|
137 |
|
|
* @return None.
|
138 |
|
|
*
|
139 |
|
|
******************************************************************************/
|
140 |
|
|
#define XIo_Out16(OutputPtr, Value) \
|
141 |
|
|
{ (*(volatile Xuint16 *)(OutputPtr) = Value); }
|
142 |
|
|
|
143 |
|
|
/*****************************************************************************/
|
144 |
|
|
/**
|
145 |
|
|
*
|
146 |
|
|
* Performs an output operation for a 32-bit memory location by writing the
|
147 |
|
|
* specified value to the the specified address.
|
148 |
|
|
*
|
149 |
|
|
* @param OutputPtr contains the address to perform the output operation at.
|
150 |
|
|
* @param Value contains the value to be output at the specified address.
|
151 |
|
|
*
|
152 |
|
|
* @return None.
|
153 |
|
|
*
|
154 |
|
|
******************************************************************************/
|
155 |
|
|
#define XIo_Out32(OutputPtr, Value) \
|
156 |
|
|
{ (*(volatile Xuint32 *)(OutputPtr) = Value); }
|
157 |
|
|
|
158 |
|
|
|
159 |
|
|
/* The following macros allow the software to be transportable across
|
160 |
|
|
* processors which use big or little endian memory models.
|
161 |
|
|
*
|
162 |
|
|
* Defined first is a no-op endian conversion macro. This macro is not to
|
163 |
|
|
* be used directly by software. Instead, the XIo_To/FromLittleEndianXX and
|
164 |
|
|
* XIo_To/FromBigEndianXX macros below are to be used to allow the endian
|
165 |
|
|
* conversion to only be performed when necessary
|
166 |
|
|
*/
|
167 |
|
|
#define XIo_EndianNoop(Source, Destination) (*DestPtr = Source)
|
168 |
|
|
|
169 |
|
|
#ifdef XLITTLE_ENDIAN
|
170 |
|
|
|
171 |
|
|
#define XIo_ToLittleEndian16 XIo_EndianNoop
|
172 |
|
|
#define XIo_ToLittleEndian32 XIo_EndianNoop
|
173 |
|
|
#define XIo_FromLittleEndian16 XIo_EndianNoop
|
174 |
|
|
#define XIo_FromLittleEndian32 XIo_EndianNoop
|
175 |
|
|
|
176 |
|
|
#define XIo_ToBigEndian16(Source, DestPtr) XIo_EndianSwap16(Source, DestPtr)
|
177 |
|
|
#define XIo_ToBigEndian32(Source, DestPtr) XIo_EndianSwap32(Source, DestPtr)
|
178 |
|
|
#define XIo_FromBigEndian16 XIo_ToBigEndian16
|
179 |
|
|
#define XIo_FromBigEndian32 XIo_ToBigEndian32
|
180 |
|
|
|
181 |
|
|
#else
|
182 |
|
|
|
183 |
|
|
#define XIo_ToLittleEndian16(Source, DestPtr) XIo_EndianSwap16(Source, DestPtr)
|
184 |
|
|
#define XIo_ToLittleEndian32(Source, DestPtr) XIo_EndianSwap32(Source, DestPtr)
|
185 |
|
|
#define XIo_FromLittleEndian16 XIo_ToLittleEndian16
|
186 |
|
|
#define XIo_FromLittleEndian32 XIo_ToLittleEndian32
|
187 |
|
|
|
188 |
|
|
#define XIo_ToBigEndian16 XIo_EndianNoop
|
189 |
|
|
#define XIo_ToBigEndian32 XIo_EndianNoop
|
190 |
|
|
#define XIo_FromBigEndian16 XIo_EndianNoop
|
191 |
|
|
#define XIo_FromBigEndian32 XIo_EndianNoop
|
192 |
|
|
|
193 |
|
|
#endif
|
194 |
|
|
|
195 |
|
|
/************************** Function Prototypes ******************************/
|
196 |
|
|
|
197 |
|
|
/* The following functions allow the software to be transportable across
|
198 |
|
|
* processors which use big or little endian memory models. These functions
|
199 |
|
|
* should not be directly called, but the macros XIo_To/FromLittleEndianXX and
|
200 |
|
|
* XIo_To/FromBigEndianXX should be used to allow the endian conversion to only
|
201 |
|
|
* be performed when necessary.
|
202 |
|
|
*/
|
203 |
|
|
void XIo_EndianSwap16(Xuint16 Source, Xuint16* DestPtr);
|
204 |
|
|
void XIo_EndianSwap32(Xuint32 Source, Xuint32* DestPtr);
|
205 |
|
|
|
206 |
|
|
/* The following functions handle IO addresses where data must be swapped
|
207 |
|
|
* They cannot be implemented as macros
|
208 |
|
|
*/
|
209 |
|
|
Xuint16 XIo_InSwap16(XIo_Address InAddress);
|
210 |
|
|
Xuint32 XIo_InSwap32(XIo_Address InAddress);
|
211 |
|
|
void XIo_OutSwap16(XIo_Address OutAddress, Xuint16 Value);
|
212 |
|
|
void XIo_OutSwap32(XIo_Address OutAddress, Xuint32 Value);
|
213 |
|
|
|
214 |
|
|
#endif /* end of protection macro */
|