mirror of
https://github.com/rvtr/twl_wrapsdk.git
synced 2025-10-31 06:11:10 -04:00
slim down
git-svn-id: file:///Users/lillianskinner/Downloads/platinum/twl/twl_wrapsdk/trunk@170 4ee2a332-4b2b-5046-8439-1ba90f034370
This commit is contained in:
parent
f94e6d3f1b
commit
a048755d9e
@ -37,6 +37,7 @@ SUBDIRS = \
|
||||
devices \
|
||||
dsp \
|
||||
el \
|
||||
sample_dll \
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
export NITRO_BLXCHECKED = yes
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: CTR - rtfs interface for SD Memory Card
|
||||
Project: TWL - rtfs interface for SD Memory Card
|
||||
File: drnand.h
|
||||
|
||||
Copyright 2006,2007 Nintendo. All rights reserved.
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: CTR - rtfs interface for SD Memory Card
|
||||
Project: TWL - rtfs interface for SD Memory Card
|
||||
File: drsdmc.h
|
||||
|
||||
Copyright 2006,2007 Nintendo. All rights reserved.
|
||||
|
||||
@ -1,9 +1,15 @@
|
||||
/*
|
||||
Project: CTR SD Card driver
|
||||
File: sd_card.c
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: TWL - SD low-level driver
|
||||
File: sdif.c
|
||||
|
||||
2006, Research and Development Department, Nintendo.
|
||||
*/
|
||||
Copyright 2006,2007 Nintendo. All rights reserved.
|
||||
|
||||
These coded instructions, statements, and computer programs contain
|
||||
proprietary information of Nintendo of America Inc. and/or Nintendo
|
||||
Company Ltd., and are protected by Federal copyright law. They may
|
||||
not be disclosed to third parties or copied or duplicated in any form,
|
||||
in whole or in part, without the prior written consent of Nintendo.
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#include <twl.h>
|
||||
#include "sdmc_config.h"
|
||||
@ -1010,15 +1016,9 @@ void SD_SetErr(u16 Error)
|
||||
{
|
||||
OSIntrMode irq_core_flag;
|
||||
|
||||
#if (TARGET_OS_CTR == 1)
|
||||
irq_core_flag = osDisableInterrupts(); /* 割込み禁止 */
|
||||
SDCARD_ErrStatus |= Error; /* エラーステータスを設定 */
|
||||
osRestoreInterrupts( irq_core_flag); /* 割り込み設定を元に戻す */
|
||||
#else
|
||||
irq_core_flag = OS_DisableInterrupts();
|
||||
SDCARD_ErrStatus |= Error; /* エラーステータスを設定 */
|
||||
OS_RestoreInterrupts( irq_core_flag);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
@ -1035,15 +1035,9 @@ void SD_ClrErr(u16 Error)
|
||||
{
|
||||
OSIntrMode irq_core_flag;
|
||||
|
||||
#if (TARGET_OS_CTR == 1)
|
||||
irq_core_flag = osDisableInterrupts(); /* 割込み禁止 */
|
||||
SDCARD_ErrStatus &= ~(Error); /* エラーステータスをクリア */
|
||||
osRestoreInterrupts( irq_core_flag); /* 割り込み設定を元に戻す */
|
||||
#else
|
||||
irq_core_flag = OS_DisableInterrupts(); /* 割込み禁止 */
|
||||
SDCARD_ErrStatus &= ~(Error); /* エラーステータスをクリア */
|
||||
OS_RestoreInterrupts( irq_core_flag); /* 割り込み設定を元に戻す */
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: CTR - SD driver
|
||||
File: sd_ip_reg.h
|
||||
File: sdif_reg.h
|
||||
|
||||
Copyright 2006 Nintendo. All rights reserved.
|
||||
Copyright 2006,2007 Nintendo. All rights reserved.
|
||||
|
||||
These coded instructions, statements, and computer programs contain
|
||||
proprietary information of Nintendo of America Inc. and/or Nintendo
|
||||
|
||||
@ -1,28 +1,22 @@
|
||||
/*
|
||||
Project: CTR SD port driver
|
||||
File: sdmc.c
|
||||
/*---------------------------------------------------------------------------*
|
||||
Project: TWL - SD port driver
|
||||
File: sdmc.c
|
||||
|
||||
2006-2007, Research and Development Department, Nintendo.
|
||||
*/
|
||||
Copyright 2006,2007 Nintendo. All rights reserved.
|
||||
|
||||
These coded instructions, statements, and computer programs contain
|
||||
proprietary information of Nintendo of America Inc. and/or Nintendo
|
||||
Company Ltd., and are protected by Federal copyright law. They may
|
||||
not be disclosed to third parties or copied or duplicated in any form,
|
||||
in whole or in part, without the prior written consent of Nintendo.
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#include <twl.h>
|
||||
//#include <twl/hw/ARM7/ioreg_MI.h>
|
||||
#include "sdmc_config.h"
|
||||
#include "sdif_reg.h" /* IP 対応レジスタ定義 */
|
||||
#include "sdif_reg.h" /* IP 対応レジスタ定義 */
|
||||
#include <twl/sdmc.h>
|
||||
#include "sdif_ip.h" /* IP 対応フラグ定義 */
|
||||
|
||||
/*#if (SD_DEBUG_PRINT_ON == 1)
|
||||
#if (CTR_DEF_ENVIRONMENT_DSEMU == 1)
|
||||
#define PRINTDEBUG osTPrintf
|
||||
#else
|
||||
#include <ctr/vlink.h>
|
||||
#define PRINTDEBUG vlink_dos_printf
|
||||
#endif
|
||||
#else
|
||||
#define PRINTDEBUG( ...) ((void)0)
|
||||
#endif*/
|
||||
|
||||
// #define PRINTDEBUG OS_TPrintf
|
||||
#define PRINTDEBUG( ...) ((void)0)
|
||||
|
||||
@ -202,8 +196,6 @@ SDPortContext SDPort1Context;
|
||||
|
||||
|
||||
|
||||
u16 TransCount; /* R/W転送カウント変数 */
|
||||
|
||||
u32 ulSDCARD_Size; /* カード全セクタ数 */
|
||||
|
||||
volatile s16 SDCARD_ATC0_Flag; /* 全ATC完了フラグ */
|
||||
@ -224,6 +216,34 @@ void (*func_SDCARD_Out)(void); /*
|
||||
/* void (*func_SDCARD_CallBack)(SdmcResultInfo *info); 処理結果通知用コールバック保存用 */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: MyCpuRecv*
|
||||
|
||||
Description: CPUで同じアドレスからデータを受け取ります
|
||||
|
||||
Arguments: src : 転送元アドレス、dest : 転送先アドレス、size : 転送サイズ(Bytes)
|
||||
|
||||
Returns: None
|
||||
*---------------------------------------------------------------------------*/
|
||||
static void MyCpuRecv32( u32* src, u32* dest, u16 size)
|
||||
{
|
||||
u32 i;
|
||||
for( i=0; i<(size/sizeof(u32)); i++) {
|
||||
*(u32*)dest++ = *(u32*)src;
|
||||
}
|
||||
}
|
||||
static void MyCpuRecv16( u16* src, u16* dest, u16 size)
|
||||
{
|
||||
u32 i;
|
||||
for( i=0; i<(size/sizeof(u16)); i++) {
|
||||
*(u16*)dest++ = *(u16*)src;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: SDCARD_Backup_port0
|
||||
|
||||
@ -303,23 +323,10 @@ static void SDCARD_Backup_port1(void)
|
||||
*---------------------------------------------------------------------------*/
|
||||
static void i_sdmcEnable( void)
|
||||
{
|
||||
#if (TARGET_OS_CTR == 1)
|
||||
/*SD interrupt setting*/
|
||||
// osInitIntrFlag();
|
||||
// osClearInterruptPendingID( OS_INTR_ID_SD);
|
||||
// *(vu32*)CTR_INT_IF = CTR_IE_SD_MASK;
|
||||
osSetInterruptHandler( OS_INTR_ID_SD, SDCARD_irq_Handler);
|
||||
osEnableInterruptID( OS_INTR_ID_SD);
|
||||
// *(vu32*)CTR_INT_SE = CTR_IE_SD_MASK; //割り込み(IRQ)発生許可
|
||||
// *(vu32*)CTR_INT_IE = CTR_IE_SD_MASK;
|
||||
// osEnableInterrupts();
|
||||
// *(vu16*)0x04000208 = 1;
|
||||
#else
|
||||
/*SD割り込みのIF解除*/
|
||||
*(vu16*)CTR_INT_IF = CTR_IE_SD_MASK;
|
||||
OS_SetIrqFunction( OS_IE_SD, SDCARD_irq_Handler);
|
||||
OS_EnableIrqMask( OS_IE_SD);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
@ -349,15 +356,10 @@ static void i_sdmcDisable( void)
|
||||
*---------------------------------------------------------------------------*/
|
||||
void SDCARD_irq_Handler( void)
|
||||
{
|
||||
#if (TARGET_OS_CTR == 1)
|
||||
iwup_tsk( sdmc_intr_tsk_id);
|
||||
#else
|
||||
PRINTDEBUG( "SD irq!\n");
|
||||
// OS_DumpThreadList();
|
||||
OS_SetIrqCheckFlag( OS_IE_SD);
|
||||
// sdmc_intr_wakeup_count++;
|
||||
// OS_WakeupThreadDirect( &sdmc_intr_tsk);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
@ -389,91 +391,9 @@ static void SDCARD_Dmy_Handler( void)
|
||||
*---------------------------------------------------------------------------*/
|
||||
SDMC_ERR_CODE sdmcInit( SDMC_DMA_NO dma_no, void (*func1)(),void (*func2)())
|
||||
{
|
||||
#if (TARGET_OS_CTR == 1)
|
||||
T_CALM calm;
|
||||
T_CTSK ctsk;
|
||||
T_CDTQ cdtq;
|
||||
#endif
|
||||
// SDCARDMsg SdMsg;
|
||||
// u32 init_msg;
|
||||
SDMC_ERR_CODE api_result;
|
||||
|
||||
if( sdmc_tsk_created == FALSE) {
|
||||
/*---------- OS準備 ----------*/
|
||||
/* アラームハンドラ登録 */
|
||||
#if (TARGET_OS_CTR == 1)
|
||||
calm.almatr = TA_HLNG; // set attribution : for high level language
|
||||
calm.exinf = 0; // set argument for alarm handler
|
||||
calm.almhdr = SDCARD_Timer_irq; // set alarm handler
|
||||
sdmc_alm_id = acre_alm(&calm);
|
||||
if (sdmc_alm_id < 0)
|
||||
{
|
||||
PRINTDEBUG("create_alarm_simple: Cannot create new alarm handler (%d).\n", sdmc_alm_id);
|
||||
}
|
||||
|
||||
/* メッセージ初期化 */
|
||||
// setup dataqueue structure
|
||||
cdtq.dtqatr = TA_TFIFO; // set attribution : normal FIFO
|
||||
cdtq.dtqcnt = 1; // there are 2 datas in queue
|
||||
cdtq.dtq = NULL; // set data queue address : NULL means automatically allocated by kernel
|
||||
sdmc_dtq_id = acre_dtq(&cdtq);
|
||||
if (sdmc_dtq_id < 0)
|
||||
{
|
||||
PRINTDEBUG("create_dataqueue_simple: Cannot create new data queue.\n");
|
||||
}
|
||||
/**/
|
||||
cdtq.dtqatr = TA_TFIFO; // set attribution : normal FIFO
|
||||
cdtq.dtqcnt = 1; // there are 2 datas in queue
|
||||
cdtq.dtq = NULL; // set data queue address : NULL means automatically allocated by kernel
|
||||
sdmc_result_dtq_id = acre_dtq(&cdtq);
|
||||
if (sdmc_result_dtq_id < 0)
|
||||
{
|
||||
PRINTDEBUG("create_dataqueue_simple: Cannot create new data queue.\n");
|
||||
}
|
||||
|
||||
// OS_InitThread(); //自分の優先度が16になる
|
||||
// chg_pri( (ID)0, (PRI)12);
|
||||
|
||||
/* SDタスクの立ち上げ */
|
||||
ctsk.tskatr = TA_HLNG | TA_ACT; // set attribution : for high level language and running now
|
||||
ctsk.task = SDCARD_Thread; // set task routine
|
||||
ctsk.exinf = (void*)0; // set argument for task routine
|
||||
ctsk.itskpri = SD_THREAD_PRIO; // set priority
|
||||
ctsk.stksz = SD_STACK_SIZE; // set stack size
|
||||
ctsk.stk = NULL; // set stack address : NULL means automatically allocated by kernel
|
||||
sdmc_tsk_id = acre_tsk(&ctsk);
|
||||
if (sdmc_tsk_id < 0)
|
||||
{
|
||||
PRINTDEBUG("create_task_sd: Cannot create new task.\n");
|
||||
}else{
|
||||
if( (sdmc_tsk_id == E_NOID)||(sdmc_tsk_id == E_NOMEM)||(sdmc_tsk_id == E_RSATR)||
|
||||
(sdmc_tsk_id == E_PAR)||(sdmc_tsk_id == E_OBJ)) {
|
||||
PRINTDEBUG("create_task_sd: Cannot create new task.\n");
|
||||
}
|
||||
PRINTDEBUG("create_task_sd: 0x%x\n", sdmc_tsk_id);
|
||||
}
|
||||
/*----------------------------*/
|
||||
|
||||
/* SD割り込み処理タスクの立ち上げ */
|
||||
ctsk.tskatr = TA_HLNG | TA_ACT; // set attribution : for high level language and running now
|
||||
ctsk.task = SDCARD_Intr_Thread; // set task routine
|
||||
ctsk.exinf = (void*)0; // set argument for task routine
|
||||
ctsk.itskpri = SD_INTR_THREAD_PRIO; // set priority
|
||||
ctsk.stksz = SD_STACK_SIZE; // set stack size
|
||||
ctsk.stk = NULL; // set stack address : NULL means automatically allocated by kernel
|
||||
sdmc_intr_tsk_id = acre_tsk(&ctsk);
|
||||
if (sdmc_intr_tsk_id < 0)
|
||||
{
|
||||
PRINTDEBUG("create_intr_task_sd: Cannot create new task.\n");
|
||||
}else{
|
||||
if( (sdmc_intr_tsk_id == E_NOID)||(sdmc_intr_tsk_id == E_NOMEM)||(sdmc_intr_tsk_id == E_RSATR)||
|
||||
(sdmc_intr_tsk_id == E_PAR)||(sdmc_intr_tsk_id == E_OBJ)) {
|
||||
PRINTDEBUG("create_intr_task_sd: Cannot create new task.\n");
|
||||
}
|
||||
PRINTDEBUG("create_intr_task_sd: 0x%x\n", sdmc_intr_tsk_id);
|
||||
}
|
||||
|
||||
#else //(TARGET_OS_NITRO = 1)
|
||||
/*---------- OS準備 ----------*/
|
||||
if( !OS_IsAlarmAvailable()) { /* アラームチェック(OS_InitAlarm済みか?) */
|
||||
SDCARD_ErrStatus |= SDMC_ERR_END;
|
||||
@ -501,7 +421,7 @@ SDMC_ERR_CODE sdmcInit( SDMC_DMA_NO dma_no, void (*func1)(),void (*func2)())
|
||||
OS_WakeupThreadDirect( &sdmc_intr_tsk);
|
||||
PRINTDEBUG( "sdmc_intr_tsk:0x%x\n", &sdmc_intr_tsk);
|
||||
/*----------------------------*/
|
||||
#endif
|
||||
|
||||
/**/
|
||||
sdmc_tsk_created = TRUE;
|
||||
}
|
||||
@ -519,26 +439,13 @@ SDMC_ERR_CODE sdmcInit( SDMC_DMA_NO dma_no, void (*func1)(),void (*func2)())
|
||||
SDMC_ERR_CODE sdmcGoIdle( void (*func1)(),void (*func2)())
|
||||
{
|
||||
SDCARDMsg SdMsg;
|
||||
#if (TARGET_OS_CTR == 1)
|
||||
u32 init_msg;
|
||||
#else
|
||||
OSMessage init_msg;
|
||||
#endif
|
||||
SDMC_ERR_CODE api_result;
|
||||
|
||||
func_SDCARD_In = func1; /* カード挿入イベント用関数のアドレスを設定 */
|
||||
func_SDCARD_Out = func2; /* カード排出イベント用関数のアドレスを設定 */
|
||||
|
||||
/*----- SDスレッドと通信 -----*/
|
||||
#if (TARGET_OS_CTR == 1)
|
||||
SdMsg.operation = SD_OPERATION_INIT;
|
||||
|
||||
snd_dtq( sdmc_dtq_id, (VP_INT)&SdMsg);
|
||||
|
||||
/* 返り値待ち */
|
||||
rcv_dtq( sdmc_result_dtq_id, (VP_INT*)&init_msg);
|
||||
api_result = (SDMC_ERR_CODE)init_msg;
|
||||
#else
|
||||
SdMsg.operation = SD_OPERATION_INIT;
|
||||
// SdMsg.func = func1;
|
||||
// SdMsg.func2 = func2;
|
||||
@ -549,7 +456,6 @@ SDMC_ERR_CODE sdmcGoIdle( void (*func1)(),void (*func2)())
|
||||
/* 返り値待ち */
|
||||
OS_ReceiveMessage( &sdmc_result_dtq, &init_msg, OS_MESSAGE_BLOCK);
|
||||
api_result = (SDMC_ERR_CODE)init_msg;
|
||||
#endif
|
||||
/*----------------------------------*/
|
||||
|
||||
return api_result;
|
||||
@ -613,11 +519,8 @@ SDMC_ERR_CODE sdmcReset( void)
|
||||
pSDCARD_info = NULL;
|
||||
SDCARD_OutFlag = FALSE; /* カード排出発生判定フラグクリア */
|
||||
|
||||
#if (TARGET_OS_CTR == 1)
|
||||
irq_core_flag = osDisableInterrupts(); /* 割込み禁止 */
|
||||
#else
|
||||
irq_core_flag = OS_DisableInterrupts(); /* 割込み禁止 */
|
||||
#endif
|
||||
|
||||
*SDIF_CNT_L = (SDIF_CNT_FCLR | SDIF_CNT_USEFIFO); //ラッパーレジスタ
|
||||
*SDIF_CNT_L = 0x0000; //ラッパーレジスタ
|
||||
*SDIF_FDS_L = 0;
|
||||
@ -631,11 +534,7 @@ SDMC_ERR_CODE sdmcReset( void)
|
||||
SDCARD_Backup_port0(); /* port0 backup */
|
||||
SDCARD_Backup_port1(); /* port1 backup */
|
||||
|
||||
#if (TARGET_OS_CTR == 1)
|
||||
osRestoreInterrupts( irq_core_flag); /* 割り込み設定を元に戻す */
|
||||
#else
|
||||
OS_RestoreInterrupts( irq_core_flag); /* 割り込み設定を元に戻す */
|
||||
#endif
|
||||
|
||||
return SDCARD_ErrStatus;
|
||||
}
|
||||
@ -664,7 +563,6 @@ static SDMC_ERR_CODE SDCARD_Layer_Init(void)
|
||||
SDCARD_SDFlag = FALSE; /* SDカード判定フラグクリア */
|
||||
SDCARD_OutFlag = FALSE; /* カード排出発生判定フラグクリア */
|
||||
ulSDCARD_Size = 0; /* カード全セクタ数クリア */
|
||||
TransCount = 0; /* 転送カウント変数クリア */
|
||||
// init_io_exist = 0;
|
||||
// init_mem_exist = 0;
|
||||
|
||||
@ -1089,11 +987,7 @@ static u32 SDCARD_GetR1Status(void)
|
||||
SDMC_ERR_CODE sdmcReadFifo(void* buf,u32 bufsize,u32 offset,void(*func)(void),SdmcResultInfo *info)
|
||||
{
|
||||
SDCARDMsg SdMsg;
|
||||
#if (TARGET_OS_CTR == 1)
|
||||
u32 recv_dat;
|
||||
#else
|
||||
OSMessage recv_dat;
|
||||
#endif
|
||||
SDMC_ERR_CODE api_result; //SDCARD関数の返り値
|
||||
|
||||
SdMsg.buf = buf;
|
||||
@ -1103,23 +997,12 @@ SDMC_ERR_CODE sdmcReadFifo(void* buf,u32 bufsize,u32 offset,void(*func)(void),Sd
|
||||
SdMsg.info = info;
|
||||
SdMsg.operation = SD_OPERATION_READ_WITH_FIFO;
|
||||
|
||||
#if (TARGET_OS_CTR == 1)
|
||||
PRINTDEBUG( "readfifo : snd_dtq begin\n");
|
||||
snd_dtq( sdmc_dtq_id, (VP_INT)&SdMsg);
|
||||
|
||||
/* 返り値待ち */
|
||||
PRINTDEBUG( "readfifo : rcv_dtq begin\n");
|
||||
rcv_dtq( sdmc_result_dtq_id, (VP_INT*)&recv_dat);
|
||||
|
||||
api_result = (SDMC_ERR_CODE)recv_dat;
|
||||
#else
|
||||
recv_dat = (OSMessage)&SdMsg; //SdMsgのアドレスを伝える
|
||||
OS_SendMessage( &sdmc_dtq, recv_dat, OS_MESSAGE_BLOCK);
|
||||
|
||||
/* 返り値待ち */
|
||||
OS_ReceiveMessage( &sdmc_result_dtq, &recv_dat, OS_MESSAGE_BLOCK);
|
||||
api_result = (SDMC_ERR_CODE)recv_dat;
|
||||
#endif
|
||||
|
||||
return api_result;
|
||||
}
|
||||
@ -1175,11 +1058,7 @@ static SDMC_ERR_CODE SDCARDi_ReadFifo(void* buf,u32 bufsize,u32 offset,void(*fun
|
||||
SDMC_ERR_CODE sdmcRead(void* buf,u32 bufsize,u32 offset,void(*func)(void),SdmcResultInfo *info)
|
||||
{
|
||||
SDCARDMsg SdMsg;
|
||||
#if (TARGET_OS_CTR == 1)
|
||||
u32 recv_dat;
|
||||
#else
|
||||
OSMessage recv_dat;
|
||||
#endif
|
||||
SDMC_ERR_CODE api_result;
|
||||
|
||||
SdMsg.buf = buf;
|
||||
@ -1189,21 +1068,12 @@ SDMC_ERR_CODE sdmcRead(void* buf,u32 bufsize,u32 offset,void(*func)(void),SdmcRe
|
||||
SdMsg.info = info;
|
||||
SdMsg.operation = SD_OPERATION_READ;
|
||||
|
||||
#if (TARGET_OS_CTR == 1)
|
||||
snd_dtq( sdmc_dtq_id, (VP_INT)&SdMsg);
|
||||
|
||||
/* 返り値待ち */
|
||||
rcv_dtq( sdmc_result_dtq_id, (VP_INT*)&recv_dat);
|
||||
|
||||
api_result = (SDMC_ERR_CODE)recv_dat;
|
||||
#else
|
||||
recv_dat = (OSMessage)&SdMsg;
|
||||
OS_SendMessage( &sdmc_dtq, recv_dat, OS_MESSAGE_BLOCK);
|
||||
|
||||
/* 返り値待ち */
|
||||
OS_ReceiveMessage( &sdmc_result_dtq, &recv_dat, OS_MESSAGE_BLOCK);
|
||||
api_result = (SDMC_ERR_CODE)recv_dat;
|
||||
#endif
|
||||
|
||||
return api_result;
|
||||
}
|
||||
@ -1330,82 +1200,44 @@ static void SDCARD_FPGA_irq(void)
|
||||
if( ulSDCARD_RestSectorCount) { /* 残りセクタ数が有る時 */
|
||||
ulSDCARD_RestSectorCount--; /* 残りセクタ数をデクリメント */
|
||||
|
||||
if( TransCount==0) { /* 転送カウント数が0か? (R/W割込み要求時の 1回のみ設定)*/
|
||||
if( SDCARD_UseFifoFlag) {
|
||||
TransCount = (u16)(SDCARD_SectorSize/4); /* 転送カウント設定 (32bit転送なのでセクタサイズの1/4) */
|
||||
}else{
|
||||
TransCount = (u16)(SDCARD_SectorSize/2); /* 転送カウント設定 (16bit転送なのでセクタサイズの半分) */
|
||||
}
|
||||
}
|
||||
|
||||
/*--- SDカードからのリード時 ---*/
|
||||
if(bRead){
|
||||
while(TransCount != 0){ /* 転送カウント分のループ */
|
||||
if( SDCARD_UseFifoFlag) { /*--- FIFOを使うとき ---*/
|
||||
*((u32*)pSDCARD_BufferAddr) = *(SDIF_FI); /* 32bit読み出し */
|
||||
}else{ /*--- FIFOを使わないとき ---*/
|
||||
*(pSDCARD_BufferAddr) = *(SD_BUF0); /* 16bit読み出し */
|
||||
}
|
||||
TransCount = (u16)(TransCount-1); /* 転送カウントのデクリメント */
|
||||
if(TransCount == 0){ /* 転送カウント分終了? */
|
||||
if( ulSDCARD_RestSectorCount <= 0) { /* 要求セクタ数リード完了したか? */
|
||||
if(SD_CheckFPGAReg(SD_STOP,SD_STOP_SEC_ENABLE)){ /* SD_SECCNTレジスタがEnableか? */
|
||||
// SD_DisableSeccnt(); /* SD_SECCNTレジスタ無効設定 */
|
||||
}else{ /* SD_SECCNTレジスタがDisableのとき */
|
||||
SD_StopTransmission(); /* カード転送終了をFPGAに通知(CMD12発行) */
|
||||
}
|
||||
}
|
||||
SDCARD_ATC0_irq(); /* 転送完了後の処理 */
|
||||
}
|
||||
if( SDCARD_UseFifoFlag) {
|
||||
pSDCARD_BufferAddr+=2; /* 読込みデータのバッファアドレスをインクリメント */
|
||||
}else{
|
||||
pSDCARD_BufferAddr++; /* 読込みデータのバッファアドレスをインクリメント */
|
||||
if( SDCARD_UseFifoFlag) { /*--- FIFOを使うとき ---*/
|
||||
MyCpuRecv32( (u32*)SDIF_FI, (u32*)pSDCARD_BufferAddr, SDCARD_SectorSize);
|
||||
}else{ /*--- FIFOを使わないとき ---*/
|
||||
MyCpuRecv16( (u16*)SD_BUF0, pSDCARD_BufferAddr, SDCARD_SectorSize);
|
||||
}
|
||||
if( ulSDCARD_RestSectorCount <= 0) { /* 要求セクタ数リード完了したか? */
|
||||
if(SD_CheckFPGAReg(SD_STOP,SD_STOP_SEC_ENABLE)){ /* SD_SECCNTレジスタがEnableか? */
|
||||
// SD_DisableSeccnt(); /* SD_SECCNTレジスタ無効設定 */
|
||||
}else{ /* SD_SECCNTレジスタがDisableのとき */
|
||||
SD_StopTransmission(); /* カード転送終了をFPGAに通知(CMD12発行) */
|
||||
}
|
||||
}
|
||||
}else{ /*--- SDカードへのライト時 ---*/
|
||||
while(TransCount != 0){ /* 転送カウント分のループ */
|
||||
if( SDCARD_UseFifoFlag) { /*--- FIFOを使うとき ---*/
|
||||
#if (CTR_DEF_ENVIRONMENT_DSEMU == 1)
|
||||
*(vu16*)0x08030200 = 1; /* ブレッドボード固有の先読み無効 */
|
||||
#endif
|
||||
*(SDIF_FI) = *((u32*)pSDCARD_BufferAddr); /* 32bit書き込み */
|
||||
#if (CTR_DEF_ENVIRONMENT_DSEMU == 1)
|
||||
*(vu16*)0x08030200 = 0; /* ブレッドボード固有の先読み有効 */
|
||||
#endif
|
||||
}else{ /*--- FIFOを使わないとき ---*/
|
||||
#if (CTR_DEF_ENVIRONMENT_DSEMU == 1)
|
||||
*(vu16*)0x08030200 = 1; /* ブレッドボード固有の先読み無効 */
|
||||
#endif
|
||||
*(SD_BUF0) = *(pSDCARD_BufferAddr); /* 16bit書き込み */
|
||||
#if (CTR_DEF_ENVIRONMENT_DSEMU == 1)
|
||||
*(vu16*)0x08030200 = 0; /* ブレッドボード固有の先読み有効 */
|
||||
#endif
|
||||
if( SDCARD_UseFifoFlag) { /*--- FIFOを使うとき ---*/
|
||||
MI_CpuSend32( pSDCARD_BufferAddr, SDIF_FI, SDCARD_SectorSize);
|
||||
}else{ /*--- FIFOを使わないとき ---*/
|
||||
MI_CpuSend16( pSDCARD_BufferAddr, SD_BUF0, SDCARD_SectorSize);
|
||||
}
|
||||
if( ulSDCARD_RestSectorCount <= 0){ /* 要求セクタ数ライト完了? */
|
||||
if( SDCARD_UseFifoFlag) { /* FIFOを使用するときは */
|
||||
while( (*SDIF_CNT & SDIF_CNT_NEMP)) {}; /* FIFOにデータが残っているうちは終了しない */
|
||||
}
|
||||
TransCount = (u16)(TransCount-1); /* 転送カウントのデクリメント */
|
||||
if(TransCount == 0){ /* 転送カウント分終了? */
|
||||
if( ulSDCARD_RestSectorCount <= 0){ /* 要求セクタ数ライト完了? */
|
||||
if( SDCARD_UseFifoFlag) { /* FIFOを使用するときは */
|
||||
while( (*SDIF_CNT & SDIF_CNT_NEMP)) {}; /* FIFOにデータが残っているうちは終了しない */
|
||||
}
|
||||
if(SD_CheckFPGAReg(SD_STOP,SD_STOP_SEC_ENABLE)){ /* SD_SECCNTレジスタがEnableか? */
|
||||
// SD_DisableSeccnt(); /* SD_SECCNTレジスタ無効設定 */
|
||||
}else{ /* SD_SECCNTレジスタがDisableのとき */
|
||||
SD_StopTransmission(); /* カード転送終了をFPGAに通知(CMD12発行) */
|
||||
}
|
||||
}
|
||||
SDCARD_ATC0_irq(); /* 転送完了後の処理 */
|
||||
}
|
||||
if( SDCARD_UseFifoFlag) {
|
||||
pSDCARD_BufferAddr+=2; /* 書込みデータのバッファアドレスをインクリメント */
|
||||
}else{
|
||||
pSDCARD_BufferAddr++; /* 書込みデータのバッファアドレスをインクリメント */
|
||||
if(SD_CheckFPGAReg(SD_STOP,SD_STOP_SEC_ENABLE)){ /* SD_SECCNTレジスタがEnableか? */
|
||||
// SD_DisableSeccnt(); /* SD_SECCNTレジスタ無効設定 */
|
||||
}else{ /* SD_SECCNTレジスタがDisableのとき */
|
||||
SD_StopTransmission(); /* カード転送終了をFPGAに通知(CMD12発行) */
|
||||
}
|
||||
}
|
||||
}
|
||||
/* リード/ライト共通処理 */
|
||||
SDCARD_ATC0_irq(); /* 転送完了後の処理 */
|
||||
pSDCARD_BufferAddr+=(512/2); /* 書込みデータのバッファアドレスをインクリメント */
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: SDCARD_ATC0_irq
|
||||
|
||||
@ -1480,9 +1312,9 @@ static void SYSFPGA_irq(void)
|
||||
/* (CTRはポート1のCD端子が未接続(常に挿入状態)なので、ポート1の挿抜チェックは行わない) */
|
||||
|
||||
/*--- 割り込み要求と割り込みマスクを保存 ---*/
|
||||
SD_GetFPGA( SD_INFO1_VALUE, SD_INFO1);
|
||||
SD_GetFPGA( SD_INFO1_VALUE, SD_INFO1);
|
||||
SD_GetFPGA( SD_INFO1_MASK_VALUE, SD_INFO1_MASK);
|
||||
SD_GetFPGA( SD_INFO2_VALUE, SD_INFO2);
|
||||
SD_GetFPGA( SD_INFO2_VALUE, SD_INFO2);
|
||||
SD_GetFPGA( SD_INFO2_MASK_VALUE, SD_INFO2_MASK);
|
||||
/*------------------------------------------*/
|
||||
|
||||
@ -1621,13 +1453,7 @@ static void SDCARD_Timer_irq(void* arg)
|
||||
PRINTDEBUG( "SD_INFO2_MASK : 0x%x\n", tmp);
|
||||
tmp = SD_ERR_STS1;
|
||||
PRINTDEBUG( "SD_ERR_STS1 : 0x%x\n", tmp);
|
||||
#if (CTR_DEF_ENVIRONMENT_DSEMU == 1)
|
||||
*(vu16*)0x08030200 = 1;
|
||||
#endif
|
||||
tmp = SD_ERR_STS2;
|
||||
#if (CTR_DEF_ENVIRONMENT_DSEMU == 1)
|
||||
*(vu16*)0x08030200 = 0;
|
||||
#endif
|
||||
PRINTDEBUG( "SD_ERR_STS2 : 0x%x\n", tmp);
|
||||
tmp = *(vu16 *)(SD_IF_BASE+0x00);
|
||||
PRINTDEBUG( "SD_CNT : 0x%x\n", tmp);
|
||||
@ -2059,11 +1885,7 @@ static u16 i_sdmcCheckWP(void)
|
||||
SDMC_ERR_CODE sdmcWriteFifo(void* buf,u32 bufsize,u32 offset,void(*func)(),SdmcResultInfo *info)
|
||||
{
|
||||
SDCARDMsg SdMsg;
|
||||
#if (TARGET_OS_CTR == 1)
|
||||
u32 recv_dat;
|
||||
#else
|
||||
OSMessage recv_dat;
|
||||
#endif
|
||||
SDMC_ERR_CODE api_result;
|
||||
|
||||
SdMsg.buf = buf;
|
||||
@ -2073,21 +1895,12 @@ SDMC_ERR_CODE sdmcWriteFifo(void* buf,u32 bufsize,u32 offset,void(*func)(),SdmcR
|
||||
SdMsg.info = info;
|
||||
SdMsg.operation = SD_OPERATION_WRITE_WITH_FIFO;
|
||||
|
||||
#if (TARGET_OS_CTR == 1)
|
||||
snd_dtq( sdmc_dtq_id, (VP_INT)&SdMsg);
|
||||
|
||||
/* 返り値待ち */
|
||||
rcv_dtq( sdmc_result_dtq_id, (VP_INT*)&recv_dat);
|
||||
|
||||
api_result = (SDMC_ERR_CODE)recv_dat;
|
||||
#else
|
||||
recv_dat = (OSMessage)&SdMsg;
|
||||
OS_SendMessage( &sdmc_dtq, recv_dat, OS_MESSAGE_BLOCK);
|
||||
|
||||
/* 返り値待ち */
|
||||
OS_ReceiveMessage( &sdmc_result_dtq, &recv_dat, OS_MESSAGE_BLOCK);
|
||||
api_result = (SDMC_ERR_CODE)recv_dat;
|
||||
#endif
|
||||
|
||||
return api_result;
|
||||
}
|
||||
@ -2143,11 +1956,7 @@ static SDMC_ERR_CODE SDCARDi_WriteFifo(void* buf,u32 bufsize,u32 offset,void(*fu
|
||||
SDMC_ERR_CODE sdmcWrite(void* buf,u32 bufsize,u32 offset,void(*func)(),SdmcResultInfo *info)
|
||||
{
|
||||
SDCARDMsg SdMsg;
|
||||
#if (TARGET_OS_CTR == 1)
|
||||
u32 recv_dat;
|
||||
#else
|
||||
OSMessage recv_dat;
|
||||
#endif
|
||||
SDMC_ERR_CODE api_result;
|
||||
|
||||
SdMsg.buf = buf;
|
||||
@ -2157,21 +1966,12 @@ SDMC_ERR_CODE sdmcWrite(void* buf,u32 bufsize,u32 offset,void(*func)(),SdmcResul
|
||||
SdMsg.info = info;
|
||||
SdMsg.operation = SD_OPERATION_WRITE;
|
||||
|
||||
#if (TARGET_OS_CTR == 1)
|
||||
snd_dtq( sdmc_dtq_id, (VP_INT)&SdMsg);
|
||||
|
||||
/* 返り値待ち */
|
||||
rcv_dtq( sdmc_result_dtq_id, (VP_INT*)&recv_dat);
|
||||
|
||||
api_result = (SDMC_ERR_CODE)recv_dat;
|
||||
#else
|
||||
recv_dat = (OSMessage)&SdMsg;
|
||||
OS_SendMessage( &sdmc_dtq, recv_dat, OS_MESSAGE_BLOCK);
|
||||
|
||||
/* 返り値待ち */
|
||||
OS_ReceiveMessage( &sdmc_result_dtq, &recv_dat, OS_MESSAGE_BLOCK);
|
||||
api_result = (SDMC_ERR_CODE)recv_dat;
|
||||
#endif
|
||||
|
||||
return api_result;
|
||||
}
|
||||
@ -2554,21 +2354,13 @@ SDMC_ERR_CODE sdmcSelect(u16 select)
|
||||
static void SDCARD_Thread( void* arg)
|
||||
{
|
||||
SDCARDMsg* SdMsg;
|
||||
#if (TARGET_OS_CTR == 1)
|
||||
u32 current_dat;
|
||||
#else
|
||||
OSMessage current_dat;
|
||||
#endif
|
||||
SDMC_ERR_CODE api_result;
|
||||
|
||||
while( TRUE) {
|
||||
/* メッセージ待ち */
|
||||
PRINTDEBUG( "rcv mes sdThread\n");
|
||||
#if (TARGET_OS_CTR == 1)
|
||||
rcv_dtq( sdmc_dtq_id, (VP_INT*)¤t_dat);
|
||||
#else
|
||||
OS_ReceiveMessage( &sdmc_dtq, ¤t_dat, OS_MESSAGE_BLOCK);
|
||||
#endif
|
||||
SdMsg = (SDCARDMsg*)current_dat;
|
||||
PRINTDEBUG( "sd task : receive command : %d\n", SdMsg->operation);
|
||||
|
||||
@ -2610,11 +2402,7 @@ static void SDCARD_Thread( void* arg)
|
||||
|
||||
/*メッセージ返送*/
|
||||
current_dat = (OSMessage)api_result;
|
||||
#if (TARGET_OS_CTR == 1)
|
||||
snd_dtq( sdmc_result_dtq_id, (VP_INT)api_result);
|
||||
#else
|
||||
OS_SendMessage( &sdmc_result_dtq, current_dat, OS_MESSAGE_BLOCK);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@ -2633,22 +2421,15 @@ static void SDCARD_Intr_Thread( void* arg)
|
||||
OSIntrMode enabled;
|
||||
|
||||
while( 1) {
|
||||
PRINTDEBUG( "next_tsk:0x%x\n", OS_SelectThread());
|
||||
PRINTDEBUG( "Slp sdIntr\n");
|
||||
|
||||
OS_WaitIrq( FALSE, OS_IE_SD);
|
||||
// OS_DisableIrqMask( OS_IE_SD);
|
||||
// if( sdmc_intr_wakeup_count == 0) {
|
||||
// OS_SleepThread( NULL);
|
||||
// }
|
||||
// sdmc_intr_wakeup_count--;
|
||||
// OS_EnableIrqMask( OS_IE_SD);
|
||||
// enabled = OS_DisableInterrupts();
|
||||
|
||||
(void)OS_ClearIrqCheckFlag( OS_IE_SD);
|
||||
/*SD割り込みのIF解除*/
|
||||
*(vu16*)CTR_INT_IF = CTR_IE_SD_MASK;
|
||||
// (void)OS_RestoreInterrupts( enabled);
|
||||
*(vu16*)CTR_INT_IF = CTR_IE_SD_MASK; /*SD割り込みのIF解除*/
|
||||
|
||||
PRINTDEBUG( "sdIntr waked\n");
|
||||
|
||||
|
||||
/*--- FIFOを使うとき ---*/
|
||||
if( SDCARD_UseFifoFlag) {
|
||||
@ -2660,40 +2441,34 @@ static void SDCARD_Intr_Thread( void* arg)
|
||||
OS_DisableIrqMask( OS_IE_SD);
|
||||
SDCARD_FPGA_irq(); /*カードからのリードライト要求割り込み*/
|
||||
OS_EnableIrqMask( OS_IE_SD);
|
||||
/* FIFO割り込みとALLEND割り込みがほぼ同時の場合に対応 */
|
||||
if( SD_CheckFPGAReg( sd_info1, SD_INFO1_ALL_END)) {
|
||||
(void)OS_ClearIrqCheckFlag( OS_IE_SD);
|
||||
/*SD割り込みのIF解除*/
|
||||
*(vu16*)CTR_INT_IF = CTR_IE_SD_MASK;
|
||||
OS_DisableIrqMask( OS_IE_SD);
|
||||
SYSFPGA_irq();
|
||||
OS_EnableIrqMask( OS_IE_SD);
|
||||
if( thread_flag) {
|
||||
PRINTDEBUG( "--Wup sdThread!--\n");
|
||||
sdmc_wakeup_count++;
|
||||
PRINTDEBUG( "wakeup\n");
|
||||
OS_WakeupThreadDirect( &sdmc_tsk);
|
||||
}
|
||||
}
|
||||
|
||||
}else{
|
||||
|
||||
/*----- FIFO-EmptyFlag未修正の場合、Writeの1回目はBWE割り込みに頼る必要がある -----*/
|
||||
if( SD_CheckFPGAReg( SD_INFO2, (SD_INFO2_MASK_BRE | SD_INFO2_MASK_BWE))) {
|
||||
PRINTDEBUG ( ">>>SD Intr(R/W Req)\n");
|
||||
PRINTDEBUG ( ">>>SD Intr(R/W Req)\n");
|
||||
//ここで自動的にラッパーのFIFO<->SD_BUF0間で通信が行われる
|
||||
// if((!(*SDIF_CNT & SDIF_CNT_NEMP))&&(*SDIF_CNT & SDIF_CNT_FEIE)) {
|
||||
OS_DisableIrqMask( OS_IE_SD);
|
||||
SDCARD_FPGA_irq();
|
||||
OS_EnableIrqMask( OS_IE_SD);
|
||||
}else{
|
||||
PRINTDEBUG( ">>>SD Intr(End or Err)\n");
|
||||
OS_DisableIrqMask( OS_IE_SD);
|
||||
SYSFPGA_irq(); /*完了またはエラー割り込み*/
|
||||
OS_EnableIrqMask( OS_IE_SD);
|
||||
/**/
|
||||
if( thread_flag) {
|
||||
PRINTDEBUG( "--Wup sdThread!--\n");
|
||||
sdmc_wakeup_count++;
|
||||
OS_WakeupThreadDirect( &sdmc_tsk);
|
||||
}
|
||||
}
|
||||
/*----------*/
|
||||
|
||||
}
|
||||
|
||||
/* FIFO割り込みとALLEND割り込みがほぼ同時の場合に対応 */
|
||||
if( SD_CheckFPGAReg( sd_info1, SD_INFO1_ALL_END)) {
|
||||
PRINTDEBUG( ">>>SD Intr(End or Err)\n");
|
||||
(void)OS_ClearIrqCheckFlag( OS_IE_SD);
|
||||
*(vu16*)CTR_INT_IF = CTR_IE_SD_MASK; /*SD割り込みのIF解除*/
|
||||
OS_DisableIrqMask( OS_IE_SD);
|
||||
SYSFPGA_irq();
|
||||
OS_EnableIrqMask( OS_IE_SD);
|
||||
if( thread_flag) {
|
||||
PRINTDEBUG( "--Wup sdThread!--\n");
|
||||
sdmc_wakeup_count++;
|
||||
PRINTDEBUG( "wakeup\n");
|
||||
OS_WakeupThreadDirect( &sdmc_tsk);
|
||||
}
|
||||
}
|
||||
/*--- FIFOを使わないとき ---*/
|
||||
|
||||
@ -55,6 +55,22 @@ void MY_SdTransferRewind( void)
|
||||
my_buf_offset = 0;
|
||||
}
|
||||
|
||||
static void dump(const char *str, const void *buf, unsigned int len)
|
||||
{
|
||||
int i;
|
||||
const unsigned char *ptr = buf;
|
||||
OS_TPrintf("\n%s (%d bytes):\n", str, len);
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
if ((i&0xf) == 0) OS_TPrintf("\n%08X: ", i);
|
||||
else OS_TPrintf(" ");
|
||||
OS_TPrintf("%02X", *ptr++);
|
||||
}
|
||||
OS_TPrintf("\n");
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: TwlSpMain
|
||||
|
||||
@ -71,7 +87,7 @@ void TwlSpMain(void)
|
||||
SDMC_ERR_CODE result;
|
||||
SdmcResultInfo SdResult;
|
||||
PCFD fd;
|
||||
CHKDISK_STATS dstat;
|
||||
CHKDISK_STATS dstat;
|
||||
|
||||
// OS<4F>‰Šú‰»
|
||||
OS_Init();
|
||||
@ -232,6 +248,15 @@ void TwlSpMain(void)
|
||||
PRINTDEBUG( "po_open success.\n");
|
||||
/*----------*/
|
||||
|
||||
dump( "BlockBuf", BlockBuf, 0x200);
|
||||
PRINTDEBUG( "po_write : 0x%x\n", po_write( fd, (u8*)BlockBuf2, 512));
|
||||
dump( "BlockBuf2(write data)", BlockBuf2, 0x200);
|
||||
|
||||
po_lseek( fd, 0, PSEEK_SET);
|
||||
|
||||
PRINTDEBUG( "po_read : 0x%x\n", po_read( fd, (u8*)BlockBuf, 512));
|
||||
dump( "BlockBuf(read data)", BlockBuf, 0x200);
|
||||
|
||||
/*----------*/
|
||||
if( po_close( fd) < 0) {
|
||||
PRINTDEBUG( "po_close failed.\n");
|
||||
@ -239,6 +264,13 @@ void TwlSpMain(void)
|
||||
}
|
||||
PRINTDEBUG( "po_close success.\n");
|
||||
/*----------*/
|
||||
|
||||
|
||||
if( pc_regression_test( (u8*)"E:", FALSE) == FALSE) {
|
||||
PRINTDEBUG( "pc_regression_test failed.\n");
|
||||
}else{
|
||||
PRINTDEBUG( "pc_regression_test success.\n");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -257,6 +289,7 @@ void TwlSpMain(void)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
Name: InitializeAllocateSystem
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user