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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? fat.c

?? yampp的MP3資料 非常好大家來看一看
?? C
字號:

/*
  Copyright (C) 2001 Jesper Hansen <jesperh@telia.com>.

  This file is part of the yampp system.

  This program is free software; you can redistribute it and/or
  modify it under the terms of the GNU General Public License
  as published by the Free Software Foundation; either version 2
  of the License, or (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software Foundation, 
  Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*/


#include <io.h>
#include <string.h>

#include "types.h"
#include "ata_if.h"
#include "fat.h"
#include "mem.h"
#include "progmem.h"
#include "uart.h"

u08 *SectorBuffer;
u08 *long_name_buffer;
u08 *dir_name_buffer;

u32 FirstDataSector;
u16 Bytes_Per_Sector;
u16 Sectors_Per_Cluster;
u32 FirstFATSector;
u32 FirstDirSector;
u32 FileSize;
u32 FatInCache;
u32 MyCluster;


/*************************************************************************/
/*************************************************************************/


u32 clust2sect(u32 clust)
{
	return ((clust-2) * Sectors_Per_Cluster) + FirstDataSector;
}

u08 init_fat( u08 device)
{
	struct partrecord *pr;
	struct bpb710 *bpb;
    u32 first_sec;

	// setup pointers
	long_name_buffer = (u08 *) LONGNAME_BUF;
	dir_name_buffer  = (u08 *) DIRNAME_BUF;

	// clear cache 
	FatInCache = 0;


//+++++++++++++++++++++++++++++++++++++++
//
     //fix from Uli (Ulrich.Behrenbeck@Informatik-Werkstatt.de)
 	ATA_SW_Reset();
    ATA_Read_Sectors(DRIVE0,1,1,1,1,SectorBuffer);  // LBA bit NOT set !!!,a raw erroneous CHS access
//
//++++++++++++++++++++++++++++++++++++++++

	// read partition table
    ATA_Read_Sectors_LBA( 	DRIVE0,
    						0,
							1,
                            SectorBuffer);
	
	// get the partition record
	pr = (struct partrecord *) ((struct partsector *) SectorBuffer)->psPart;

	// and find the first valid sector
	first_sec = pr->prStartLBA;

	// Read the Partition BootSector
    ATA_Read_Sectors_LBA( 	DRIVE0,
    						first_sec,
							1,
                            SectorBuffer);

	// get BIOS parameter block
	bpb = (struct bpb710 *)  ((struct bootsector710 *) SectorBuffer)->bsBPB;

	// and setup some constants
	FirstDataSector 	= bpb->bpbResSectors + bpb->bpbFATs * bpb->bpbBigFATsecs;
	FirstDataSector    += first_sec;
	Sectors_Per_Cluster = bpb->bpbSecPerClust;
	Bytes_Per_Sector 	= bpb->bpbBytesPerSec;
	FirstFATSector 		= bpb->bpbResSectors + first_sec;
	FirstDirSector 		= bpb->bpbRootClust;

	return 0;	
}

//////////////////////////////////////////////////////////////




extern u08 *buffer1;

u16 entrycount;
u08 dirlisting = 0;


struct direntry * get_de(u16 entry, u32 basecluster)
{
    u32 prevcluster;
	struct direntry *de;	
    u16 i,index;
	
	// always clear the longname buffer
	*long_name_buffer = 0;

	//avoid warnings
	de = 0; 
	prevcluster = 0;

