cartdma.c
2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#include <PR/bcp.h>
#include <PR/bbsim.h>
#include <PR/os.h>
#define PRINTF osSyncPrintf
/*
* Thread and stack structures
*/
#define IDLE_STACKSIZE 4096
char idleStack[IDLE_STACKSIZE] __attribute__ ((aligned (8)));
static OSThread idleThread;
static char idleThreadStack[IDLE_STACKSIZE] __attribute__ ((aligned (8)));
static void idleproc(char *);
extern void *_ftext;
const u32 dmaTestData[] = {
0x00010203,
0x04050607,
0x08090a0b,
0x0c0d0e0f,
0x10111213,
0x14151617,
0x18191a1b,
0x1c1d1e1f
};
void boot()
{
osInitialize();
osCreateThread(&idleThread, 1, (void(*)(void *))idleproc, (void *)0,
idleThreadStack+IDLE_STACKSIZE, 8);
osStartThread(&idleThread);
}
void idleproc(char *argv)
{
int i;
u32 val;
PRINTF("Entered idle thread...\n");
PRINTF("dmaTestData[0] = %08x\n",((u32 *)K0_TO_K1(&dmaTestData))[0]);
val = (u32)((u32)(&dmaTestData) - (u32)(&_ftext));
PRINTF("Offset = %08x\n",val);
PRINTF("DRAM address: %08x\n",PHYS_TO_K1(0x100000));
for(i=0;i<sizeof(dmaTestData);i+=4){
*(u32 *)PHYS_TO_K1(0x100000+i) = i;
}
for(i=0;i<sizeof(dmaTestData);i+=4){
PRINTF("%08x\n",*(u32 *)PHYS_TO_K1(0x100000+i));
}
IO_WRITE(PI_STATUS_REG,0);
PRINTF("PI_STATUS_REG = %08x\n",IO_READ(PI_STATUS_REG));
/* try a dma */
IO_WRITE(PI_DRAM_ADDR_REG, 0x100000);
IO_WRITE(PI_CART_ADDR_REG, PI_DOM1_ADDR2 + val);
IO_WRITE(PI_WR_LEN_REG, sizeof(dmaTestData)-1);
while(IO_READ(PI_STATUS_REG) & (PI_STATUS_IO_BUSY | PI_STATUS_DMA_BUSY)) {
if (IO_READ(PI_STATUS_REG) & PI_STATUS_ERROR){
PRINTF("DMA Failed!!!\n");
break;
}
}
for(i=0;i<sizeof(dmaTestData);i+=4){
PRINTF("%08x\n",*(u32 *)PHYS_TO_K1(0x100000+i));
}
exit:
PRINTF("\nAPP FINISHED\n");
/* power off (cannot do this since not in secure mode) */
IO_WRITE(PI_GPIO_REG, 0|(1 << PI_GPIO_ENABLE_SHIFT));
while(1){}
}