From 3cdc20a9dedb12cecc5ed402bd16abc2bc51e1a6 Mon Sep 17 00:00:00 2001 From: uwe Date: Fri, 23 Feb 2007 03:24:47 +0000 Subject: [PATCH] Brute force _lock_cas() by disabling interrupts. Need to redo it with RAS later. --- sys/arch/sh3/sh3/lock_stubs.S | 48 +++++++++++++++++++++++++++++++++-- 1 file changed, 46 insertions(+), 2 deletions(-) diff --git a/sys/arch/sh3/sh3/lock_stubs.S b/sys/arch/sh3/sh3/lock_stubs.S index 5cdad2267ec9..0ec1b5e158a9 100644 --- a/sys/arch/sh3/sh3/lock_stubs.S +++ b/sys/arch/sh3/sh3/lock_stubs.S @@ -1,6 +1,34 @@ -/* $NetBSD: lock_stubs.S,v 1.1 2007/02/22 22:53:26 uwe Exp $ */ +/* $NetBSD: lock_stubs.S,v 1.2 2007/02/23 03:24:47 uwe Exp $ */ + +/* + * Copyright (c) 2007 Valeriy E. Ushakov + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ #include +#include /* * LINTSTUB: include @@ -9,7 +37,23 @@ /* * LINTSTUB: Func: int _lock_cas(volatile uintptr_t *ptr, uintptr_t old, uintptr_t new); + * + * Brute force with splhigh() for now. Need to be redone as RAS. */ NENTRY(_lock_cas) + mov #PSL_IMASK, r2 ! 0xf0 - gets sign extended + stc sr, r3 + extu.b r2, r2 ! undo sign extention + mov r3, r7 ! preserve SR + or r2, r3 ! mask all interrupts + ldc r3, sr + + mov.l @r4, r1 + cmp/eq r1, r5 ! T = (*ptr == old) + bf.s 1f + movt r0 ! retval = T + mov.l r6, @r4 ! *ptr = new +1: + ldc r7, sr ! restore SR (cannot be in delay slot) rts - mov #0, r0 + nop