00001 #include <stdint.h>
00002
00003 #include <moc.h>
00004 #include <internal/ppu/imoc_core_ppu.h>
00005 #include <internal/ppu/imoc_dma_ppu.h>
00006
00007
00008
00009
00010
00011
00012 static unsigned short tags[8];
00013
00014 int moc_tag_reserve(unsigned int speid)
00015 {
00016 if (speid > 8)
00017 return MOC_ERR_INTERN;
00018 int i;
00019 unsigned short bit_tag = 1;
00020 for (i = 0; i < 15; i++)
00021 {
00022
00023 if ((tags[speid] >> i) % 2 == 0)
00024 {
00025 tags[speid] |= bit_tag << i;
00026 return i;
00027 }
00028 }
00029 return MOC_ERR_INTERN;
00030 }
00031
00032 int moc_tag_release(unsigned int speid, int tag)
00033 {
00034 if ((speid > 8) || (tag < 0) || (tag > 14))
00035 return MOC_ERR_INTERN;
00036 unsigned short bit_tag = 1;
00037 bit_tag = bit_tag << tag;
00038 bit_tag = ~bit_tag;
00039 tags[speid] &= bit_tag;
00040 return MOC_SUCCESS;
00041 }