hd6446x_subr.S revision 1.5 1 /* $NetBSD: hd6446x_subr.S,v 1.5 2006/01/22 05:16:58 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 mov r4, r1
59 or r2, r1 /* r1 = (SR & ~0xf0) | s */
60 ldc r1, sr /* SR = r1 */
61 shlr2 r4
62 shlr r4
63 mov.l 2f, r1
64 add r4, r1
65 mov.w @r1, r2 /* r2 = hd6446x_imask[s >> 4] */
66 mov.l 3f, r1
67 mov.w r2, @r1 /* Set new interrupt mask to HD6446x */
68 1: rts
69 nop /* return (SR & 0xf0) */
70
71 .align 2
72 2: .long _C_LABEL(hd6446x_imask)
73 3: .long HD6446X_NIMR
74
75 SET_ENTRY_SIZE(hd6446x_intr_raise)
76
77
78 /*
79 * LINTSTUB: Func: int hd6446x_intr_resume(int s)
80 * Set SR.IMASK and HD6446x interrupt mask register to
81 * 's' interrupt level. Returns previous SR.IMASK.
82 */
83 NENTRY(hd6446x_intr_resume)
84 mov r4, r0
85 shlr2 r0
86 shlr r0
87 mov.l 2f, r1
88 add r0, r1
89 mov.w @r1, r2 /* r2 = hd6446x_imask[s >> 4] */
90 mov.l 3f, r1
91 mov.w r2, @r1 /* Set new interrupt mask to HD6446x */
92 stc sr, r0 /* r0 = SR */
93 mov #0x78, r2
94 shll r2 /* r2 = 0x000000f0 */
95 not r2, r1 /* r1 = 0xffffff0f */
96 and r0, r1 /* r1 = (SR & ~0xf0) */
97 or r1, r4 /* r4 = (SR & ~0xf0) | level */
98 ldc r4, sr /* Set new IMASK to SR */
99 rts
100 and r2, r0 /* return (SR & 0xf0) */
101
102 .align 2
103 2: .long _C_LABEL(hd6446x_imask)
104 3: .long HD6446X_NIMR
105
106 SET_ENTRY_SIZE(hd6446x_intr_resume)
107