亚洲欧美第一页_禁久久精品乱码_粉嫩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一区二区三区免费野_久草精品视频
欧美国产精品中文字幕| 久久福利资源站| 麻豆精品视频在线观看视频| 波波电影院一区二区三区| 欧美区在线观看| 亚洲天堂精品在线观看| 精品一区二区三区在线播放| 日本高清免费不卡视频| 国产午夜精品福利| 久久国产三级精品| 欧美日韩在线直播| 亚洲人午夜精品天堂一二香蕉| 黑人巨大精品欧美一区| 91精品在线观看入口| 亚洲在线中文字幕| 色婷婷狠狠综合| 国产精品色噜噜| 国产精品99久久久久久似苏梦涵 | 亚洲国产精品久久久久婷婷884| 国产精品18久久久久久久久| 91精品午夜视频| 亚洲成人av福利| 在线视频一区二区三区| 国产精品乱人伦| 成人午夜免费av| 欧美国产一区二区在线观看| 麻豆精品在线观看| 日韩一级高清毛片| 日本成人在线电影网| 欧美日韩第一区日日骚| 视频一区视频二区中文| 欧美日韩一区三区| 午夜亚洲国产au精品一区二区| 99国产精品视频免费观看| 成人欧美一区二区三区视频网页| 风间由美一区二区av101| 国产人久久人人人人爽| 成人午夜激情片| 欧美极品aⅴ影院| av中文字幕在线不卡| 国产精品国产精品国产专区不蜜| 99视频超级精品| 亚洲色大成网站www久久九九| eeuss鲁片一区二区三区在线观看 eeuss鲁片一区二区三区在线看 | 欧美特级限制片免费在线观看| 日韩理论片在线| 欧美色网站导航| 五月天一区二区三区| 欧美第一区第二区| 高清av一区二区| 亚洲精品亚洲人成人网在线播放| 91国偷自产一区二区开放时间 | 国产大陆a不卡| 国产精品―色哟哟| 欧美三级韩国三级日本一级| 日韩高清不卡一区| 久久久久久久精| 一本大道久久a久久精二百 | 国内一区二区在线| 国产精品福利电影一区二区三区四区| 色综合咪咪久久| 青草av.久久免费一区| 欧美不卡在线视频| 不卡大黄网站免费看| 午夜精品一区二区三区免费视频| 日韩三级视频在线看| 成人中文字幕合集| 天天操天天色综合| 国产日韩欧美a| 欧美日韩一区高清| 国产成人在线免费| 视频一区免费在线观看| 久久久精品免费免费| 欧美性色黄大片| 国产精品一区不卡| 日韩av不卡一区二区| 日韩毛片视频在线看| 久久尤物电影视频在线观看| 99久久精品国产一区二区三区 | 在线亚洲欧美专区二区| 青娱乐精品视频在线| 亚洲另类在线一区| 久久众筹精品私拍模特| 欧美综合亚洲图片综合区| 韩国女主播一区二区三区| 亚洲一区二区三区四区五区黄| 久久综合99re88久久爱| 欧美精品一二三| 欧美在线你懂得| 99久久精品国产导航| 国内精品伊人久久久久av影院 | 中文字幕日韩欧美一区二区三区| 日韩精品中午字幕| 欧美日韩综合在线免费观看| 97久久人人超碰| 国产99精品国产| 国产一区二区三区高清播放| 免费成人在线观看视频| 亚洲国产精品影院| 一区二区免费在线播放| 国产精品乱人伦| 欧美激情在线看| 亚洲国产精华液网站w| 亚洲精品在线电影| 精品久久99ma| 日韩精品中文字幕在线一区| 91精品国产综合久久精品性色| 欧美在线一二三| 欧美三级电影网| 欧美在线三级电影| 欧美日韩国产a| 欧美日韩精品一区二区三区四区 | 国产精品久久久久久久裸模| 国产欧美一区二区三区沐欲| 精品国产网站在线观看| 久久午夜免费电影| 久久精品欧美一区二区三区不卡| 日韩欧美视频一区| 欧美成人精品1314www| 精品日韩av一区二区| 精品处破学生在线二十三| 国产午夜亚洲精品午夜鲁丝片 | 91精品国产色综合久久不卡电影 | 在线欧美一区二区| 欧美日韩在线播| 日韩一级片网址| 久久综合九色综合欧美亚洲| 国产欧美一区二区精品性色| 最新热久久免费视频| 亚洲综合色噜噜狠狠| 亚洲va国产va欧美va观看| 日本成人在线不卡视频| 国产精品一区二区在线看| 国产iv一区二区三区| 91性感美女视频| 9191久久久久久久久久久| 精品va天堂亚洲国产| 中文字幕在线不卡一区| 亚洲午夜久久久久久久久电影院 | 99久久久无码国产精品| 精品视频在线免费看| 51精品视频一区二区三区| 精品国产乱子伦一区| 亚洲人成影院在线观看| 日本不卡一二三| 成人高清视频在线观看| 欧美日韩国产综合草草| 国产亚洲成aⅴ人片在线观看| 亚洲精品国产精华液| 久久www免费人成看片高清| 国产**成人网毛片九色| 欧美日韩激情一区二区| 国产欧美一区二区精品忘忧草 | 国产一区二区三区久久久| 色视频欧美一区二区三区| 日韩久久免费av| 亚洲一区二区欧美激情| 国产高清精品网站| 欧美日韩成人高清| 国产精品污污网站在线观看| 日韩av网站在线观看| 99精品久久只有精品| 精品国内片67194| 亚洲国产视频在线| 成人高清视频在线| 欧美成人精品二区三区99精品| 亚洲视频一区在线| 国产精品1区2区3区| 这里是久久伊人| 一区二区国产视频| 99re热视频精品| 亚洲一区二区三区四区在线免费观看| 另类的小说在线视频另类成人小视频在线 | 午夜久久福利影院| 91香蕉视频在线| 亚洲国产精品黑人久久久| 老司机免费视频一区二区| 欧美色手机在线观看| 亚洲六月丁香色婷婷综合久久| 懂色av中文字幕一区二区三区| 日韩欧美一二区| 天堂va蜜桃一区二区三区漫画版| 色婷婷综合久久久久中文一区二区 | 日韩视频免费直播| 五月婷婷久久丁香| 欧美亚洲国产一区二区三区va| 日韩一区在线看| jlzzjlzz欧美大全| 国产精品国产精品国产专区不蜜| 国产一区二区三区视频在线播放| 日韩三级高清在线| 首页亚洲欧美制服丝腿| 欧美三电影在线| 五月天中文字幕一区二区| 欧美另类z0zxhd电影| 丝袜a∨在线一区二区三区不卡 | 色香蕉成人二区免费| 亚洲视频在线观看一区| 色婷婷久久久久swag精品 | 欧美日韩一级黄|