Welcome to mirror list, hosted at ThFree Co, Russian Federation.

spu_timer_flih.S « spu « machine « libc « newlib - cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 63f5f074ca0dabf69d9b786c95e837e6ca804ab4 (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
/*
(C) Copyright IBM Corp. 2008

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 IBM nor the names of its contributors may be
used to endorse or promote products derived from this software without
specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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.
*/

/*  First-level interrupt handler.  */

/* The following two convenience macros assist in the coding of the
   saving and restoring the volatile register starting from register
   2 up to register 79.

   saveregs     first, last    Saves registers from first to the last.
   restoreregs  first, last    Restores registers from last down to first.

   Note:       first must be less than or equal to last.  */

.macro  saveregs        first, last
	stqd            $\first, -(STACK_SKIP+\first)*16($SP)
.if     \last-\first
	saveregs        "(\first+1)",\last
.endif
.endm


.macro  restoreregs     first, last
	lqd             $\last, (82-\last)*16($SP)
.if     \last-\first
	restoreregs     \first,"(\last-1)"
.endif
.endm

	.section        .interrupt,"ax"
	.align          3
	.type           spu_flih, @function
spu_flih:
	/* Adjust the stack pointer to skip the maximum register save area
	   (STACK_SKIP quadword registers) in case an interrupt occurred while
	   executing a leaf function that used the stack area without actually
	   allocating its own stack frame.  */
	.set            STACK_SKIP, 125

	/* Save the current link register on a new stack frame for the
	   normal spu_flih() version of this file.  */
	stqd            $0,  -(STACK_SKIP+80)*16($SP)
	stqd            $SP, -(STACK_SKIP+82)*16($SP)   /* Save back chain pointer.  */

	saveregs        2, 39

	il              $2,  -(STACK_SKIP+82)*16        /* Stack frame size.  */
	rdch            $3, $SPU_RdEventStat            /* Read event status.  */

	rdch            $6, $SPU_RdEventMask            /* Read event mask.  */
	hbrp                                            /* Open a slot for instruction prefetch.  */

	saveregs        40,59

	clz             $4, $3                          /* Get first slih index.  */
	stqd            $6,  -(STACK_SKIP+1)*16($SP)    /* Save event mask on stack.  */

	saveregs        60, 67

	/* Do not disable/ack the decrementer event here.
	   The timer library manages this and expects it
	   to be enabled upon entry to the SLIH. */
	il              $7, 0x20
	andc            $5, $3, $7
	andc            $7, $6, $5                      /* Clear event bits.  */
	saveregs        68, 69

	wrch            $SPU_WrEventAck, $3             /* Ack events(s) - include decrementer event.  */
	wrch            $SPU_WrEventMask, $7            /* Disable event(s) - exclude decrementer event.  */

	saveregs        70, 79

	a               $SP, $SP, $2                    /* Instantiate flih stack frame.  */
next_event:
	/* Fetch and dispatch the event handler for the first non-zero event. The
	   dispatch handler is indexed into the __spu_slih_handlers array using the
	   count of zero off the event status as an index.  */
	ila             $5, __spu_slih_handlers         /* Slih array offset.  */

	shli            $4, $4, 2                       /* Slih entry offset.  */
	lqx             $5, $4, $5                      /* Load slih address.  */
	rotqby          $5, $5, $4                      /* Rotate to word 0.  */
	bisl            $0, $5                          /* Branch to slih.  */

	clz             $4, $3                          /* Get next slih index.  */
	brnz            $3, next_event


	lqd             $2, 81*16($SP)                  /* Read event mask from stack.  */

	restoreregs     40, 79

	wrch            $SPU_WrEventMask, $2            /* Restore event mask.  */
	hbrp                                            /* Open a slot for instruction pre-fetch.  */

	restoreregs     2, 39

	/* Restore the link register from the new stack frame for the
	   normal spu_flih() version of this file.  */
	lqd             $0,  2*16($SP)

	lqd             $SP, 0*16($SP)                 /* restore stack pointer from back chain ptr.  */

	irete                                          /* Return from interrupt and re-enable interrupts.  */
	.size           spu_flih, .-spu_flih
/* spu_slih_handlers[]
   Here we initialize 33 default event handlers.  The first entry in this array
   corresponds to the event handler for the event associated with bit 0 of
   Channel 0 (External Event Status).  The 32nd entry in this array corresponds
   to bit 31 of Channel 0 (DMA Tag Status Update Event).  The 33rd entry in
   this array is a special case entry to handle "phantom events" which occur
   when the channel count for Channel 0 is 1, causing an asynchronous SPU
   interrupt, but the value returned for a read of Channel 0 is 0.  The index
   calculated into this array by spu_flih() for this case is 32, hence the
   33rd entry.  */
.data
	.align  4
	.extern __spu_default_slih
	.global __spu_slih_handlers
	.type   __spu_slih_handlers, @object
__spu_slih_handlers:
	.rept 33
	.long   __spu_default_slih
	.endr
	.size   __spu_slih_handlers, .-__spu_slih_handlers