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

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

?? bootpart.cpp

?? 6410BSP3
?? CPP
?? 第 1 頁 / 共 3 頁
字號:
//
// Copyright (c) Microsoft Corporation.  All rights reserved.
//
//
// Use of this source code is subject to the terms of the Microsoft end-user
// license agreement (EULA) under which you licensed this SOFTWARE PRODUCT.
// If you did not accept the terms of the EULA, you are not authorized to use
// this source code. For a copy of the EULA, please see the LICENSE.RTF on your
// install media.
//
extern "C"	// hmseo-061028
{
#include <WMRConfig.h>
#include <WMRTypes.h>
}

#include <bootpart.h>
#include "bppriv.h"

LPBYTE g_pbMBRSector = NULL;
LPBYTE g_pbBlock = NULL;
DWORD g_dwMBRSectorNum = INVALID_ADDR;
FlashInfo g_FlashInfo;
PARTSTATE g_partStateTable[NUM_PARTS];
PSectorInfo g_pSectorInfoBuf;
DWORD g_dwLastLogSector;          // Stores the last valid logical sector
DWORD g_dwDataBytesPerBlock;
DWORD g_dwLastWrittenLoc;  // Stores the byte address of the last physical flash address written to

//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
static Addr LBAtoCHS(FlashInfo *pFlashInfo, Addr lba)
{
    if(lba.type == CHS)
        return lba;

    Addr chs;
    DWORD tmp = pFlashInfo->dwNumBlocks * pFlashInfo->wSectorsPerBlock;

    chs.type = CHS;
    chs.chs.cylinder = (WORD)(lba.lba / tmp);
    tmp = lba.lba % tmp;
    chs.chs.head = (WORD)(tmp / pFlashInfo->wSectorsPerBlock);
    chs.chs.sector = (WORD)((tmp % pFlashInfo->wSectorsPerBlock) + 1);

    return chs;
}

//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
static Addr CHStoLBA(FlashInfo *pFlashInfo, Addr chs)
{
    Addr lba;

    if(chs.type == LBA)
        return chs;

    lba.type = LBA;
    lba.lba = ((chs.chs.cylinder * pFlashInfo->dwNumBlocks + chs.chs.head)
        * pFlashInfo->wSectorsPerBlock)+ chs.chs.sector - 1;

    return lba;
}

#define Log2Phys(sector)	(sector)

#define SECTOR_TO_BLOCK(sector)     ((sector) / (SECTORS_PER_SUPAGE*PAGES_PER_SUBLK) )
#define BLOCK_TO_SECTOR(block)      ((block)  * (SECTORS_PER_SUPAGE*PAGES_PER_SUBLK) )

extern BOOL WriteBlock(DWORD dwBlock, LPBYTE pbBlock, PSectorInfo pSectorInfoTable);
extern BOOL ReadBlock(DWORD dwBlock, LPBYTE pbBlock, PSectorInfo pSectorInfoTable);


//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
static BOOL WriteMBR()
{
	DWORD dwMBRBlockNum = g_dwMBRSectorNum / g_FlashInfo.wSectorsPerBlock;

	RETAILMSG(1, (TEXT("WriteMBR: MBR block = 0x%x.\r\n"), dwMBRBlockNum));

	memset (g_pbBlock, 0xff, g_dwDataBytesPerBlock);
	memset (g_pSectorInfoBuf, 0xff, sizeof(SectorInfo) * g_FlashInfo.wSectorsPerBlock);

	// No need to check return, since a failed read means data hasn't been written yet.
	ReadBlock (dwMBRBlockNum, g_pbBlock, g_pSectorInfoBuf);

	if (!FMD_EraseBlock (dwMBRBlockNum)) {
		RETAILMSG (1, (TEXT("CreatePartition: error erasing block 0x%x\r\n"), dwMBRBlockNum));
		return FALSE;
	}

	memcpy (g_pbBlock + (g_dwMBRSectorNum % g_FlashInfo.wSectorsPerBlock) * g_FlashInfo.wDataBytesPerSector, g_pbMBRSector, g_FlashInfo.wDataBytesPerSector);
	g_pSectorInfoBuf->bOEMReserved &= ~OEM_BLOCK_READONLY;
	g_pSectorInfoBuf->wReserved2 &= ~SECTOR_WRITE_COMPLETED;
	g_pSectorInfoBuf->dwReserved1 = 0;

	RETAILMSG(1, (TEXT("WriteBlock: dwMBRBlockNum = 0x%x.\r\n"), dwMBRBlockNum));
#if 0
	for (DWORD i = 0; i < 512; i++) {
		if (i % 16 == 0)
			RETAILMSG(1, (L"0x%x: ", g_pbBlock+i));
		RETAILMSG(1, (L"%x%x ", (g_pbBlock[i] >> 4) & 0x0f, g_pbBlock[i] & 0x0f));
		if ((i + 1) % 16 == 0)
			RETAILMSG(1, (L"\r\n"));
	}
#endif
	if (!WriteBlock (dwMBRBlockNum, g_pbBlock, g_pSectorInfoBuf)) {
		RETAILMSG (1, (TEXT("CreatePartition: could not write to block 0x%x\r\n"), dwMBRBlockNum));
		return FALSE;
	}

	return TRUE;
}

