1 /***********************license start***************
2 * Copyright (c) 2003-2008 Cavium Networks (support@cavium.com). All rights
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
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.
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
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.
35 * For any questions regarding licensing please contact marketing@caviumnetworks.com
37 ***********************license end**************************************/
47 * This file provides support for the processor local scratch memory.
48 * Scratch memory is byte addressable - all addresses are byte addresses.
51 * <hr>$Revision: 41586 $<hr>
57 #ifndef __CVMX_SCRATCH_H__
58 #define __CVMX_SCRATCH_H__
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 */
70 * Reads an 8 bit value from the processor local scratchpad memory.
72 * @param address byte address to read from
76 static inline uint8_t cvmx_scratch_read8(uint64_t address)
78 return *CASTPTR(volatile uint8_t, CVMX_SCRATCH_BASE + address);
81 * Reads a 16 bit value from the processor local scratchpad memory.
83 * @param address byte address to read from
87 static inline uint16_t cvmx_scratch_read16(uint64_t address)
89 return *CASTPTR(volatile uint16_t, CVMX_SCRATCH_BASE + address);
92 * Reads a 32 bit value from the processor local scratchpad memory.
94 * @param address byte address to read from
98 static inline uint32_t cvmx_scratch_read32(uint64_t address)
100 return *CASTPTR(volatile uint32_t, CVMX_SCRATCH_BASE + address);
103 * Reads a 64 bit value from the processor local scratchpad memory.
105 * @param address byte address to read from
109 static inline uint64_t cvmx_scratch_read64(uint64_t address)
111 return *CASTPTR(volatile uint64_t, CVMX_SCRATCH_BASE + address);
117 * Writes an 8 bit value to the processor local scratchpad memory.
119 * @param address byte address to write to
120 * @param value value to write
122 static inline void cvmx_scratch_write8(uint64_t address, uint64_t value)
124 *CASTPTR(volatile uint8_t, CVMX_SCRATCH_BASE + address) = (uint8_t)value;
127 * Writes a 32 bit value to the processor local scratchpad memory.
129 * @param address byte address to write to
130 * @param value value to write
132 static inline void cvmx_scratch_write16(uint64_t address, uint64_t value)
134 *CASTPTR(volatile uint16_t, CVMX_SCRATCH_BASE + address) = (uint16_t)value;
137 * Writes a 16 bit value to the processor local scratchpad memory.
139 * @param address byte address to write to
140 * @param value value to write
142 static inline void cvmx_scratch_write32(uint64_t address, uint64_t value)
144 *CASTPTR(volatile uint32_t, CVMX_SCRATCH_BASE + address) = (uint32_t)value;
147 * Writes a 64 bit value to the processor local scratchpad memory.
149 * @param address byte address to write to
150 * @param value value to write
152 static inline void cvmx_scratch_write64(uint64_t address, uint64_t value)
154 *CASTPTR(volatile uint64_t, CVMX_SCRATCH_BASE + address) = value;
161 #endif /* __CVMX_SCRATCH_H__ */