2440 bootloader中,MBR是什么东西?
请教,bootloader中有这么一个函数:
// lqm: 1G08:dwStartSector = 7 * 64 (boot:7个block)HANDLE BP_OpenPartition(DWORD dwStartSector, DWORD dwNumSectors, DWORD dwPartType, BOOL fActive, DWORD dwCreationFlags){ DWORD dwPartIndex; BOOL fExists; ASSERT (g_pbMBRSector); if (!IsValidMBR()) // 这里的目的是什么??? { DWORD dwFlags = 0; if (dwCreationFlags == PART_OPEN_EXISTING) { RETAILMSG(1, (TEXT("OpenPartition: Invalid MBR. Cannot open existing partition 0x%x.\r\n"), dwPartType)); return INVALID_HANDLE_VALUE; } RETAILMSG(1, (TEXT("OpenPartition: Invalid MBR. Formatting flash.\r\n"))); if (g_FlashInfo.flashType == NOR) { dwFlags |= FORMAT_SKIP_BLOCK_CHECK; } BP_LowLevelFormat (0, g_FlashInfo.dwNumBlocks, dwFlags); dwPartIndex = 0; fExists = FALSE; } else { fExists = GetPartitionTableIndex(dwPartType, fActive, &dwPartIndex); } RETAILMSG(1, (TEXT("OpenPartition: Partition Exists=0x%x for part 0x%x.\r\n"), fExists, dwPartType)); if (fExists) { // Partition was found. if (dwCreationFlags == PART_CREATE_NEW) return INVALID_HANDLE_VALUE; if (g_partStateTable[dwPartIndex].pPartEntry == NULL) { // Open partition. If this is the boot section partition, then file pointer starts after MBR g_partStateTable[dwPartIndex].pPartEntry = (PPARTENTRY)(g_pbMBRSector + PARTTABLE_OFFSET + sizeof(PARTENTRY)*dwPartIndex); g_partStateTable[dwPartIndex].dwDataPointer = 0; } return (HANDLE)&g_partStateTable[dwPartIndex]; } else { // If there are already 4 partitions, or creation flag specified OPEN_EXISTING, fail. if ((dwPartIndex == NUM_PARTS) || (dwCreationFlags == PART_OPEN_EXISTING)) return INVALID_HANDLE_VALUE; // Create new partition return CreatePartition (dwStartSector, dwNumSectors, dwPartType, fActive, dwPartIndex); } return INVALID_HANDLE_VALUE; }
static BOOL IsValidMBR() { // Check to see if the MBR is valid // MBR block is always located at logical sector 0 g_dwMBRSectorNum = GetMBRSectorNum(); 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; } // lqm added for test.10-04-12 RETAILMSG (1, (TEXT("g_pbMBRSector[0] = 0x%x\r\n"), g_pbMBRSector[0])); RETAILMSG (1, (TEXT("g_pbMBRSector[1] = 0x%x\r\n"), g_pbMBRSector[1])); RETAILMSG (1, (TEXT("g_pbMBRSector[2] = 0x%x\r\n"), g_pbMBRSector[2])); RETAILMSG (1, (TEXT("g_pbMBRSector[SECTOR_SIZE-2] = 0x%x\r\n"), g_pbMBRSector[SECTOR_SIZE-2])); RETAILMSG (1, (TEXT("g_pbMBRSector[SECTOR_SIZE-1] = 0x%x\r\n"), g_pbMBRSector[SECTOR_SIZE-1])); // end added. 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));}
g_pbMBRSector[0] = 0x0
g_pbMBRSector[1] = 0x0
g_pbMBRSector[2] = 0x0
g_pbMBRSector[SECTOR_SIZE-2] = 0x0
g_pbMBRSector[SECTOR_SIZE-1] = 0x0
为什么这些会是0?错在哪里?
从程序分析,上面两个板的MBR都是放在block0的第0页?????
[解决办法]
建议楼主 好好看看这篇 文章:
http://blog.csdn.net/hugohong/archive/2009/05/20/4204700.aspx