membar_ops.S revision 1.6
11.6Smatt/*	$NetBSD: membar_ops.S,v 1.6 2015/06/01 23:16:54 matt Exp $	*/
21.1Sad
31.1Sad/*-
41.1Sad * Copyright (c) 2006, 2007 The NetBSD Foundation, Inc.
51.1Sad * All rights reserved.
61.1Sad *
71.1Sad * This code is derived from software contributed to The NetBSD Foundation
81.1Sad * by Jason R. Thorpe, and by Andrew Doran.
91.1Sad *
101.1Sad * Redistribution and use in source and binary forms, with or without
111.1Sad * modification, are permitted provided that the following conditions
121.1Sad * are met:
131.1Sad * 1. Redistributions of source code must retain the above copyright
141.1Sad *    notice, this list of conditions and the following disclaimer.
151.1Sad * 2. Redistributions in binary form must reproduce the above copyright
161.1Sad *    notice, this list of conditions and the following disclaimer in the
171.1Sad *    documentation and/or other materials provided with the distribution.
181.1Sad *
191.1Sad * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
201.1Sad * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
211.1Sad * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
221.1Sad * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
231.1Sad * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
241.1Sad * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
251.1Sad * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
261.1Sad * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
271.1Sad * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
281.1Sad * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
291.1Sad * POSSIBILITY OF SUCH DAMAGE.
301.1Sad */
311.1Sad
321.1Sad#include "atomic_op_asm.h"
331.1Sad
341.4Smatt#if defined(_KERNEL)
351.4Smatt
361.1Sad#ifdef _KERNEL_OPT
371.1Sad#include "opt_cputype.h"
381.1Sad#include "opt_lockdebug.h"
391.1Sad#include "opt_multiprocessor.h"
401.1Sad#endif
411.1Sad
421.1Sad
431.1Sad#include <machine/cpu.h>
441.1Sad
451.4Smatt#if (MIPS_HAS_LLSC != 0 && defined(MULTIPROCESSOR)) || !defined(__mips_o32)
461.4Smatt#define	SYNC		sync
471.4Smatt#endif
481.4Smatt#elif !defined(__mips_o32)
491.1Sad#define	SYNC		sync
501.1Sad#endif
511.1Sad
521.1Sad	.text
531.5Smatt	.set noreorder
541.1Sad
551.3SchsLEAF(_membar_sync)
561.4Smatt	j	ra
571.4Smatt#ifdef SYNC
581.5Smatt	 SYNC
591.4Smatt#else
601.5Smatt	 nop
611.4Smatt#endif
621.1SadEND(_membar_sync)
631.1Sad
641.6Smatt#ifdef __OCTEON__
651.6SmattLEAF(_membar_producer)
661.6Smatt	j	ra
671.6Smatt	 syncw
681.6SmattEND(_membar_producer)
691.6Smatt#endif
701.6Smatt
711.4Smatt#ifdef _KERNEL
721.4SmattSTRONG_ALIAS(mb_read, _membar_sync)
731.6Smatt#ifdef __OCTEON__
741.6SmattSTRONG_ALIAS(mb_write, _membar_producer)
751.6Smatt#else
761.4SmattSTRONG_ALIAS(mb_write, _membar_sync)
771.6Smatt#endif
781.4SmattSTRONG_ALIAS(mb_memory, _membar_sync)
791.4Smatt#endif
801.4Smatt
811.1SadATOMIC_OP_ALIAS(membar_sync,_membar_sync)
821.1SadATOMIC_OP_ALIAS(membar_enter,_membar_sync)
831.1SadSTRONG_ALIAS(_membar_enter,_membar_sync)
841.6Smatt#ifdef __OCTEON__
851.6SmattATOMIC_OP_ALIAS(membar_exit,_membar_producer)
861.6SmattSTRONG_ALIAS(_membar_exit,_membar_producer)
871.6SmattSTRONG_ALIAS(membar_producer,_membar_producer)
881.6Smatt#else
891.1SadATOMIC_OP_ALIAS(membar_exit,_membar_sync)
901.1SadSTRONG_ALIAS(_membar_exit,_membar_sync)
911.1SadATOMIC_OP_ALIAS(membar_producer,_membar_sync)
921.1SadSTRONG_ALIAS(_membar_producer,_membar_sync)
931.6Smatt#endif
941.1SadATOMIC_OP_ALIAS(membar_consumer,_membar_sync)
951.1SadSTRONG_ALIAS(_membar_consumer,_membar_sync)
96