wdenk | 337f565 | 2004-10-28 00:09:35 +0000 | [diff] [blame] | 1 | /* |
| 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 <mpc8220.h> |
| 11 | |
| 12 | /* Multichannel DMA microcode */ |
| 13 | extern int taskTable; |
| 14 | |
| 15 | void loadtask (int basetask, int tasks) |
| 16 | { |
| 17 | int *sram = (int *) (MMAP_SRAM + 512); |
| 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 *) MMAP_DMA = (MMAP_SRAM + 512); |
| 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 - |
| 60 | (unsigned int) sram); |
| 61 | start /= 4; |
| 62 | end /= 4; |
| 63 | for (i = start; i < end; i++) { |
| 64 | sram[i] = task_org[i]; |
| 65 | } |
| 66 | |
| 67 | /* relocate function decriptors */ |
| 68 | start = ((sram[basetask * 8 + 3] & 0xfffffffc) - (unsigned int) sram); |
| 69 | end = ((sram[(basetask + tasks - 1) * 8 + 3] & 0xfffffffc) + 256 - |
| 70 | (unsigned int) sram); |
| 71 | start /= 4; |
| 72 | end /= 4; |
| 73 | for (i = start; i < end; i++) { |
| 74 | sram[i] = task_org[i]; |
| 75 | } |
| 76 | |
| 77 | asm volatile ("sync"); |
| 78 | } |