Home | History | Annotate | Line # | Download | only in hd6446x
hd6446x_subr.S revision 1.6
      1 /*	$NetBSD: hd6446x_subr.S,v 1.6 2006/07/22 01:16:16 uwe Exp $	*/
      2 
      3 /*-
      4  * Copyright (c) 2002 The NetBSD Foundation, Inc.
      5  * All rights reserved.
      6  *
      7  * This code is derived from software contributed to The NetBSD Foundation
      8  * by UCHIYAMA Yasushi.
      9  *
     10  * Redistribution and use in source and binary forms, with or without
     11  * modification, are permitted provided that the following conditions
     12  * are met:
     13  * 1. Redistributions of source code must retain the above copyright
     14  *    notice, this list of conditions and the following disclaimer.
     15  * 2. Redistributions in binary form must reproduce the above copyright
     16  *    notice, this list of conditions and the following disclaimer in the
     17  *    documentation and/or other materials provided with the distribution.
     18  * 3. All advertising materials mentioning features or use of this software
     19  *    must display the following acknowledgement:
     20  *        This product includes software developed by the NetBSD
     21  *        Foundation, Inc. and its contributors.
     22  * 4. Neither the name of The NetBSD Foundation nor the names of its
     23  *    contributors may be used to endorse or promote products derived
     24  *    from this software without specific prior written permission.
     25  *
     26  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36  * POSSIBILITY OF SUCH DAMAGE.
     37  */
     38 
     39 #include <sh3/asm.h>
     40 #include <hpcsh/dev/hd6446x/hd6446xintcreg.h>
     41 
     42 /*
     43  * LINTSTUB: Func: int hd6446x_intr_raise(int s)
     44  *	raise SR.IMASK and HD6446x ICU interrupt mask to 's'.
     45  *	if current SR.IMASK is greater equal 's',nothing to do.
     46  *	Returns previous SR.IMASK.
     47  */
     48 NENTRY(hd6446x_intr_raise)
     49 	stc	sr,	r2
     50 	mov	#0x78,	r1
     51 	mov	r2,	r0
     52 	shll	r1		/* r1 = 0xf0 */
     53 	and	r1,	r0	/* r0 = SR & 0xf0 */
     54 	cmp/ge	r4,	r0	/* r0 >= r4 ? T = 1 */
     55 	bt/s	1f
     56 	 not	r1,	r1	/* r1 = 0xffffff0f */
     57 	and	r1,	r2	/* r2 = SR & ~0xf0 */
     58 	or	r4,	r2	/* r2 = (SR & ~0xf0) | s */
     59 	ldc	r2,	sr	/* SR = r2 */
     60 	shlr2	r4
     61 	shlr	r4
     62 	mov.l	2f,	r1
     63 	add	r4,	r1
     64 	mov.w	@r1,	r2	/* r2 = hd6446x_imask[s >> 4] */
     65 	mov.l	3f,	r1
     66 	mov.w	r2,	@r1	/* Set new interrupt mask to HD6446x */
     67 1:	rts
     68 	 nop			/* return (SR & 0xf0) */
     69 
     70 	.align	2
     71 2:	.long	_C_LABEL(hd6446x_imask)
     72 3:	.long	HD6446X_NIMR
     73 
     74 	SET_ENTRY_SIZE(hd6446x_intr_raise)
     75 
     76 
     77 /*
     78  * LINTSTUB: Func: int hd6446x_intr_resume(int s)
     79  *	Set SR.IMASK and HD6446x interrupt mask register to
     80  *	's' interrupt level. Returns previous SR.IMASK.
     81  */
     82 NENTRY(hd6446x_intr_resume)
     83 	mov	r4,	r0
     84 	shlr2	r0
     85 	shlr	r0
     86 	mov.l	2f,	r1
     87 	add	r0,	r1
     88 	mov.w	@r1,	r2	/* r2 = hd6446x_imask[s >> 4] */
     89 	mov.l	3f,	r1
     90 	mov.w	r2,	@r1	/* Set new interrupt mask to HD6446x */
     91 	stc	sr,	r0	/* r0 = SR */
     92 	mov	#0x78,	r2
     93 	shll	r2		/* r2 = 0x000000f0 */
     94 	not	r2,	r1	/* r1 = 0xffffff0f */
     95 	and	r0,	r1	/* r1 = (SR & ~0xf0) */
     96 	or	r1,	r4	/* r4 = (SR & ~0xf0) | level */
     97 	ldc	r4,	sr	/* Set new IMASK to SR */
     98 	rts
     99 	 and	r2,	r0	/* return (SR & 0xf0) */
    100 
    101 	.align	2
    102 2:	.long	_C_LABEL(hd6446x_imask)
    103 3:	.long	HD6446X_NIMR
    104 
    105 	SET_ENTRY_SIZE(hd6446x_intr_resume)
    106