xref: /minix3/common/lib/libc/arch/mips/atomic/membar_ops.S (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc/*	$NetBSD: membar_ops.S,v 1.8 2015/06/23 20:56:17 matt Exp $	*/
2b6cbf720SGianluca Guida
3b6cbf720SGianluca Guida/*-
4b6cbf720SGianluca Guida * Copyright (c) 2006, 2007 The NetBSD Foundation, Inc.
5b6cbf720SGianluca Guida * All rights reserved.
6b6cbf720SGianluca Guida *
7b6cbf720SGianluca Guida * This code is derived from software contributed to The NetBSD Foundation
8b6cbf720SGianluca Guida * by Jason R. Thorpe, and by Andrew Doran.
9b6cbf720SGianluca Guida *
10b6cbf720SGianluca Guida * Redistribution and use in source and binary forms, with or without
11b6cbf720SGianluca Guida * modification, are permitted provided that the following conditions
12b6cbf720SGianluca Guida * are met:
13b6cbf720SGianluca Guida * 1. Redistributions of source code must retain the above copyright
14b6cbf720SGianluca Guida *    notice, this list of conditions and the following disclaimer.
15b6cbf720SGianluca Guida * 2. Redistributions in binary form must reproduce the above copyright
16b6cbf720SGianluca Guida *    notice, this list of conditions and the following disclaimer in the
17b6cbf720SGianluca Guida *    documentation and/or other materials provided with the distribution.
18b6cbf720SGianluca Guida *
19b6cbf720SGianluca Guida * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20b6cbf720SGianluca Guida * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21b6cbf720SGianluca Guida * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22b6cbf720SGianluca Guida * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23b6cbf720SGianluca Guida * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24b6cbf720SGianluca Guida * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25b6cbf720SGianluca Guida * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26b6cbf720SGianluca Guida * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27b6cbf720SGianluca Guida * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28b6cbf720SGianluca Guida * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29b6cbf720SGianluca Guida * POSSIBILITY OF SUCH DAMAGE.
30b6cbf720SGianluca Guida */
31b6cbf720SGianluca Guida
32b6cbf720SGianluca Guida#include "atomic_op_asm.h"
33b6cbf720SGianluca Guida
34*0a6a1f1dSLionel Sambuc// If we are on building for MIPS III or later, put in SYNCs
35*0a6a1f1dSLionel Sambuc#if __mips >= 3 || !defined(__mips_o32)
36b6cbf720SGianluca Guida# define SYNC		sync
37*0a6a1f1dSLionel Sambuc#else
38*0a6a1f1dSLionel Sambuc# define SYNC		nop
39b6cbf720SGianluca Guida#endif
40b6cbf720SGianluca Guida
41b6cbf720SGianluca Guida	.text
42f14fb602SLionel Sambuc	.set noreorder
43b6cbf720SGianluca Guida
44b6cbf720SGianluca GuidaLEAF(_membar_sync)
45b6cbf720SGianluca Guida	j	ra
46b6cbf720SGianluca Guida	 SYNC
47b6cbf720SGianluca GuidaEND(_membar_sync)
48b6cbf720SGianluca Guida
49*0a6a1f1dSLionel Sambuc#ifdef __OCTEON__
50*0a6a1f1dSLionel SambucLEAF(_membar_producer)
51*0a6a1f1dSLionel Sambuc	j	ra
52*0a6a1f1dSLionel Sambuc	 syncw
53*0a6a1f1dSLionel SambucEND(_membar_producer)
54*0a6a1f1dSLionel Sambuc#endif
55*0a6a1f1dSLionel Sambuc
56b6cbf720SGianluca Guida#ifdef _KERNEL
57b6cbf720SGianluca GuidaSTRONG_ALIAS(mb_read, _membar_sync)
58*0a6a1f1dSLionel Sambuc#ifdef __OCTEON__
59*0a6a1f1dSLionel SambucSTRONG_ALIAS(mb_write, _membar_producer)
60*0a6a1f1dSLionel Sambuc#else
61b6cbf720SGianluca GuidaSTRONG_ALIAS(mb_write, _membar_sync)
62*0a6a1f1dSLionel Sambuc#endif
63b6cbf720SGianluca GuidaSTRONG_ALIAS(mb_memory, _membar_sync)
64b6cbf720SGianluca Guida#endif
65b6cbf720SGianluca Guida
66b6cbf720SGianluca GuidaATOMIC_OP_ALIAS(membar_sync,_membar_sync)
67b6cbf720SGianluca GuidaATOMIC_OP_ALIAS(membar_enter,_membar_sync)
68b6cbf720SGianluca GuidaSTRONG_ALIAS(_membar_enter,_membar_sync)
69*0a6a1f1dSLionel Sambuc#ifdef __OCTEON__
70*0a6a1f1dSLionel SambucATOMIC_OP_ALIAS(membar_exit,_membar_producer)
71*0a6a1f1dSLionel SambucSTRONG_ALIAS(_membar_exit,_membar_producer)
72*0a6a1f1dSLionel SambucSTRONG_ALIAS(membar_producer,_membar_producer)
73*0a6a1f1dSLionel Sambuc#else
74b6cbf720SGianluca GuidaATOMIC_OP_ALIAS(membar_exit,_membar_sync)
75b6cbf720SGianluca GuidaSTRONG_ALIAS(_membar_exit,_membar_sync)
76b6cbf720SGianluca GuidaATOMIC_OP_ALIAS(membar_producer,_membar_sync)
77b6cbf720SGianluca GuidaSTRONG_ALIAS(_membar_producer,_membar_sync)
78*0a6a1f1dSLionel Sambuc#endif
79b6cbf720SGianluca GuidaATOMIC_OP_ALIAS(membar_consumer,_membar_sync)
80b6cbf720SGianluca GuidaSTRONG_ALIAS(_membar_consumer,_membar_sync)
81