Mercurial > ecos-v2_0-branch
annotate packages/hal/powerpc/arch/current/include/hal_io.h @ 66:bf00f99aec69 ecos-sw-2000-02-02
Merge from eCos master repository on 2000-02-02-19:16:44-GMT
| author | jlarmour |
|---|---|
| date | Wed, 02 Feb 2000 19:57:02 +0000 |
| parents | c38311975d4f |
| children | e0c0827131d1 |
| rev | line source |
|---|---|
| 0 | 1 #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 //####COPYRIGHTBEGIN#### | |
|
64
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
12 // |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
13 // ------------------------------------------- |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
14 // The contents of this file are subject to the Red Hat eCos Public License |
|
66
bf00f99aec69
Merge from eCos master repository on 2000-02-02-19:16:44-GMT
jlarmour
parents:
64
diff
changeset
|
15 // Version 1.1 (the "License"); you may not use this file except in |
|
64
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
16 // compliance with the License. You may obtain a copy of the License at |
|
66
bf00f99aec69
Merge from eCos master repository on 2000-02-02-19:16:44-GMT
jlarmour
parents:
64
diff
changeset
|
17 // http://www.redhat.com/ |
|
64
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
18 // |
|
66
bf00f99aec69
Merge from eCos master repository on 2000-02-02-19:16:44-GMT
jlarmour
parents:
64
diff
changeset
|
19 // Software distributed under the License is distributed on an "AS IS" |
|
64
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
20 // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
21 // License for the specific language governing rights and limitations under |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
22 // the License. |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
23 // |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
24 // The Original Code is eCos - Embedded Configurable Operating System, |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
25 // released September 30, 1998. |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
26 // |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
27 // The Initial Developer of the Original Code is Red Hat. |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
28 // Portions created by Red Hat are |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
29 // Copyright (C) 1998, 1999, 2000 Red Hat, Inc. |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
30 // All Rights Reserved. |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
31 // ------------------------------------------- |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
32 // |
| 0 | 33 //####COPYRIGHTEND#### |
| 34 //============================================================================= | |
| 35 //#####DESCRIPTIONBEGIN#### | |
| 36 // | |
| 37 // Author(s): nickg | |
| 38 // Contributors: nickg | |
| 39 // Date: 1998-02-17 | |
| 40 // Purpose: Define IO register support | |
| 41 // Description: The macros defined here provide the HAL APIs for handling | |
| 42 // device IO control registers. | |
| 43 // | |
| 44 // Usage: | |
| 45 // #include <cyg/hal/hal_io.h> | |
| 46 // ... | |
| 47 // | |
| 48 // | |
| 49 //####DESCRIPTIONEND#### | |
| 50 // | |
| 51 //============================================================================= | |
| 52 | |
| 53 #include <cyg/infra/cyg_type.h> | |
| 54 | |
| 55 //----------------------------------------------------------------------------- | |
| 56 // Enforce in-order IO for all HAL reads/writes using this macro. | |
| 57 #define HAL_IO_BARRIER() \ | |
| 2 | 58 asm volatile ( "eieio" : : : "memory" ) |
| 0 | 59 |
| 60 //----------------------------------------------------------------------------- | |
| 61 // IO Register address. | |
| 62 // This type is for recording the address of an IO register. | |
| 63 | |
| 64 typedef volatile CYG_ADDRWORD HAL_IO_REGISTER; | |
| 65 | |
| 66 //----------------------------------------------------------------------------- | |
| 67 // BYTE Register access. | |
| 68 // Individual and vectorized access to 8 bit registers. | |
| 69 | |
| 2 | 70 #define HAL_READ_UINT8( _register_, _value_ ) \ |
| 71 CYG_MACRO_START \ | |
| 72 ((_value_) = *((volatile CYG_BYTE *)(_register_))); \ | |
| 73 HAL_IO_BARRIER (); \ | |
| 74 CYG_MACRO_END | |
| 0 | 75 |
| 2 | 76 #define HAL_WRITE_UINT8( _register_, _value_ ) \ |
| 77 CYG_MACRO_START \ | |
| 78 (*((volatile CYG_BYTE *)(_register_)) = (_value_)); \ | |
| 79 HAL_IO_BARRIER (); \ | |
| 80 CYG_MACRO_END | |
| 0 | 81 |
| 82 #define HAL_READ_UINT8_VECTOR( _register_, _buf_, _count_, _step_ ) \ | |
| 83 CYG_MACRO_START \ | |
| 84 cyg_count32 _i_,_j_; \ | |
| 85 for( _i_ = 0, _j_ = 0; _i_ < (_count_); _i_++, _j_ += (_step_)) { \ | |
| 86 (_buf_)[_i_] = ((volatile CYG_BYTE *)(_register_))[_j_]; \ | |
| 87 HAL_IO_BARRIER (); \ | |
| 88 } \ | |
| 89 CYG_MACRO_END | |
| 90 | |
| 91 #define HAL_WRITE_UINT8_VECTOR( _register_, _buf_, _count_, _step_ ) \ | |
| 92 CYG_MACRO_START \ | |
| 93 cyg_count32 _i_,_j_; \ | |
| 94 for( _i_ = 0, _j_ = 0; _i_ < (_count_); _i_++, _j_ += (_step_)) { \ | |
| 95 ((volatile CYG_BYTE *)(_register_))[_j_] = (_buf_)[_i_]; \ | |
| 96 HAL_IO_BARRIER (); \ | |
| 97 } \ | |
| 98 CYG_MACRO_END | |
| 99 | |
| 100 | |
| 101 //----------------------------------------------------------------------------- | |
| 102 // 16 bit access. | |
| 103 // Individual and vectorized access to 16 bit registers. | |
| 104 | |
| 105 #define HAL_READ_UINT16( _register_, _value_ ) \ | |
| 2 | 106 CYG_MACRO_START \ |
| 107 ((_value_) = *((volatile CYG_WORD16 *)(_register_))); \ | |
| 108 HAL_IO_BARRIER (); \ | |
| 109 CYG_MACRO_END | |
| 0 | 110 |
| 111 #define HAL_WRITE_UINT16( _register_, _value_ ) \ | |
| 2 | 112 CYG_MACRO_START \ |
| 113 (*((volatile CYG_WORD16 *)(_register_)) = (_value_)); \ | |
| 114 HAL_IO_BARRIER (); \ | |
| 115 CYG_MACRO_END | |
| 0 | 116 |
| 117 #define HAL_READ_UINT16_VECTOR( _register_, _buf_, _count_, _step_ ) \ | |
| 118 CYG_MACRO_START \ | |
| 119 cyg_count32 _i_,_j_; \ | |
| 120 for( _i_ = 0, _j_ = 0; _i_ < (_count_); _i_++, _j_ += (_step_)) { \ | |
| 121 (_buf_)[_i_] = ((volatile CYG_WORD16 *)(_register_))[_j_]; \ | |
| 122 HAL_IO_BARRIER (); \ | |
| 123 } \ | |
| 124 CYG_MACRO_END | |
| 125 | |
| 126 #define HAL_WRITE_UINT16_VECTOR( _register_, _buf_, _count_, _step_ ) \ | |
| 127 CYG_MACRO_START \ | |
| 128 cyg_count32 _i_,_j_; \ | |
| 129 for( _i_ = 0, _j_ = 0; _i_ < (_count_); _i_++, _j_ += (_step_)) { \ | |
| 130 ((volatile CYG_WORD16 *)(_register_))[_j_] = (_buf_)[_i_]; \ | |
| 131 HAL_IO_BARRIER (); \ | |
| 132 } \ | |
| 133 CYG_MACRO_END | |
| 134 | |
| 135 //----------------------------------------------------------------------------- | |
| 136 // 32 bit access. | |
| 137 // Individual and vectorized access to 32 bit registers. | |
| 138 | |
| 139 #define HAL_READ_UINT32( _register_, _value_ ) \ | |
| 2 | 140 CYG_MACRO_START \ |
| 141 ((_value_) = *((volatile CYG_WORD32 *)(_register_))); \ | |
| 142 HAL_IO_BARRIER (); \ | |
| 143 CYG_MACRO_END | |
| 0 | 144 |
| 145 #define HAL_WRITE_UINT32( _register_, _value_ ) \ | |
| 2 | 146 CYG_MACRO_START \ |
| 147 (*((volatile CYG_WORD32 *)(_register_)) = (_value_)); \ | |
| 148 HAL_IO_BARRIER (); \ | |
| 149 CYG_MACRO_END | |
| 0 | 150 |
| 151 #define HAL_READ_UINT32_VECTOR( _register_, _buf_, _count_, _step_ ) \ | |
| 152 CYG_MACRO_START \ | |
| 153 cyg_count32 _i_,_j_; \ | |
| 154 for( _i_ = 0, _j_ = 0; _i_ < (_count_); _i_++, _j_ += (_step_)) { \ | |
| 155 (_buf_)[_i_] = ((volatile CYG_WORD32 *)(_register_))[_j_]; \ | |
| 156 HAL_IO_BARRIER (); \ | |
| 157 } \ | |
| 158 CYG_MACRO_END | |
| 159 | |
| 160 #define HAL_WRITE_UINT32_VECTOR( _register_, _buf_, _count_, _step_ ) \ | |
| 161 CYG_MACRO_START \ | |
| 162 cyg_count32 _i_,_j_; \ | |
| 163 for( _i_ = 0, _j_ = 0; _i_ < (_count_); _i_++, _j_ += (_step_)) { \ | |
| 164 ((volatile CYG_WORD32 *)(_register_))[_j_] = (_buf_)[_i_]; \ | |
| 165 HAL_IO_BARRIER (); \ | |
| 166 } \ | |
| 167 CYG_MACRO_END | |
| 168 | |
| 169 //----------------------------------------------------------------------------- | |
| 170 #endif // ifndef CYGONCE_HAL_IO_H | |
| 171 // End of hal_io.h |
