1 /***********************license start***************
2 * Copyright (c) 2003-2010 Cavium Inc. (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 Inc. 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 * This Software, including technical data, may be subject to U.S. export control
24 * laws, including the U.S. Export Administration Act and its associated
25 * regulations, and may be subject to export or import regulations in other
28 * TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS"
29 * AND WITH ALL FAULTS AND CAVIUM INC. MAKES NO PROMISES, REPRESENTATIONS OR
30 * WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH RESPECT TO
31 * THE SOFTWARE, INCLUDING ITS CONDITION, ITS CONFORMITY TO ANY REPRESENTATION OR
32 * DESCRIPTION, OR THE EXISTENCE OF ANY LATENT OR PATENT DEFECTS, AND CAVIUM
33 * SPECIFICALLY DISCLAIMS ALL IMPLIED (IF ANY) WARRANTIES OF TITLE,
34 * MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, LACK OF
35 * VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION OR
36 * CORRESPONDENCE TO DESCRIPTION. THE ENTIRE RISK ARISING OUT OF USE OR
37 * PERFORMANCE OF THE SOFTWARE LIES WITH YOU.
38 ***********************license end**************************************/
49 * This file provides support for the processor local scratch memory.
50 * Scratch memory is byte addressable - all addresses are byte addresses.
53 * <hr>$Revision: 70030 $<hr>
59 #ifndef __CVMX_SCRATCH_H__
60 #define __CVMX_SCRATCH_H__
66 /* Note: This define must be a long, not a long long in order to compile
67 without warnings for both 32bit and 64bit. */
68 #define CVMX_SCRATCH_BASE (-32768l) /* 0xffffffffffff8000 */
72 * Reads an 8 bit value from the processor local scratchpad memory.
74 * @param address byte address to read from
78 static inline uint8_t cvmx_scratch_read8(uint64_t address)
80 return *CASTPTR(volatile uint8_t, CVMX_SCRATCH_BASE + address);
83 * Reads a 16 bit value from the processor local scratchpad memory.
85 * @param address byte address to read from
89 static inline uint16_t cvmx_scratch_read16(uint64_t address)
91 return *CASTPTR(volatile uint16_t, CVMX_SCRATCH_BASE + address);
94 * Reads a 32 bit value from the processor local scratchpad memory.
96 * @param address byte address to read from
100 static inline uint32_t cvmx_scratch_read32(uint64_t address)
102 return *CASTPTR(volatile uint32_t, CVMX_SCRATCH_BASE + address);
105 * Reads a 64 bit value from the processor local scratchpad memory.
107 * @param address byte address to read from
111 static inline uint64_t cvmx_scratch_read64(uint64_t address)
113 return *CASTPTR(volatile uint64_t, CVMX_SCRATCH_BASE + address);
119 * Writes an 8 bit value to the processor local scratchpad memory.
121 * @param address byte address to write to
122 * @param value value to write
124 static inline void cvmx_scratch_write8(uint64_t address, uint64_t value)
126 *CASTPTR(volatile uint8_t, CVMX_SCRATCH_BASE + address) = (uint8_t)value;
129 * Writes a 32 bit value to the processor local scratchpad memory.
131 * @param address byte address to write to
132 * @param value value to write
134 static inline void cvmx_scratch_write16(uint64_t address, uint64_t value)
136 *CASTPTR(volatile uint16_t, CVMX_SCRATCH_BASE + address) = (uint16_t)value;
139 * Writes a 16 bit value to the processor local scratchpad memory.
141 * @param address byte address to write to
142 * @param value value to write
144 static inline void cvmx_scratch_write32(uint64_t address, uint64_t value)
146 *CASTPTR(volatile uint32_t, CVMX_SCRATCH_BASE + address) = (uint32_t)value;
149 * Writes a 64 bit value to the processor local scratchpad memory.
151 * @param address byte address to write to
152 * @param value value to write
154 static inline void cvmx_scratch_write64(uint64_t address, uint64_t value)
156 *CASTPTR(volatile uint64_t, CVMX_SCRATCH_BASE + address) = value;
163 #endif /* __CVMX_SCRATCH_H__ */