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

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

?? msdos.c

?? 這個(gè)是嵌入式arm系列的一個(gè)bootloader程序。對需要編寫bootloader的很有參考價(jià)值
?? C
字號(hào):
/*



Module Name:

    msdos.c

Abstract:
	Implements routines to process an MS-DOS partition.

*/


#include <windows.h>
#include <halether.h>
#include <nkintr.h> 

#include "msdos.h"
#include "CFLoad.h"
#include "CFDisk.h"

#define DBG_VERBOSE_MSG 0
#define DBG_READFILE_MSG 0
#define DBG_FILEDIR_MSG 0
#define DBG_LOADFILE_MSG 0
#define DBG_ERROR_MSG 0

BYTE	sectorBuffer[mBytesPerSector];
//BYTE	fatBuffer[mMaxFATSize * mBytesPerSector];
PBYTE   fatBuffer = (PBYTE) mFATLoadAddr;
PBYTE	bootFileContent = (PBYTE) mMSDFileLoadAddr;
BYTE	mBootFileName[mBootfileNameLength];
BYTE	mBootFileExtension[mBootfileExtLength];


int		sectorsPerCluster;
int		reservedSectors;
int		copiesOfFAT;
int		rootDirEntries;
int		totalSectors;
int		sectorsPerFAT;
int		hiddenSectors;
int		partitionMap;
int		partitionStart;
int		partitionLength;
int		partitionType;
int		directoryStart;
int		fatStart;
int		clusterStart;
int		bootFileStart;
int		bootFileLength;

int currentCluster;
ULONG clusterIndex;

#if (DBG_VERBOSE_MSG | DBG_READFILE_MSG)
BOOL BootGetMemory(ULONG startAddr, ULONG length, BYTE dataSize);
#endif


//	Function to read unaligned WORDs and DWORDs from a buffer.
DWORD
bytesToNum(BYTE *b, int bytes)
{
	DWORD	result = 0;
	int		i;

	for(i=0; i < bytes; i++)
		result |= b[i] << (i << 3);

	return result;
}


//	Function to compute the next cluster of a file based on table lookup.
int
getNextCluster(int cluster)
{
	int		temp;
	int		next;

	if (partitionType == mFAT16Type || partitionType == mDOS32MegType)
	{
		next = bytesToNum(fatBuffer + (cluster << 1), 2);
	}
	else if (partitionType == mFAT12Type)
	{
		temp = cluster * 3;
		next = bytesToNum(fatBuffer + (temp >> 1), 2);
		if (temp & 0x0001)
			next >>= 4;
		next &= 0xFFF;
	}
	else
	{
		return 0;
	}

	return next;
}


//	Read a cluster into the specified buffer.
void
readCluster(int cluster, BYTE *p)
{
	int		i;
	int		sector;

	sector = clusterStart + (cluster - 2) * sectorsPerCluster;
	for(i=0; i < sectorsPerCluster; i++)
	{
		CFReadSector(sector + i, p);
//	EdbgOutputDebugString("CF Read Sector = 0x%x\n\r", sector+i);

		p += mBytesPerSector;
	}
}


//	Scans the partition map looking for the first bootable partition.
BOOL
findBootPartition(void)
{
	partitionType = mEmptyType;

#if 0
	{
		DWORD i = 0;
		DWORD selection;
		
		for (;;i++)
		{
			while(1)
		    {
				selection = OEMReadDebugByte();
				if (selection == 0x20)
					break;
				if (selection == 0x0d)
				    goto testend;
			}
			CFReadSector(i, sectorBuffer);
			BootGetMemory((ULONG) sectorBuffer, mBytesPerSector, sizeof(BYTE));
		}
	}
	
testend:
#endif

	CFReadSector(0, sectorBuffer);
//	EdbgOutputDebugString("CF Read Sector(Find Boot Partition)\n\r");
#if DBG_VERBOSE_MSG
	EdbgOutputDebugString("findBootPartition: Boot Partition at Sector 0\n\r");
	BootGetMemory((ULONG) sectorBuffer, mBytesPerSector, sizeof(BYTE));
#endif
	for(partitionMap = mPartitionMapOffset; partitionMap < mPartitionSigOffset; partitionMap += mPartitionMapSize)
	{
		if (bytesToNum(sectorBuffer + partitionMap, 1) != mPartitionBootableFlag)
			continue;

		partitionStart = bytesToNum(sectorBuffer + partitionMap + mPartitionStartOffset, mPartitionStartLength);
		partitionLength = bytesToNum(sectorBuffer + partitionMap + mPartitionLengthOffset, mPartitionLengthLength);
		partitionType = bytesToNum(sectorBuffer + partitionMap + mPartitionTypeOffset, mPartitionTypeLength);

		EdbgOutputDebugString("findBootPartition: partitionStart = %d = 0x%x\n\r", partitionStart, partitionStart);
		EdbgOutputDebugString("findBootPartition: partitionLength = %d = 0x%x\n\r", partitionLength, partitionLength);
		EdbgOutputDebugString("findBootPartition: partitionType = %d = 0x%x\n\r", partitionType, partitionType);

        switch(partitionType)
      	  {           
            case mFAT16Type:        // 16-bit FAT < 32MB
            case mDOS32MegType:     // 16-bit FAT >= 32MB - 2GB
            case mFAT12Type:        // 12-bit FAT < 16MB
                return TRUE;
                break;
            default:
        	    EdbgOutputDebugString("findBootPartition: partition type %d not supported!\r\n", partitionType);
                return FALSE;
          }
	}

	EdbgOutputDebugString("findBootPartition: partitionStart and partitionLength NOT FOUND\n\r");

	return FALSE;
}


