亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? sd_drv.c

?? SDIO實現(xiàn)底層驅(qū)動文件.非常有用.經(jīng)典!
?? C
字號:
/*****************************************************************************
*  Copyright Statement:
*  --------------------
*  This software is protected by Copyright and the information contained
*  herein is confidential. The software may not be copied and the information
*  contained herein may not be used or disclosed except with the written
*  permission of MediaTek Inc. (C) 2005
*
*  BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
*  THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
*  RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
*  AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
*  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
*  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
*  NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
*  SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
*  SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
*  THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
*  NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
*  SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
*
*  BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
*  LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
*  AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
*  OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
*  MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. 
*
*  THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
*  WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
*  LAWS PRINCIPLES.  ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
*  RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
*  THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
*
*****************************************************************************/

/*****************************************************************************
 *
 * Filename:
 * ---------
 *   ms_drv.c
 *
 * Project:
 * --------
 *   Maui_Software
 *
 * Description:
 * ------------
 *   Adaption driver of file system for SD card
 *
 * Author:
 * -------
 * -------
 *
 *============================================================================
 *             HISTORY
 * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
 *------------------------------------------------------------------------------
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 * removed!
 * removed!
 * removed!
 * removed!
 * removed!
 * removed!
 * removed!
 * removed!
 * removed!
 * removed!
 * removed!
 * removed!
 * removed!
 * removed!
 * removed!
 * removed!
 * removed!
 * removed!
 * removed!
 * removed!
 * removed!
 * removed!
 * removed!
 * removed!
 * removed!
 * removed!
 * removed!
 * removed!
 * removed!
 * removed!
 * removed!
 * removed!
 * removed!
 * removed!
 * removed!
 * removed!
 * removed!
 * removed!
 * removed!
 * removed!
 * removed!
 * removed!
 * removed!
 * removed!
 * removed!
 * removed!
 * removed!
 * removed!
 * removed!
 * removed!
 * removed!
 * removed!
 * removed!
 * removed!
 * removed!
 * removed!
 * removed!
 * removed!
 * removed!
 * removed!
 * removed!
 * removed!
 * removed!
 * removed!
 * removed!
 * removed!
 * removed!
 * removed!
 * removed!
 * removed!
 * removed!
 * removed!
 *------------------------------------------------------------------------------
 * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
 *============================================================================ 
 ****************************************************************************/
#include "kal_release.h"
#include "app_buff_alloc.h"
#include "fat_fs.h"
#include "msdc_def.h"
#include "sd_def.h"
#include "ms_def.h"
#include "intrCtrl.h"

#if defined(__MSDC_SD_MMC__)

#define MAX_CLUSTERS (0x0FFF6 - 2)
#define SECTOR_SIZE 512	
#define MSDC_MEDIA_DESCRIPTOR		0xF8
#define SD_MAX_RETRY	3

static int  ReadSectors(void * DriveData, DWORD Sector, UINT Sectors, void * Buffer);
static int  WriteSectors(void * DriveData, DWORD Sector, UINT Sectors, void * Buffer);
static kal_uint32 sd_r,sd_w;
#if 0
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
#endif

static int  DiscardSectors(void * DriveData, DWORD Sector, UINT Sectors)
{
#if 0
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
#endif
   return FS_NO_ERROR;
}

/*-----------------------------------*/
static int  ReadSectors(void * DriveData, DWORD Sector, UINT Sectors, void * Buffer)
{
	
	SDC_CMD_STATUS status;
	kal_uint8 retry = 0;

	// kal_prompt_trace(MOD_AUD,"R: %d, %d",Sector Sectors);
	//dbg_print("R: %x, %x\r\n",Sector, Sectors);
	gMSDC_Handle.timeout_count = 0;
start:
	if(!gMSDC_Handle.mIsInitialized)
	{
		//dbg_print("Read but not Initialized \r\n");
		MSDC_PDNControl(KAL_TRUE);
		return FS_MSDC_READ_SECTOR_ERROR;
	}
	retry ++;
	MSDC_PDNControl(KAL_FALSE);
	if(Sectors > 1)
		status = SD_ReadMultiBlock((kal_uint32)Sector*SECTOR_SIZE,(kal_uint32*)Buffer,(kal_uint32)Sectors);
	else
		status = SD_ReadSingleBlock((kal_uint32)Sector*SECTOR_SIZE,(kal_uint32*)Buffer);
	if(status != NO_ERROR)
	{		
		sd_r++;
		//dbg_print("read retry:%d,status:%d,total %d\r\n",retry,status,sd_r);
		if(status == ERR_CMD_TIMEOUT || status == MSDC_GPT_TIMEOUT_ERR)
			gMSDC_Handle.timeout_count++;
		if(gMSDC_Handle.timeout_count == 3 && gMSDC_Handle.mIsPresent == KAL_TRUE)
		{
			kal_print("[MSDC]:re-mount(read fail)");
			gMSDC_Handle.mIsInitialized = KAL_FALSE;
			retry = 0;
			if(SD_Initialize() != NO_ERROR)
			{
				MSDC_PDNControl(KAL_TRUE);
				return FS_MSDC_READ_SECTOR_ERROR;
			}
		}
		if(retry >= SD_MAX_RETRY)
		{
			MSDC_PDNControl(KAL_TRUE);
			return FS_MSDC_READ_SECTOR_ERROR;
		}
		else
		{
			// kal_prompt_trace(MOD_AUD,"CRC etry:%d,status:%d",retry,status);
			goto start;			
		}
	}
	MSDC_PDNControl(KAL_TRUE);
   return FS_NO_ERROR;
}

