?lang_form? ?lang_select? ?lang_submit? ?lang_endform?
{HEADER END}
{BLAME START}

library

?curdirlinks? -

Blame information for rev 32

Line No. Rev Author Line
1 32 kaklik /******************************************************************************
2 *
3 * Microchip Memory Disk Drive File System
4 *
5 ******************************************************************************
6 * FileName: FSDefs.h
7 * Dependencies: GenericTypeDefs.h
8 * Processor: PIC18/PIC24/dsPIC30/dsPIC33/PIC32
9 * Compiler: C18/C30/C32
10 * Company: Microchip Technology, Inc.
11 *
12 * Software License Agreement
13 *
14 * The software supplied herewith by Microchip Technology Incorporated
15 * (the “Company”) for its PICmicro® Microcontroller is intended and
16 * supplied to you, the Company’s customer, for use solely and
17 * exclusively on Microchip PICmicro Microcontroller products. The
18 * software is owned by the Company and/or its supplier, and is
19 * protected under applicable copyright laws. All rights are reserved.
20 * Any use in violation of the foregoing restrictions may subject the
21 * user to criminal sanctions under applicable laws, as well as to
22 * civil liability for the breach of the terms and conditions of this
23 * license.
24 *
25 * THIS SOFTWARE IS PROVIDED IN AN “AS IS” CONDITION. NO WARRANTIES,
26 * WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED
27 * TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
28 * PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT,
29 * IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR
30 * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
31 *
32 *****************************************************************************/
33 //DOM-IGNORE-BEGIN
34 /********************************************************************
35 Change History:
36 Rev Description
37 ---- -----------------------
38 1.2.4 - 1.2.6 No Change
39 ********************************************************************/
40 //DOM-IGNORE-END
41  
42 #ifndef _FSDEF__H
43 #define _FSDEF__H
44  
45 #include "GenericTypeDefs.h"
46  
47 // Summary: An enumeration used for various error codes.
48 // Description: The CETYPE enumeration is used to indicate different error conditions during device operation.
49 typedef enum _CETYPE
50 {
51 CE_GOOD = 0, // No error
52 CE_ERASE_FAIL, // An erase failed
53 CE_NOT_PRESENT, // No device was present
54 CE_NOT_FORMATTED, // The disk is of an unsupported format
55 CE_BAD_PARTITION, // The boot record is bad
56 CE_UNSUPPORTED_FS, // The file system type is unsupported
57 CE_INIT_ERROR, // An initialization error has occured
58 CE_NOT_INIT, // An operation was performed on an uninitialized device
59 CE_BAD_SECTOR_READ, // A bad read of a sector occured
60 CE_WRITE_ERROR, // Could not write to a sector
61 CE_INVALID_CLUSTER, // Invalid cluster value > maxcls
62 CE_FILE_NOT_FOUND, // Could not find the file on the device
63 CE_DIR_NOT_FOUND, // Could not find the directory
64 CE_BAD_FILE, // File is corrupted
65 CE_DONE, // No more files in this directory
66 CE_COULD_NOT_GET_CLUSTER, // Could not load/allocate next cluster in file
67 CE_FILENAME_2_LONG, // A specified file name is too long to use
68 CE_FILENAME_EXISTS, // A specified filename already exists on the device
69 CE_INVALID_FILENAME, // Invalid file name
70 CE_DELETE_DIR, // The user tried to delete a directory with FSremove
71 CE_DIR_FULL, // All root dir entry are taken
72 CE_DISK_FULL, // All clusters in partition are taken
73 CE_DIR_NOT_EMPTY, // This directory is not empty yet, remove files before deleting
74 CE_NONSUPPORTED_SIZE, // The disk is too big to format as FAT16
75 CE_WRITE_PROTECTED, // Card is write protected
76 CE_FILENOTOPENED, // File not opened for the write
77 CE_SEEK_ERROR, // File location could not be changed successfully
78 CE_BADCACHEREAD, // Bad cache read
79 CE_CARDFAT32, // FAT 32 - card not supported
80 CE_READONLY, // The file is read-only
81 CE_WRITEONLY, // The file is write-only
82 CE_INVALID_ARGUMENT, // Invalid argument
83 CE_TOO_MANY_FILES_OPEN, // Too many files are already open
84 CE_UNSUPPORTED_SECTOR_SIZE // Unsupported sector size
85 } CETYPE;
86  
87  
88 // Summary: A macro indicating a dir entry was found
89 // Description: The FOUND macro indicates that a directory entry was found in the specified position
90 #define FOUND 0
91  
92 // Summary: A macro indicating no dir entry was found
93 // Description: The NOT_FOUND macro indicates that the specified directory entry to load was deleted
94 #define NOT_FOUND 1
95  
96 // Summary: A macro indicating that no more files were found
97 // Description: The NO_MORE macro indicates that there are no more directory entries to search for
98 #define NO_MORE 2
99  
100  
101  
102 // Summary: A macro indicating the device is formatted with FAT12
103 // Description: The FAT12 macro is used to indicate that the file system on the device being accessed is a FAT12 file system.
104 #define FAT12 1
105  
106 // Summary: A macro indicating the device is formatted with FAT16
107 // Description: The FAT16 macro is used to indicate that the file system on the device being accessed is a FAT16 file system.
108 #define FAT16 2
109  
110 // Summary: A macro indicating the device is formatted with FAT32
111 // Description: The FAT32 macro is used to indicate that the file system on the device being accessed is a FAT32 file system.
112 #define FAT32 3
113  
114  
115  
116 // Summary: A read-only attribute macro
117 // Description: A macro for the read-only attribute. A file with this attribute should not be written to. Note that this
118 // attribute will not actually prevent a write to the file; that functionality is operating-system dependant. The
119 // user should take care not to write to a read-only file.
120 #define ATTR_READ_ONLY 0x01
121  
122 // Summary: A hidden attribute macro
123 // Description: A macro for the hidden attribute. A file with this attribute may be hidden from the user, depending on the
124 // implementation of the operating system.
125 #define ATTR_HIDDEN 0x02
126  
127 // Summary: A system attribute macro
128 // Description: A macro for the system attribute. A file with this attribute is used by the operating system, and should not be
129 // modified. Note that this attribute will not actually prevent a write to the file.
130 #define ATTR_SYSTEM 0x04
131  
132 // Summary: A volume attribute macro
133 // Description: A macro for the volume attribute. If the first directory entry in the root directory has the volume attribute set,
134 // the device will use the name in that directory entry as the volume name.
135 #define ATTR_VOLUME 0x08
136  
137 // Summary: A macro for the attributes for a long-file name entry
138 // Description: A macro for the long-name attributes. If a directory entry is used in a long-file name implementation, it will have
139 // all four lower bits set. This indicates that any software that does not support long file names should ignore that
140 // entry.
141 #define ATTR_LONG_NAME 0x0f
142  
143 // Summary: A directory attribute macro
144 // Description: A macro for the directory attribute. If a directory entry has this attribute set, the file it points to is a directory-
145 // type file, and will contain directory entries that point to additional directories or files.
146 #define ATTR_DIRECTORY 0x10
147  
148 // Summary: An archive attribute macro
149 // Description: A macro for the archive attribute. This attribute will indicate to some archiving programs that the file with this
150 // attribute needs to be backed up. Most operating systems create files with the archive attribute set.
151 #define ATTR_ARCHIVE 0x20
152  
153 // Summary: A macro for all attributes
154 // Description: A macro for all attributes. The search functions in this library require an argument that determines which attributes
155 // a file is allowed to have in order to be found. If ATTR_MASK is specified as this argument, any file may be found, regardless
156 // of its attributes.
157 #define ATTR_MASK 0x3f
158  
159  
160  
161 // Summary: A macro to indicate an empty FAT entry
162 // Description: The CLUSTER_EMPTY value is used to indicate that a FAT entry and it's corresponding cluster are available.
163 #define CLUSTER_EMPTY 0x0000
164  
165 // Summary: A macro to indicate the last cluster value for FAT12
166 // Description: The LAST_CLUSTER_FAT12 macro is used when reading the FAT to indicate that the next FAT12 entry for a file contains
167 // the end-of-file value.
168 #define LAST_CLUSTER_FAT12 0xff8
169  
170 // Summary: A macro to indicate the last cluster value for FAT16
171 // Description: The LAST_CLUSTER_FAT16 macro is used when reading the FAT to indicate that the next FAT16 entry for a file contains
172 // the end-of-file value.
173 #define LAST_CLUSTER_FAT16 0xfff8
174  
175 // Summary: A macro to indicate the last allocatable cluster for FAT12
176 // Description: The END_CLUSTER_FAT12 value is used as a comparison in FAT12 to determine that the firmware has reached the end of
177 // the range of allowed allocatable clusters.
178 #define END_CLUSTER_FAT12 0xFF7
179  
180 // Summary: A macro to indicate the last allocatable cluster for FAT16
181 // Description: The END_CLUSTER_FAT16 value is used as a comparison in FAT16 to determine that the firmware has reached the end of
182 // the range of allowed allocatable clusters.
183 #define END_CLUSTER_FAT16 0xFFF7
184  
185 // Summary: A macro to indicate the failure of the ReadFAT function
186 // Description: The CLUSTER_FAIL_FAT16 macro is used by the ReadFAT function to indicate that an error occured reading a FAT12 or FAT16
187 // file allocation table. Note that since '0xFFF8' is used for the last cluster return value in the FAT16 implementation
188 // the end-of-file value '0xFFFF' can be used to indicate an error condition.
189 #define CLUSTER_FAIL_FAT16 0xFFFF
190  
191  
192  
193 #ifdef SUPPORT_FAT32
194 // Summary: A macro to indicate the last cluster value for FAT32
195 // Description: The LAST_CLUSTER_FAT32 macro is used when reading the FAT to indicate that the next FAT32 entry for a file contains
196 // the end-of-file value.
197 #define LAST_CLUSTER_FAT32 0x0FFFFFF8
198  
199 // Summary: A macro to indicate the last allocatable cluster for FAT32
200 // Description: The END_CLUSTER_FAT32 value is used as a comparison in FAT32 to determine that the firmware has reached the end of
201 // the range of allowed allocatable clusters.
202 #define END_CLUSTER_FAT32 0x0FFFFFF7
203  
204 // Summary: A macro to indicate the failure of the ReadFAT function
205 // Description: The CLUSTER_FAIL_FAT32 macro is used by the ReadFAT function to indicate that an error occured reading a FAT32
206 // file allocation able.
207 #define CLUSTER_FAIL_FAT32 0x0FFFFFFF
208  
209 #endif
210  
211 // Summary: A macro indicating the number of bytes in a directory entry.
212 // Description: The NUMBER_OF_BYTES_IN_DIR_ENTRY macro represents the number of bytes in one directory entry. It is used to calculate
213 // the number of sectors in the root directory based on information in the boot sector.
214 #define NUMBER_OF_BYTES_IN_DIR_ENTRY 32
215  
216  
217  
218 // Summary: A macro for a deleted dir entry marker.
219 // Description: The DIR_DEL macro is used to mark a directory entry as deleted. When a file is deleted, this value will replace the
220 // first character in the file name, and will indicate that the file the entry points to was deleted.
221 #define DIR_DEL 0xE5
222  
223 // Summary: A macro for the last dir entry marker.
224 // Description: The DIR_EMPTY macro is used to indicate the last entry in a directory. Since entries in use cannot start with a 0 and
225 // deleted entries start with the DIR_DEL character, a 0 will mark the end of the in-use or previously used group of
226 // entries in a directory
227 #define DIR_EMPTY 0
228  
229  
230  
231 // Summary: A macro used to indicate the length of an 8.3 file name
232 // Description: The DIR_NAMESIZE macro is used when validing the name portion of 8.3 filenames
233 #define DIR_NAMESIZE 8
234  
235 // Summary: A macro used to indicate the length of an 8.3 file extension
236 // Description: The DIR_EXTENSION macro is used when validating the extension portion of 8.3 filenames
237 #define DIR_EXTENSION 3
238  
239 // Summary: A macro used to indicate the length of an 8.3 file name and extension
240 // Description: The DIR_NAMECOMP macro is used when validating 8.3 filenames
241 #define DIR_NAMECOMP (DIR_NAMESIZE+DIR_EXTENSION)
242  
243  
244  
245 // Summary: A macro to write a byte to RAM
246 // Description: The RAMwrite macro is used to write a byte of data to a RAM array
247 #define RAMwrite( a, f, d) *(a+f) = d
248  
249 // Summary: A macro to read a byte from RAM
250 // Description: The RAMread macro is used to read a byte of data from a RAM array
251 #define RAMread( a, f) *(a+f)
252  
253 // Summary: A macro to read a 16-bit word from RAM
254 // Description: The RAMreadW macro is used to read two bytes of data from a RAM array
255 #define RAMreadW( a, f) *(WORD *)(a+f)
256  
257 // Summary: A macro to read a 32-bit word from RAM
258 // Description: The RAMreadD macro is used to read four bytes of data from a RAM array
259 #define RAMreadD( a, f) *(DWORD *)(a+f)
260  
261  
262  
263 #ifndef EOF
264 // Summary: Indicates error conditions or end-of-file conditions
265 // Description: The EOF macro is used to indicate error conditions in some function calls. It is also used to indicate
266 // that the end-of-file has been reached.
267 #define EOF ((int)-1)
268 #endif
269  
270  
271  
272 // Summary: A structure containing information about the device.
273 // Description: The DISK structure contains information about the device being accessed.
274 typedef struct
275 {
276 BYTE * buffer; // Address of the global data buffer used to read and write file information
277 DWORD firsts; // Logical block address of the first sector of the FAT partition on the device
278 DWORD fat; // Logical block address of the FAT
279 DWORD root; // Logical block address of the root directory
280 DWORD data; // Logical block address of the data section of the device.
281 WORD maxroot; // The maximum number of entries in the root directory.
282 DWORD maxcls; // The maximum number of clusters in the partition.
283 DWORD sectorSize; // The size of a sector in bytes
284 DWORD fatsize; // The number of sectors in the FAT
285 BYTE fatcopy; // The number of copies of the FAT in the partition
286 BYTE SecPerClus; // The number of sectors per cluster in the data region
287 BYTE type; // The file system type of the partition (FAT12, FAT16 or FAT32)
288 BYTE mount; // Device mount flag (TRUE if disk was mounted successfully, FALSE otherwise)
289 #if defined __PIC32MX__ || defined __C30__
290 } __attribute__ ((packed)) DISK;
291 #else
292 } DISK;
293 #endif
294  
295  
296 #ifdef __18CXX
297 // Summary: A 24-bit data type
298 // Description: The SWORD macro is used to defined a 24-bit data type. For 16+ bit architectures, this must be represented as
299 // an array of three bytes.
300 typedef unsigned short long SWORD;
301 #else
302 // Summary: A 24-bit data type
303 // Description: The SWORD macro is used to defined a 24-bit data type. For 16+ bit architectures, this must be represented as
304 // an array of three bytes.
305 typedef struct
306 {
307 unsigned char array[3];
308 #if defined __PIC32MX__ || defined __C30__
309 } __attribute__ ((packed)) SWORD;
310 #else
311 } SWORD;
312 #endif
313 #endif
314  
315  
316  
317 // Summary: A structure containing the bios parameter block for a FAT12 file system (in the boot sector)
318 // Description: The _BPB_FAT12 structure provides a layout of the "bios parameter block" in the boot sector of a FAT12 partition.
319 typedef struct {
320 SWORD BootSec_JumpCmd; // Jump Command
321 BYTE BootSec_OEMName[8]; // OEM name
322 WORD BootSec_BPS; // Number of bytes per sector
323 BYTE BootSec_SPC; // Number of sectors per cluster
324 WORD BootSec_ResrvSec; // Number of reserved sectors at the beginning of the partition
325 BYTE BootSec_FATCount; // Number of FATs on the partition
326 WORD BootSec_RootDirEnts; // Number of root directory entries
327 WORD BootSec_TotSec16; // Total number of sectors
328 BYTE BootSec_MDesc; // Media descriptor
329 WORD BootSec_SPF; // Number of sectors per FAT
330 WORD BootSec_SPT; // Number of sectors per track
331 WORD BootSec_HeadCnt; // Number of heads
332 DWORD BootSec_HiddenSecCnt; // Number of hidden sectors
333 DWORD BootSec_Reserved; // Reserved space
334 BYTE BootSec_DriveNum; // Drive number
335 BYTE BootSec_Reserved2; // Reserved space
336 BYTE BootSec_BootSig; // Boot signature - equal to 0x29
337 BYTE BootSec_VolID[4]; // Volume ID
338 BYTE BootSec_VolLabel[11]; // Volume Label
339 BYTE BootSec_FSType[8]; // File system type in ASCII. Not used for determination
340 #if defined __PIC32MX__ || defined __C30__
341 } __attribute__ ((packed)) _BPB_FAT12;
342 #else
343 } _BPB_FAT12;
344 #endif
345  
346 // Summary: A structure containing the bios parameter block for a FAT16 file system (in the boot sector)
347 // Description: The _BPB_FAT16 structure provides a layout of the "bios parameter block" in the boot sector of a FAT16 partition.
348 typedef struct {
349 SWORD BootSec_JumpCmd; // Jump Command
350 BYTE BootSec_OEMName[8]; // OEM name
351 WORD BootSec_BPS; // Number of bytes per sector
352 BYTE BootSec_SPC; // Number of sectors per cluster
353 WORD BootSec_ResrvSec; // Number of reserved sectors at the beginning of the partition
354 BYTE BootSec_FATCount; // Number of FATs on the partition
355 WORD BootSec_RootDirEnts; // Number of root directory entries
356 WORD BootSec_TotSec16; // Total number of sectors
357 BYTE BootSec_MDesc; // Media descriptor
358 WORD BootSec_SPF; // Number of sectors per FAT
359 WORD BootSec_SPT; // Number of sectors per track
360 WORD BootSec_HeadCnt; // Number of heads
361 DWORD BootSec_HiddenSecCnt; // Number of hidden sectors
362 DWORD BootSec_TotSec32; // Total sector count (32 bits)
363 BYTE BootSec_DriveNum; // Drive number
364 BYTE BootSec_Reserved; // Reserved space
365 BYTE BootSec_BootSig; // Boot signature - equal to 0x29
366 BYTE BootSec_VolID[4]; // Volume ID
367 BYTE BootSec_VolLabel[11]; // Volume Label
368 BYTE BootSec_FSType[8]; // File system type in ASCII. Not used for determination
369 #if defined __PIC32MX__ || defined __C30__
370 } __attribute__ ((packed)) _BPB_FAT16;
371 #else
372 } _BPB_FAT16;
373 #endif
374  
375 // Summary: A structure containing the bios parameter block for a FAT32 file system (in the boot sector)
376 // Description: The _BPB_FAT32 structure provides a layout of the "bios parameter block" in the boot sector of a FAT32 partition.
377 typedef struct {
378 SWORD BootSec_jmpBoot; // Jump Command
379 BYTE BootSec_OEMName[8]; // OEM name
380 WORD BootSec_BytsPerSec; // Number of bytes per sector
381 BYTE BootSec_SecPerClus; // Number of sectors per cluster
382 WORD BootSec_RsvdSecCnt; // Number of reserved sectors at the beginning of the partition
383 BYTE BootSec_NumFATs; // Number of FATs on the partition
384 WORD BootSec_RootEntCnt; // Number of root directory entries
385 WORD BootSec_TotSec16; // Total number of sectors
386 BYTE BootSec_Media; // Media descriptor
387 WORD BootSec_FATSz16; // Number of sectors per FAT
388 WORD BootSec_SecPerTrk; // Number of sectors per track
389 WORD BootSec_NumHeads; // Number of heads
390 DWORD BootSec_HiddSec; // Number of hidden sectors
391 DWORD BootSec_TotSec32; // Total sector count (32 bits)
392 DWORD BootSec_FATSz32; // Sectors per FAT (32 bits)
393 WORD BootSec_ExtFlags; // Presently active FAT. Defined by bits 0-3 if bit 7 is 1.
394 WORD BootSec_FSVers; // FAT32 filesystem version. Should be 0:0
395 DWORD BootSec_RootClus; // Start cluster of the root directory (should be 2)
396 WORD BootSec_FSInfo; // File system information
397 WORD BootSec_BkBootSec; // Backup boot sector address.
398 BYTE BootSec_Reserved[12]; // Reserved space
399 BYTE BootSec_DrvNum; // Drive number
400 BYTE BootSec_Reserved1; // Reserved space
401 BYTE BootSec_BootSig; // Boot signature - 0x29
402 BYTE BootSec_VolID[4]; // Volume ID
403 BYTE BootSec_VolLab[11]; // Volume Label
404 BYTE BootSec_FilSysType[8]; // File system type in ASCII. Not used for determination
405 #if defined __PIC32MX__ || defined __C30__
406 } __attribute__ ((packed)) _BPB_FAT32;
407 #else
408 } _BPB_FAT32;
409 #endif
410  
411  
412 // Description: A macro for the boot sector bytes per sector value offset
413 #define BSI_BPS 11
414  
415 // Description: A macro for the boot sector sector per cluster value offset
416 #define BSI_SPC 13
417  
418 // Description: A macro for the boot sector reserved sector count value offset
419 #define BSI_RESRVSEC 14
420  
421 // Description: A macro for the boot sector FAT count value offset
422 #define BSI_FATCOUNT 16
423  
424 // Description: A macro for the boot sector root directory entry count value offset
425 #define BSI_ROOTDIRENTS 17
426  
427 // Description: A macro for the boot sector 16-bit total sector count value offset
428 #define BSI_TOTSEC16 19
429  
430 // Description: A macro for the boot sector sectors per FAT value offset
431 #define BSI_SPF 22
432  
433 // Description: A macro for the boot sector 32-bit total sector count value offset
434 #define BSI_TOTSEC32 32
435  
436 // Description: A macro for the boot sector boot signature offset
437 #define BSI_BOOTSIG 38
438  
439 // Description: A macro for the boot sector file system type string offset
440 #define BSI_FSTYPE 54
441  
442 // Description: A macro for the boot sector 32-bit sector per FAT value offset
443 #define BSI_FATSZ32 36
444  
445 // Description: A macro for the boot sector start cluster of root directory value offset
446 #define BSI_ROOTCLUS 44
447  
448 // Description: A macro for the FAT32 boot sector boot signature offset
449 #define BSI_FAT32_BOOTSIG 66
450  
451 // Description: A macro for the FAT32 boot sector file system type string offset
452 #define BSI_FAT32_FSTYPE 82
453  
454  
455  
456 // Summary: A partition table entry structure.
457 // Description: The PTE_MBR structure contains values found in a partition table entry in the MBR of a device.
458 typedef struct
459 {
460 BYTE PTE_BootDes; // The boot descriptor (should be 0x00 in a non-bootable device)
461 SWORD PTE_FrstPartSect; // The cylinder-head-sector address of the first sector of the partition
462 BYTE PTE_FSDesc; // The file system descriptor
463 SWORD PTE_LstPartSect; // The cylinder-head-sector address of the last sector of the partition
464 DWORD PTE_FrstSect; // The logical block address of the first sector of the partition
465 DWORD PTE_NumSect; // The number of sectors in a partition
466 #if defined __PIC32MX__ || defined __C30__
467 } __attribute__ ((packed)) PTE_MBR;
468 #else
469 } PTE_MBR;
470 #endif
471  
472  
473 // Summary: A structure of the organization of a master boot record.
474 // Description: The _PT_MBR structure has the same form as a master boot record. When the MBR is loaded from the device, it will
475 // be cast as a _PT_MBR structure so the MBR elements can be accessed.
476 typedef struct
477 {
478 BYTE ConsChkRtn[446]; // Boot code
479 PTE_MBR Partition0; // The first partition table entry
480 PTE_MBR Partition1; // The second partition table entry
481 PTE_MBR Partition2; // The third partition table entry
482 PTE_MBR Partition3; // The fourth partition table entry
483 BYTE Signature0; // MBR signature code - equal to 0x55
484 BYTE Signature1; // MBR signature code - equal to 0xAA
485 #if defined __PIC32MX__ || defined __C30__
486 }__attribute__((packed)) _PT_MBR;
487 #else
488 }_PT_MBR;
489 #endif
490  
491 // Summary: A pointer to a _PT_MBR structure
492 // Description: The PT_MBR pointer points to a _PT_MBR structure.
493 typedef _PT_MBR * PT_MBR;
494  
495  
496  
497 // Summary: A structure of the organization of a boot sector.
498 // Description: The _BootSec structure has the same form as a boot sector. When the boot sector is loaded from the device, it will
499 // be cast as a _BootSec structure so the boot sector elements can be accessed.
500 typedef struct
501 {
502 // A union of different bios parameter blocks
503 union
504 {
505 _BPB_FAT32 FAT_32;
506 _BPB_FAT16 FAT_16;
507 _BPB_FAT12 FAT_12;
508 }FAT;
509 BYTE Reserved[512-sizeof(_BPB_FAT32)-2]; // Reserved space
510 BYTE Signature0; // Boot sector signature code - equal to 0x55
511 BYTE Signature1; // Boot sector signature code - equal to 0xAA
512 #if defined __PIC32MX__ || defined __C30__
513 } __attribute__ ((packed)) _BootSec;
514 #else
515 } _BootSec;
516 #endif
517  
518 // Summary: A pointer to a _BootSec structure
519 // Description: The BootSec pointer points to a _BootSec structure.
520 typedef _BootSec * BootSec;
521  
522  
523  
524 // Summary: A macro indicating the offset for the master boot record
525 // Description: FO_MBR is a macro that indicates the addresss of the master boot record on the device. When the device is initialized
526 // this sector will be read
527 #define FO_MBR 0L
528  
529  
530  
531 // Summary: A macro for the first boot sector/MBR signature byte
532 // Description: The FAT_GOOD_SIGN_0 macro is used to determine that the first byte of the MBR or boot sector signature code is correct
533 #define FAT_GOOD_SIGN_0 0x55
534  
535 // Summary: A macro for the second boot sector/MBR signature byte
536 // Description: The FAT_GOOD_SIGN_1 macro is used to determine that the second byte of the MBR or boot sector signature code is correct
537 #define FAT_GOOD_SIGN_1 0xAA
538  
539  
540 typedef struct
541 {
542 BYTE errorCode;
543 union
544 {
545 BYTE value;
546 struct
547 {
548 BYTE sectorSize : 1;
549 BYTE maxLUN : 1;
550 } bits;
551 } validityFlags;
552  
553 WORD sectorSize;
554 BYTE maxLUN;
555 } MEDIA_INFORMATION;
556  
557 typedef enum
558 {
559 MEDIA_NO_ERROR, // No errors
560 MEDIA_DEVICE_NOT_PRESENT, // The requested device is not present
561 MEDIA_CANNOT_INITIALIZE // Cannot initialize media
562 } MEDIA_ERRORS;
563  
564  
565 #endif
{BLAME END}
{FOOTER START}

Powered by WebSVN v2.8.3