//	Reads partition information from the master boot record.  This also reads the FAT
//	into memory for later access.
BOOL
processBootRecord(void)
{
	int		i;
	PBYTE dog = sectorBuffer;

	EdbgOutputDebugString("processBootRecord: partitionStart = %d = 0x%x\n\r", partitionStart, partitionStart);

	CFReadSector(partitionStart, sectorBuffer);
	EdbgOutputDebugString("CF Read Sector (ProcessBootRecord)\n\r");
    
	sectorsPerCluster = bytesToNum(sectorBuffer+mSectorsPerClusterOffset, mSectorsPerClusterSize);
	reservedSectors = bytesToNum(sectorBuffer+mReservedSectorsOffset, mReservedSectorsSize);
	copiesOfFAT = bytesToNum(sectorBuffer+mCopiesOfFATOffset, mCopiesOfFATSize);
	rootDirEntries = bytesToNum(sectorBuffer+mRootDirEntriesOffset, mRootDirEntriesSize);
	sectorsPerFAT = bytesToNum(sectorBuffer+mSectorsPerFATOffset, mSectorsPerFATSize);
	hiddenSectors = bytesToNum(sectorBuffer+mHiddenSectorsOffset, mHiddenSectorsSize);

#if DBG_VERBOSE_MSG
	EdbgOutputDebugString("processBootRecord: Boot Record at partitionStart Sector: %d\n\r", partitionStart);
	BootGetMemory((ULONG) sectorBuffer, mBytesPerSector, sizeof(BYTE));

	EdbgOutputDebugString("processBootRecord: sectorsPerCluster = %d = 0x%x\n\r", sectorsPerCluster, sectorsPerCluster);
	EdbgOutputDebugString("processBootRecord: reservedSectors = %d = 0x%x\n\r", reservedSectors, reservedSectors);
	EdbgOutputDebugString("processBootRecord: copiesOfFAT = %d = 0x%x\n\r", copiesOfFAT, copiesOfFAT);
	EdbgOutputDebugString("processBootRecord: rootDirEntries = %d = 0x%x\n\r", rootDirEntries, rootDirEntries);
	EdbgOutputDebugString("processBootRecord: sectorsPerFAT = %d = 0x%x\n\r", sectorsPerFAT, sectorsPerFAT);
	EdbgOutputDebugString("processBootRecord: hiddenSectors = %d = 0x%x\n\r", hiddenSectors, hiddenSectors);
	EdbgOutputDebugString("processBootRecord: fatStart = %d = 0x%x\n\r", fatStart, fatStart);
	EdbgOutputDebugString("processBootRecord: directoryStart = %d = 0x%x\n\r", directoryStart, directoryStart);
	EdbgOutputDebugString("processBootRecord: clusterStart = %d = 0x%x\n\r", clusterStart, clusterStart);
#endif
    if (sectorsPerFAT > mMaxFATSize)
    {
    	EdbgOutputDebugString("processBootRecord: %d sectors too large for internal buffer of %d sectors!\r\n", sectorsPerFAT, mMaxFATSize);
        return FALSE;
    }
 
	EdbgOutputDebugString("processBootRecord: partitionStart = %d = 0x%x\n\r", partitionStart, partitionStart);

	fatStart = partitionStart + reservedSectors;
	directoryStart = fatStart + copiesOfFAT * sectorsPerFAT;
	clusterStart = directoryStart + rootDirEntries * mDirectoryEntrySize / mBytesPerSector;

    //	read FAT
	for(i=0; i < sectorsPerFAT; i++)
	{
		CFReadSector(fatStart + i, fatBuffer + (i * mBytesPerSector));

      //	EdbgOutputDebugString("CF Read Sector (Read FAT)\n\r");
#if DBG_VERBOSE_MSG
		EdbgOutputDebugString("processBootRecord: fatBuffer = %d = 0x%x\n\r", (fatBuffer + (i * mBytesPerSector)), (fatBuffer + (i * mBytesPerSector)));
		BootGetMemory(((ULONG) (fatBuffer + (i * mBytesPerSector))), (mBytesPerSector), sizeof(BYTE));
#endif
	}
#if DBG_VERBOSE_MSG
	EdbgOutputDebugString("processBootRecord: fatBuffer\n\r");
	BootGetMemory((ULONG) fatBuffer, (mBytesPerSector * sectorsPerFAT), sizeof(BYTE));
#endif

    return TRUE;
}


