inline unsigned getchanend(unsigned otherside) { unsigned chanend; __asm__ __volatile__ ("getr %0, 2" : "=r" (chanend)); __asm__ __volatile__ ("setd res[%0], %1" : : "r" (chanend), "r" (otherside) ); return chanend; } inline void freechanend(unsigned chanend) { __asm__ __volatile__ ("freer res[%0]" : /* no output */ : "r" (chanend)); } inline void getr(unsigned chan, unsigned token) { __asm__ __volatile__ ("out res[%0], %1" : /* no output */ : "r" (chan) , "r" (token)); } inline void outt(unsigned chan, unsigned token) { __asm__ __volatile__ ("outt res[%0], %1" : /* no output */ : "r" (chan) , "r" (token)); } inline void outct(unsigned chan, unsigned token) { __asm__ __volatile__ ("outct res[%0], %1" : /* no output */ : "r" (chan) , "r" (token)); } inline void chkct(unsigned chan, unsigned token) { __asm__ __volatile__ ("chkct res[%0], %1" : /* no output */ : "r" (chan) , "r" (token)); } void setRegVal(int processor, int psctl, int reg, int n) { int o = processor<<16 | (psctl ? 0xC20C : 0xC30C); unsigned c = getchanend(o); outct(c, 0xc0); //CTOKEN_CWRITE outt(c, 0); outt(c, 0); outt(c, (c>>8)); outt(c, 0); // reg num outt(c, reg); // reg num outt(c, 0); // val outt(c, 0); // val outt(c, 0); // val outt(c, n); // val outct(c, 1); chkct(c,3); chkct(c,1); freechanend(c); } /* Example main() { setRegVal(1, 6, 1, 128); setRegVal(1, 6, 2, 128); setRegVal(1, 6, 3, 128); setRegVal(0, 7, 0, 128); // setRegVal(1, 6, 0, 128); while(1); } */