📄 l2_dmac.c
字号:
//PRINT_L2(" L2_SetDRAMDMA: Exit L2_SetDRAMDMA\n");
return L2K_SUCCESS;
}
//-----------------------------------------------------------------------------
//L2_SetSRAMDMA
//-----------------------------------------------------------------------------
/*
routine description:
SRAM DMA setting
arguments:
SRAMAddr: 4K SRAM buffer, starting address (0x0000 - 0x0FFF)
return value:
0x00 - success
others - error
*/
UCHAR L2_SetSRAMDMA(USHORT SRAMAddr) USING_0
{
//PRINT_L2(" L2_SetSRAMDMA: Enter L2_SetSRAMDMA(SRAMAddr=%x)\n",SRAMAddr);
if((SRAMAddr & 0xF000)!=0) return 0x01 ;
XBYTE[0x2C12] = (UCHAR)SRAMAddr&0xFF;
XBYTE[0x2C13] = (UCHAR)(SRAMAddr>>8)&0x0F;
XBYTE[0x2C11] |= 0x04;
XBYTE[0x2C11] &= 0xFB;
//PRINT_L2(" L2_SetSRAMDMA: Exit L2_SetSRAMDMA\n");
return L2K_SUCCESS;
}
//-----------------------------------------------------------------------------
//L2_SetUSBDMA
//-----------------------------------------------------------------------------
/*
routine description:
USB DMA setting
arguments:
USBDMASrc:
0: endpoint 3
1: endpoint 8
USBDMADst:
0: endpoint 2
1: endpoint 4
2: endpoint 7
3: endpoint 9
return value:
0x00 - success
others - error
*/
UCHAR L2_SetUSBDMA(UCHAR USBDMASrc, UCHAR USBDMADst) USING_0
{
//PRINT_L2(" L2_SetUSBDMA: Enter L2_SetUSBDMA(USBDMASrc=%x,USBDMADst=%x)\n",(USHORT)USBDMASrc,(USHORT)USBDMADst);
XBYTE[0x2510] = USBDMASrc;
XBYTE[0x2511] = USBDMADst;
//PRINT_L2(" L2_SetUSBDMA: Exit L2_SetUSBDMA\n");
return L2K_SUCCESS;
}
//-----------------------------------------------------------------------------
//L2_SetAudDMA
//-----------------------------------------------------------------------------
/*
routine description:
Audio DMA setting
arguments:
AudBufMode : 4, audio is for DMA source
5, audio is for DMA destination
return value:
0x00 - success
others - error
*/
UCHAR L2_SetAudDMA(UCHAR AudBufMode) USING_0
{
//PRINT_L2(" L2_SetAudDMA: Enter L2_SetAudDMA(AudBufMode=%x)\n",(USHORT)AudBufMode);
XBYTE[0x2605] = AudBufMode;
//PRINT_L2(" L2_SetAudDMA: Exit L2_SetAudDMA\n");
return L2K_SUCCESS;
}
//-----------------------------------------------------------------------------
//L2_ReadDRAMDMAAdr
//-----------------------------------------------------------------------------
/*
routine description:
Read DRAM DMA address
arguments:
DRAMAddr: DRAM DMA starting address
return value:
none
*/
void L2_ReadDRAMDMAAdr(ULONG* DRAMAddr) USING_0
{
//PRINT_L2(" L2_ReadDRAMDMAAdr: Enter L2_ReadDRAMDMAAdr(DRAMAddr=%lx)\n",DRAMAddr);
*DRAMAddr = (ULONG)XBYTE[0x2750];
*DRAMAddr |= (ULONG)XBYTE[0x2751]<<8;
*DRAMAddr |= (ULONG)XBYTE[0x2752]<<16;
//PRINT_L2(" L2_ReadDRAMDMAAdr: Exit L2_ReadDRAMDMAAdr\n");
}
//-----------------------------------------------------------------------------
//L2_SearchPattern
//-----------------------------------------------------------------------------
/*
routine description:
Search FAT12/FAT16 pattern in DMA
arguments:
DRAMAddr: DRAM starting address
Dst: the SRAM address of DMA will write data to ; total 1008 bytes once
0: 0x1000 - 0x13EF
1: 0x1400 - 0x17EF
2: 0x1800 - 0x1BEF
3: 0x1C00 - 0x1FEF
Mode:
0: for Fat16
1: for Fat12
Pattern: the searching pattern
FirstMatchAddr: the first hit address in the DMA cycle
MatchCount: the number of hit in current DMA cycle
return value:
0x00 - success
others - error
*/
UCHAR L2_SearchPattern(ULONG DRAMAddr, UCHAR Dst, UCHAR Mode, USHORT Pattern, USHORT* FirstMatchAddr, USHORT* MatchCount) USING_0
{
UCHAR tmp0,tmp1,tmp2;
//PRINT_L2(" L2_SearchPattern: Enter L2_SearchPattern(DRAMAddr=%lx,Dst=%x,Mode=%x,Pattern=%x,)\n",DRAMAddr,(USHORT)Dst,(USHORT)Mode,Pattern);
if(Dst == 0) tmp0 = L2_SetSRAMDMA(0x0000);
else if(Dst == 1) tmp0 = L2_SetSRAMDMA(0x0400);
else if(Dst == 2) tmp0 = L2_SetSRAMDMA(0x0800);
else if(Dst == 3) tmp0 = L2_SetSRAMDMA(0x0C00);
if(tmp0==0x01) return 0x02;
tmp0 = L2_SetDRAMDMA(DRAMAddr);
if(tmp0==0x01) return 0x03;
if(Mode==0x00) XBYTE[0x2310] = 0x11;
else if(Mode==0x01) XBYTE[0x2310] = 0x12;
tmp2 = XBYTE[0x2310];
XBYTE[0x2311] = (UCHAR)Pattern&0xff;
XBYTE[0x2312] = (UCHAR)(Pattern>>8)&0xff;
*FirstMatchAddr = 1;
*MatchCount = 0;
for (tmp1=0 ; tmp1<8 ; tmp1++)
{
XBYTE[0x2313] = 0x00;
XBYTE[0x2310] = 0x00;
XBYTE[0x2310] = tmp2;
tmp0 = L2_SetDRAMDMA(DRAMAddr+63*tmp1);
tmp0 = L2_DoDMA(0,1,126,0,0);
//tmp0 = L2_DoDMA(2,1,126,0,0);
tmp0 = XBYTE[0x2313];
*MatchCount = tmp0+*MatchCount;
if(*FirstMatchAddr == 1 && tmp0 !=0) *FirstMatchAddr = XBYTE[0x23A1]+126*tmp1+1;
//PRINT_L2(" L2_SearchPattern: (%x,%x) \n",(USHORT)tmp0,*FirstMatchAddr);
}
//tmp0 = L2_DoDMA(2,1,4,0,0);
//PRINT_L2(" L2_SearchPattern: Exit L2_SearchPattern\n");
return L2K_SUCCESS;
}
#ifdef TestModeEn
//-----------------------------------------------------------------------------
//L2_TestDMAC
//-----------------------------------------------------------------------------
/*
routine description:
DMAC module test.
arguments:
TestLevel: the level of test
return value:
0x00 - success
others - error
*/
UCHAR L2_TestDMAC(UCHAR TestLevel) USING_0
{
UCHAR error;
UCHAR value;
error = 0;
if(TestLevel == 0 || TestLevel==3)
{
//0x2301
value = XBYTE[0x2301];
XBYTE[0x2301] = 0xFF;
if(XBYTE[0x2301]!=0x77) error = 1; //test 0 to 1 toggle
XBYTE[0x2301] = 0x00;
if(XBYTE[0x2301]!=0x00) error = 1; //test 1 to 0 toggle
XBYTE[0x2301] = value;
//0x2302
value = XBYTE[0x2302];
XBYTE[0x2302] = 0xFF;
if(XBYTE[0x2302]!=0xFF) error = 1; //test 0 to 1 toggle
XBYTE[0x2302] = 0x00;
if(XBYTE[0x2302]!=0x00) error = 1; //test 1 to 0 toggle
XBYTE[0x2302] = value;
//0x2303
value = XBYTE[0x2303];
XBYTE[0x2303] = 0xFF;
if(XBYTE[0x2303]!=0x03) error = 1; //test 0 to 1 toggle
XBYTE[0x2303] = 0x00;
if(XBYTE[0x2303]!=0x00) error = 1; //test 1 to 0 toggle
XBYTE[0x2303] = value;
//0x2304
value = XBYTE[0x2304];
XBYTE[0x2304] = 0xFF;
if(XBYTE[0x2304]!=0x0F) error = 1; //test 0 to 1 toggle
XBYTE[0x2304] = 0x00;
if(XBYTE[0x2304]!=0x00) error = 1; //test 1 to 0 toggle
XBYTE[0x2304] = value;
//0x2310
value = XBYTE[0x2310];
XBYTE[0x2310] = 0xFF;
if(XBYTE[0x2310]!=0x13) error = 1; //test 0 to 1 toggle
XBYTE[0x2310] = 0x00;
if(XBYTE[0x2310]!=0x00) error = 1; //test 1 to 0 toggle
XBYTE[0x2310] = value;
//0x2311
value = XBYTE[0x2311];
XBYTE[0x2311] = 0xFF;
if(XBYTE[0x2311]!=0xFF) error = 1; //test 0 to 1 toggle
XBYTE[0x2311] = 0x00;
if(XBYTE[0x2311]!=0x00) error = 1; //test 1 to 0 toggle
XBYTE[0x2311] = value;
//0x2312
value = XBYTE[0x2312];
XBYTE[0x2312] = 0xFF;
if(XBYTE[0x2312]!=0xFF) error = 1; //test 0 to 1 toggle
XBYTE[0x2312] = 0x00;
if(XBYTE[0x2312]!=0x00) error = 1; //test 1 to 0 toggle
XBYTE[0x2312] = value;
//0x23d0
value = XBYTE[0x23d0];
XBYTE[0x23d0] = 0xFF;
if(XBYTE[0x23d0]!=0x01) error = 1; //test 0 to 1 toggle
XBYTE[0x23d0] = 0x00;
if(XBYTE[0x23d0]!=0x00) error = 1; //test 1 to 0 toggle
XBYTE[0x23d0] = value;
}
return error;
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -