⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bootpart.h

📁 Embest IDE下s3c2440的测试工程
💻 H
字号:
//
// 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.
//
#ifndef _BOOTPART_H_
#define _BOOTPART_H_
#include "def.h"

//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// end of master boot record contains 4 partition entries
typedef struct _PARTENTRY {
        BYTE            Part_BootInd;           // If 80h means this is boot partition
        BYTE            Part_FirstHead;         // Partition starting head based 0
        BYTE            Part_FirstSector;       // Partition starting sector based 1
        BYTE            Part_FirstTrack;        // Partition starting track based 0
        BYTE            Part_FileSystem;        // Partition type signature field
        BYTE            Part_LastHead;          // Partition ending head based 0
        BYTE            Part_LastSector;        // Partition ending sector based 1
        BYTE            Part_LastTrack;         // Partition ending track based 0
        BYTE           Part_StartSector1;       // Logical starting sector based 0
        BYTE           Part_StartSector2;       // Logical starting sector based 0
        BYTE           Part_StartSector3;       // Logical starting sector based 0
        BYTE           Part_StartSector4;       // Logical starting sector based 0
        BYTE           Part_TotalSectors1;      // Total logical sectors in partition
        BYTE           Part_TotalSectors2;      // Total logical sectors in partition
        BYTE           Part_TotalSectors3;      // Total logical sectors in partition
        BYTE           Part_TotalSectors4;      // Total logical sectors in partition
} PARTENTRY __attribute__ ((aligned(8))) ;

typedef PARTENTRY  *PPARTENTRY;
#define DEFAULT_SECTOR_SIZE             512
#define NUM_PARTS                   4
#define SIZE_END_SIG              2
#define PART_ENTRY_SIG          0xabcdabcd
#define INVALID_ADDR            0xffffffff
#define INVALID_PART             0xffffffff
#define INVALID_HANDLE         (HANDLE)-1
// end of sector - 2 bytes for signature - maximum of 4 16-byte partition records
#define PARTTABLE_OFFSET        (DEFAULT_SECTOR_SIZE - SIZE_END_SIG - (sizeof(PARTENTRY) * NUM_PARTS))

#define SECTOR_WRITE_COMPLETED 0x0004  // Indicates data is valid for the FAL
#define MINIMUM_FLASH_BLOCKS_TO_RESERVE				2
#define PERCENTAGE_OF_MEDIA_TO_RESERVE				400		// 0.25% of the media {NOTE: 100% / 0.25% == 400}
#define NUM_OF_BLOCK_TO_RESERVE						512

typedef struct _PARTSTATE {
        PPARTENTRY  pPartEntry;
        DWORD         dwDataPointer;        // Pointer to where next read and write will occur
} PARTSTATE, *PPARTSTATE;


// Flags for Part_BootInd
#define PART_IND_ACTIVE                      0x1
#define PART_IND_READ_ONLY               0x2
#define PART_IND_HIDDEN                     0x4

// Flags for Part_FileSystem

#define PART_UNKNOWN            0
#define PART_DOS2_FAT           0x01    // legit DOS partition
#define PART_DOS3_FAT           0x04    // legit DOS partition
#define PART_EXTENDED           0x05    // legit DOS partition
#define PART_DOS4_FAT           0x06    // legit DOS partition
#define PART_DOS32              0x0B    // legit DOS partition (FAT32)
#define PART_DOS32X13           0x0C    // Same as 0x0B only "use LBA"
#define PART_DOSX13             0x0E    // Same as 0x06 only "use LBA"
#define PART_DOSX13X            0x0F    // Same as 0x05 only "use LBA"

// CE only partition types for Part_FileSystem

#define PART_CE_HIDDEN          0x18
#define PART_BOOTSECTION        0x20
#define PART_BINFS              0x21    // BINFS file system
#define PART_XIP                0x22    // XIP ROM Image
#define PART_ROMIMAGE           0x22    // XIP ROM Image (same as PART_XIP)
#define PART_RAMIMAGE           0x23    // XIP RAM Image
#define PART_IMGFS              0x25    // IMGFS file system
#define PART_BINARY             0x26    // Raw Binary Data


// Flags for dwCreationFlags
#define     PART_CREATE_NEW          0
#define     PART_OPEN_EXISTING      1
#define     PART_OPEN_ALWAYS        2

// Flags for BP_LowLevelFormat
#define     FORMAT_SKIP_BLOCK_CHECK      0x1
#define     FORMAT_SKIP_RESERVED         0x2

#define NEXT_FREE_LOC -1
#define USE_REMAINING_SPACE -1

#define IS_BLOCK_BAD(blockID) ((FMD_GetBlockStatus (blockID) & BLOCK_STATUS_BAD) > 0)
#define IS_BLOCK_READONLY(blockID) ((FMD_GetBlockStatus (blockID) & BLOCK_STATUS_READONLY) > 0)
#define IS_BLOCK_RESERVED(blockID) ((FMD_GetBlockStatus (blockID) & BLOCK_STATUS_RESERVED) > 0)
#define IS_BLOCK_UNUSABLE(blockID) ((FMD_GetBlockStatus (blockID) & (BLOCK_STATUS_BAD|BLOCK_STATUS_RESERVED)) > 0)

#define IS_PART_READONLY(bootind) ((bootind & PART_IND_READ_ONLY) != 0)


//#ifdef __cplusplus
//extern "C" {
//#endif	// __cplusplus
//
// Bootpart public functions
//
BOOL BP_Init(LPBYTE pMemory, DWORD dwSize); //, LPCTSTR lpActiveReg, PPCI_REG_INFO pRegIn, PPCI_REG_INFO pRegOut);
//HANDLE BP_OpenPartition(DWORD dwStartSector, DWORD dwNumSectors, DWORD dwPartType, BOOL fActive, DWORD dwCreationFlags);
//BOOL   BP_ReadData(HANDLE hPartition, LPBYTE pbBuffer, DWORD dwLength);
//BOOL   BP_WriteData(HANDLE hPartition, LPBYTE pbBuffer, DWORD dwLength);
//BOOL   BP_SetDataPointer (HANDLE hPartition, DWORD dwAddress);
//BOOL   BP_SetPhysDataPointer (HANDLE hPartition, DWORD dwPhysAddress);
//PPARTENTRY BP_GetPartitionInfo (HANDLE hPartition);
BOOL BP_LowLevelFormat(DWORD dwStartBlock, DWORD dwNumBlocks, DWORD dwFlags);
//#ifdef __cplusplus
//}
//#endif	// __cplusplus

#endif	// _BOOTPART_H_

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -