/* Disable the Fixed-Interval-Timer */ void fit_disable() { U32 tcr; MFSPR(tcr, TCR); tcr &= ~FIT_INT_ENABLE; MTSPR(tcr, TCR); }
void fit_init() { U32 tcr; MFSPR(tcr, TCR); tcr |= FIT_TIME_PERIOD_3; MTSPR(tcr, TCR); }
/* Enable the Fixed-Interval-Timer */ void fit_enable() { U32 msr, tcr; MFSPR(tcr, TCR); tcr |= FIT_INT_ENABLE; MTSPR(tcr, TCR); MFMSR(msr); msr |= MSR_EXTERNAL_IRQ_ENABLE; MTMSR(msr); ISYNC; }
int main(int argc, char **argv) { char src1[4096] = "Hello world."; char dst1[4096] = "1111111111111111111111111111111111"; char src2[4096] = "The whole world spread before you."; char dst2[4096] = "2222222222222222222222222222222222"; // Attach the external interrupt handler for 'intr0' int_init(); int_add(0, (void *)interruptHandler, NULL); int_enable(0); // Enable external interrupts Uns32 spr = MFSPR(17); spr |= 0x4; MTSPR(17, spr); writeReg8(DMA_BASE, DMA_CONFIGURATION, BURST_SIZE); /* reset */ LOG("initial dst1 '%s' dst2 '%s'\n", dst1, dst2); /* write to DMAC registers to start burst */ dmaBurst(0, src1, dst1, strlen(src1)+1); dmaBurst(1, src2, dst2, strlen(src2)+1); /* wait for burst to complete */ LOG("Waiting for interrupts\n"); while ( interruptCount < 2 ) ; LOG("%u interrupts received\n", interruptCount); /* check results */ LOG("DMA result dst1 '%s' dst2 '%s'\n", dst1, dst2); return 1; }
static void mfspr(int d, int s) { MFSPR(s, d); }