	index = 16*Sectors_Per_Cluster;	// crank it up
	do 
	{
		if (index == 16*Sectors_Per_Cluster)	// time for a new cluster ?
		{
			ATA_Read_Sectors_LBA( 	DRIVE0,
   									clust2sect(basecluster),
									Sectors_Per_Cluster,
           			                buffer1);
				
            prevcluster = basecluster;					// save cluster for directry backstep below
            basecluster = next_cluster(basecluster);
			de = (struct direntry *) buffer1;
			index = 0;
		}	
	
		if (*de->deName != 0xE5)	// if not a deleted entry
		{
			// if this is a long name entry
			if (de->deAttributes == ATTR_LONG_FILENAME)
			{
				struct winentry *we;
			    char *p;
				u16 b;

				we = (struct winentry *) de;
				b = 13 *( (we->weCnt-1) & 0x0f);				// index into string
				p = &long_name_buffer[b];
				for (i=0;i<5;i++)	*p++ = we->wePart1[i*2];	// copy first part			
				for (i=0;i<6;i++)	*p++ = we->wePart2[i*2];	// second part
				for (i=0;i<2;i++)	*p++ = we->wePart3[i*2];	// and third part
				if (we->weCnt & 0x40) *p = 0;					// in case dirnamelength is multiple of 13
			}
			else 
			if ((de->deAttributes & (ATTR_HIDDEN|ATTR_SYSTEM|ATTR_VOLUME)) == 0) // normal file entry (including directories)
			{
				// if the longname buffer is empty, copy the short name in there
				
				// ignore the dot names/directories 
				if (*de->deName != '.')
				{
					if (*long_name_buffer == 0)
					{
						char *p = long_name_buffer;
						for (i=0;i<8;i++)	*p++ = de->deName[i];		// copy first part			
						*p++ = '.';
						for (i=0;i<3;i++)	*p++ = (de->deExtension[i] & 0x5F);	// copy second part	(in lower case)		
						*p = 0;
					}

					if (de->deAttributes == ATTR_DIRECTORY)	// is it a directory ?
					{
							struct direntry *subde;
							char *p;
							
							// copy name buffer to directory buffer
							strcpy(dir_name_buffer,long_name_buffer);

							// special handling for directory names that only have a short entry
							// they may have a dot and some spaces in the name from the copying above
							// fix this
							
							if ( (p = strrchr(dir_name_buffer,'.')) != 0 )
							{
								while (*p == ' ' || *p == '.')
										*p-- = 0;
							}
							
							// add a slash to the directory
							strcat(dir_name_buffer,"/");

							subde = get_de(entry,((u32)de->deHighClust << 16) + de->deStartCluster);
							if (subde)
							{
								return subde;
							}	
							else	
							{
				    		  	ATA_Read_Sectors_LBA( 	DRIVE0,			// reload original sector
	    												clust2sect(prevcluster),
														Sectors_Per_Cluster,
	                    		    	    			buffer1);
								*dir_name_buffer = 0;
	                    	}
					}
					else
					{
						if (dirlisting == DIRLIST_VERBOSE)	
						{
							// print the name
							UART_Puts(dir_name_buffer);
							UART_Putsln(long_name_buffer);
						}

						// if this is the entry we're looking for, exit
						if (entrycount == entry)
						{
							// check for ".mp3" extension, and if it exist,
							// then cut it off, else skip file
							char *p;
							if ( (p = strrchr(long_name_buffer,'.')) != 0 )
							{
								if ( *(p+1) == 'm' && *(p+2) == 'p' && *(p+3) == '3' )
								{
									*p = 0;	// cut it
									
									if (!dirlisting)
										return de;
								}	
							}
						}
						*long_name_buffer = 0;
						entrycount++;			// increment entry counter		
					}
				}	
			}				
		}
		de++;		// point to next directory entry
		index++;	// increment index count within this sector
		
	} while (index == (16*Sectors_Per_Cluster) || *de->deName);	// 0 in de->deName[0] if no more entries


	return 0;
}


//
// do a directory listing 
// either just scan to find # of files,
// or print dir/filename on each
//
u16 dirlist(u08 mode)
{
	*dir_name_buffer = 0;
	*long_name_buffer = 0;
	entrycount = 0;

	dirlisting = mode;
	get_de(-1,FirstDirSector);	// scan through all
	dirlisting = 0;
	return entrycount;
}


//
//
//
u32 get_dir_entry(u16 entry)
{
	struct direntry *de;

	*dir_name_buffer = 0;
	*long_name_buffer = 0;

	entrycount = 0;

	de = get_de(entry,FirstDirSector);	// check in root

	if (de)
	{
		FileSize = de->deFileSize;
		MyCluster = (u32) ((u32)de->deHighClust << 16) + de->deStartCluster;
		return MyCluster;
	}

	return 0;
}


//
// return the size of the last directory entry
//
u32 get_filesize(void)
{
	return FileSize;
}