//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
BOOL CreateMBR() 
{
    // This, plus a valid partition table, is all the CE partition manager needs to recognize 
    // the MBR as valid. It does not contain boot code.

    memset (g_pbMBRSector, 0xff, g_FlashInfo.wDataBytesPerSector);
    g_pbMBRSector[0] = 0xE9;
    g_pbMBRSector[1] = 0xfd;
    g_pbMBRSector[2] = 0xff;
    g_pbMBRSector[SECTOR_SIZE-2] = 0x55;
    g_pbMBRSector[SECTOR_SIZE-1] = 0xAA;

    // Zero out partition table so that mspart treats entries as empty.
    memset (g_pbMBRSector+PARTTABLE_OFFSET, 0, sizeof(PARTENTRY) * NUM_PARTS);

    return WriteMBR();

}  

BOOL IsValidMBR() 
{
    // Check to see if the MBR is valid

    // MBR block is always located at logical sector 0
#if 0	// hmseo-061029
    g_dwMBRSectorNum = 0;	//GetMBRSectorNum();        
#else	// hmseo-061029
//    g_dwMBRSectorNum = BLOCK_TO_SECTOR(FTL_AREA_START);	// hmseo-061029 set the MBR sector to FTL area start sector.
#endif	// hmseo-061029
		
    RETAILMSG (1, (TEXT("IsValidMBR: MBR sector = 0x%x\r\n"), g_dwMBRSectorNum));
   
    if ((g_dwMBRSectorNum == INVALID_ADDR) || !FMD_ReadSector (g_dwMBRSectorNum, g_pbMBRSector, NULL, 1)) {
        return FALSE;  
    }
    
#if 0
    LPBYTE pbBuf = g_pbMBRSector + 512 - 0x42;
    RETAILMSG(1, (L"g_pbMBRSector = 0x%x\r\n", g_pbMBRSector));
    for (DWORD i = 0; i < 0x40; i++) {
    	if (i % 16 == 0)
    		RETAILMSG(1, (L"0x%x: ", pbBuf+i));
    	RETAILMSG(1, (L"%x%x ", (pbBuf[i] >> 4) & 0x0f, pbBuf[i] & 0x0f));
    	if ((i + 1) % 16 == 0)
    		RETAILMSG(1, (L"\r\n"));
    }
#endif
    return ((g_pbMBRSector[0] == 0xE9) &&
         (g_pbMBRSector[1] == 0xfd) &&
         (g_pbMBRSector[2] == 0xff) &&
         (g_pbMBRSector[SECTOR_SIZE-2] == 0x55) &&
         (g_pbMBRSector[SECTOR_SIZE-1] == 0xAA));
}  

BOOL IsValidMBRSector(DWORD dwBlock)
{
	g_dwMBRSectorNum = BLOCK_TO_SECTOR(dwBlock);

	return IsValidMBR();
}

static BOOL IsValidPart (PPARTENTRY pPartEntry)
{
    return (pPartEntry->Part_FileSystem != 0xff) && (pPartEntry->Part_FileSystem != 0);
}

/*  AddPartitionTableEntry
 *
 *  Generates the partition entry for the partition table and copies the entry 
 *  into the MBR that is stored in memory.
 *  
 *
 *  ENTRY
 *      entry - index into partition table
 *      startSector - starting logical sector
 *      totalSectors - total logical sectors
 *      fileSystem - type of partition
 *      bootInd - byte in partition entry that stores various flags such as
 *          active and read-only status.
 *
 *  EXIT
 */
 