/*-----------------------------------*/
static int  WriteSectors(void * DriveData, DWORD Sector, UINT Sectors, void * Buffer)
{
	SDC_CMD_STATUS status;
	kal_uint8 retry = 0;
	
	//dbg_print("W: %x, %x\r\n",Sector, Sectors);
	gMSDC_Handle.timeout_count = 0;	
start:
	if(!gMSDC_Handle.mIsInitialized)
	{
		//dbg_print("Write but not Initialized \r\n");
		MSDC_PDNControl(KAL_TRUE);
		return FS_MSDC_WRITE_SECTOR_ERROR;
	}
	retry++;
	MSDC_PDNControl(KAL_FALSE);
	if(Sectors > 1)
	{
		if(gMSDC_Handle.mMSDC_type == SD_CARD)
			SD_SetPreEraseBlk(Sectors);		
		status = SD_WriteMultiBlock((kal_uint32)Sector*SECTOR_SIZE,(kal_uint32*)Buffer,(kal_uint32)Sectors);
	}
	else
		status = SD_WriteSingleBlock((kal_uint32)Sector*SECTOR_SIZE,(kal_uint32*)Buffer);	
	if(status != NO_ERROR)
	{
		sd_w++;
		//dbg_print("write retry:%d,status:%d,total %d\r\n",retry,status,sd_w);
		if(status == ERR_CMD_TIMEOUT || status == MSDC_GPT_TIMEOUT_ERR)
			gMSDC_Handle.timeout_count++;
		if(gMSDC_Handle.timeout_count == 3 && gMSDC_Handle.mIsPresent == KAL_TRUE)
		{
			kal_print("[MSDC]:SD re-mount (write fail)");
			gMSDC_Handle.mIsInitialized = KAL_FALSE;
			retry = 0;
			if(SD_Initialize() != NO_ERROR)
			{
				MSDC_PDNControl(KAL_TRUE);
				return FS_MSDC_WRITE_SECTOR_ERROR;
			}
		}		
		if(retry >= SD_MAX_RETRY)
		{
			MSDC_PDNControl(KAL_TRUE);
			return FS_MSDC_WRITE_SECTOR_ERROR;
		}
		else
		{
			// kal_prompt_trace(MOD_AUD,"CRC write Error retry %d",retry);
			goto start;			
		}
	}
	MSDC_PDNControl(KAL_TRUE);
   return FS_NO_ERROR;
}

/*-----------------------------------*/
static int  MountDevice(void * DriveData, int DeviceNumber, int DeviceType, DWORD Flags)
{	
	kal_uint8 retry = 0;

	//dbg_print("MountDevice_SD \r\n");
	
	if(gMSDC_Handle.mIsInitialized)
		return SECTOR_SIZE;
		
start:		
	if(!gMSDC_Handle.mIsPresent)
	{		
		//dbg_print("not present \r\n");
		
		#if defined(_NAND_FLASH_BOOTING_)
		// add the following code for solving plug in or out the SD card during 
		// NFB loading process. The card detection interruptwill disapperared 		 
		// while interrupt controller is masked.
		IRQMask(IRQ_MSDC_CODE);
		if(*(volatile kal_uint16*)MSDC_PS & MSDC_PS_PIN0)
		{
			if(gMSDC_Handle.ins_level == MSDC_IOCTRL_PULL_UP)
				gMSDC_Handle.mIsPresent = KAL_FALSE;	
			else
				gMSDC_Handle.mIsPresent = KAL_TRUE;	
		}
		else
		{
			if(gMSDC_Handle.ins_level == MSDC_IOCTRL_PULL_UP)
				gMSDC_Handle.mIsPresent = KAL_TRUE;
			else
				gMSDC_Handle.mIsPresent = KAL_FALSE;	
		}
		IRQUnmask(IRQ_MSDC_CODE);
		#endif // _NAND_FLASH_BOOTING_
		
		if(!gMSDC_Handle.mIsPresent)	
		{
			MSDC_PDNControl(KAL_TRUE);			
			return FS_MSDC_MOUNT_ERROR;
		}
	}
	MSDC_PDNControl(KAL_FALSE);
	if(SD_Initialize() != NO_ERROR)
	{		
		goto err_exit;
	}	
	//if(SD_MountDevice(DeviceType) != FS_NO_ERROR)
		//return FS_MSDC_MOUNT_ERROR;

	//dbg_print("Mount success! \r\n");
	MSDC_PDNControl(KAL_TRUE);
   return SECTOR_SIZE;
   
err_exit:
	if(retry++ <= SD_MAX_RETRY)
	{
		//dbg_print("SD MountDevice failed! retry: %d \r\n",retry);
		goto start;
	}
	#if defined(__MSDC_NOT_SUPPORT_HOT_PLUG__)
	gMSDC_Handle.mIsPresent = KAL_FALSE;
	#endif	
	
	MSDC_PDNControl(KAL_TRUE);
	return FS_MSDC_MOUNT_ERROR;
	
}

