]> CyberLeo.Net >> Repos - FreeBSD/releng/8.2.git/blob - sys/contrib/octeon-sdk/cvmx-scratch.h
Copy stable/8 to releng/8.2 in preparation for FreeBSD-8.2 release.
[FreeBSD/releng/8.2.git] / sys / contrib / octeon-sdk / cvmx-scratch.h
1 /***********************license start***************
2  *  Copyright (c) 2003-2008 Cavium Networks (support@cavium.com). All rights
3  *  reserved.
4  *
5  *
6  *  Redistribution and use in source and binary forms, with or without
7  *  modification, are permitted provided that the following conditions are
8  *  met:
9  *
10  *      * Redistributions of source code must retain the above copyright
11  *        notice, this list of conditions and the following disclaimer.
12  *
13  *      * Redistributions in binary form must reproduce the above
14  *        copyright notice, this list of conditions and the following
15  *        disclaimer in the documentation and/or other materials provided
16  *        with the distribution.
17  *
18  *      * Neither the name of Cavium Networks nor the names of
19  *        its contributors may be used to endorse or promote products
20  *        derived from this software without specific prior written
21  *        permission.
22  *
23  *  TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS"
24  *  AND WITH ALL FAULTS AND CAVIUM NETWORKS MAKES NO PROMISES, REPRESENTATIONS
25  *  OR WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH
26  *  RESPECT TO THE SOFTWARE, INCLUDING ITS CONDITION, ITS CONFORMITY TO ANY
27  *  REPRESENTATION OR DESCRIPTION, OR THE EXISTENCE OF ANY LATENT OR PATENT
28  *  DEFECTS, AND CAVIUM SPECIFICALLY DISCLAIMS ALL IMPLIED (IF ANY) WARRANTIES
29  *  OF TITLE, MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR
30  *  PURPOSE, LACK OF VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET
31  *  POSSESSION OR CORRESPONDENCE TO DESCRIPTION.  THE ENTIRE RISK ARISING OUT
32  *  OF USE OR PERFORMANCE OF THE SOFTWARE LIES WITH YOU.
33  *
34  *
35  *  For any questions regarding licensing please contact marketing@caviumnetworks.com
36  *
37  ***********************license end**************************************/
38
39
40
41
42
43
44 /**
45  * @file
46  *
47  * This file provides support for the processor local scratch memory.
48  * Scratch memory is byte addressable - all addresses are byte addresses.
49  *
50  *
51  * <hr>$Revision: 41586 $<hr>
52  *
53  *
54  */
55
56
57 #ifndef __CVMX_SCRATCH_H__
58 #define __CVMX_SCRATCH_H__
59
60 #ifdef  __cplusplus
61 extern "C" {
62 #endif
63
64 /* Note: This define must be a long, not a long long in order to compile
65         without warnings for both 32bit and 64bit. */
66 #define CVMX_SCRATCH_BASE       (-32768l) /* 0xffffffffffff8000 */
67
68
69 /**
70  * Reads an 8 bit value from the processor local scratchpad memory.
71  *
72  * @param address byte address to read from
73  *
74  * @return value read
75  */
76 static inline uint8_t cvmx_scratch_read8(uint64_t address)
77 {
78     return *CASTPTR(volatile uint8_t, CVMX_SCRATCH_BASE + address);
79 }
80 /**
81  * Reads a 16 bit value from the processor local scratchpad memory.
82  *
83  * @param address byte address to read from
84  *
85  * @return value read
86  */
87 static inline uint16_t cvmx_scratch_read16(uint64_t address)
88 {
89     return *CASTPTR(volatile uint16_t, CVMX_SCRATCH_BASE + address);
90 }
91 /**
92  * Reads a 32 bit value from the processor local scratchpad memory.
93  *
94  * @param address byte address to read from
95  *
96  * @return value read
97  */
98 static inline uint32_t cvmx_scratch_read32(uint64_t address)
99 {
100     return *CASTPTR(volatile uint32_t, CVMX_SCRATCH_BASE + address);
101 }
102 /**
103  * Reads a 64 bit value from the processor local scratchpad memory.
104  *
105  * @param address byte address to read from
106  *
107  * @return value read
108  */
109 static inline uint64_t cvmx_scratch_read64(uint64_t address)
110 {
111     return *CASTPTR(volatile uint64_t, CVMX_SCRATCH_BASE + address);
112 }
113
114
115
116 /**
117  * Writes an 8 bit value to the processor local scratchpad memory.
118  *
119  * @param address byte address to write to
120  * @param value   value to write
121  */
122 static inline void cvmx_scratch_write8(uint64_t address, uint64_t value)
123 {
124     *CASTPTR(volatile uint8_t, CVMX_SCRATCH_BASE + address) = (uint8_t)value;
125 }
126 /**
127  * Writes a 32 bit value to the processor local scratchpad memory.
128  *
129  * @param address byte address to write to
130  * @param value   value to write
131  */
132 static inline void cvmx_scratch_write16(uint64_t address, uint64_t value)
133 {
134     *CASTPTR(volatile uint16_t, CVMX_SCRATCH_BASE + address) = (uint16_t)value;
135 }
136 /**
137  * Writes a 16 bit value to the processor local scratchpad memory.
138  *
139  * @param address byte address to write to
140  * @param value   value to write
141  */
142 static inline void cvmx_scratch_write32(uint64_t address, uint64_t value)
143 {
144     *CASTPTR(volatile uint32_t, CVMX_SCRATCH_BASE + address) = (uint32_t)value;
145 }
146 /**
147  * Writes a 64 bit value to the processor local scratchpad memory.
148  *
149  * @param address byte address to write to
150  * @param value   value to write
151  */
152 static inline void cvmx_scratch_write64(uint64_t address, uint64_t value)
153 {
154     *CASTPTR(volatile uint64_t, CVMX_SCRATCH_BASE + address) = value;
155 }
156
157 #ifdef  __cplusplus
158 }
159 #endif
160
161 #endif /* __CVMX_SCRATCH_H__ */