Kinetis Bootloader  2.0.0
Common bootloader for Kinetis devices
usb_msd_disk.h
1 /*
2  * Copyright (c) 2013, Freescale Semiconductor, Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without modification,
6  * are permitted provided that the following conditions are met:
7  *
8  * o Redistributions of source code must retain the above copyright notice, this list
9  * of conditions and the following disclaimer.
10  *
11  * o Redistributions in binary form must reproduce the above copyright notice, this
12  * list of conditions and the following disclaimer in the documentation and/or
13  * other materials provided with the distribution.
14  *
15  * o Neither the name of Freescale Semiconductor, Inc. nor the names of its
16  * contributors may be used to endorse or promote products derived from this
17  * software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
23  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
26  * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  */
30 #if !defined(_USB_MSD_DISK_H_)
31 #define _USB_MSD_DISK_H_
32 
33 //#include "bootloader_common.h"
34 #include "fsl_common.h"
35 
38 
39 /*******************************************************************************
40  * Definitions
41  ******************************************************************************/
42 
44 
45 #define U32_LE(n) ((n)&0xff), (((n) >> 8) & 0xff), (((n) >> 16) & 0xff), (((n) >> 24) & 0xff)
47 
49 #define U16_LE(n) ((n)&0xff), (((n) >> 8) & 0xff)
50 
51 
53 enum _disk_constants
54 {
63  kDiskSectorsPerFat = (kDiskDataClusterCount * kDiskFat16EntrySize + kDiskSectorSize - 1) /
65 };
66 
68 enum _sector_numbers
69 {
70  kPbsSector = 0,
81 
83 };
84 
86 #define CLUSTER_FROM_SECTOR(s) (((s)-kFirstClusterSector) / kDiskClusterSize)
87 
89 enum _root_dir_entry_numbers
90 {
91  kInfoFileDirEntry = 11,
92  kStatusFileDirEntry = 12,
93  kFirstUnusedDirEntry = 13
94 };
95 
100 typedef struct SectorInfo
101 {
102  uint32_t sector;
103  const uint8_t *data;
104  uint32_t length;
105 } sector_info_t;
106 
107 /*******************************************************************************
108  * Variables
109  ******************************************************************************/
110 #if defined(__cplusplus)
111 extern "C" {
112 #endif /* __cplusplus */
113 
114 extern const sector_info_t g_msdDiskSectors[];
115 
116 #if defined(__cplusplus)
117 }
118 #endif /* __cplusplus */
119 
121 
122 #endif // _USB_MSD_DISK_H_
First sector available for data.
Definition: usb_msd_disk.h:80
Number of sectors per cluster.
Definition: usb_msd_disk.h:61
Sector number of the first cluster.
Definition: usb_msd_disk.h:82
Sector information.
Definition: msc_disk.h:119
Number of sectors occupied by each FAT, rounded up.
Definition: usb_msd_disk.h:63
Mac OS X '.fseventsd' directory.
Definition: usb_msd_disk.h:75
Size in bytes of each sector of the disk.
Definition: usb_msd_disk.h:55
FAT2 (unused)
Definition: usb_msd_disk.h:72
Windows 8.1 'System Volume Information' directory.
Definition: usb_msd_disk.h:76
Root directory 2 (16 x 32-byte entries)
Definition: usb_msd_disk.h:74
PBS.
Definition: usb_msd_disk.h:59
Size in bytes of the total disk.
Definition: usb_msd_disk.h:57
Root directory 1 (16 x 32-byte entries)
Definition: usb_msd_disk.h:73
Windows 8.1 'IndexerVolumeGuid' file.
Definition: usb_msd_disk.h:77
Partition Boot Sector.
Definition: usb_msd_disk.h:70
Number of SCSI LUNs.
Definition: usb_msd_disk.h:58
Info .txt file.
Definition: usb_msd_disk.h:78
Total number of sectors in the disk.
Definition: usb_msd_disk.h:56
Status .txt file.
Definition: usb_msd_disk.h:79
FAT1.
Definition: usb_msd_disk.h:71
Two bytes per FAT16 entry.
Definition: usb_msd_disk.h:60