static void AddPartitionTableEntry(DWORD entry, DWORD startSector, DWORD totalSectors, BYTE fileSystem, BYTE bootInd)
{
    PARTENTRY partentry = {0};
    Addr startAddr;
    Addr endAddr;

    ASSERT(entry < 4);

    // no checking with disk info and start/total sectors because we allow
    // bogus partitions for testing purposes

    // initially known partition table entry
    partentry.Part_BootInd = bootInd;
    partentry.Part_FileSystem = fileSystem;
    partentry.Part_StartSector = startSector;
    partentry.Part_TotalSectors = totalSectors;

    // logical block addresses for the first and final sector (start on the second head)
    startAddr.type = LBA;
    startAddr.lba = partentry.Part_StartSector;
    endAddr.type = LBA;
    endAddr.lba = partentry.Part_StartSector + partentry.Part_TotalSectors-1;

    // translate the LBA addresses to CHS addresses
    startAddr = LBAtoCHS(&g_FlashInfo, startAddr);
    endAddr = LBAtoCHS(&g_FlashInfo, endAddr);

    // starting address
    partentry.Part_FirstTrack = (BYTE)(startAddr.chs.cylinder & 0xFF);
    partentry.Part_FirstHead = (BYTE)(startAddr.chs.head & 0xFF);
    // lower 6-bits == sector, upper 2-bits = cylinder upper 2-bits of 10-bit cylinder #
    partentry.Part_FirstSector = (BYTE)((startAddr.chs.sector & 0x3F) | ((startAddr.chs.cylinder & 0x0300) >> 2));

    // ending address:
    partentry.Part_LastTrack = (BYTE)(endAddr.chs.cylinder & 0xFF);
    partentry.Part_LastHead = (BYTE)(endAddr.chs.head & 0xFF);
    // lower 6-bits == sector, upper 2-bits = cylinder upper 2-bits of 10-bit cylinder #
    partentry.Part_LastSector = (BYTE)((endAddr.chs.sector & 0x3F) | ((endAddr.chs.cylinder & 0x0300) >> 2));

    memcpy(g_pbMBRSector+PARTTABLE_OFFSET+(sizeof(PARTENTRY)*entry), &partentry, sizeof(PARTENTRY));
}



/*  GetPartitionTableIndex
 *
 *  Get the partition index for a particular partition type and active status. 
 *  If partition is not found, then the index of the next free partition in the
 *  partition table of the MBR is returned.
 *  
 *
 *  ENTRY
 *      dwPartType - type of partition 
 *      fActive - TRUE indicates the active partition.  FALSE indicates inactive.
 *
 *  EXIT
 *      pdwIndex - Contains the index of the partition if found.  If not found,
 *          contains the index of the next free partition
 *      returns TRUE if partition found. FALSE if not found.
 */

static BOOL GetPartitionTableIndex (DWORD dwPartType, BOOL fActive, PDWORD pdwIndex)
{
    PPARTENTRY pPartEntry = (PPARTENTRY)(g_pbMBRSector + PARTTABLE_OFFSET);
    DWORD iEntry = 0;
    
    for (iEntry = 0; iEntry < NUM_PARTS; iEntry++, pPartEntry++) {
        if ((pPartEntry->Part_FileSystem == dwPartType) && (((pPartEntry->Part_BootInd & PART_IND_ACTIVE) != 0) == fActive)) {
            *pdwIndex = iEntry;
            return TRUE;
        }
        if (!IsValidPart (pPartEntry)) {
            *pdwIndex = iEntry;
            return FALSE;
        }
    }

    return FALSE;
}

/* WriteLogicalNumbers
 *
 *  Writes a range of logical sector numbers
 *
 *  ENTRY
 *      dwStartSector - starting logical sector
 *      dwNumSectors - number of logical sectors to mark
 *      fReadOnly - TRUE indicates to mark read-only.  FALSE to mark not read-only
 *
 *  EXIT
 *      TRUE on success
 */


