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

📄 fat.h

📁 sd card for pxa270 (在bootloader 下)
💻 H
📖 第 1 页 / 共 2 页
字号:
#ifndef __CF_H__
#define __CF_H__
///////////////////////////////////////////////////
#include <windows.h>

#define ATA_REG_DATA        0
#define ATA_REG_FEATURE     1   // write
#define ATA_REG_ERROR       1   // read
#define ATA_REG_SECT_CNT    2
#define ATA_REG_SECT_NUM    3
#define ATA_REG_CYL_LOW     4
#define ATA_REG_CYL_HIGH    5
#define ATA_REG_DRV_HEAD    6
#define ATA_REG_COMMAND     7   // write
#define ATA_REG_STATUS      7   // read     (reading this acknowledges the interrupt)

#define ATA_ALT_STATUS		14
#define ATA_ALT_DEVCTRL		14


#define ATA_HEAD_MUST_BE_ON         0xA0
#define ATA_CMD_RECALIBRATE         0x10 // move drive heads to track 0
#define ATA_CMD_READ                0x20 // NO retries enabled
#define ATA_CMD_WRITE               0x30 // No retries enabled
#define ATA_CMD_MULTIPLE_READ       0xC4 // No retries enabled
#define ATA_CMD_MULTIPLE_WRITE      0xC5 // No retries enabled
#define ATA_CMD_SET_MULTIPLE        0xC6 // Set Multiple Mode 
#define ATA_CMD_SEEK                0x70
#define ATA_CMD_SET_DRIVE_PARMS     0x91 // set drive parameters
#define ATA_CMD_IDLE                0x97
#define ATA_CMD_IDENTIFY            0xEC // ATA identify drive parameters
#define ATA_CMD_ACKMEDIACHANGE      0xDB // Acknowledge media change
#define ATA_CMD_READ_DMA            0xC8 // DMA Read with retries
#define ATA_CMD_WRITE_DMA           0xCA // DMA Write with retries
//
// ATA device control register bit masks.
//
#define ATA_CTRL_ENABLE_INTR        0x00
#define ATA_CTRL_DISABLE_INTR       0x02
#define ATA_CTRL_RESET              0x04
//
// ATA status register bit masks.
//
#define ATA_STATUS_ERROR            0x01 // error bit in status register
#define ATA_STATUS_CORRECTED_ERROR  0x04 // corrected error in status register
#define ATA_STATUS_DATA_REQ         0x08 // data request bit in status register
#define ATA_STATUS_SEEK_DONE        0x10 // DSC - Drive Seek Complete
#define ATA_STATUS_WRITE_FAULT      0x20 // DWF - Drive Write Fault
#define ATA_STATUS_READY            0x40
#define ATA_STATUS_IDLE             0x50
#define ATA_STATUS_BUSY             0x80

#define ATA_ERROR_GENERAL          0x01
#define ATA_ERROR_ABORTED          0x04
#define ATA_ERROR_BAD_SECT_NUM     0x10
#define ATA_ERROR_UNCORRECTABLE    0x40
#define ATA_ERROR_BAD_BLOCK        0x80

#define ATA_ERR_NONE    0x00                // No Error
#define ATA_ERR_AMNF    0x01                // Address Mark Not Found
#define ATA_ERR_TK0NF   0x02                // Track zero not found
#define ATA_ERR_ABRT    0x04                // Aborted Command
#define ATA_ERR_MCR     0x08                // Media Change Requested
#define ATA_ERR_IDNF    0x10                // ID Not Found
#define ATA_ERR_MC      0x20                // Media Change
#define ATA_ERR_UNC     0x40                // Uncorrectable Data Error
#define ATA_ERR_BBK     0x80                // Bad Block Detected
#define ATA_ERR_PARM    0x100               // Invalid parameter to ATA function
    
#define PARTITION_TABLE_OFFS    0x1be       // Partition table offset in sec 0
#define PART_FAT12  0x01                    // SystemFlag value for 32-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   0xFF7
#define FAT12_CLUSTER_END   0xff8
#define FAT12_CLUSTER_MAX   0xff0

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

#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

