diff options
Diffstat (limited to 'firmware/test/fat/fat-fsi_sector.h')
-rw-r--r-- | firmware/test/fat/fat-fsi_sector.h | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/firmware/test/fat/fat-fsi_sector.h b/firmware/test/fat/fat-fsi_sector.h new file mode 100644 index 0000000000..c329148bfa --- /dev/null +++ b/firmware/test/fat/fat-fsi_sector.h | |||
@@ -0,0 +1,80 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2002 by Alan Korr | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | #ifndef __LIBRARY_FAT_FSI_SECTOR_H__ | ||
20 | #define __LIBRARY_FAT_FSI_SECTOR_H__ | ||
21 | |||
22 | // [Alan]: | ||
23 | // I would like to draw your attention about the fact that SH1 | ||
24 | // cannot use misaligned address access so you must be very cautious | ||
25 | // with structures stored in FAT32 partition because they come from | ||
26 | // PC world where misaligned address accesses are usual and not | ||
27 | // problematic. To avoid such a trouble, I decide to use special | ||
28 | // structures where fields are moved in such a way they can be | ||
29 | // accessed by SH1. It is possible thanks to the callback mechanism | ||
30 | // I use for reading or writing from/to an ATA device in ata.h/c. | ||
31 | // So don't be puzzled if those structures seem odd compared | ||
32 | // with the usual ones from PC world. I use this mechanism for structures | ||
33 | // 'partition_info', 'mbr_sector' and 'fsi_sector' for instance, but | ||
34 | // not for structure 'bpb_sector' which is too much complex to handle | ||
35 | // that way, I think. | ||
36 | // By the way, SH1 is big endian, not little endian as PC is. | ||
37 | |||
38 | /////////////////////////////////////////////////////////////////////////////////// | ||
39 | // FSI SECTOR : | ||
40 | /////////////// | ||
41 | // | ||
42 | // | ||
43 | |||
44 | struct __fat_fsi_sector /* File System Info Sector */ | ||
45 | { | ||
46 | unsigned long | ||
47 | left_free_clusters; | ||
48 | unsigned long | ||
49 | next_free_cluster; | ||
50 | short | ||
51 | data[0]; | ||
52 | long /* 0x61415252 - aARR */ | ||
53 | fsi_signature0; | ||
54 | char | ||
55 | reserved0[480]; | ||
56 | long /* 0x41617272 - Aarr */ | ||
57 | fsi_signature1; | ||
58 | short | ||
59 | end0[0]; | ||
60 | char | ||
61 | reserved1[12]; | ||
62 | long /* 0x000055AA */ | ||
63 | signature; | ||
64 | short | ||
65 | end1[0]; | ||
66 | }; | ||
67 | |||
68 | int __fat_get_fsi_sector_callback (struct __fat_fsi_sector *fsi_sector); | ||
69 | int __fat_put_fsi_sector_callback (struct __fat_fsi_sector *fsi_sector); | ||
70 | |||
71 | static inline int __fat_get_fsi_sector (unsigned long partition_start,unsigned long lba,struct __fat_fsi_sector *fsi_sector) | ||
72 | { return ata_read_sectors (partition_start + lba,1,fsi_sector,(int(*)(void *))get_fsi_sector_callback); } | ||
73 | |||
74 | static inline int __fat_put_fsi_sector (unsigned long partition_start,unsigned long lba,struct __fat_fsi_sector *fsi_sector) | ||
75 | { return ata_write_sectors (partition_start + lba,1,fsi_sector,(int(*)(void *))put_fsi_sector_callback); } | ||
76 | |||
77 | // | ||
78 | /////////////////////////////////////////////////////////////////////////////////// | ||
79 | |||
80 | #endif \ No newline at end of file | ||