4.30.2009

MBR and partition table

Windows CE 有在看 parition table,partition table 的

Disk 的 Driver 要寫好,放在 StorageManager\AutoLoad\
系統啟動後就會自動 load 這個 driver 進來,丟入 disk parameter 要求初始化,
這個 driver 就要讀入 partition table,回應給system。

system 依照 partition table 的內容,filesystem type,load 對應的 driver 進來。

msdn 說 partition table 是 mbr 的一部分,描述 disk 的 partition layout。最多可以包含 4 個 partition。

mbr 會有一個 end mark : 0x55AA。
在這個 end mark 的前面,擺 partition table [4]。

一般的mbr 是 512 bytes,所以parition table 的 offset 就是:
512 - 2 - (16x4) =

partition table 的entry (一個parititon) 的structure 定義在 COMMON\OAK\INC\bootpart.h
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
DWORD Part_StartSector; // Logical starting sector based 0
DWORD Part_TotalSectors; // Total logical sectors in partition
} PARTENTRY;
size是16 bytes.
Part_BootInd 的value 也定義在 bootpart.h;
// Flags for Part_BootInd
#define PART_IND_ACTIVE 0x1
#define PART_IND_READ_ONLY 0x2
#define PART_IND_HIDDEN 0x4

其中Filesystem 定義在 COMMON\OAK\INC\bootpart.h
#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

沒有留言: