source: mainline/kernel/arch/sparc64/include/barrier.h@ 32c2c8f

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 32c2c8f was c0699467, checked in by Martin Decky <martin@…>, 14 years ago

do not provide general access to kernel headers from uspace, only allow specific headers to be accessed or shared
externalize headers which serve as kernel/uspace API/ABI into a special tree

  • Property mode set to 100644
File size: 3.4 KB
RevLine 
[2a99fa8]1/*
[df4ed85]2 * Copyright (c) 2005 Jakub Jermar
[2a99fa8]3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
[7a0359b]29/** @addtogroup sparc64
[b45c443]30 * @{
31 */
32/** @file
33 */
34
[ed166f7]35#ifndef KERN_sparc64_BARRIER_H_
36#define KERN_sparc64_BARRIER_H_
[2a99fa8]37
[7a0359b]38#include <trace.h>
39
[2a99fa8]40/*
[1ecdbb0]41 * Our critical section barriers are prepared for the weakest RMO memory model.
[2a99fa8]42 */
[7a0359b]43#define CS_ENTER_BARRIER() \
44 asm volatile ( \
45 "membar #LoadLoad | #LoadStore\n" \
46 ::: "memory" \
[1ecdbb0]47 )
[7a0359b]48
49#define CS_LEAVE_BARRIER() \
50 asm volatile ( \
51 "membar #StoreStore\n" \
52 "membar #LoadStore\n" \
53 ::: "memory" \
54 )
55
56#define memory_barrier() \
57 asm volatile ( \
58 "membar #LoadLoad | #StoreStore\n" \
59 ::: "memory" \
60 )
61
62#define read_barrier() \
63 asm volatile ( \
64 "membar #LoadLoad\n" \
65 ::: "memory" \
[1ecdbb0]66 )
[2a99fa8]67
[7a0359b]68#define write_barrier() \
69 asm volatile ( \
70 "membar #StoreStore\n" \
71 ::: "memory" \
72 )
[2a99fa8]73
[7a0359b]74#define flush(a) \
75 asm volatile ( \
76 "flush %[reg]\n" \
77 :: [reg] "r" ((a)) \
78 : "memory" \
79 )
[e25eca80]80
[c711efe]81/** Flush Instruction pipeline. */
[7a0359b]82NO_TRACE static inline void flush_pipeline(void)
[c52ed6b]83{
[c8e99bb]84 uint64_t pc;
[7a0359b]85
[c52ed6b]86 /*
[9ea8a7ca]87 * The FLUSH instruction takes address parameter.
88 * As such, it may trap if the address is not found in DTLB.
[32fffef0]89 *
90 * The entire kernel text is mapped by a locked ITLB and
91 * DTLB entries. Therefore, when this function is called,
[c8e99bb]92 * the %pc register will always be in the range mapped by
[32fffef0]93 * DTLB.
[7a0359b]94 *
[c52ed6b]95 */
[7a0359b]96
97 asm volatile (
98 "rd %%pc, %[pc]\n"
99 "flush %[pc]\n"
100 : [pc] "=&r" (pc)
[c8e99bb]101 );
[c52ed6b]102}
[b00fdde]103
[9ea8a7ca]104/** Memory Barrier instruction. */
[7a0359b]105NO_TRACE static inline void membar(void)
[b5e0bb8]106{
[7a0359b]107 asm volatile (
108 "membar #Sync\n"
109 );
[b5e0bb8]110}
111
[723060a]112#if defined (US)
113
[7a0359b]114#define FLUSH_INVAL_MIN 4
[e25eca80]115
[7a0359b]116#define smc_coherence(a) \
117 do { \
118 write_barrier(); \
119 flush((a)); \
120 } while (0)
121
122#define smc_coherence_block(a, l) \
123 do { \
124 unsigned long i; \
125 write_barrier(); \
126 \
127 for (i = 0; i < (l); i += FLUSH_INVAL_MIN) \
128 flush((void *)(a) + i); \
129 } while (0)
[d5087aa]130
[723060a]131#elif defined (US3)
132
[7a0359b]133#define smc_coherence(a) \
134 do { \
135 write_barrier(); \
136 flush_pipeline(); \
137 } while (0)
[723060a]138
[7a0359b]139#define smc_coherence_block(a, l) \
140 do { \
141 write_barrier(); \
142 flush_pipeline(); \
143 } while (0)
[723060a]144
[7a0359b]145#endif /* defined(US3) */
[723060a]146
[2a99fa8]147#endif
[b45c443]148
[0ffa3ef5]149/** @}
[b45c443]150 */
Note: See TracBrowser for help on using the repository browser.