xref: /netbsd-src/common/lib/libc/arch/riscv/atomic/membar_ops.S (revision 4f8ce3b31dd3bccb2f78a8118c558aacc733ac7d)
1*4f8ce3b3Sriastradh/*	$NetBSD: membar_ops.S,v 1.4 2022/04/09 23:32:52 riastradh Exp $	*/
26cf6fe02Smatt
36cf6fe02Smatt/*-
46cf6fe02Smatt * Copyright (c) 2006, 2007 The NetBSD Foundation, Inc.
56cf6fe02Smatt * All rights reserved.
66cf6fe02Smatt *
76cf6fe02Smatt * This code is derived from software contributed to The NetBSD Foundation
86cf6fe02Smatt * by Jason R. Thorpe, and by Andrew Doran.
96cf6fe02Smatt *
106cf6fe02Smatt * Redistribution and use in source and binary forms, with or without
116cf6fe02Smatt * modification, are permitted provided that the following conditions
126cf6fe02Smatt * are met:
136cf6fe02Smatt * 1. Redistributions of source code must retain the above copyright
146cf6fe02Smatt *    notice, this list of conditions and the following disclaimer.
156cf6fe02Smatt * 2. Redistributions in binary form must reproduce the above copyright
166cf6fe02Smatt *    notice, this list of conditions and the following disclaimer in the
176cf6fe02Smatt *    documentation and/or other materials provided with the distribution.
186cf6fe02Smatt *
196cf6fe02Smatt * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
206cf6fe02Smatt * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
216cf6fe02Smatt * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
226cf6fe02Smatt * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
236cf6fe02Smatt * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
246cf6fe02Smatt * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
256cf6fe02Smatt * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
266cf6fe02Smatt * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
276cf6fe02Smatt * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
286cf6fe02Smatt * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
296cf6fe02Smatt * POSSIBILITY OF SUCH DAMAGE.
306cf6fe02Smatt */
316cf6fe02Smatt
326cf6fe02Smatt#include "atomic_op_asm.h"
336cf6fe02Smatt
346cf6fe02SmattENTRY_NP(_membar_sync)
356cf6fe02Smatt	fence	rw,rw
366cf6fe02Smatt	ret
376cf6fe02SmattEND(_membar_sync)
386cf6fe02SmattATOMIC_OP_ALIAS(membar_sync,_membar_sync)
396cf6fe02SmattCRT_ALIAS(__sync_synchronize,_membar_sync)
406cf6fe02Smatt
41*4f8ce3b3SriastradhENTRY_NP(_membar_acquire)
42*4f8ce3b3Sriastradh	fence	r,rw
43*4f8ce3b3Sriastradh	ret
44*4f8ce3b3SriastradhEND(_membar_acquire)
45*4f8ce3b3SriastradhATOMIC_OP_ALIAS(membar_acquire,_membar_acquire)
46*4f8ce3b3Sriastradh
47*4f8ce3b3SriastradhENTRY_NP(_membar_release)
48*4f8ce3b3Sriastradh	fence	rw,w
49*4f8ce3b3Sriastradh	ret
50*4f8ce3b3SriastradhEND(_membar_release)
51*4f8ce3b3SriastradhATOMIC_OP_ALIAS(membar_release,_membar_release)
52*4f8ce3b3Sriastradh
536cf6fe02SmattENTRY_NP(_membar_enter)
54d808f015Sriastradh	fence	rw,rw
556cf6fe02Smatt	ret
566cf6fe02SmattEND(_membar_enter)
576cf6fe02SmattATOMIC_OP_ALIAS(membar_enter,_membar_enter)
586cf6fe02Smatt
596cf6fe02SmattENTRY_NP(_membar_exit)
606cf6fe02Smatt	fence	rw,w
616cf6fe02Smatt	ret
626cf6fe02SmattEND(_membar_exit)
636cf6fe02SmattATOMIC_OP_ALIAS(membar_exit,_membar_exit)
646cf6fe02Smatt
656cf6fe02SmattENTRY_NP(_membar_producer)
666cf6fe02Smatt	fence	w,w
676cf6fe02Smatt	ret
686cf6fe02SmattEND(_membar_producer)
696cf6fe02SmattATOMIC_OP_ALIAS(membar_producer,_membar_producer)
706cf6fe02Smatt
716cf6fe02SmattENTRY_NP(_membar_consumer)
726cf6fe02Smatt	fence	r,r
736cf6fe02Smatt	ret
746cf6fe02SmattEND(_membar_consumer)
756cf6fe02SmattATOMIC_OP_ALIAS(membar_consumer,_membar_consumer)
76