//
// return the long name of the last directory entry
//
u08 *get_filename(void)
{	
	return long_name_buffer;
}

//
// return the directory of the last directory entry
//
u08 *get_dirname(void)
{	
	return dir_name_buffer;
}


//
// load a clusterfull of data
//
void load_sectors(u08 *buffer)
{

	if (!MyCluster)
		return;

	// read cluster
	while ( ATA_Read_Sectors_LBA( 	DRIVE0,
   									clust2sect(MyCluster),
									Sectors_Per_Cluster,
           	                		buffer) != 0)
    {
    	UART_SendByte('*');
    	ATA_SW_Reset();
    };

	MyCluster = next_cluster(MyCluster);

}

//
// find next cluster in the FAT chain
//
u32 next_cluster(u32 cluster)
{
	u32 FatOffset = cluster << 2;	
	u32 sector    = FirstFATSector + (FatOffset / Bytes_Per_Sector);
	u16 offset 	= FatOffset % Bytes_Per_Sector;

	if (sector != FatInCache)
	{
		// read sector
	    while (ATA_Read_Sectors_LBA(DRIVE0,
	   								sector,
									1,
	           	                	(u08*)FATCACHE) != 0)
	    {
	    	UART_SendByte('&');
	    	ATA_SW_Reset();
	    };

		FatInCache = sector;
    }
           	                
	FatOffset =  (*((u32*) &((char*)FATCACHE)[offset])) & FAT32_MASK;

	if ( FatOffset >= (CLUST_EOFS & FAT32_MASK) )
		FatOffset = 0;

	return FatOffset;
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
av在线不卡电影| 亚洲国产美国国产综合一区二区| 久久麻豆一区二区| 91精品国产麻豆| 26uuu亚洲综合色欧美 | 亚洲bt欧美bt精品777| 偷拍与自拍一区| 久久69国产一区二区蜜臀 | 精品久久人人做人人爰| 久久一区二区视频| 国产精品福利一区二区| 图片区小说区国产精品视频| 国产一区二区主播在线| 成人性生交大合| 欧美午夜精品久久久久久超碰| 日韩一区二区三区精品视频| 久久久久9999亚洲精品| 亚洲一区二区三区中文字幕| 久久精品国产**网站演员| 99久久er热在这里只有精品15 | 国产精品一二三四| 91福利国产精品| 国产女主播视频一区二区| 午夜国产不卡在线观看视频| 成人av在线资源网站| 精品成人a区在线观看| 亚洲电影一级黄| 91看片淫黄大片一级在线观看| 日韩免费看的电影| 免费观看在线色综合| 色94色欧美sute亚洲线路一ni | 欧美三级在线视频| 亚洲精品欧美在线| 色欲综合视频天天天| 一区二区中文视频| 成人免费黄色在线| 日韩毛片视频在线看| 666欧美在线视频| 日韩免费成人网| 亚洲国产va精品久久久不卡综合| 粉嫩av一区二区三区在线播放| 欧美精品色综合| 亚洲gay无套男同| 日韩亚洲欧美在线| 麻豆极品一区二区三区| 亚洲精品一区二区三区香蕉| 久久99精品网久久| 亚洲国产精品精华液ab| 国产麻豆91精品| 依依成人精品视频| 欧美日本一道本| 国产精品1区2区3区在线观看| 欧美zozozo| 94-欧美-setu| 国内精品自线一区二区三区视频| 欧美成人aa大片| 色综合天天综合网国产成人综合天 | 亚洲精品中文字幕在线观看| 欧美日韩夫妻久久| 成人天堂资源www在线| 亚洲伊人伊色伊影伊综合网| 欧美一区二区在线不卡| 国产一区二区三区四| 伊人婷婷欧美激情| 中文字幕日韩一区二区| 欧美日韩国产另类一区| 东方aⅴ免费观看久久av| 老司机精品视频在线| 欧美国产成人精品| 久久免费的精品国产v∧| 欧美色电影在线| 91免费版在线| 99久久婷婷国产综合精品 | 欧美一级二级在线观看| 在线观看国产日韩| 色先锋aa成人| 欧美日韩一区二区欧美激情| 97久久精品人人澡人人爽| 国产大陆亚洲精品国产| 韩国视频一区二区| 国产一区二区不卡老阿姨| 精品夜夜嗨av一区二区三区| 日韩精品91亚洲二区在线观看| 亚洲成人免费av| 三级欧美韩日大片在线看| 日韩电影免费在线| 国产精品一二三区在线| 国产999精品久久久久久| 国产不卡视频一区二区三区| 大胆欧美人体老妇| 色天使色偷偷av一区二区| 欧美日韩一区二区三区高清| 91精品国产一区二区人妖| 日韩欧美国产小视频| 久久这里都是精品| 国产精品天干天干在线综合| 亚洲靠逼com| 麻豆精品视频在线观看| aaa国产一区| 5858s免费视频成人| 国产亚洲精品中文字幕| 天堂在线一区二区| 国模一区二区三区白浆| 色综合色狠狠综合色| 精品久久久久久久人人人人传媒| 国产午夜精品一区二区三区视频| 亚洲免费色视频| 国产成人av在线影院| 欧美吻胸吃奶大尺度电影| 久久亚洲春色中文字幕久久久| 中文幕一区二区三区久久蜜桃| 日韩精品亚洲一区| 色88888久久久久久影院按摩| 国产午夜一区二区三区| 日韩影院在线观看| 91激情五月电影| 日韩伦理免费电影| 国产精品一区二区免费不卡 | 欧美国产乱子伦| 国产成人高清在线| 精品国产乱码久久久久久蜜臀| 亚洲一区二区在线播放相泽| 国产精品资源网| 中文一区一区三区高中清不卡| 国产精品一区三区| 欧美激情一区不卡| 高清视频一区二区| 亚洲视频一区在线观看| 色视频一区二区| 日韩制服丝袜先锋影音| 日韩一区和二区| 久久福利视频一区二区| 亚洲精品一区二区三区99| 高清视频一区二区| 亚洲另类在线制服丝袜| 欧美日韩免费一区二区三区视频| 亚洲电影激情视频网站| 欧美成人三级在线| 丁香五精品蜜臀久久久久99网站 | 欧美欧美欧美欧美首页| 五月综合激情婷婷六月色窝| 日韩免费在线观看| 精品一区二区免费在线观看| 久久精品一二三| 欧美日韩国产一级二级| 国产真实乱对白精彩久久| 亚洲同性gay激情无套| 日韩免费看的电影| 在线视频观看一区| 国产成人在线免费| 亚洲.国产.中文慕字在线| 精品欧美一区二区三区精品久久 | 亚洲欧美国产高清| 欧美一级欧美三级在线观看| 成人黄色av电影| 麻豆视频观看网址久久| 亚洲资源中文字幕| 国产精品久久久久久户外露出 | 精品国产成人系列| 337p亚洲精品色噜噜| 91天堂素人约啪| 高清视频一区二区| 久久精品国产99久久6| 视频一区二区三区中文字幕| 日韩毛片视频在线看| 国产精品三级久久久久三级| 久久久青草青青国产亚洲免观| 欧美精品vⅰdeose4hd| 欧美日韩一级片在线观看| 94色蜜桃网一区二区三区| 成人av网站在线| 91麻豆蜜桃一区二区三区| 国产成人久久精品77777最新版本 国产成人鲁色资源国产91色综 | 日本视频在线一区| 日产国产欧美视频一区精品| 爽好多水快深点欧美视频| 日本不卡中文字幕| 免费观看在线色综合| 美女在线一区二区| 国产成人精品在线看| 色天天综合色天天久久| 91精品国产综合久久福利| 日韩午夜激情av| 欧美国产日韩精品免费观看| 亚洲精品成人悠悠色影视| 视频一区在线播放| 国产一区二区三区高清播放| 91视频com| 欧美二区乱c少妇| 国产午夜精品一区二区| 一区二区国产盗摄色噜噜| 老司机免费视频一区二区 | 久久久www成人免费毛片麻豆| 国产精品另类一区| 日韩影院精彩在线| 日本电影欧美片| 欧美国产亚洲另类动漫| 日本怡春院一区二区| 99精品黄色片免费大全| 精品国偷自产国产一区|