summaryrefslogtreecommitdiffstats
path: root/sys/mips/cavium/asm_octeon.S
blob: d9f79f134ffdfb40dada4b55b3294e78a6812c89 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
/***********************license start***************
 *  Copyright (c) 2003-2008 Cavium Networks (support@cavium.com). All rights
 *  reserved.
 *
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are
 *  met:
 *
 *      * Redistributions of source code must retain the above copyright
 *        notice, this list of conditions and the following disclaimer.
 *
 *      * 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.
 *
 *      * Neither the name of Cavium Networks nor the names of
 *        its contributors may be used to endorse or promote products
 *        derived from this software without specific prior written
 *        permission.
 *
 *  TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS"
 *  AND WITH ALL FAULTS AND CAVIUM NETWORKS MAKES NO PROMISES, REPRESENTATIONS
 *  OR WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH
 *  RESPECT TO THE SOFTWARE, INCLUDING ITS CONDITION, ITS CONFORMITY TO ANY
 *  REPRESENTATION OR DESCRIPTION, OR THE EXISTENCE OF ANY LATENT OR PATENT
 *  DEFECTS, AND CAVIUM SPECIFICALLY DISCLAIMS ALL IMPLIED (IF ANY) WARRANTIES
 *  OF TITLE, MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR
 *  PURPOSE, LACK OF VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET
 *  POSSESSION OR CORRESPONDENCE TO DESCRIPTION.  THE ENTIRE RISK ARISING OUT
 *  OF USE OR PERFORMANCE OF THE SOFTWARE LIES WITH YOU.
 *
 *
 *  For any questions regarding licensing please contact marketing@caviumnetworks.com
 *
 ***********************license end**************************************/

/* $FreeBSD$ */

#include <machine/asm.h>
#include <machine/cache_r4k.h>
#include <machine/cpuregs.h>
#include <machine/param.h>
#include <machine/pte.h>

#include "assym.s"
	


#define CPU_DISABLE_INTERRUPTS(reg, reg2, reg3) \
        mfc0    reg, MIPS_COP_0_STATUS; \
        nop; \
        move    reg3, reg; \
        li      reg2, ~MIPS_SR_INT_IE; \
        and     reg, reg2, reg; \
        mtc0    reg, MIPS_COP_0_STATUS; \
        COP0_SYNC



#define CPU_ENABLE_INTERRUPTS(reg, reg3) \
        mfc0    reg, MIPS_COP_0_STATUS; \
        nop; \
        or      reg, reg, reg3; \
        mtc0    reg, MIPS_COP_0_STATUS; \
        COP0_SYNC


#define PUSHR(reg) \
        addiu   sp,sp,-16        ; \
        sd      reg, 8(sp)      ; \
        nop                     ; 

#define POPR(reg) \
        ld      reg, 8(sp)      ; \
        addiu   sp,sp,16        ; \
        nop                     ; 



                
/*
 * octeon_ciu_get_interrupt_reg_addr
 *
 * Given  Int-X, En-X combination, return the CIU Interrupt Enable Register addr
 * a0 = ciu Int-X:  0/1
 * a1 = ciu EN-0:   0/1
 */
LEAF(octeon_ciu_get_interrupt_reg_addr)
        .set    noreorder
        .set    mips3

        beqz    a0, ciu_get_interrupt_reg_addr_Int_0
        nop

ciu_get_interrupt_reg_addr_Int_1:
        beqz    a1, ciu_get_interrupt_reg_addr_Int_1_En_0
        nop

ciu_get_interrupt_reg_addr_Int_1_En1:
        li      a0, OCTEON_CIU_ADDR_HI
        dsll32  a0, a0, 0
        nop
        ori      a0, OCTEON_CIU_EN1_INT1_LO
        j       ciu_get_interrupt_reg_addr_ret
        nop

ciu_get_interrupt_reg_addr_Int_1_En_0:
        li      a0, OCTEON_CIU_ADDR_HI
        dsll32  a0, a0, 0
        nop
        ori     a0, OCTEON_CIU_EN0_INT1_LO
        j       ciu_get_interrupt_reg_addr_ret
        nop

ciu_get_interrupt_reg_addr_Int_0:
        beqz    a1, ciu_get_interrupt_reg_addr_Int_0_En_0
        nop

ciu_get_interrupt_reg_addr_Int_0_En_1:
        li      a0, OCTEON_CIU_ADDR_HI
        dsll32  a0, a0, 0
        nop
        ori     a0, OCTEON_CIU_EN1_INT0_LO
        j       ciu_get_interrupt_reg_addr_ret
        nop

ciu_get_interrupt_reg_addr_Int_0_En_0:
        li      a0, OCTEON_CIU_ADDR_HI
        dsll32  a0, a0, 0
        nop
        ori     a0, OCTEON_CIU_EN0_INT0_LO
                
        
ciu_get_interrupt_reg_addr_ret: 
        j       ra
        nop
        
        .set	mips0
        .set    reorder
END(octeon_ciu_get_interrupt_reg_addr)


                
/*
 * octeon_ciu_mask_all_interrupts
 *
 * a0 = ciu Interrupt-X:  0/1
 * a1 = ciu Enable-X:   0/1
 */
LEAF(octeon_ciu_mask_all_interrupts)
	.set    noreorder
        .set    mips3

        PUSHR(ra)
        PUSHR(s0)
        
        move    t0, a0
        move    t1, a1
        li      a0, MIPS_SR_INT_IE
        CPU_DISABLE_INTERRUPTS(a2, a1, s0)
        move    a0, t0
        move    t1, a1
        jal     octeon_ciu_get_interrupt_reg_addr
        nop
        ld      a2, 0(a0)       # Dummy read
        nop
        move    a2, zero        # Clear all
        sd      a2, 0(a0)       # Write new Enable bits
        nop
        CPU_ENABLE_INTERRUPTS(a2, s0)

        POPR(s0)
        POPR(ra)
	j	ra			# Return
	nop				# (bd slot)

        .set	mips0
	.set	reorder
END(octeon_ciu_mask_all_interrupts)

OpenPOWER on IntegriCloud