//	Searches the root directory for a specific file (NKImage.BIN).  When found, sets up the
//	file start cluster and file length.
BOOL
findBootFile(PBYTE fileName, PBYTE fileExt)
{
	PBYTE	dirEntry = 0;
	int		i;
	PBYTE	p = bootFileContent;

	for (i=0; i < rootDirEntries; i++)
	{
		dirEntry += mDirectoryEntrySize;
		if ((i & 0xF) == 0)
		{
			//EdbgOutputDebugString("findBootFile: Directory Sector = %d = 0x%x\n\r", directoryStart, directoryStart);
			//EdbgOutputDebugString("findBootFile: dirEntry = %d = 0x%x\n\r", dirEntry, dirEntry);

			CFReadSector(directoryStart++, sectorBuffer);
			//EdbgOutputDebugString("CF Read Sector (FindBootFile)\n\r");
			dirEntry = sectorBuffer;
#if DBG_FILEDIR_MSG
			EdbgOutputDebugString("findBootFile: Directory Sector\n\r");
			BootGetMemory(((ULONG) sectorBuffer), mBytesPerSector, sizeof(BYTE));
#endif
		}

		if (!(compare(dirEntry+mDirNameOffset, fileName, mBootfileNameLength) && 
			  compare(dirEntry+mDirExtOffset, fileExt, mBootfileExtLength)))
			continue;

		bootFileStart = bytesToNum(dirEntry+mDirStartOffset, mDirStartSize);
		bootFileLength = bytesToNum(dirEntry+mDirLengthOffset, mDirLengthSize);

		//EdbgOutputDebugString("findBootFile: bootFileStart = %d = 0x%x\n\r", (USHORT) bootFileStart, (USHORT) bootFileStart);
		//EdbgOutputDebugString("findBootFile: bootFileLength = %d = 0x%x\n\r", (USHORT) bootFileLength, (USHORT) bootFileLength);

		currentCluster = bootFileStart;
		clusterIndex = 0;

		return TRUE;
	}

	return FALSE;
}

//	Simple compare routine (small).
BOOL
compare(PBYTE a, PBYTE b, int length)
{
	while (length--)
		if (*a++ != *b++)
			return FALSE;
	return TRUE;
}


//	Simple copy routine (small).
void
copy(PBYTE a, PBYTE b, int length)
{
	while(length--)
		*b++ = *a++;
}

