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

📄 uti.h

📁 常见卡(SD,NAND,XD,MS,ATA,CF)完整DRIVER
💻 H
字号:
/*
*******************************************************************************
*                               Magic Pixel
*                  5F, No.3, Creation Road III, Science_Based 
*                   Industrial Park, Hsinchu, Taiwan, R.O.C
*               (c) Copyright 2004, Magic Pixel Inc, Hsinchu, Taiwan
*
* All rights reserved. Magic Pixel's source code is an unpublished work and the 
* use of a copyright notice does not imply otherwise. This source code contains
* confidential, trad secret material. Any attempt or participation in 
* deciphering, decoding, reverse engineering or in ay way altering the source 
* code is strictly prohibited, unless the prior written consent of Magic 
* Pixel is obtained.
*
* Filename      : uti.h
* Programmer(s) : 
* Created       : 
* Descriptions  :
*******************************************************************************
*/
#ifndef	__UTI_H
#define __UTI_H

/*
// Include section 
*/
#include "utiltypedef.h"
#include "mcard.h"
#include "devio.h"
/*
// Constant declarations
*/
#define MCARD_ENABLE            0x00000001
#define MCARD_FIFO_ENABLE       0x00000002
#define MCARD_DMA_CF            0x00000000
#define MCARD_DMA_SM            0x00000004
#define MCARD_DMA_MMC           0x00000008
#define MCARD_DMA_SD            0x0000000c
#define MCARD_DMA_DIR_MC        0x00000000
#define MCARD_DMA_DIR_CM        0x00000010
#define MCARD_MS_P_MODE         0x00000020
#define MCARD_MS_S_MODE         0x00000060
#define MCARD_PHASE_INV         0x00000080
#define MCARD_ATA_ENABLE        0x00000100
#define MCARD_FIFO_EMPTY        0x00000400
#define MCARD_DMA_LIMIT_ENABLE  0x00800000
#define MCARD_WDT_ENABLE        0x00200000

#define MCARD_DMA_ENABLE        0x00000001
#define MCARD_INT_DBFEND_ENABLE 0x01000000

#define MCARD_SECTOR_SIZE       0x200
#define MCARD_SECTOR_BIT_OFFSET 9

#define MCARD_RETRY_TIME    3

/*
// Structure declarations
*/

struct ST_DISK_PARAMETER_TAG
{
    //master boot record information
    BYTE bFatType;
    BYTE bNumFats;
    WORD wNumHeads;
    WORD wTrackSectors;
    WORD wClusterSize;
    WORD wRootEntries;
    WORD wNumFatSectors;
    WORD wReserveSectors;
    WORD wSectorSize;
    DWORD dwHiddenSectors;
    DWORD dwTotalSectors;

    //partition boot record information
    DWORD dwLogTotalSectors; // Total sector from MBR Lba
    DWORD dwLogStartSector; // FAT1 start lba
    DWORD dwLogEndSector;

    WORD wBackupBootSecter;//Lighter 4/13: fat 16 bug fixed
	BYTE bTotalParNum;
	BYTE bParNum;
    DWORD dwParSize;
};

struct ST_PARTITION_TAG		
{
	BYTE bDefaultBootPartion;
	BYTE bStartHead;
	BYTE bStartSector;
	BYTE bStartCylinder;
	BYTE bPartitionType;
	BYTE bEndHead;
	BYTE bEndSector;
	BYTE bEndCylinder;
	BYTE bStartSectorExt[4];
	BYTE bNumSectors[4];
};

struct ST_PARTITION_BOOT_PARAM_TAG
{
	BYTE bJMP[3];
	BYTE bOEMData[8];
	
	BYTE bBytePerSector[2];
	BYTE bSectorPerCluster;
	BYTE bReservedSectors[2];
	BYTE bNumFATs;
	BYTE bRootDirEntries[2];
	BYTE bTotalSectors[2];
	BYTE bMediaIDByte;
	BYTE bNumFATSectors[2];
	BYTE bSectorsPerTrack[2];
	BYTE bNumHeads[2];
	BYTE bHiddenSectors[4];
	BYTE bHugeSectors[4];
	BYTE bBigSectorPerFAT[4];
};

/*
// Type declarations
*/
typedef struct ST_DISK_PARAMETER_TAG ST_DISK_PARAMETER;
typedef struct ST_PARTITION_TAG ST_PARTITION;
typedef struct ST_PARTITION_BOOT_PARAM_TAG ST_PARTITION_BOOT_PARAM;

/*
// Macro declarations
*/		//test MS delay time   //          DWORD i, j; //
#define McardIODelay(DelayCount)                        \
        {                                               \
          volatile DWORD i, j;                          \
          for (i = 0; i < DelayCount; i++)              \
            for (j = 0; j < DelayCount; j++);           \
        }

/*
// Function prototype 
*/
void McardClrInt (void);
BYTE McardGetInt (void);
void McardIsr (void);
void McardSetClock (BYTE bClock);
extern SWORD McardGetParameter (ST_DISK_PARAMETER *sDiskParam, DWORD dwSize);
//extern void McardMakeMbr (ST_DISK_PARAMETER *sDiskParam, BYTE *pbBuffer);//
extern void McardMakeMbr (ST_DISK_PARAMETER *sDiskParam, BYTE *pbBuffer,DWORD dwParNum);//rick 0803
//extern SWORD McardCheckMbr (ST_DISK_PARAMETER *sDiskParam, BYTE *pbBuffer);
extern SWORD MCardCheckMbr (ST_DISK_PARAMETER *sDiskParam, BYTE *pbBuffer,DWORD dwParNum);//rick 0803
extern void McardMakePbr (ST_DISK_PARAMETER *sDiskParam, BYTE *pbBuffer);
extern SWORD McardCheckPbr (ST_DISK_PARAMETER *sDiskParam, BYTE *pbBuffer);
#endif	// __UTI_H

⌨️ 快捷键说明

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