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

📄 mmcfldr.h

📁 老外的一个开源项目
💻 H
字号:
// Copyright (c) David Vescovi.  All rights reserved.
// Part of Project DrumStix
// Windows Embedded Developers Interest Group (WE-DIG) community project.
// http://www.we-dig.org
// Copyright (c) Microsoft Corporation.  All rights reserved.
//------------------------------------------------------------------------------
//
//  File: mmcfldr.h
//
//  This file contains definitions specific to the MMC and CF image loader.
//
//
//------------------------------------------------------------------------------
#ifndef __MMCFLDR_H__
#define __MMCFLDR_H__

#ifdef __cplusplus
extern "C" {
#endif

#include "atapi.h"

typedef struct _ATA_CMDREG {
	UCHAR	Data;                       // Data Register
	union{
		UCHAR   Error;                      // Error Register (read)
		UCHAR   Feature;                    // Feature register (write)
	};
	UCHAR   SecCount;                       // Sector Count
	UCHAR   SecNum;                         // Sector Number
	UCHAR   CylinderLo;                     // Cylinder Number Low
	UCHAR   CylinderHi;                     // Cylinder Number High
	UCHAR   Head;                           // Drive/Head Number
	union{
		UCHAR   Status;                     // Status Register (read)
		UCHAR   Command;                    // Command Register (write)
	};
} ATA_CMDREG;


typedef struct _ATA_CTLREG {
	union {
		UCHAR   AltStatus;                  // Alternate Status Reg. (read)
		UCHAR   DevControl;                 // Device Control Reg. (write)
	};
	UCHAR   Address;                        // Address Register
} ATA_CTLREG;


typedef	struct _PARTITION 
{
	UCHAR	BootFlag;						// Bootable	partition indicator
	UCHAR	Start[3];						// Partition Start Sector
	UCHAR	SystemFlag;						// Partition Type information
	UCHAR	End[3];							// Partition End Sector
	ULONG	StartSector;					// LBA of Start	Sector
	ULONG	NumSectors;						// # of	sectors	in partition
} PARTITION;
	
#define	PARTITION_TABLE_OFFS	0x1be		// Partition table offset in sec 0
#define	PART_FAT12	0x01					// SystemFlag value	for	12-bit FAT
#define	PART_FAT16	0x04					// SystemFlag value	for	16-bit FAT
#define	PART_FATBIG	0x06					// SystemFlag for 16-bit BIGDOS	FAT

#define	FAT12_CLUSTER_BAD	0x0ff7
#define	FAT12_CLUSTER_END	0x0ff8
#define	FAT12_CLUSTER_MAX	0x0ff0

#define	FAT16_CLUSTER_BAD	0xfff7
#define	FAT16_CLUSTER_END	0xfff8
#define	FAT16_CLUSTER_MAX	0xfff0

typedef	struct _BOOTSECT 
{
	UCHAR	x86Jump[3];						// [00]	x86	Jump instruction
	UCHAR	OEMName[8];						// [03]	OEM	Name string
	UCHAR	BytesPerSec[2];					// [0b]	# of bytes per sector
	UCHAR	SecPerAlloc;					// [0d]	Sectors	per	cluster
	USHORT	ResvSectors;					// [0e]	# of reserved sectors
	UCHAR	NumFATs;						// [10]	# of of	FATs
	UCHAR	RootDirEntries[2];				// [11]	# of root directory	entries
	UCHAR	LogSectors[2];					// [13]	# of logical sectors
	UCHAR	MediaDesc;						// [15]	Media Descriptor byte
	USHORT	SectorsPerFAT;					// [16]	# of sectors per FAT
	USHORT	SectorsPerTrack;				// [18]	# of sectors per track
	USHORT	NumHeads;						// [1a]	Number of Heads
	USHORT	HiddenSectors;					// [1c]	Number of Hidden Sectors
} BOOTSECT;

typedef	struct _DIRENTRY 
{
	UCHAR	FileName[8];					// [00]	ASCII File Name
	UCHAR	Extension[3];					// [08]	ASCII File Extension
	UCHAR	Attribute;						// [0b]	Attribute Byte
	UCHAR	Reserved[10];					// [0c]	Reserved Bytes
	USHORT	AccessTime;						// [16]	Time of	Last Access
	USHORT	AccessDate;						// [18]	Date of	Last Access
	USHORT	StartCluster;					// [1a]	Starting Cluster Number
	ULONG	Length;							// [1c]	Length of File
} DIRENTRY;

#define	DIRENT_UNUSED	0x00				// Entry has never been	used
#define	DIRENT_DELETED	0xe5				// Entry has been deleted
#define	DIRENT_E5CHAR	0x05				// First char is 0xe5
#define	DIRENT_DIR		0x2e				// Entry is	a directory
#define	DIRENT_LONG		0x41				// Entry is	long file name type

#define	FATTR_RONLY		0x01				// Read	Only
#define	FATTR_HIDDEN	0x02				// Hidden File
#define	FATTR_SYSTEM	0x04				// System File
#define	FATTR_VOLUME	0x08				// Volume Label
#define	FATTR_DIR		0x10				// Directory
#define	FATTR_ARCHIVE	0x20				// Archive bit
#define	FATTR_LONG		0x0F				// Long	file name attribute

#define DEVICE_TYPE_MMC	1
#define DEVICE_TYPE_CF  2

typedef	struct _MMCF_DEVICE 
{
	ULONG   CmdBase;                        // Command registers port address
	ULONG   CtlBase;                        // Control registers port address
	ULONG	DeviceType;                     // Device type
	USHORT	BytesPerSec;					// # of	bytes per sector
	USHORT	SecPerCluster;					// Size	of each	allocation unit
	USHORT	SecPerTrack;					// # of	sectors	per	track
	USHORT	Heads;							// # of	heads
	USHORT	NumCyl;							// # of	Cylinders

	PARTITION Partition;					// Primary Partition Information
	UCHAR	NumFATs;						// FAT Number from boot	sector
	USHORT	SecPerFAT;						// Sectors per FAT from	boot sector
	USHORT	DirEntries;						// Number of root directory	entries

	volatile char *FATBuf;					// Pointer to the device FAT
	
} MMCF_DEVICE;


#ifdef __cplusplus
}
#endif

#endif __MMCFLDR_H__

⌨️ 快捷键说明

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