summaryrefslogtreecommitdiff
path: root/firmware/test/fat/fat-partition.h
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/test/fat/fat-partition.h')
-rw-r--r--firmware/test/fat/fat-partition.h161
1 files changed, 0 insertions, 161 deletions
diff --git a/firmware/test/fat/fat-partition.h b/firmware/test/fat/fat-partition.h
deleted file mode 100644
index 1b0e363efb..0000000000
--- a/firmware/test/fat/fat-partition.h
+++ /dev/null
@@ -1,161 +0,0 @@
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_PARTITION_H__
20#define __LIBRARY_FAT_PARTITION_H__
21#include <ata/ata.h>
22
23// [Alan]:
24// I would like to draw your attention about the fact that SH1
25// cannot use misaligned address access so you must be very cautious
26// with structures stored in FAT32 partition because they come from
27// PC world where misaligned address accesses are usual and not
28// problematic. To avoid such a trouble, I decide to use special
29// structures where fields are moved in such a way they can be
30// accessed by SH1. It is possible thanks to the callback mechanism
31// I use for reading or writing from/to an ATA device in ata.h/c.
32// So don't be puzzled if those structures seem odd compared
33// with the usual ones from PC world. I use this mechanism for structures
34// 'partition_info', 'mbr_sector' and 'fsi_sector' for instance, but
35// not for structure 'bpb_sector' which is too much complex to handle
36// that way, I think.
37// By the way, SH1 is big endian, not little endian as PC is.
38
39///////////////////////////////////////////////////////////////////////////////////
40// PARTITION INFO :
41///////////////////
42//
43//
44
45struct __fat_partition_info
46 {
47 // Absolute start sector in this partition :
48 // start = start_cylinder * heads * sectors + start_head * sectors + start_sector - 1
49 unsigned long
50 start;
51
52 // Number of sectors in this partition :
53 // sectors = end_cylinder * heads * sectors + end_head * sectors + end_sector - start_sector
54 unsigned long
55 sectors;
56
57 // File system type.
58 // Must be a FAT32 file system type (0x0B or 0x0C)
59 // for Rockbox.
60 char
61 filesystem_type;
62
63 // Is this partition bootable ?
64 // Not used by Rockbox.
65 char
66 bootable;
67
68 // Not used by Rockbox.
69 unsigned char
70 start_head;
71
72 // Not used by Rockbox.
73 unsigned char
74 start_cylinder;
75
76 // Not used by Rockbox.
77 unsigned char
78 start_sector;
79
80 // Not used by Rockbox.
81 unsigned char
82 end_head;
83
84 // Not used by Rockbox.
85 unsigned char
86 end_cylinder;
87
88 // Not used by Rockbox.
89 unsigned char
90 end_sector;
91 };
92
93
94// load partition info into memory
95static inline void __fat_get_partition_info (struct partition_info *__fat_partition_info)
96 {
97 //
98 union { unsigned long si[4]; unsigned short hi[8]; unsigned char qi[16]; } words;
99 short *data = words.hi,*end;
100 for (end = data + 8; data < end; ++data)
101 *data = HI(ATAR_DATA);
102 partition_info->start = swawSI(words.si[2]);
103 partition_info->sectors = swawSI(words.si[3]);
104 partition_info->bootable = words.qi[1];
105 partition_info->filesystem_type = words.qi[5];
106 partition_info->start_head = words.qi[0];
107 partition_info->start_cylinder = words.qi[3];
108 partition_info->start_sector = words.qi[2];
109 partition_info->end_head = words.qi[4];
110 partition_info->end_cylinder = words.qi[7];
111 partition_info->end_sector = words.qi[6];
112 }
113
114// store partition info into harddisk
115static inline void __fat_put_partition_info (struct partition_info *__fat_partition_info)
116 {
117 union { unsigned long si[4]; short hi[8]; unsigned char qi[16]; } words;
118 short *data = words.hi,*end;
119 words.si[2] = swawSI(partition_info->start);
120 words.si[3] = swawSI(partition_info->sectors);
121 words.qi[1] = partition_info->bootable;
122 words.qi[5] = partition_info->filesystem_type;
123 words.qi[0] = partition_info->start_head;
124 words.qi[3] = partition_info->start_cylinder;
125 words.qi[2] = partition_info->start_sector;
126 words.qi[4] = partition_info->end_head;
127 words.qi[7] = partition_info->end_cylinder;
128 words.qi[6] = partition_info->end_sector;
129 for (end = data + 8; data < end;)
130 HI(ATAR_DATA) = *data++;
131 }
132
133//
134///////////////////////////////////////////////////////////////////////////////////
135
136///////////////////////////////////////////////////////////////////////////////////
137// PARTITION TABLE :
138////////////////////
139//
140//
141
142// load the partition table from a mbr sector
143static inline void __fat_get_partition_table (struct partition_info table[4])
144 {
145 struct partition_info *last;
146 for (last = table + 4; table < last;)
147 __fat_get_partition_info (table++);
148 }
149
150// store the partition table into a mbr sector
151static inline void __fat_put_partition_table (struct partition_info const table[4])
152 {
153 struct partition_info const *last;
154 for (last = table + 4; table < last;)
155 __fat_put_partition_info (table++);
156 }
157
158//
159///////////////////////////////////////////////////////////////////////////////////
160
161#endif \ No newline at end of file