//
// Data returned by the ATAPI_CMD_IDENTIFY command
//
#pragma pack(1)
#if 0
typedef struct _IDENTIFY_DATA{
    USHORT GeneralConfiguration;            // 00   Mandatory for ATAPI
    USHORT NumberOfCylinders;               // 01   Not used for ATAPI
    USHORT Reserved1;                       // 02   Not used for ATAPI
    USHORT NumberOfHeads;                   // 03   Not used for ATAPI
    USHORT UnformattedBytesPerTrack;        // 04   Not used for ATAPI
    USHORT UnformattedBytesPerSector;       // 05   Not used for ATAPI
    USHORT SectorsPerTrack;                 // 06   Not used for ATAPI
    USHORT VendorUnique1[3];                // 07-09    Not used for ATAPI
    USHORT SerialNumber[10];                // 10   Optional for ATAPI
    USHORT BufferType;                      // 20   Not used for ATAPI
    USHORT BufferSectorSize;                // 21   Not used for ATAPI
    USHORT NumberOfEccBytes;                // 22   Not used for ATAPI
    USHORT FirmwareRevision[4];             // 23   Mandatory for ATAPI
    USHORT ModelNumber[20];                 // 27   Mandatory for ATAPI
    UCHAR  MaximumBlockTransfer;            // 47 low byte     Not used for ATAPI
    UCHAR  VendorUnique2;                   // 47 high byte    Not used for ATAPI
    USHORT DoubleWordIo;                    // 48   Not used for ATAPI
    USHORT Capabilities;                    // 49   Mandatory for ATAPI
    USHORT Reserved2;                       // 50
    UCHAR  VendorUnique3;                   // 51 low byte      Mandatory for ATAPI
    UCHAR  PioCycleTimingMode;              // 51 high byte     Mandatory for ATAPI
    UCHAR  VendorUnique4;                   // 52 low byte      Mandatory for ATAPI
    UCHAR  DmaCycleTimingMode;              // 52 high byte     Mandatory for ATAPI
    USHORT TranslationFieldsValid;          // 53 (low bit)     Mandatory for ATAPI
    USHORT NumberOfCurrentCylinders;        // 54   Not used for ATAPI
    USHORT NumberOfCurrentHeads;            // 55   Not used for ATAPI
    USHORT CurrentSectorsPerTrack;          // 56   Not used for ATAPI
    ULONG  CurrentSectorCapacity;           // 57 & 58          Not used for ATAPI
    UCHAR  MultiSectorCount;                // 59 low           Not used for ATAPI
    UCHAR  MultiSectorSettingValid;         // 59 high (low bit)Not used for ATAPI
    ULONG  TotalUserAddressableSectors;     // 60 & 61          Not used for ATAPI
    UCHAR  SingleDmaModesSupported;         // 62 low byte      Mandatory for ATAPI
    UCHAR  SingleDmaTransferActive;         // 62 high byte     Mandatory for ATAPI
    UCHAR  MultiDmaModesSupported;          // 63 low byte      Mandatory for ATAPI
    UCHAR  MultiDmaTransferActive;          // 63 high byte     Mandatory for ATAPI
    UCHAR  AdvancedPIOxferreserved;         // 64 low byte      Mandatory for ATAPI
    UCHAR  AdvancedPIOxfer;                 // 64 high byte     Mandatory for ATAPI
    USHORT MinimumMultiwordDMATime;         // 65 Mandatory for ATAPI
    USHORT ManuRecomendedDMATime;           // 66 Mandatory for ATAPI
    USHORT MinimumPIOxferTimeWOFlow;        // 67 Mandatory for ATAPI
    USHORT MinimumPIOxferTimeIORDYFlow;     // 68 Mandatory for ATAPI
    USHORT ReservedADVPIOSupport[2];        // 69 Not used for ATAPI
    USHORT TypicalProcTimeForOverlay;       // 71 Optional for ATAPI
    USHORT TypicalRelTimeForOverlay;        // 72 Optional for ATAPI
    USHORT MajorRevisionNumber;             // 73 Optional for ATAPI
    USHORT MinorRevisionNumber;             // 74 Optional for ATAP  
    USHORT QueueDepth;                      // 75
    USHORT Reserved6[4];                    // 76-79
    USHORT MajorVersionNumber;              // 80
    USHORT MinorVersionNumber;              // 81
    USHORT CommandSetSupported1;            // 82
    USHORT CommandSetSupported2;            // 83
    USHORT CommandSetFeaturesSupported;     // 84
    USHORT CommandSetFeatureEnabled1;       // 85
    USHORT CommandSetFeatureEnabled2;       // 86
    USHORT CommandSetFeatureDefault ;       // 87
    UCHAR  UltraDMASupport;                 // 88 High
    UCHAR  UltraDMAActive;                  // 88 Low
    USHORT TimeRequiredForSecurityErase;    // 89 Time Required For Security Erase Unit Completion
    USHORT TimeReuiregForEnhancedSecurtity; // 90 Time Required For Enhanced Security Erase Unit Completion
    USHORT CurrentAdvancePowerMng;          // 91 CurrentAdvanced Power Managemnt Value
    USHORT MasterPasswordRevisionCode;      // 92 Master Password Revision Code
    USHORT HardwareResetResult;             // 93  Hardware Reset Result
    USHORT Reserved7[33];                   // 94-126

⌨️ 快捷键说明

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