18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * locks.S: SMP low-level lock primitives on Sparc. 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu) 68c2ecf20Sopenharmony_ci * Copyright (C) 1998 Anton Blanchard (anton@progsoc.uts.edu.au) 78c2ecf20Sopenharmony_ci * Copyright (C) 1998 Jakub Jelinek (jj@ultra.linux.cz) 88c2ecf20Sopenharmony_ci */ 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci#include <asm/ptrace.h> 118c2ecf20Sopenharmony_ci#include <asm/psr.h> 128c2ecf20Sopenharmony_ci#include <asm/smp.h> 138c2ecf20Sopenharmony_ci#include <asm/spinlock.h> 148c2ecf20Sopenharmony_ci#include <asm/export.h> 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_ci .text 178c2ecf20Sopenharmony_ci .align 4 188c2ecf20Sopenharmony_ci 198c2ecf20Sopenharmony_ci /* Read/writer locks, as usual this is overly clever to make it 208c2ecf20Sopenharmony_ci * as fast as possible. 218c2ecf20Sopenharmony_ci */ 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_ci /* caches... */ 248c2ecf20Sopenharmony_ci___rw_read_enter_spin_on_wlock: 258c2ecf20Sopenharmony_ci orcc %g2, 0x0, %g0 268c2ecf20Sopenharmony_ci be,a ___rw_read_enter 278c2ecf20Sopenharmony_ci ldstub [%g1 + 3], %g2 288c2ecf20Sopenharmony_ci b ___rw_read_enter_spin_on_wlock 298c2ecf20Sopenharmony_ci ldub [%g1 + 3], %g2 308c2ecf20Sopenharmony_ci___rw_read_try_spin_on_wlock: 318c2ecf20Sopenharmony_ci andcc %g2, 0xff, %g0 328c2ecf20Sopenharmony_ci be,a ___rw_read_try 338c2ecf20Sopenharmony_ci ldstub [%g1 + 3], %g2 348c2ecf20Sopenharmony_ci xnorcc %g2, 0x0, %o0 /* if g2 is ~0, set o0 to 0 and bugger off */ 358c2ecf20Sopenharmony_ci bne,a ___rw_read_enter_spin_on_wlock 368c2ecf20Sopenharmony_ci ld [%g1], %g2 378c2ecf20Sopenharmony_ci retl 388c2ecf20Sopenharmony_ci mov %g4, %o7 398c2ecf20Sopenharmony_ci___rw_read_exit_spin_on_wlock: 408c2ecf20Sopenharmony_ci orcc %g2, 0x0, %g0 418c2ecf20Sopenharmony_ci be,a ___rw_read_exit 428c2ecf20Sopenharmony_ci ldstub [%g1 + 3], %g2 438c2ecf20Sopenharmony_ci b ___rw_read_exit_spin_on_wlock 448c2ecf20Sopenharmony_ci ldub [%g1 + 3], %g2 458c2ecf20Sopenharmony_ci___rw_write_enter_spin_on_wlock: 468c2ecf20Sopenharmony_ci orcc %g2, 0x0, %g0 478c2ecf20Sopenharmony_ci be,a ___rw_write_enter 488c2ecf20Sopenharmony_ci ldstub [%g1 + 3], %g2 498c2ecf20Sopenharmony_ci b ___rw_write_enter_spin_on_wlock 508c2ecf20Sopenharmony_ci ld [%g1], %g2 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_ci .globl ___rw_read_enter 538c2ecf20Sopenharmony_ciEXPORT_SYMBOL(___rw_read_enter) 548c2ecf20Sopenharmony_ci___rw_read_enter: 558c2ecf20Sopenharmony_ci orcc %g2, 0x0, %g0 568c2ecf20Sopenharmony_ci bne,a ___rw_read_enter_spin_on_wlock 578c2ecf20Sopenharmony_ci ldub [%g1 + 3], %g2 588c2ecf20Sopenharmony_ci ld [%g1], %g2 598c2ecf20Sopenharmony_ci add %g2, 1, %g2 608c2ecf20Sopenharmony_ci st %g2, [%g1] 618c2ecf20Sopenharmony_ci retl 628c2ecf20Sopenharmony_ci mov %g4, %o7 638c2ecf20Sopenharmony_ci 648c2ecf20Sopenharmony_ci .globl ___rw_read_exit 658c2ecf20Sopenharmony_ciEXPORT_SYMBOL(___rw_read_exit) 668c2ecf20Sopenharmony_ci___rw_read_exit: 678c2ecf20Sopenharmony_ci orcc %g2, 0x0, %g0 688c2ecf20Sopenharmony_ci bne,a ___rw_read_exit_spin_on_wlock 698c2ecf20Sopenharmony_ci ldub [%g1 + 3], %g2 708c2ecf20Sopenharmony_ci ld [%g1], %g2 718c2ecf20Sopenharmony_ci sub %g2, 0x1ff, %g2 728c2ecf20Sopenharmony_ci st %g2, [%g1] 738c2ecf20Sopenharmony_ci retl 748c2ecf20Sopenharmony_ci mov %g4, %o7 758c2ecf20Sopenharmony_ci 768c2ecf20Sopenharmony_ci .globl ___rw_read_try 778c2ecf20Sopenharmony_ciEXPORT_SYMBOL(___rw_read_try) 788c2ecf20Sopenharmony_ci___rw_read_try: 798c2ecf20Sopenharmony_ci orcc %g2, 0x0, %g0 808c2ecf20Sopenharmony_ci bne ___rw_read_try_spin_on_wlock 818c2ecf20Sopenharmony_ci ld [%g1], %g2 828c2ecf20Sopenharmony_ci add %g2, 1, %g2 838c2ecf20Sopenharmony_ci st %g2, [%g1] 848c2ecf20Sopenharmony_ci set 1, %o1 858c2ecf20Sopenharmony_ci retl 868c2ecf20Sopenharmony_ci mov %g4, %o7 878c2ecf20Sopenharmony_ci 888c2ecf20Sopenharmony_ci .globl ___rw_write_enter 898c2ecf20Sopenharmony_ciEXPORT_SYMBOL(___rw_write_enter) 908c2ecf20Sopenharmony_ci___rw_write_enter: 918c2ecf20Sopenharmony_ci orcc %g2, 0x0, %g0 928c2ecf20Sopenharmony_ci bne ___rw_write_enter_spin_on_wlock 938c2ecf20Sopenharmony_ci ld [%g1], %g2 948c2ecf20Sopenharmony_ci andncc %g2, 0xff, %g0 958c2ecf20Sopenharmony_ci bne,a ___rw_write_enter_spin_on_wlock 968c2ecf20Sopenharmony_ci stb %g0, [%g1 + 3] 978c2ecf20Sopenharmony_ci retl 988c2ecf20Sopenharmony_ci mov %g4, %o7 99