/*-----------------------------------*/
static int  MediaChanged(void * DriveData)
{
   //dbg_print("MediaChanged\n\r");
	if(gMSDC_Handle.mIsPresent)
	{
		if(gMSDC_Handle.mIsInitialized)
		{
		   //dbg_print("Ready\n\r");
   		return FS_NO_ERROR;
		}
		else
		{
		   //dbg_print("Not Init\n\r");
			return FS_MSDC_PRESNET_NOT_READY;
		}
	}

   //dbg_print("No card\n\r");
	return FS_MSDC_NOT_PRESENT;
}

/*-----------------------------------*/
static int  GetDiskGeometry(void * DriveData, FS_PartitionRecord * DiskGeometry, BYTE * MediaDescriptor)
{
	
   kal_mem_set((void*)DiskGeometry, 0, sizeof * DiskGeometry);
   DiskGeometry->Sectors = gSD.mCSD.capacity/512;
   // 0xF8 is the standard value for fixed media, 0xF0 is for removable media.
   // The important point is whatever value is put in here must also be put in the first
   // byte of he FAT[0].
	*MediaDescriptor = MSDC_MEDIA_DESCRIPTOR;
	if(gSD.mWPEnabled)
		return FS_WRITE_PROTECTION;		
   return FS_NO_ERROR;
}

/*-----------------------------------*/
static int  ShutDown(void * DriveData)
{
   return FS_NO_ERROR;
}

FS_Driver FS_SdDrv = {
   MountDevice,
   ShutDown,
   ReadSectors,
   WriteSectors,
   MediaChanged,
   DiscardSectors,
   GetDiskGeometry,
   NULL,
   NULL,
   NULL,
   NULL,
   NULL,
   NULL,
   MSDC_GetCardStatus   
};
#endif // (__MSDC_SD_MMC__)