static BOOL WriteLogicalNumbers (DWORD dwStartSector, DWORD dwNumSectors, BOOL fReadOnly)
{
    DWORD dwNumSectorsWritten = 0;

    DWORD dwPhysSector = Log2Phys (dwStartSector);
    DWORD dwBlockNum = dwPhysSector / g_FlashInfo.wSectorsPerBlock;
    DWORD dwOffset = dwPhysSector % g_FlashInfo.wSectorsPerBlock;
    
    while (dwNumSectorsWritten < dwNumSectors) {

        // If bad block, move to the next block 
#if 0        
        if (IS_BLOCK_UNUSABLE (dwBlockNum)) {
            dwBlockNum++;
            continue;
        }
#endif

        memset (g_pbBlock, 0xff, g_dwDataBytesPerBlock);
        memset (g_pSectorInfoBuf, 0xff, sizeof(SectorInfo) * g_FlashInfo.wSectorsPerBlock);
        // No need to check return, since a failed read means data hasn't been written yet.
        ReadBlock (dwBlockNum, g_pbBlock, g_pSectorInfoBuf);
        if (!FMD_EraseBlock (dwBlockNum)) {
            return FALSE;
        }

        DWORD dwSectorsToWrite = g_FlashInfo.wSectorsPerBlock - dwOffset;
        PSectorInfo pSectorInfo = g_pSectorInfoBuf + dwOffset;

        // If this is the last block, then calculate sectors to write if there isn't a full block to update
        if ((dwSectorsToWrite + dwNumSectorsWritten) > dwNumSectors)
            dwSectorsToWrite = dwNumSectors - dwNumSectorsWritten;
        
        for (DWORD iSector = 0; iSector < dwSectorsToWrite; iSector++, pSectorInfo++, dwNumSectorsWritten++) {
            // Assert read only by setting bit to 0 to prevent wear-leveling by FAL
            if (fReadOnly)
                pSectorInfo->bOEMReserved &= ~OEM_BLOCK_READONLY;
            // Set to write completed so FAL can map the sector  
            pSectorInfo->wReserved2 &= ~SECTOR_WRITE_COMPLETED;        
            // Write the logical sector number
            pSectorInfo->dwReserved1 = dwStartSector + dwNumSectorsWritten;            
        }

        if (!WriteBlock (dwBlockNum, g_pbBlock, g_pSectorInfoBuf))
            return FALSE; 
        
        dwOffset = 0;
        dwBlockNum++;
    }
    return TRUE;
}



