1 /* Copyright (C) 2007, 2009 Free Software Foundation, Inc.
3 This file is free software; you can redistribute it and/or modify it under
4 the terms of the GNU General Public License as published by the Free
5 Software Foundation; either version 3 of the License, or (at your option)
8 This file is distributed in the hope that it will be useful, but WITHOUT
9 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 You should have received a copy of the GNU General Public License
14 along with this file; see the file COPYING3. If not see
15 <http://www.gnu.org/licenses/>. */
19 #include <spu_mfcio.h>
22 /* This test directly accesses the internal table used
23 by the MFC tag manager. */
24 extern vector
unsigned int __mfc_tag_table
;
27 /* This tag tests invalid tag release. Invalid tag release does
28 nothing to the tag table. */
30 test_tag_release01 (void)
33 copy
= spu_extract (__mfc_tag_table
, 0);
36 if (copy
!= spu_extract (__mfc_tag_table
, 0))
40 /* More invalid release tests. */
42 test_tag_release_invalid (void)
45 copy
= spu_extract (__mfc_tag_table
, 0);
47 if (mfc_tag_release (32) != MFC_TAG_INVALID
)
49 if (copy
!= spu_extract (__mfc_tag_table
, 0))
52 if (mfc_tag_release (17) != MFC_TAG_INVALID
)
54 if (copy
!= spu_extract (__mfc_tag_table
, 0))
58 /* Invalid multiple-tag release tests. */
60 test_tag_group_release_invalid (void)
63 copy
= spu_extract (__mfc_tag_table
, 0);
65 if (mfc_multi_tag_release (32, 10) != MFC_TAG_INVALID
)
67 if (copy
!= spu_extract (__mfc_tag_table
, 0))
70 if (mfc_multi_tag_release (28, 10) != MFC_TAG_INVALID
)
72 if (copy
!= spu_extract (__mfc_tag_table
, 0))
75 if (mfc_multi_tag_release (17, 10) != MFC_TAG_INVALID
)
77 if (copy
!= spu_extract (__mfc_tag_table
, 0))
80 if (mfc_multi_tag_release (32, 10) != MFC_TAG_INVALID
)
82 if (copy
!= spu_extract (__mfc_tag_table
, 0))
86 /* The tag table should be in a pristine mode to run this test. */
88 test_tag_reserve01 (void)
90 unsigned int correct_table
[32] =
92 0x80000000, 0xC0000000, 0xE0000000,
93 0xF0000000, 0xF8000000, 0xFC000000, 0xFE000000,
94 0xFF000000, 0xFF800000, 0xFFC00000, 0xFFE00000,
95 0xFFF00000, 0xFFF80000, 0xFFFC0000, 0xFFFE0000,
96 0xFFFF0000, 0xFFFF8000, 0xFFFFC000, 0xFFFFE000,
97 0xFFFFF000, 0xFFFFF800, 0xFFFFFC00, 0xFFFFFE00,
98 0xFFFFFF00, 0xFFFFFF80, 0xFFFFFFC0, 0xFFFFFFE0,
99 0xFFFFFFF0, 0xFFFFFFF8, 0xFFFFFFFC, 0xFFFFFFFE,
106 for (i
= 0; i
< 32; i
++)
108 tag
= mfc_tag_reserve ();
113 for (i
= 0; i
< 32; i
++)
115 tag
= mfc_tag_reserve ();
116 if (tag
!= MFC_TAG_INVALID
)
120 for (i
= 0; i
< 32; i
++)
123 if (spu_extract (__mfc_tag_table
, 0) != correct_table
[i
])
128 /* The tag table should be in a pristine mode to run this test. */
130 test_tag_reserve02 (void)
132 unsigned int correct_table
[32] =
134 0x80000000, 0xC0000000, 0xA0000000, 0xF0000000,
135 0xA8000000, 0xFC000000, 0xAA000000, 0xFF000000,
136 0xAA800000, 0xFFC00000, 0xAAA00000, 0xFFF00000,
137 0xAAA80000, 0xFFFC0000, 0xAAAA0000, 0xFFFF0000,
138 0xAAAA8000, 0xFFFFC000, 0xAAAAA000, 0xFFFFF000,
139 0xAAAAA800, 0xFFFFFC00, 0xAAAAAA00, 0xFFFFFF00,
140 0xAAAAAA80, 0xFFFFFFC0, 0xAAAAAAA0, 0xFFFFFFF0,
141 0xAAAAAAA8, 0xFFFFFFFC, 0xAAAAAAAA, 0xFFFFFFFF
144 unsigned int correct_table2
[32] =
146 0x80000000, 0xEAAAAAAA, 0xA0000000, 0xFAAAAAAA,
147 0xA8000000, 0xFEAAAAAA, 0xAA000000, 0xFFAAAAAA,
148 0xAA800000, 0xFFEAAAAA, 0xAAA00000, 0xFFFAAAAA,
149 0xAAA80000, 0xFFFEAAAA, 0xAAAA0000, 0xFFFFAAAA,
150 0xAAAA8000, 0xFFFFEAAA, 0xAAAAA000, 0xFFFFFAAA,
151 0xAAAAA800, 0xFFFFFEAA, 0xAAAAAA00, 0xFFFFFFAA,
152 0xAAAAAA80, 0xFFFFFFEA, 0xAAAAAAA0, 0xFFFFFFFA,
153 0xAAAAAAA8, 0xFFFFFFFE, 0xAAAAAAAA, 0xFFFFFFFF
159 /* Reserve all 32 tags. */
160 for (i
= 0; i
< 32; i
++)
162 tag
= mfc_tag_reserve();
167 for (i
= 0; i
< 32; i
++)
169 tag
= mfc_tag_reserve();
170 if (tag
!= MFC_TAG_INVALID
)
174 /* Release only 16 tags with a stride of 2. */
175 for (i
= 0; i
< 32; i
+= 2)
178 if (spu_extract (__mfc_tag_table
, 0) != correct_table
[i
])
182 /* Release the other 16 tags with a stride of 2. */
183 for (i
= 1; i
< 32; i
+= 2)
186 if (spu_extract (__mfc_tag_table
, 0) != correct_table2
[i
])
191 /* The tag table should be in a pristine mode to run this test. */
193 test_tag_reserve03 (void)
198 /* Reserve all 32 tags. */
199 for (i
= 0; i
< 32; i
++)
201 tag
= mfc_tag_reserve ();
206 for (i
= 0; i
< 32; i
++)
208 tag
= mfc_tag_reserve ();
209 if (tag
!= MFC_TAG_INVALID
)
213 /* Release only 16 tags with a stride of 2. */
214 for (i
= 0; i
< 32; i
+= 2)
217 /* Now let's re-reserve those tags. */
218 for (i
= 0; i
< 32; i
+= 2)
220 tag
= mfc_tag_reserve ();
225 /* Release all tags. */
226 for (i
= 0; i
< 32; i
++)
229 if (spu_extract (__mfc_tag_table
,0) != 0xFFFFFFFF)
235 test_tag_group_reserve (void)
241 /* Reserve all tags. */
242 for (i
= 0; i
< 32; i
++)
245 /* Release the first 4. */
246 for (i
= 0; i
< 4; i
++)
249 /* Release tag 5 to 7. */
250 for (i
= 5; i
< 8; i
++)
253 /* Release tag 9 to 19. */
254 for (i
= 9; i
< 20; i
++)
257 /* Tag table should be 0xF77FF000. */
258 if (spu_extract (__mfc_tag_table
, 0) != 0xF77FF000)
262 /* Verify invalid release is detected. */
263 copy
= spu_extract (__mfc_tag_table
, 0);
264 if (mfc_multi_tag_release (1, 5) != MFC_TAG_INVALID
)
266 if (copy
!= spu_extract (__mfc_tag_table
, 0))
270 /* Reserve multiple tags. */
271 tag
= mfc_multi_tag_reserve (5);
275 /* Tag table should be 0xF703F000. */
276 if (spu_extract (__mfc_tag_table
, 0) != 0xF703F000)
280 /* Release 5 tags in the group. */
281 mfc_multi_tag_release (tag
, 5);
283 /* Tag table should be 0xF77FF000. */
284 if (spu_extract (__mfc_tag_table
, 0) != 0xF77FF000)
288 /* This call should not do anything. */
289 mfc_multi_tag_release (32, 5);
291 /* Tag table should be 0xF77FF000. */
292 if (spu_extract (__mfc_tag_table
, 0) != 0xF77FF000)
300 test_tag_release01 ();
301 test_tag_release_invalid ();
302 test_tag_group_release_invalid ();
304 test_tag_reserve01 ();
305 test_tag_reserve02 ();
306 test_tag_reserve03 ();
308 test_tag_group_reserve ();