1
2
3
4
5
6
7
8
9#include <common.h>
10#include <mpc5xxx.h>
11
12
13extern int taskTable;
14
15void loadtask(int basetask, int tasks)
16{
17 int *sram = (int *)MPC5XXX_SRAM;
18 int *task_org = &taskTable;
19 unsigned int start, offset, end;
20 int i;
21
22#ifdef DEBUG
23 printf("basetask = %d, tasks = %d\n", basetask, tasks);
24 printf("task_org = 0x%08x\n", (unsigned int)task_org);
25#endif
26
27
28 *(vu_long *)MPC5XXX_SDMA = MPC5XXX_SRAM;
29
30
31 offset = (unsigned int)sram;
32 for (i = basetask; i < basetask + tasks; i++) {
33 sram[i * 8 + 0] = task_org[i * 8 + 0] + offset;
34 sram[i * 8 + 1] = task_org[i * 8 + 1] + offset;
35 sram[i * 8 + 2] = task_org[i * 8 + 2] + offset;
36 sram[i * 8 + 3] = task_org[i * 8 + 3] + offset;
37 sram[i * 8 + 4] = task_org[i * 8 + 4];
38 sram[i * 8 + 5] = task_org[i * 8 + 5];
39 sram[i * 8 + 6] = task_org[i * 8 + 6] + offset;
40 sram[i * 8 + 7] = task_org[i * 8 + 7];
41 }
42
43
44 start = (sram[basetask * 8] - (unsigned int)sram);
45 end = (sram[(basetask + tasks - 1) * 8 + 1] - (unsigned int)sram);
46
47#ifdef DEBUG
48 printf ("TDT start = 0x%08x, end = 0x%08x\n", start, end);
49#endif
50
51 start /= 4;
52 end /= 4;
53 for (i = start; i <= end; i++) {
54 sram[i] = task_org[i];
55 }
56
57
58 start = (sram[basetask * 8 + 2] - (unsigned int)sram);
59 end = (sram[(basetask + tasks - 1) * 8 + 2] + 256 - (unsigned int)sram);
60 start /= 4;
61 end /= 4;
62 for (i = start; i < end; i++) {
63 sram[i] = task_org[i];
64 }
65
66
67 start = ((sram[basetask * 8 + 3] & 0xfffffffc) - (unsigned int)sram);
68 end = ((sram[(basetask + tasks - 1) * 8 + 3] & 0xfffffffc) + 256 - (unsigned int)sram);
69 start /= 4;
70 end /= 4;
71 for (i = start; i < end; i++) {
72 sram[i] = task_org[i];
73 }
74
75 asm volatile ("sync");
76}
77