1 |
282 |
jeremybenn |
/* Copyright (C) 2007, 2009 Free Software Foundation, Inc.
|
2 |
|
|
|
3 |
|
|
This file is part of GCC.
|
4 |
|
|
|
5 |
|
|
GCC is free software; you can redistribute it and/or modify it under
|
6 |
|
|
the terms of the GNU General Public License as published by the Free
|
7 |
|
|
Software Foundation; either version 3, or (at your option) any later
|
8 |
|
|
version.
|
9 |
|
|
|
10 |
|
|
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
|
11 |
|
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
12 |
|
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
13 |
|
|
for more details.
|
14 |
|
|
|
15 |
|
|
Under Section 7 of GPL version 3, you are granted additional
|
16 |
|
|
permissions described in the GCC Runtime Library Exception, version
|
17 |
|
|
3.1, as published by the Free Software Foundation.
|
18 |
|
|
|
19 |
|
|
You should have received a copy of the GNU General Public License and
|
20 |
|
|
a copy of the GCC Runtime Library Exception along with this program;
|
21 |
|
|
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
22 |
|
|
<http://www.gnu.org/licenses/>. */
|
23 |
|
|
|
24 |
|
|
#include <spu_mfcio.h>
|
25 |
|
|
extern vector unsigned int __mfc_tag_table;
|
26 |
|
|
|
27 |
|
|
/* Release a sequential group of tags from exclusive use. The sequential
|
28 |
|
|
group of tags is the range starting from <first_tag> through
|
29 |
|
|
<first_tag>+<number_of_tags>-1. Upon sucessful release, MFC_DMA_TAG_VALID
|
30 |
|
|
is returned and the tags become available for future reservation.
|
31 |
|
|
|
32 |
|
|
If the specified tags were not previously reserved, no action is
|
33 |
|
|
taken and MFC_DMA_TAG_INVALID is returned. */
|
34 |
|
|
|
35 |
|
|
unsigned int
|
36 |
|
|
__mfc_multi_tag_release (unsigned int first_tag, unsigned int number_of_tags)
|
37 |
|
|
{
|
38 |
|
|
vector unsigned int table_copy, tmp, tmp1;
|
39 |
|
|
vector unsigned int one = (vector unsigned int)
|
40 |
|
|
{ 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF };
|
41 |
|
|
vector unsigned int is_invalid;
|
42 |
|
|
unsigned int last_tag;
|
43 |
|
|
vector unsigned int has_been_reserved;
|
44 |
|
|
|
45 |
|
|
last_tag = first_tag + number_of_tags;
|
46 |
|
|
|
47 |
|
|
table_copy = spu_sl (one, number_of_tags);
|
48 |
|
|
table_copy = spu_rl (table_copy, -last_tag);
|
49 |
|
|
table_copy = spu_xor (table_copy, -1);
|
50 |
|
|
|
51 |
|
|
/* Make sure the tags are in range and valid. */
|
52 |
|
|
tmp = spu_cmpgt (spu_promote(last_tag, 0), 32);
|
53 |
|
|
tmp1 = spu_cmpgt (spu_promote(number_of_tags, 0), 32);
|
54 |
|
|
is_invalid = spu_cmpgt (spu_promote(first_tag, 0), 31);
|
55 |
|
|
|
56 |
|
|
/* All bits are set to 1 if invalid, 0 if valid. */
|
57 |
|
|
is_invalid = spu_or (tmp, is_invalid);
|
58 |
|
|
is_invalid = spu_or (tmp1, is_invalid);
|
59 |
|
|
|
60 |
|
|
/* check whether these tags have been reserved */
|
61 |
|
|
tmp = spu_rlmask (one, (int)-number_of_tags);
|
62 |
|
|
tmp1 = spu_sl (__mfc_tag_table, first_tag);
|
63 |
|
|
has_been_reserved = spu_cmpgt(tmp1, tmp);
|
64 |
|
|
|
65 |
|
|
is_invalid = spu_or (has_been_reserved, is_invalid);
|
66 |
|
|
|
67 |
|
|
table_copy = spu_sel (__mfc_tag_table, table_copy, table_copy);
|
68 |
|
|
__mfc_tag_table = spu_sel (table_copy, __mfc_tag_table, is_invalid);
|
69 |
|
|
|
70 |
|
|
return spu_extract (is_invalid, 0);
|
71 |
|
|
}
|
72 |
|
|
|