blob: 47e7b596a6f58236859d7559555e04a76bc1851f [file] [log] [blame]
wdenk21136db2003-07-16 21:53:01 +00001/*
2 * (C) Copyright 2003
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4 *
5 * This file is based on code
6 * (C) Copyright Motorola, Inc., 2000
7 */
8
9#include <common.h>
10#include <mpc5xxx.h>
11
12/* BestComm/SmartComm microcode */
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 /* setup TaskBAR register */
28 *(vu_long *)MPC5XXX_SDMA = MPC5XXX_SRAM;
29
30 /* relocate task table entries */
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 /* relocate task descriptors */
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 /* relocate variables */
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 /* relocate function decriptors */
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}