Files
lib_xua/module_usb_aud_shared/reboot.xcnot
Russell 8b0ad92d87 Free chanend in device_reboot so there is one to talk to the sswitch on.
Compiled to assembly and frigged the accounting of chanends to get it passed the mapper.
2012-01-06 16:26:58 +00:00

22 lines
641 B
Plaintext

#include <xs1.h>
#include <print.h>
int write_sswitch_reg_blind(unsigned coreid, unsigned reg, unsigned data);
/* Reboots XMOS device by writing to the PLL config register */
void device_reboot(chanend spare)
{
// Need a spare chanend so we can talk to the pll register
asm("freer res[%0]"::"r"(spare));
// Need to tell the mapper we have freed one
//asm(".set device_reboot.maxchanends, 0");
{
unsigned int pllVal;
unsigned int core_id = get_core_id();
read_sswitch_reg(core_id, 6, pllVal);
write_sswitch_reg_blind(core_id^0x8000, 6, pllVal);
write_sswitch_reg_blind(core_id, 6, pllVal);
}
}