/*  CreatePartition 
 *
 *  Creates a new partition.  If it is a boot section partition, then it formats
 *  flash.
 *
 *  ENTRY
 *      dwStartSector - Logical sector to start the partition.  NEXT_FREE_LOC if  

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久网站热最新地址| 色婷婷久久久综合中文字幕| 日韩国产一二三区| 性久久久久久久| 美女性感视频久久| 青青草国产成人av片免费| 日本中文在线一区| 理论电影国产精品| 国产毛片一区二区| 成人黄色777网| 色综合中文字幕国产 | 麻豆成人久久精品二区三区红| 午夜精品久久久久久不卡8050| 亚洲一级不卡视频| 免费看日韩a级影片| 九色综合狠狠综合久久| 丰满亚洲少妇av| 99久久er热在这里只有精品15 | 欧美伊人精品成人久久综合97| 色成人在线视频| 欧美日韩夫妻久久| 精品国产一区二区精华| 久久久亚洲高清| 亚洲嫩草精品久久| 日韩福利视频导航| 国产精品一二一区| 欧美日韩一二三区| 精品国产污污免费网站入口| 亚洲色图色小说| 日本 国产 欧美色综合| 大胆亚洲人体视频| 欧美久久久久久久久久| 久久综合精品国产一区二区三区 | 白白色 亚洲乱淫| 欧美在线免费播放| 精品久久久久一区二区国产| 一区二区成人在线观看| 蜜桃视频一区二区三区在线观看 | 精一区二区三区| a亚洲天堂av| 欧美一区二区三区四区五区| 国产精品久久久爽爽爽麻豆色哟哟| 香蕉久久一区二区不卡无毒影院 | 日韩高清在线观看| 国产999精品久久久久久绿帽| 欧美揉bbbbb揉bbbbb| 国产日产精品1区| 免费在线观看一区二区三区| 色噜噜狠狠一区二区三区果冻| 精品入口麻豆88视频| 一区二区三区四区亚洲| 国产a精品视频| 日韩午夜激情视频| 亚洲亚洲精品在线观看| 97久久精品人人澡人人爽| 26uuu亚洲婷婷狠狠天堂| 亚洲一级不卡视频| 色综合久久中文字幕| 国产日产欧美精品一区二区三区| 免费观看日韩电影| 欧美日韩情趣电影| 亚洲图片欧美综合| 在线看国产日韩| 亚洲桃色在线一区| 成人18精品视频| 日本一区二区三区高清不卡| 国产一区二三区好的| 日韩精品一区二区三区在线观看| 日本va欧美va瓶| 91麻豆精品国产91久久久更新时间| 亚洲主播在线观看| 色婷婷久久久综合中文字幕| 亚洲精品第1页| 一本色道久久综合狠狠躁的推荐| 亚洲色图在线视频| 日本福利一区二区| 亚洲第一会所有码转帖| 欧美乱妇一区二区三区不卡视频| 亚洲一区二区三区四区不卡| 欧美午夜电影在线播放| 亚洲自拍欧美精品| 91精品午夜视频| 伦理电影国产精品| 久久久久久日产精品| 国产 日韩 欧美大片| 国产精品乱码妇女bbbb| av不卡免费在线观看| 一区二区三区四区不卡在线| 精品污污网站免费看| 视频一区视频二区中文| 精品久久免费看| 成人av动漫网站| 亚洲大片精品永久免费| 日韩一区二区三区电影在线观看 | 国产激情一区二区三区四区| 日本一区二区三区国色天香| 一本色道亚洲精品aⅴ| 亚洲高清久久久| 久久精品视频在线免费观看| 97久久精品人人做人人爽50路| 亚洲午夜久久久久| 精品999久久久| 99久免费精品视频在线观看| 亚洲成人av福利| 精品美女一区二区| 色综合亚洲欧洲| 看电视剧不卡顿的网站| 国产日本欧美一区二区| 91福利精品视频| 国内欧美视频一区二区| 一区二区在线免费| 精品久久人人做人人爰| 欧美伊人精品成人久久综合97| 国产一区二区三区四区五区美女| 亚洲女同一区二区| 亚洲精品一区二区三区影院| 欧美在线视频全部完| 激情小说亚洲一区| 亚洲一区二区三区四区不卡| 亚洲国产精品二十页| 欧美日韩国产影片| 99久久国产综合精品女不卡| 久久99精品国产.久久久久久| 亚洲日本在线视频观看| 精品国产一区二区三区av性色| 欧美午夜精品一区二区蜜桃| 成人v精品蜜桃久久一区| 麻豆国产精品官网| 五月婷婷欧美视频| 亚洲欧美另类图片小说| 精品99999| 日韩精品一区二区三区四区| 欧美久久久一区| 在线亚洲+欧美+日本专区| 国产一区二区电影| 日本少妇一区二区| 亚洲成精国产精品女| 1000部国产精品成人观看| 精品国产三级电影在线观看| 欧美精品久久99| 在线国产亚洲欧美| 91高清视频在线| 欧洲亚洲国产日韩| 91在线高清观看| 91亚洲精品久久久蜜桃| 成人国产精品免费观看| 国产成人免费视频网站高清观看视频 | 一区二区三区四区国产精品| 自拍偷拍欧美激情| 亚洲色图20p| 亚洲一区二区三区四区在线观看| 亚洲男人天堂av网| 一区二区三区四区在线播放 | 99re这里都是精品| 一本一道久久a久久精品综合蜜臀| 99久久精品国产一区二区三区| 成人h版在线观看| 91蜜桃在线观看| 色婷婷精品久久二区二区蜜臂av | 欧美日韩在线播放三区四区| 欧美日韩在线三级| 8x福利精品第一导航| 日韩欧美电影在线| 欧美激情综合五月色丁香小说| 最新热久久免费视频| 亚洲精品国产视频| 日日夜夜精品视频免费| 美国毛片一区二区| 成人午夜在线视频| 色呦呦日韩精品| 91精品国产91热久久久做人人 | 亚洲v日本v欧美v久久精品| 舔着乳尖日韩一区| 国产一区二区精品在线观看| 成人h精品动漫一区二区三区| 欧美日韩视频第一区| 日韩一区二区三区精品视频| 久久精品水蜜桃av综合天堂| 亚洲免费在线视频一区 二区| 亚洲va欧美va人人爽午夜| 麻豆一区二区三区| 成人v精品蜜桃久久一区| 欧美午夜片在线看| 国产亚洲综合在线| 亚洲午夜在线视频| 国产不卡视频在线播放| 欧美综合天天夜夜久久| 精品剧情v国产在线观看在线| 亚洲欧洲在线观看av| 无码av免费一区二区三区试看| 国产成人啪午夜精品网站男同| 欧美午夜精品一区二区蜜桃| 久久久久久久免费视频了| 亚洲国产一区视频| 成人精品视频网站| 日韩三级视频在线看| 亚洲精品美国一| 国产激情偷乱视频一区二区三区| 欧美二区在线观看| 亚洲视频在线观看三级|