]> git.ipfire.org Git - thirdparty/gcc.git/blame - libgcc/config/spu/mfc_tag_release.c
Move libgcc2 to toplevel libgcc
[thirdparty/gcc.git] / libgcc / config / spu / mfc_tag_release.c
CommitLineData
748086b7 1/* Copyright (C) 2007, 2009 Free Software Foundation, Inc.
1763dfa7
UW
2
3This file is part of GCC.
4
5GCC is free software; you can redistribute it and/or modify it under
6the terms of the GNU General Public License as published by the Free
748086b7 7Software Foundation; either version 3, or (at your option) any later
1763dfa7
UW
8version.
9
1763dfa7
UW
10GCC is distributed in the hope that it will be useful, but WITHOUT ANY
11WARRANTY; without even the implied warranty of MERCHANTABILITY or
12FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13for more details.
14
748086b7
JJ
15Under Section 7 of GPL version 3, you are granted additional
16permissions described in the GCC Runtime Library Exception, version
173.1, as published by the Free Software Foundation.
18
19You should have received a copy of the GNU General Public License and
20a copy of the GCC Runtime Library Exception along with this program;
21see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
22<http://www.gnu.org/licenses/>. */
1763dfa7
UW
23
24#include <spu_mfcio.h>
25extern vector unsigned int __mfc_tag_table;
26
27/* Release the specified DMA tag from exclusive use. Once released, the
28 tag is available for future reservation. Upon sucessful release,
29 MFC_DMA_TAG_VALID is returned. If the specified tag is not in the
30 range 0 to 31, or had not been reserved, no action is taken and
31 MFC_DMA_TAG_INVALID is returned. */
32
33unsigned int
34__mfc_tag_release (unsigned int tag)
35{
36 vector unsigned int is_invalid;
37 vector unsigned int mask = (vector unsigned int)
38 { 0x80000000, 0x80000000, 0x80000000, 0x80000000 };
39 vector signed int zero = (vector signed int) { 0, 0, 0, 0 };
40
41 vector signed int has_been_reserved;
42
43 /* Check if the tag is out of range. */
44 is_invalid = spu_cmpgt (spu_promote (tag, 0), 31);
45
46 /* Check whether the tag has been reserved, set to all 1 if has not
47 been reserved, 0 otherwise. */
48 has_been_reserved = (vector signed int) spu_rl (__mfc_tag_table, tag);
49 has_been_reserved = (vector signed int) spu_cmpgt (zero, has_been_reserved);
50
51 /* Set invalid. */
52 is_invalid = spu_or ((vector unsigned int) has_been_reserved, is_invalid);
53
54 mask = spu_rlmask (mask, (int)(-tag));
55 __mfc_tag_table = spu_or (__mfc_tag_table, mask);
56
57 return spu_extract(is_invalid, 0);
58}
59