//	Processes .BIN file.
BOOL
readBootFile(PBYTE Addr, ULONG bytesToRead, PULONG bytesRead)
{
	PBYTE addrPtr = Addr;
	ULONG bytesPerCluster;

	//EdbgOutputDebugString("readBootFile: Addr = 0x%x, bytesToRead = %d = 0x%x\n\r", Addr, bytesToRead, bytesToRead);

	bytesPerCluster = mBytesPerSector * sectorsPerCluster;
	*bytesRead = 0;

	while (bytesToRead > 0)
	{
		//EdbgOutputDebugString("readBootFile: addrPtr = 0x%x\n\r", addrPtr);
		//EdbgOutputDebugString("readBootFile: bytesToRead = %d = 0x%x\n\r", bytesToRead, bytesToRead);
		//EdbgOutputDebugString("readBootFile: bytesRead = %d = 0x%x\n\r", *bytesRead, *bytesRead);
		//EdbgOutputDebugString("readBootFile: currentCluster = 0x%x\n\r", currentCluster);

		readCluster(currentCluster, bootFileContent);
#if DBG_READFILE_MSG
		EdbgOutputDebugString("loadBootFile: Read Cluster: %d = 0x%x\n\r", currentCluster, currentCluster);
		BootGetMemory(((ULONG) bootFileContent), bytesPerCluster, sizeof(BYTE));
#endif

		if((currentCluster & mClusterEndOfFileMask) == mClusterEndOfFile)
		{
			EdbgOutputDebugString("loadBootFile: Cluster EOF Found\n\r");
			break;
		}

		if ((clusterIndex + bytesToRead) > bytesPerCluster)
		{
			
			memcpy(addrPtr, (bootFileContent + clusterIndex), (bytesPerCluster - clusterIndex));
			bytesToRead -= (bytesPerCluster - clusterIndex);
			*bytesRead += (bytesPerCluster - clusterIndex);
			addrPtr += (bytesPerCluster - clusterIndex);
			currentCluster = getNextCluster(currentCluster);
			clusterIndex = 0;
		}
		else
		{
			
			memcpy(addrPtr, (bootFileContent + clusterIndex), bytesToRead);
			clusterIndex += bytesToRead;
			*bytesRead += bytesToRead;
			addrPtr += bytesToRead;
			bytesToRead -= bytesToRead;
		}
	}

#if DBG_READFILE_MSG
	EdbgOutputDebugString("readBootFile: Addr = 0x%x, bytesRead = %d = 0x%x\n\r", Addr, *bytesRead, *bytesRead);
	BootGetMemory(((ULONG) Addr), *bytesRead, sizeof(BYTE));
#endif
	return TRUE;
}

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
麻豆久久久久久久| 亚洲激情中文1区| 欧美老人xxxx18| 欧美又粗又大又爽| 在线观看不卡一区| 欧美日韩国产综合一区二区 | 99久久免费视频.com| 国产v综合v亚洲欧| 欧美色倩网站大全免费| 日本乱人伦aⅴ精品| 色婷婷一区二区| 欧美日韩激情一区| 日韩欧美国产精品一区| 欧美大黄免费观看| 中文字幕第一区二区| 国产精品久久久久久久久久久免费看 | 91在线视频在线| 在线观看av不卡| 日韩一区二区三区在线视频| 欧美成人高清电影在线| 国产蜜臀av在线一区二区三区| 国产欧美一区二区三区网站| 国产精品每日更新| 日韩中文字幕亚洲一区二区va在线| 男人操女人的视频在线观看欧美| 麻豆精品在线播放| 成人禁用看黄a在线| 欧美在线影院一区二区| 2020日本不卡一区二区视频| 国产精品免费丝袜| 天堂在线一区二区| 粉嫩嫩av羞羞动漫久久久| 日韩欧美一区电影| 亚洲三级电影网站| 久久精品国产99国产| 成人久久18免费网站麻豆| 欧美精品在线观看一区二区| 国产欧美一区二区精品忘忧草| 亚洲最大成人综合| 国产一区二区三区四区五区美女| 99riav一区二区三区| 日韩欧美国产午夜精品| 亚洲柠檬福利资源导航| 国内成+人亚洲+欧美+综合在线| 99国产精品久久久久久久久久 | 欧美一级夜夜爽| 中文字幕一区二区三区在线不卡| 五月天中文字幕一区二区| 国产激情精品久久久第一区二区| 精品视频999| 国产精品福利影院| 国产在线精品一区二区 | 日韩av高清在线观看| 99久久久无码国产精品| 国产亚洲欧美中文| 美女视频网站久久| 欧美日本韩国一区| 一区二区三区在线免费视频| 成人免费av资源| 精品成人a区在线观看| 视频一区中文字幕国产| 91福利社在线观看| 亚洲美女视频在线观看| 不卡一区二区三区四区| 久久九九99视频| 国产精品影视网| 精品成人免费观看| 国产伦精品一区二区三区免费| 欧美一级专区免费大片| 亚洲第一会所有码转帖| 欧美伊人久久久久久久久影院 | 在线看日本不卡| 亚洲女厕所小便bbb| 色久优优欧美色久优优| 一区二区三区精密机械公司| 91成人在线观看喷潮| 亚洲一区二区三区四区在线观看| 91蜜桃免费观看视频| 青青草视频一区| 欧美一级高清片| 麻豆中文一区二区| 久久久美女艺术照精彩视频福利播放| 激情文学综合丁香| 国产日韩欧美电影| 丰满亚洲少妇av| 夜夜嗨av一区二区三区中文字幕| 色婷婷久久久综合中文字幕| 夜夜嗨av一区二区三区网页| 欧美日韩成人一区二区| 久久99深爱久久99精品| xvideos.蜜桃一区二区| 成人伦理片在线| 亚洲mv在线观看| 日韩欧美国产精品| jlzzjlzz亚洲女人18| 有码一区二区三区| 日韩午夜电影在线观看| 国产精品一区二区不卡| 综合中文字幕亚洲| 欧美日本一道本在线视频| 国产在线精品一区在线观看麻豆| 国产精品日日摸夜夜摸av| 欧美伊人久久大香线蕉综合69| 日本欧美一区二区| 国产精品无圣光一区二区| 日本伦理一区二区| 国内成人精品2018免费看| 自拍偷拍国产精品| 日韩无一区二区| 99综合电影在线视频| 日本亚洲天堂网| 一色屋精品亚洲香蕉网站| 欧美一区二区啪啪| 91婷婷韩国欧美一区二区| 久久精品久久精品| 亚洲精品中文在线| 久久精品视频在线看| 欧美日韩一区二区三区在线看| 国产精品中文字幕日韩精品 | 亚洲一级二级在线| 久久精品夜色噜噜亚洲a∨| 欧美网站一区二区| 国产91在线|亚洲| 日韩中文字幕一区二区三区| 亚洲女人小视频在线观看| 久久亚洲二区三区| 精品国产伦一区二区三区免费| 色综合久久中文字幕| 国产一区二区不卡| 欧美96一区二区免费视频| 亚洲欧美日韩成人高清在线一区| 日韩欧美在线1卡| 欧美视频在线观看一区二区| 国产91综合一区在线观看| 国精品**一区二区三区在线蜜桃| 亚洲高清免费观看| 亚洲精品菠萝久久久久久久| 中文字幕乱码日本亚洲一区二区 | 亚洲成人tv网| 亚洲日本中文字幕区| 中文在线免费一区三区高中清不卡| 欧美一区二区三区精品| 欧美高清性hdvideosex| 欧美色图免费看| 在线视频中文字幕一区二区| 成人av资源网站| 波波电影院一区二区三区| 国产成人综合在线观看| 国产综合久久久久久久久久久久| 石原莉奈在线亚洲三区| 亚洲欧美一区二区三区久本道91| 国产精品久久看| 国产精品九色蝌蚪自拍| 中文字幕不卡三区| 国产精品久久久久aaaa樱花| 国产日韩精品一区| 久久久国产一区二区三区四区小说| 91麻豆精品久久久久蜜臀| 欧美日韩免费一区二区三区视频| 色婷婷国产精品| 欧美亚洲自拍偷拍| 欧美日韩一二区| 日韩一卡二卡三卡四卡| 欧美成人艳星乳罩| 欧美情侣在线播放| 欧美乱熟臀69xxxxxx| 欧美白人最猛性xxxxx69交| 久久综合色一综合色88| 国产精品欧美一区二区三区| 国产精品久久久久久久久快鸭 | 粉嫩久久99精品久久久久久夜| 高清久久久久久| 99re视频精品| 欧美性生活影院| 欧美一区二区人人喊爽| 国产日韩欧美不卡| 亚洲一区二区av电影| 日本午夜精品视频在线观看 | 午夜精品久久久久久久99水蜜桃| 日韩电影在线观看一区| 国产一区在线观看视频| 成人免费视频app| 欧美中文一区二区三区| 欧美日韩国产高清一区二区| 久久色在线视频| 亚洲欧美视频在线观看视频| 免费精品视频在线| 成人综合在线观看| 欧美性感一类影片在线播放| 欧美一级理论性理论a| 中文字幕一区二区三区四区| 亚洲一卡二卡三卡四卡 | 中文字幕在线观看不卡视频| 亚洲在线视频免费观看| 韩国在线一区二区| 欧美亚洲动漫制服丝袜| 国产精品欧美经典| 免费成人在线播放| 欧美午夜精品免费| 综合久久久久综合|