1 /* Copyright (C) 2007 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 2 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 COPYING. If not, write to the Free
15 Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
20 #include <spu_mfcio.h>
23 /* This test directly accesses the internal table used
24 by the MFC tag manager. */
25 extern vector
unsigned int __mfc_tag_table
;
28 /* This tag tests invalid tag release. Invalid tag release does
29 nothing to the tag table. */
31 test_tag_release01 (void)
34 copy
= spu_extract (__mfc_tag_table
, 0);
37 if (copy
!= spu_extract (__mfc_tag_table
, 0))
41 /* More invalid release tests. */
43 test_tag_release_invalid (void)
46 copy
= spu_extract (__mfc_tag_table
, 0);
48 if (mfc_tag_release (32) != MFC_TAG_INVALID
)
50 if (copy
!= spu_extract (__mfc_tag_table
, 0))
53 if (mfc_tag_release (17) != MFC_TAG_INVALID
)
55 if (copy
!= spu_extract (__mfc_tag_table
, 0))
59 /* Invalid multiple-tag release tests. */
61 test_tag_group_release_invalid (void)
64 copy
= spu_extract (__mfc_tag_table
, 0);
66 if (mfc_multi_tag_release (32, 10) != MFC_TAG_INVALID
)
68 if (copy
!= spu_extract (__mfc_tag_table
, 0))
71 if (mfc_multi_tag_release (28, 10) != MFC_TAG_INVALID
)
73 if (copy
!= spu_extract (__mfc_tag_table
, 0))
76 if (mfc_multi_tag_release (17, 10) != MFC_TAG_INVALID
)
78 if (copy
!= spu_extract (__mfc_tag_table
, 0))
81 if (mfc_multi_tag_release (32, 10) != MFC_TAG_INVALID
)
83 if (copy
!= spu_extract (__mfc_tag_table
, 0))
87 /* The tag table should be in a pristine mode to run this test. */
89 test_tag_reserve01 (void)
91 unsigned int correct_table
[32] =
93 0x80000000, 0xC0000000, 0xE0000000,
94 0xF0000000, 0xF8000000, 0xFC000000, 0xFE000000,
95 0xFF000000, 0xFF800000, 0xFFC00000, 0xFFE00000,
96 0xFFF00000, 0xFFF80000, 0xFFFC0000, 0xFFFE0000,
97 0xFFFF0000, 0xFFFF8000, 0xFFFFC000, 0xFFFFE000,
98 0xFFFFF000, 0xFFFFF800, 0xFFFFFC00, 0xFFFFFE00,
99 0xFFFFFF00, 0xFFFFFF80, 0xFFFFFFC0, 0xFFFFFFE0,
100 0xFFFFFFF0, 0xFFFFFFF8, 0xFFFFFFFC, 0xFFFFFFFE,
107 for (i
= 0; i
< 32; i
++)
109 tag
= mfc_tag_reserve ();
114 for (i
= 0; i
< 32; i
++)
116 tag
= mfc_tag_reserve ();
117 if (tag
!= MFC_TAG_INVALID
)
121 for (i
= 0; i
< 32; i
++)
124 if (spu_extract (__mfc_tag_table
, 0) != correct_table
[i
])
129 /* The tag table should be in a pristine mode to run this test. */
131 test_tag_reserve02 (void)
133 unsigned int correct_table
[32] =
135 0x80000000, 0xC0000000, 0xA0000000, 0xF0000000,
136 0xA8000000, 0xFC000000, 0xAA000000, 0xFF000000,
137 0xAA800000, 0xFFC00000, 0xAAA00000, 0xFFF00000,
138 0xAAA80000, 0xFFFC0000, 0xAAAA0000, 0xFFFF0000,
139 0xAAAA8000, 0xFFFFC000, 0xAAAAA000, 0xFFFFF000,
140 0xAAAAA800, 0xFFFFFC00, 0xAAAAAA00, 0xFFFFFF00,
141 0xAAAAAA80, 0xFFFFFFC0, 0xAAAAAAA0, 0xFFFFFFF0,
142 0xAAAAAAA8, 0xFFFFFFFC, 0xAAAAAAAA, 0xFFFFFFFF
145 unsigned int correct_table2
[32] =
147 0x80000000, 0xEAAAAAAA, 0xA0000000, 0xFAAAAAAA,
148 0xA8000000, 0xFEAAAAAA, 0xAA000000, 0xFFAAAAAA,
149 0xAA800000, 0xFFEAAAAA, 0xAAA00000, 0xFFFAAAAA,
150 0xAAA80000, 0xFFFEAAAA, 0xAAAA0000, 0xFFFFAAAA,
151 0xAAAA8000, 0xFFFFEAAA, 0xAAAAA000, 0xFFFFFAAA,
152 0xAAAAA800, 0xFFFFFEAA, 0xAAAAAA00, 0xFFFFFFAA,
153 0xAAAAAA80, 0xFFFFFFEA, 0xAAAAAAA0, 0xFFFFFFFA,
154 0xAAAAAAA8, 0xFFFFFFFE, 0xAAAAAAAA, 0xFFFFFFFF
160 /* Reserve all 32 tags. */
161 for (i
= 0; i
< 32; i
++)
163 tag
= mfc_tag_reserve();
168 for (i
= 0; i
< 32; i
++)
170 tag
= mfc_tag_reserve();
171 if (tag
!= MFC_TAG_INVALID
)
175 /* Release only 16 tags with a stride of 2. */
176 for (i
= 0; i
< 32; i
+= 2)
179 if (spu_extract (__mfc_tag_table
, 0) != correct_table
[i
])
183 /* Release the other 16 tags with a stride of 2. */
184 for (i
= 1; i
< 32; i
+= 2)
187 if (spu_extract (__mfc_tag_table
, 0) != correct_table2
[i
])
192 /* The tag table should be in a pristine mode to run this test. */
194 test_tag_reserve03 (void)
199 /* Reserve all 32 tags. */
200 for (i
= 0; i
< 32; i
++)
202 tag
= mfc_tag_reserve ();
207 for (i
= 0; i
< 32; i
++)
209 tag
= mfc_tag_reserve ();
210 if (tag
!= MFC_TAG_INVALID
)
214 /* Release only 16 tags with a stride of 2. */
215 for (i
= 0; i
< 32; i
+= 2)
218 /* Now let's re-reserve those tags. */
219 for (i
= 0; i
< 32; i
+= 2)
221 tag
= mfc_tag_reserve ();
226 /* Release all tags. */
227 for (i
= 0; i
< 32; i
++)
230 if (spu_extract (__mfc_tag_table
,0) != 0xFFFFFFFF)
236 test_tag_group_reserve (void)
242 /* Reserve all tags. */
243 for (i
= 0; i
< 32; i
++)
246 /* Release the first 4. */
247 for (i
= 0; i
< 4; i
++)
250 /* Release tag 5 to 7. */
251 for (i
= 5; i
< 8; i
++)
254 /* Release tag 9 to 19. */
255 for (i
= 9; i
< 20; i
++)
258 /* Tag table should be 0xF77FF000. */
259 if (spu_extract (__mfc_tag_table
, 0) != 0xF77FF000)
263 /* Verify invalid release is detected. */
264 copy
= spu_extract (__mfc_tag_table
, 0);
265 if (mfc_multi_tag_release (1, 5) != MFC_TAG_INVALID
)
267 if (copy
!= spu_extract (__mfc_tag_table
, 0))
271 /* Reserve multiple tags. */
272 tag
= mfc_multi_tag_reserve (5);
276 /* Tag table should be 0xF703F000. */
277 if (spu_extract (__mfc_tag_table
, 0) != 0xF703F000)
281 /* Release 5 tags in the group. */
282 mfc_multi_tag_release (tag
, 5);
284 /* Tag table should be 0xF77FF000. */
285 if (spu_extract (__mfc_tag_table
, 0) != 0xF77FF000)
289 /* This call should not do anything. */
290 mfc_multi_tag_release (32, 5);
292 /* Tag table should be 0xF77FF000. */
293 if (spu_extract (__mfc_tag_table
, 0) != 0xF77FF000)
301 test_tag_release01 ();
302 test_tag_release_invalid ();
303 test_tag_group_release_invalid ();
305 test_tag_reserve01 ();
306 test_tag_reserve02 ();
307 test_tag_reserve03 ();
309 test_tag_group_reserve ();