?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
在线电影一区二区三区| 国产精品水嫩水嫩| 成人av电影在线观看| 亚洲国产一区视频| 亚洲欧洲韩国日本视频| 欧美精品一区二区三区高清aⅴ| 一本一本久久a久久精品综合麻豆| 国产一区二区三区在线观看免费视频| 亚洲一区二区三区小说| 国产精品免费久久久久| 日韩精品中文字幕一区二区三区| 欧美怡红院视频| 成年人国产精品| 国产精品影视在线观看| 蜜桃久久av一区| 亚洲国产日韩综合久久精品| 亚洲丝袜自拍清纯另类| 国产亚洲综合av| 欧美精品一区二区高清在线观看| 欧美日韩精品一区视频| 色婷婷国产精品综合在线观看| 国产不卡视频一区二区三区| 狠狠色丁香婷综合久久| 蜜臀久久99精品久久久久久9| 亚洲一区二区四区蜜桃| 亚洲精品网站在线观看| 亚洲欧美色图小说| 中文字幕亚洲欧美在线不卡| 国产欧美一区二区精品性| 精品国产髙清在线看国产毛片| 亚洲天天做日日做天天谢日日欢| 国产精品日韩成人| 国产精品少妇自拍| 亚洲欧美在线高清| 亚洲视频一区二区在线观看| 中文字幕日本不卡| 亚洲欧美日韩在线播放| 亚洲视频每日更新| 亚洲欧美另类久久久精品| 亚洲图片你懂的| 亚洲美女屁股眼交| 亚洲一二三区不卡| 视频一区二区国产| 免费的成人av| 国产精品123| fc2成人免费人成在线观看播放 | 天天影视色香欲综合网老头| 亚洲综合久久久久| 亚洲第一会所有码转帖| 天天爽夜夜爽夜夜爽精品视频| 日韩国产在线观看| 久久精品久久99精品久久| 国产乱对白刺激视频不卡| 国产成人亚洲综合色影视| 成人动漫一区二区在线| 色偷偷88欧美精品久久久| 欧美偷拍一区二区| 69av一区二区三区| 久久丝袜美腿综合| 中文字幕中文字幕在线一区| 一区二区三区四区蜜桃| 视频一区二区欧美| 国产成人亚洲综合a∨猫咪| 99久久精品情趣| 欧美二区乱c少妇| 欧美精品一区二区三区在线| 中文字幕一区av| 日韩精品久久理论片| 国产一区二区三区在线观看免费视频| 成人免费毛片高清视频| 欧美日韩一二三| 久久久三级国产网站| 尤物在线观看一区| 日韩影视精彩在线| 成人午夜在线视频| 欧美日韩国产高清一区二区三区| 精品精品欲导航| 亚洲欧美日韩一区二区| 日韩成人免费在线| caoporn国产精品| 日韩欧美一级精品久久| 亚洲欧美偷拍三级| 激情欧美一区二区三区在线观看| 91在线视频播放地址| 欧美一区二区三区在线观看| 中文字幕视频一区| 久久国产三级精品| 在线日韩一区二区| 国产日韩欧美在线一区| 亚洲va天堂va国产va久| 成人av电影在线观看| 欧美不卡在线视频| 成人激情免费电影网址| 91精品午夜视频| 亚洲视频一二三区| 国产福利一区二区三区视频在线| 欧美性三三影院| 亚洲国产电影在线观看| 免费日本视频一区| 日本高清不卡一区| 国产精品入口麻豆原神| 韩国一区二区三区| 91精品久久久久久久久99蜜臂| 国产精品情趣视频| 国产麻豆视频精品| 日韩视频在线一区二区| 亚洲黄色免费电影| 99精品一区二区三区| 久久久久久黄色| 久久99久久99精品免视看婷婷 | 欧美亚洲综合在线| 亚洲欧洲性图库| 国产成人啪免费观看软件| 欧美一区二区三区喷汁尤物| 亚洲高清久久久| 在线欧美日韩国产| 亚洲美女少妇撒尿| av电影一区二区| 中文字幕免费在线观看视频一区| 久国产精品韩国三级视频| 3atv一区二区三区| 午夜精品福利一区二区蜜股av| 色综合婷婷久久| 久久久噜噜噜久噜久久综合| 另类综合日韩欧美亚洲| 欧美一区二区三区小说| 日日骚欧美日韩| 在线播放中文一区| 日韩高清国产一区在线| 欧美日韩黄色影视| 亚洲成a天堂v人片| 欧美精品自拍偷拍| 日韩av中文字幕一区二区| 在线电影院国产精品| 亚洲成人中文在线| 欧美日韩中文精品| 日韩经典一区二区| 欧美成人艳星乳罩| 国产伦精品一区二区三区免费迷 | 亚洲精品一区在线观看| 久久99久久99| 日韩亚洲欧美高清| 激情综合色综合久久| 久久久久久麻豆| 99精品国产热久久91蜜凸| 樱桃国产成人精品视频| 欧美日韩国产片| 免费看欧美女人艹b| 久久夜色精品一区| 成人精品视频网站| 亚洲精品国产无套在线观| 欧美人狂配大交3d怪物一区| 日韩av一区二区三区| 精品国免费一区二区三区| 成人一区二区三区| 一二三四社区欧美黄| 婷婷丁香久久五月婷婷| 日韩三级视频中文字幕| 国产经典欧美精品| 亚洲欧洲综合另类| 欧美一区二区在线视频| 国产大片一区二区| 一区二区三区免费观看| 日韩一区二区在线免费观看| 国产不卡在线视频| 亚洲成人一区在线| 国产亚洲污的网站| 欧美性色黄大片| 国产激情一区二区三区四区| 一区二区三区在线影院| 日韩欧美国产系列| 99国内精品久久| 久久精品国产77777蜜臀| 中文欧美字幕免费| 制服.丝袜.亚洲.另类.中文| 成人午夜视频网站| 日韩av一区二区三区四区| 国产精品久久久久久久蜜臀| 欧美伦理电影网| 国产成人午夜视频| 日本女优在线视频一区二区| 国产精品久久久久久久久免费相片 | 日本中文一区二区三区| 久久精品亚洲精品国产欧美| 欧美性一二三区| 成人午夜看片网址| 免费的国产精品| 亚洲图片自拍偷拍| 欧美极品xxx| 日韩一区二区三区四区| 91蜜桃免费观看视频| 国产精品中文有码| 天堂av在线一区| 亚洲综合一区二区| 国产精品网站一区| 欧美精品一区二区三区在线播放| 欧美日韩精品久久久| 91丨国产丨九色丨pron| 国产91精品精华液一区二区三区 | 亚洲国产欧美在线|