usb_msd_disk.h
/*
* Copyright (c) 2013, Freescale Semiconductor, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* o Redistributions of source code must retain the above copyright notice, this list
* of conditions and the following disclaimer.
*
* o Redistributions in binary form must reproduce the above copyright notice, this
* list of conditions and the following disclaimer in the documentation and/or
* other materials provided with the distribution.
*
* o Neither the name of Freescale Semiconductor, Inc. nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if !defined(_USB_MSD_DISK_H_)
#define _USB_MSD_DISK_H_
//#include "bootloader_common.h"
#include "fsl_common.h"
/*******************************************************************************
* Definitions
******************************************************************************/
#define U32_LE(n) ((n)&0xff), (((n) >> 8) & 0xff), (((n) >> 16) & 0xff), (((n) >> 24) & 0xff)
#define U16_LE(n) ((n)&0xff), (((n) >> 8) & 0xff)
enum _disk_constants
{
kDiskSectorSize = 512,
kDiskTotalLogicalBlocks = 2048,
kDiskSizeInBytes = kDiskTotalLogicalBlocks * kDiskSectorSize,
kDiskLogicalUnits = 1,
kDiskHeaderSectorCount = 1,
kDiskFat16EntrySize = 2,
kDiskClusterSize = 1,
kDiskDataClusterCount = (kDiskTotalLogicalBlocks - kDiskHeaderSectorCount) / kDiskClusterSize,
kDiskSectorsPerFat = (kDiskDataClusterCount * kDiskFat16EntrySize + kDiskSectorSize - 1) /
kDiskSectorSize,
};
enum _sector_numbers
{
kPbsSector = 0,
kFat1Sector = kPbsSector + 1,
kFat2Sector = kFat1Sector + kDiskSectorsPerFat,
kRootDir1Sector = kFat2Sector + kDiskSectorsPerFat,
kRootDir2Sector,
kMacFseventsdDirSector,
kWindowsSysVolInfoDirSector,
kWindowsIndexerVolumeGuidSector,
kInfoFileSector,
kStatusFileSector,
kFirstUnusedSector,
kFirstClusterSector = kRootDir1Sector,
};
#define CLUSTER_FROM_SECTOR(s) (((s)-kFirstClusterSector) / kDiskClusterSize)
enum _root_dir_entry_numbers
{
kInfoFileDirEntry = 11,
kStatusFileDirEntry = 12,
kFirstUnusedDirEntry = 13
};
typedef struct SectorInfo
{
uint32_t sector;
const uint8_t *data;
uint32_t length;
} sector_info_t;
/*******************************************************************************
* Variables
******************************************************************************/
#if defined(__cplusplus)
extern "C" {
#endif /* __cplusplus */
extern const sector_info_t g_msdDiskSectors[];
#if defined(__cplusplus)
}
#endif /* __cplusplus */
#endif // _USB_MSD_DISK_H_
kFirstUnusedSector
First sector available for data.
Definition: usb_msd_disk.h:80
kDiskClusterSize
Number of sectors per cluster.
Definition: usb_msd_disk.h:61
kFirstClusterSector
Sector number of the first cluster.
Definition: usb_msd_disk.h:82
sector_info_t
Sector information.
Definition: msc_disk.h:119
kDiskSectorsPerFat
Number of sectors occupied by each FAT, rounded up.
Definition: usb_msd_disk.h:63
kMacFseventsdDirSector
Mac OS X &#39;.fseventsd&#39; directory.
Definition: usb_msd_disk.h:75
kDiskSectorSize
Size in bytes of each sector of the disk.
Definition: usb_msd_disk.h:55
kFat2Sector
FAT2 (unused)
Definition: usb_msd_disk.h:72
kWindowsSysVolInfoDirSector
Windows 8.1 &#39;System Volume Information&#39; directory.
Definition: usb_msd_disk.h:76
kRootDir2Sector
Root directory 2 (16 x 32-byte entries)
Definition: usb_msd_disk.h:74
kDiskHeaderSectorCount
PBS.
Definition: usb_msd_disk.h:59
kDiskSizeInBytes
Size in bytes of the total disk.
Definition: usb_msd_disk.h:57
kRootDir1Sector
Root directory 1 (16 x 32-byte entries)
Definition: usb_msd_disk.h:73
kWindowsIndexerVolumeGuidSector
Windows 8.1 &#39;IndexerVolumeGuid&#39; file.
Definition: usb_msd_disk.h:77
kPbsSector
Partition Boot Sector.
Definition: usb_msd_disk.h:70
kDiskLogicalUnits
Number of SCSI LUNs.
Definition: usb_msd_disk.h:58
kInfoFileSector
Info .txt file.
Definition: usb_msd_disk.h:78
kDiskTotalLogicalBlocks
Total number of sectors in the disk.
Definition: usb_msd_disk.h:56
kStatusFileSector
Status .txt file.
Definition: usb_msd_disk.h:79
kFat1Sector
FAT1.
Definition: usb_msd_disk.h:71
kDiskFat16EntrySize
Two bytes per FAT16 entry.
Definition: usb_msd_disk.h:60