summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Korr <alkorr@rockbox.org>2002-04-21 12:21:14 +0000
committerAlan Korr <alkorr@rockbox.org>2002-04-21 12:21:14 +0000
commitb7cf0602fd08f6a367d42f0b6adadb8322b3d35d (patch)
treeabbfb87b615f4c01a5f56eedacd75acbd2e52b87
parent257d17da6d64d2e265df3c80192a01f47e1dd2b7 (diff)
downloadrockbox-b7cf0602fd08f6a367d42f0b6adadb8322b3d35d.tar.gz
rockbox-b7cf0602fd08f6a367d42f0b6adadb8322b3d35d.zip
removing all that stuff permanently.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@159 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/test/fat/config.h26
-rw-r--r--firmware/test/fat/defines.h24
-rw-r--r--firmware/test/fat/fat-bpb_sector.h211
-rw-r--r--firmware/test/fat/fat-fsi_sector.c105
-rw-r--r--firmware/test/fat/fat-fsi_sector.h80
-rw-r--r--firmware/test/fat/fat-mbr_sector.c65
-rw-r--r--firmware/test/fat/fat-mbr_sector.h69
-rw-r--r--firmware/test/fat/fat-partition.h161
-rw-r--r--firmware/test/fat/fat-volume.c355
-rw-r--r--firmware/test/fat/fat.h27
-rw-r--r--firmware/test/fat/functions.h26
-rw-r--r--firmware/test/fat/inlines.h27
-rw-r--r--firmware/test/fat/makefile24
-rw-r--r--firmware/test/fat/return_values.h31
-rw-r--r--firmware/test/fat/types.h43
-rw-r--r--firmware/test/makefile-rules118
-rw-r--r--firmware/test/makefile-vars79
-rw-r--r--firmware/test/memory/config.h27
-rw-r--r--firmware/test/memory/defines.h39
-rw-r--r--firmware/test/memory/functions.h94
-rw-r--r--firmware/test/memory/inlines.h26
-rw-r--r--firmware/test/memory/makefile23
-rw-r--r--firmware/test/memory/memory-block.c76
-rw-r--r--firmware/test/memory/memory-block.txt0
-rw-r--r--firmware/test/memory/memory-misc.c48
-rw-r--r--firmware/test/memory/memory-misc.txt0
-rw-r--r--firmware/test/memory/memory-page.c408
-rw-r--r--firmware/test/memory/memory-page.h59
-rw-r--r--firmware/test/memory/memory-page.txt74
-rw-r--r--firmware/test/memory/memory-slab.c409
-rw-r--r--firmware/test/memory/memory-slab.h62
-rw-r--r--firmware/test/memory/memory-slab.txt0
-rw-r--r--firmware/test/memory/memory.h27
-rw-r--r--firmware/test/memory/return_values.h31
-rw-r--r--firmware/test/memory/test.l23
-rw-r--r--firmware/test/memory/test.y180
-rw-r--r--firmware/test/memory/types.h32
-rw-r--r--firmware/test/template/config.h26
-rw-r--r--firmware/test/template/defines.h24
-rw-r--r--firmware/test/template/functions.h26
-rw-r--r--firmware/test/template/inlines.h26
-rw-r--r--firmware/test/template/makefile23
-rw-r--r--firmware/test/template/return_values.h24
-rw-r--r--firmware/test/template/template.h27
-rw-r--r--firmware/test/template/types.h24
45 files changed, 0 insertions, 3309 deletions
diff --git a/firmware/test/fat/config.h b/firmware/test/fat/config.h
deleted file mode 100644
index 19777df743..0000000000
--- a/firmware/test/fat/config.h
+++ /dev/null
@@ -1,26 +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_H__
20# error "This header file must be included ONLY from fat.h."
21#endif
22#ifndef __LIBRARY_FAT_CONFIG_H__
23# define __LIBRARY_FAT_CONFIG_H__
24# define PACKAGE_NAME "fat"
25# define PACKAGE_VERSION "0.0.0"
26#endif \ No newline at end of file
diff --git a/firmware/test/fat/defines.h b/firmware/test/fat/defines.h
deleted file mode 100644
index c1b824b61c..0000000000
--- a/firmware/test/fat/defines.h
+++ /dev/null
@@ -1,24 +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_H__
20# error "This header file must be included ONLY from fat.h."
21#endif
22#ifndef __LIBRARY_FAT_DEFINES_H__
23# define __LIBRARY_FAT_DEFINES_H__
24#endif \ No newline at end of file
diff --git a/firmware/test/fat/fat-bpb_sector.h b/firmware/test/fat/fat-bpb_sector.h
deleted file mode 100644
index 247f53115c..0000000000
--- a/firmware/test/fat/fat-bpb_sector.h
+++ /dev/null
@@ -1,211 +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_BPB_SECTOR_H__
20#define __LIBRARY_FAT_BPB_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// BPB SECTOR :
40///////////////
41//
42//
43
44struct __fat_bpb_sector /* Bios Parameters Block Sector */
45 {
46 // jmp_boot has two valid ways to look like in a FAT BPB.
47 // Either EBXX90 or E9XXXX.
48 // Not used by Rockbox.
49 unsigned char
50 jmp_boot[3];
51
52 // Creator system of the fat-drive.
53 // Usually looks like "MSWIN4.x".
54 char
55 oem_name[8];
56
57 // It should be 512 if you don't want any trouble
58 // with Rockbox firmware.
59 unsigned char
60 bytes_per_sector[2];
61
62 // Must be a power of two.
63 unsigned char
64 sectors_per_cluster[1];
65
66 // Number of reserved sectors in the reserved region of the volume
67 // starting at the first sector of the volume.
68 // Usually 32 for FAT32.
69 unsigned char
70 reserved_sectors[2];
71
72 // Number of FAT structures.
73 // This value should always be 2.
74 unsigned char
75 number_of_fats[1];
76
77 // For FAT32, this field must be set to zero.
78 // Not used by Rockbox.
79 unsigned char
80 number_of_root_entries[2];
81
82 // Must be zero for FAT32, since the real value
83 // can be found in total_sectors.
84 // Not used by Rockbox.
85 unsigned char
86 total_sectors_16[2];
87
88 // Not used by Rockbox.
89 unsigned char
90 media[1];
91
92 // In FAT32 this must be zero.
93 // Not used by Rockbox.
94 unsigned char
95 sectors_per_fat_16[2];
96
97 // Sectors per track used on this media.
98 // Not used by Rockbox.
99 unsigned char
100 sectors_per_track[2];
101
102 // Number of heads used on this media.
103 // Not used by Rockbox.
104 unsigned char
105 number_of_heads[2];
106
107 // Number of hidden sectors.
108 // Not used by Rockbox.
109 unsigned char
110 hidden_sectors[4];
111
112 // Number of total sectors.
113 // For FAT32 volumes, this must be specified.
114 unsigned char
115 total_sectors[4];
116
117 // Here follows FAT12/16 or FAT32 specific data. */
118
119 // This is the number of sectors for one FAT.
120 unsigned char
121 sectors_per_fat[4];
122
123 // Extended FAT32 flags follow.
124 unsigned char
125 flags[2];
126 // bits 15-8: reserved
127 // mirroring, bit 7:
128 // 0 -> FAT is mirrored at runtime into all FATs.
129 // 1 -> only the one specified in the following field
130 // is active.
131 // Rockbox always sets it.
132 // bits 7-4 : reserved
133 // active_fat, bits 3-0:
134 // this specifies the "active" FAT mentioned previously.
135
136 // This specifies the file system version.
137 // High byte is major number, low byte is minor.
138 // The current version is 0.0.
139 unsigned char
140 filesystem_version[2];
141
142 // This is set to the cluster number of the first cluster
143 // of the root directory. Usually 2, but not required.
144 unsigned char
145 root_cluster[4];
146
147 // This specifies the sector number of the 'FSINFO' structure
148 // in the reserved area.
149 unsigned char
150 filesystem_info[2];
151
152 // If zero, this specifies where the backup of bpb
153 // can be found.
154 // Usually 6.
155 // No value other than 6 is recommended by Microsoft.
156 unsigned char
157 backup_bpb[2];
158
159 // The following area should always be set to zero
160 // when the volume is initialised.
161 unsigned char
162 zeros[12];
163
164 // Drive number for BIOS.
165 // Not used by Rockbox.
166 unsigned char
167 drive_number[0];
168
169 // Reserved for Windows NT.
170 // Should always be set to 0.
171 unsigned char
172 reserved_for_nt[0];
173
174 // Extended boot signature.
175 // If this is 0x29, the following three fields are present.
176 unsigned char
177 boot_signature[0];
178
179 // Volume serial number.
180 unsigned char
181 volume_id[4];
182
183 // Volume label.
184 // This field must be updated when the volume label
185 // in the root directory is updated.
186 char
187 volume_label[11];
188
189 // One of the strings "FAT12", "FAT16" or "FAT32".
190 // This can not be used to determine the type of the FAT,
191 // but it should be updated when creating file systems.
192 char
193 filesystem_type[8];
194
195 char
196 reserved[420];
197
198 long
199 signature;
200 };
201
202static inline int __fat_get_bpb_sector (unsigned long partition_start,unsigned long lba,struct __fat_bpb_sector *bpb_sector)
203 { return ata_read_sectors (partition_start + lba,1,bpb_sector,0); }
204
205static inline int __fat_put_bpb_sector (unsigned long partition_start,unsigned long lba,struct __fat_bpb_sector *bpb_sector)
206 { return FAT_RETURN_SUCCESS && ata_write_sectors (partition_start + lba,1,bpb_sector,0); }
207
208//
209///////////////////////////////////////////////////////////////////////////////////
210
211#endif \ No newline at end of file
diff --git a/firmware/test/fat/fat-fsi_sector.c b/firmware/test/fat/fat-fsi_sector.c
deleted file mode 100644
index 54863dc2a4..0000000000
--- a/firmware/test/fat/fat-fsi_sector.c
+++ /dev/null
@@ -1,105 +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#include <fat.h>
20#include "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
44int __fat_get_fsi_sector_callback (struct __fat_fsi_sector *fsi_sector)
45 {
46 short *data = fsi_sector->data,*end;
47 union { unsigned long si[2]; unsigned short hi[4]; unsigned char qi[8]; } words;
48 for (end = fsi_sector->end0; data < end; ++data)
49 *data = ata_get_word (0);
50#ifdef __little__
51 words.hi[0] = ata_get_word (0);
52 words.hi[1] = ata_get_word (0);
53 words.hi[2] = ata_get_word (0);
54 words.hi[3] = ata_get_word (0);
55#else
56 words.hi[1] = ata_get_word (0);
57 words.hi[0] = ata_get_word (0);
58 words.hi[3] = ata_get_word (0);
59 words.hi[2] = ata_get_word (0);
60#endif
61 for (end = fsi_sector->end1; data < end; ++data)
62 *data = ata_get_word (0);
63#ifdef __little__
64 fsi_sector->left_free_clusters = words.si[0];
65 fsi_sector->next_free_cluster = words.si[1];
66#else
67 fsi_sector->left_free_clusters = swawSI (words.si[0]);
68 fsi_sector->next_free_cluster = swawSI (words.si[1]);
69#endif
70 return ATA_RETURN_SUCCESS;
71 }
72
73int __fat_put_fsi_sector_callback (struct __fat_fsi_sector *fsi_sector)
74 {
75 short *data = fsi_sector->data,*end;
76 union { unsigned long si[2]; unsigned short hi[4]; unsigned char qi[8]; } words;
77#ifdef __little__
78 words.si[0] = swawSI (fsi_sector->left_free_clusters);
79 words.si[1] = swawSI (fsi_sector->next_free_cluster);
80#else
81 words.si[0] = swawSI (fsi_sector->left_free_clusters);
82 words.si[1] = swawSI (fsi_sector->next_free_cluster);
83#endif
84 for (end = fsi_sector->end0; data < end;)
85 ata_put_word (*data++);
86#ifdef __little__
87 ata_put_word (words.hi[0],0);
88 ata_put_word (words.hi[1],0);
89 ata_put_word (words.hi[2],0);
90 ata_put_word (words.hi[3],0);
91#else
92 ata_put_word (words.hi[1],0);
93 ata_put_word (words.hi[0],0);
94 ata_put_word (words.hi[3],0);
95 ata_put_word (words.hi[2],0);
96#endif
97 for (end = fsi_sector->end1; data < end;)
98 ata_put_word (*data++);
99 return ATA_RETURN_SUCCESS;
100 }
101
102//
103///////////////////////////////////////////////////////////////////////////////////
104
105#endif \ No newline at end of file
diff --git a/firmware/test/fat/fat-fsi_sector.h b/firmware/test/fat/fat-fsi_sector.h
deleted file mode 100644
index c329148bfa..0000000000
--- a/firmware/test/fat/fat-fsi_sector.h
+++ /dev/null
@@ -1,80 +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_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
44struct __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
68int __fat_get_fsi_sector_callback (struct __fat_fsi_sector *fsi_sector);
69int __fat_put_fsi_sector_callback (struct __fat_fsi_sector *fsi_sector);
70
71static 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
74static 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
diff --git a/firmware/test/fat/fat-mbr_sector.c b/firmware/test/fat/fat-mbr_sector.c
deleted file mode 100644
index f6b510cea5..0000000000
--- a/firmware/test/fat/fat-mbr_sector.c
+++ /dev/null
@@ -1,65 +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#include <fat.h>
20#include "fat-mbr_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// MBR SECTOR :
40///////////////
41//
42//
43
44int __fat_get_mbr_sector_callback (struct __fat_mbr_sector *mbr_sector)
45 {
46 short *data = mbr_sector->data,*end;
47 for (end = mbr_sector->end; data < end; ++data)
48 *data = ata_get_word (0);
49 __fat_get_partition_table (mbr_sector->partition_table);
50 mbr_sector->signature = HI(ATAR_DATA);
51 return FAT_RETURN_SUCCESS;
52 }
53
54int __fat_put_mbr_sector_callback (struct __fat_mbr_sector *mbr_sector)
55 {
56 short const *data = mbr_sector->data,*end;
57 for (end = mbr_sector->end; data < end;)
58 HI(ATAR_DATA) = *data++;
59 __fat_put_partition_table (mbr_sector->partition_table);
60 ata_put_word (mbr_sector->signature,0);
61 return FAT_RETURN_SUCCESS;
62 }
63
64//
65///////////////////////////////////////////////////////////////////////////////////
diff --git a/firmware/test/fat/fat-mbr_sector.h b/firmware/test/fat/fat-mbr_sector.h
deleted file mode 100644
index 11f131e440..0000000000
--- a/firmware/test/fat/fat-mbr_sector.h
+++ /dev/null
@@ -1,69 +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_MBR_SECTOR_H__
20#define __LIBRARY_FAT_MBR_SECTOR_H__
21#include "fat-partition.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// MBR SECTOR :
41///////////////
42//
43//
44
45struct __fat_mbr_sector /* Master Boot Record Sector */
46 {
47 struct
48 __fat_partition_info partition_table[4];
49 short
50 data[0x1BE/2];
51 short
52 end[0];
53 short
54 signature;
55 };
56
57int __fat_get_mbr_sector_callback (struct __fat_mbr_sector *mbr_sector);
58int __fat_put_mbr_sector_callback (struct __fat_mbr_sector *mbr_sector);
59
60static inline int __fat_get_mbr_sector (struct mbr_sector *__fat_mbr_sector)
61 { return ata_read_sectors (0,1,mbr_sector,(int(*)(void *))__fat_get_mbr_sector_callback); }
62
63static inline int __fat_put_mbr_sector (struct mbr_sector *__fat_mbr_sector)
64 { return ata_write_sectors (0,1,mbr_sector,(int(*)(void *))__fat_put_mbr_sector_callback); }
65
66//
67///////////////////////////////////////////////////////////////////////////////////
68
69#endif \ No newline at end of file
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
diff --git a/firmware/test/fat/fat-volume.c b/firmware/test/fat/fat-volume.c
deleted file mode 100644
index dada78c4e6..0000000000
--- a/firmware/test/fat/fat-volume.c
+++ /dev/null
@@ -1,355 +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#define __LIBRARY_FAT_VOLUME_C__
20
21#include <fat.h>
22#include "fat-mbr_sector.h"
23#include "fat-bpb_sector.h"
24#include "fat-fsi_sector.h"
25
26///////////////////////////////////////////////////////////////////////////////////
27// FAT VOLUME :
28///////////////
29//
30//
31
32// check fsi sector integrity
33static int __fat_check_fsi_sector (struct fat_volume *volume,struct __fat_fsi_sector *fsi_sector,unsigned long lba)
34 {
35 int error;
36 if (!lba)
37 // no FSI sector
38 {
39 volume->next_free_cluster = 2;
40 return FAT_RETURN_SUCCESS;
41 }
42 if ((error = __fat_get_fsi_sector (volume->partition_start,lba,fsi_sector)) > 0)
43 {
44 if ((fsi_sector->signature != 0x0000AA55) ||
45 (fsi_sector->fsi_signature0 != 0x52524161) ||
46 (fsi_sector->fsi_signature1 != 0x72726141))
47 {
48 return FAT_RETURN_BAD_FSI;
49 }
50 if (fsi_sector->left_free_clusters == -1)
51 fsi_sector->next_free_cluster = 2;
52 else if (fsi_sector->next_free_cluster >= volume->sectors_per_fat)
53 return FAT_RETURN_BAD_FSI;
54 volume->next_free_cluster = fsi_sector->next_free_cluster;
55 fsi_sector->left_free_clusters = -1;
56 fsi_sector->next_free_cluster = 2;
57 error = __fat_put_fsi_sector (volume->partition_start,lba,fsi_sector)));
58 }
59 return error;
60 }
61
62static inline int bit_in_range (int value,int min,int max)
63 {
64 for (;min < max; min <<= 1)
65 if (value == min)
66 return 1;
67 return 0;
68 }
69
70// check bpb sector integrity
71static int __fat_check_bpb_sector (struct fat_volume *volume,struct __fat_bpb_sector *bpb_sector,struct __fat_fsi_sector *fsi_sector)
72 {
73 long unsigned bpb_lba = 0,fsi_lba;
74 long unsigned sectors_per_cluster,sectors_per_fat,sectors,reserved_sectors,total_sectors;
75 long unsigned first_cluster_of_root,first_sector_of_fat,first_sector_of_data;
76 long unsigned clusters_per_fat,bytes_per_sector;
77 int error,backup;
78 for (backup = 0; !backup ; backup = 1)
79 {
80 if ((error = __fat_get_bpb_sector (volume->partition_start,bpb_lba,bpb_sector)) > 0)
81 {
82 bytes_per_sector = peekHI (bpb_sector->bytes_per_sector );
83 sectors_per_cluster = peekQI (bpb_sector->sectors_per_cluster);
84 sectors_per_fat = peekSI (bpb_sector->sectors_per_fat );
85 sectors = peekQI (bpb_sector->number_of_fats ) * sectors_per_fat;
86 reserved_sectors = peekHI (bpb_sector->reserved_sectors );
87 total_sectors = peekSI (bpb_sector->total_sectors );
88 first_cluster_of_root = peekSI (bpb_sector->root_cluster );
89 first_sector_of_fat = reserved_sectors + volume->partition_start;
90 first_sector_of_data = first_sector_of_fat + sectors;
91 clusters_per_fat = (total_sectors - first_sector_of_data) / sectors_per_cluster;
92
93 if (!bpb_lba)
94 {
95 bpb_lba = peekHI(bpb_sector->backup_bpb);
96 if (bpb_lba == -1)
97 bpb_lba = 0;
98 }
99
100 if ((bpb_lba >= reserved_sectors) ||
101 (bpb_sector->signature != 0x000055AA) ||
102 (clusters_per_fat < 65525) ||
103 (bytes_per_sector != 512) ||
104 (!bit_in_range (sectors_per_cluster,1,128)) ||
105 (bytes_per_sector * sectors_per_cluster >= 32 KB) ||
106 (peekHI (bpb_sector->total_sectors_16)) ||
107 (peekHI (bpb_sector->sectors_per_fat_16)) ||
108 (peekHI (bpb_sector->number_of_root_entries)) ||
109 ((bpb_sector->media[0] != 0xF0) && (bpb_sector->media[0] < 0xF8)))
110 {
111 error = FAT_RETURN_BAD_BPB;
112 if (bpb_lba) // try with backup BPB sector ?
113 continue;
114 return error;
115 }
116 if ((signed char)bpb_sector->flags[0] >= 0)
117 {
118 bpb_sector->flags[0] = 0x80;
119 if (!backup && (error = __fat_put_bpb_sector (volume->partition_start,0,bpb_sector)) <= 0)
120 return error;
121 if ((error = __fat_put_bpb_sector (volume->partition_start,bpb_lba,bpb_sector)) <= 0)
122 return error;
123 }
124
125 volume->sectors_per_cluster = sectors_per_cluster;
126 volume->sectors_per_fat = sectors_per_fat;
127 volume->first_cluster_of_root = first_cluster_of_root;
128 volume->first_sector_of_fat = first_sector_of_fat;
129 volume->first_sector_of_data = first_sector_of_data;
130 volume->clusters_per_fat = clusters_per_fat;
131
132 fsi_lba = ((long)peekHI(bpb_sector->filesystem_info));
133 if (fsi_lba == -1)
134 fsi_lba = 0;
135 else if (fsi_lba >= reserved_sectors)
136 {
137 error = FAT_RETURN_BAD_FSI;
138 if (bpb_lba) // try with backup BPB sector ?
139 continue;
140 return error;
141 }
142
143 if (((error = __fat_check_fsi_sector (volume,fsi_sector,fsi_lba + (backup ? 0 : bpb_lba))) <= 0) && bpb_lba)
144 continue;
145
146 if (backup)
147 {
148 error = __fat_put_bpb_sector (volume,0,bpb_sector)) <= 0);
149 if (!error)
150 error = __fat_put_fsi_sector (volume,fsi_lba,fsi_sector)) <= 0);
151 }
152
153 break;
154 }
155 }
156 return error;
157 }
158
159static inline int __fat_compare_volume_name (char const *name,struct fat_volume *volume)
160 {
161 return !name ? -1 : strncpy (name,volume->name,11);
162 }
163
164static struct fat_volume *__fat_splay_volume (struct fat_volume *root,char const *name)
165 {
166 struct fat_volume *down;
167 struct fat_volume *less;
168 struct fat_volume *more;
169 struct fat_volume *head[2];
170 ((struct fat_volume *)head)->less =
171 ((struct fat_volume *)head)->more = 0;
172 less =
173 more = head;
174 while (1)
175 {
176 int sign = __fat_compare_volume_name (name,root);
177 if (sign < 0)
178 {
179 if ((down = root->less))
180 {
181 sign = __fat_compare_volume_name (name,down);
182 if (sign < 0)
183 {
184 root->less = down->more;
185 down->more = root;
186 root = down;
187 if (!root->less)
188 break;
189 }
190 more->less = root;
191 more = root;
192 root = root->less;
193 continue;
194 }
195 break;
196 }
197 if (0 < sign)
198 {
199 if ((down = root->more))
200 {
201 sign = __fat_compare_volume_name (name,down);
202 if (0 < sign)
203 {
204 root->more = down->less;
205 down->less = root;
206 root = down;
207 if (!root->more)
208 break;
209 }
210 less->more = root;
211 less = root;
212 root = root->more;
213 continue;
214 }
215 }
216 break;
217 }
218 less->more = root->less;
219 more->less = root->more;
220 root->less = ((struct fat_volume *)head)->more;
221 root->more = ((struct fat_volume *)head)->less;
222 return root;
223 }
224
225static inline struct fat_volume *__fat_insert_volume (struct fat_volume *root,struct fat_volume *node)
226 {
227 if (!root)
228 {
229 node->less =
230 node->more = 0;
231 }
232 else if (node < (root = __fat_splay_volume (root,node->name)))
233 {
234 node->less = root->less;
235 node->more = root;
236 root->less = 0;
237 }
238 else if
239 {
240 node->less = root;
241 node->more = root->more;
242 node->more = 0;
243 }
244 return node;
245 }
246
247#if 0
248static inline struct fat_volume *__fat_remove_volume (struct fat_volume *root,struct memory_free_page *node)
249 {
250 root = __fat_splay_volume (root,node->name);
251 if (root->less)
252 {
253 node = __fat_splay_volume (root->less,node->name);
254 node->more = root->more;
255 }
256 else
257 node = root->more;
258 return node;
259 }
260#endif
261
262static inline struct fat_volume *__fat_lookup_volume (struct fat_volume *root,char const *name)
263 {
264 return __fat_splay_volume (root,0);
265 }
266
267static struct fat_volume *__fat_first_volume (struct fat_volume *root)
268 {
269 struct fat_volume *down;
270 struct fat_volume *less;
271 struct fat_volume *more;
272 struct fat_volume *head[2];
273 ((struct fat_volume *)head)->less =
274 ((struct fat_volume *)head)->more = 0;
275 less =
276 more = &head;
277 if (root)
278 while (1)
279 {
280 if ((down = root->less))
281 {
282 root->less = down->more;
283 down->more = root;
284 root = down;
285 if (!root->less)
286 break;
287 more->less = root;
288 more = root;
289 root = root->less;
290 continue;
291 }
292 break;
293 }
294 less->more = root->less;
295 more->less = root->more;
296 root->less = ((struct fat_volume *)head)->more;
297 root->more = ((struct fat_volume *)head)->less;
298 return root;
299 }
300
301static inline struct fat_volume *__fat_scan_volume (struct fat_volume *root,int next)
302 {
303 return __fat_first_volume (next ? root->more : root,0);
304 }
305
306static int __fat_build_volume_tree (struct fat_volume *root)
307 {
308 struct fat_volume *volume;
309 int number = 4;
310 struct __fat_partition_info *partition_info;
311 struct __fat_mbr_sector mbr_sector;
312 struct __fat_bpb_sector bpb_sector;
313 struct __fat_fsi_sector fsi_sector;
314 if (__fat_get_mbr_sector (&mbr_sector) <= 0)
315 return 0;
316 partition_info = mbr_sector.partition_table;
317 for (;number-- > 0; ++partition_info)
318 {
319 switch (partition_info->filesystem_type)
320 {
321 case 0x05: // extended partition - handle it as well
322 {
323 if (!__fat_build_volume_list (list))
324 return 0;
325 break;
326 }
327 case 0x0B: // FAT32 partitions
328 case 0x0C:
329 {
330 if (!(volume = memory_allocate_page (0)))
331 return 0;
332 volume->next = 0;
333 volume->partition_start = partition_info->start;
334 volume->partition_sectors = partition_info->sectors;
335 if (__fat_check_bpb_sector (volume,&mbr_sector,&fsi_sector) > 0)
336 {
337 dump_volume (volume);
338 *root = volume;
339 list = &volume->next;
340 break;
341 }
342 else
343 memory_release_page (volume,0);
344 }
345 }
346 }
347 return 1;
348 }
349
350static struct fat_volume *__fat_volume_root;
351
352void fat_setup (void)
353 {
354 //build_volume_list (&root);
355 }
diff --git a/firmware/test/fat/fat.h b/firmware/test/fat/fat.h
deleted file mode 100644
index e840f3f862..0000000000
--- a/firmware/test/fat/fat.h
+++ /dev/null
@@ -1,27 +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_H__
20# define __LIBRARY_FAT_H__
21# include <fat/config.h>
22# include <fat/defines.h>
23# include <fat/types.h>
24# include <fat/return_values.h>
25# include <fat/inlines.h>
26# include <fat/functions.h>
27#endif
diff --git a/firmware/test/fat/functions.h b/firmware/test/fat/functions.h
deleted file mode 100644
index 5e8ff24149..0000000000
--- a/firmware/test/fat/functions.h
+++ /dev/null
@@ -1,26 +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_H__
20# error "This header file must be included ONLY from fat.h."
21#endif
22# ifndef __LIBRARY_FAT_FUNCTIONS_H__
23# define __LIBRARY_FAT_FUNCTIONS_H__
24# ifdef TEST
25# endif
26#endif
diff --git a/firmware/test/fat/inlines.h b/firmware/test/fat/inlines.h
deleted file mode 100644
index eb776e9792..0000000000
--- a/firmware/test/fat/inlines.h
+++ /dev/null
@@ -1,27 +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_H__
20# error "This header file must be included ONLY from fat.h."
21#endif
22# ifndef __LIBRARY_FAT_INLINES_H__
23#define __LIBRARY_FAT_INLINES_H__
24
25
26
27#endif \ No newline at end of file
diff --git a/firmware/test/fat/makefile b/firmware/test/fat/makefile
deleted file mode 100644
index 1cd259b52f..0000000000
--- a/firmware/test/fat/makefile
+++ /dev/null
@@ -1,24 +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##############################################################################
19ARCH = test
20PACKAGE = fat
21VERSION = 0.0.0
22-include ../makefile-vars
23-include ../makefile-rules
24
diff --git a/firmware/test/fat/return_values.h b/firmware/test/fat/return_values.h
deleted file mode 100644
index 67747ffc36..0000000000
--- a/firmware/test/fat/return_values.h
+++ /dev/null
@@ -1,31 +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_H__
20# error "This header file must be included ONLY from fat.h."
21#endif
22#ifndef __LIBRARY_FAT_RETURN_VALUES_H__
23# define __LIBRARY_FAT_RETURN_VALUES_H__
24
25enum
26 {
27 FAT_RETURN_SUCCESS = 1,
28 FAT_RETURN_FAILURE = 0
29 };
30
31#endif \ No newline at end of file
diff --git a/firmware/test/fat/types.h b/firmware/test/fat/types.h
deleted file mode 100644
index d83de9e2c1..0000000000
--- a/firmware/test/fat/types.h
+++ /dev/null
@@ -1,43 +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_H__
20# error "This header file must be included ONLY from fat.h."
21#endif
22#ifndef __LIBRARY_FAT_TYPES_H__
23# define __LIBRARY_FAT_TYPES_H__
24
25// [Alan]:
26// I would like to draw your attention about the fact that SH1
27// cannot use misaligned address access so you must be very cautious
28// with structures stored in FAT32 partition because they come from
29// PC world where misaligned address accesses are usual and not
30// problematic. To avoid such a trouble, I decide to use special
31// structures where fields are moved in such a way they can be
32// accessed by SH1. It is possible thanks to the callback mechanism
33// I use for reading or writing from/to an ATA device in ata.h/c.
34// So don't be puzzled if those structures seem odd compared
35// with the usual ones from PC world. I use this mechanism for structures
36// 'partition_info', 'mbr_sector' and 'fsi_sector' for instance, but
37// not for structure 'bpb_sector' which is too much complex to handle
38// that way, I think.
39// By the way, SH1 is big endian, not little endian as PC is.
40
41
42
43#endif \ No newline at end of file
diff --git a/firmware/test/makefile-rules b/firmware/test/makefile-rules
deleted file mode 100644
index 320d05a6c2..0000000000
--- a/firmware/test/makefile-rules
+++ /dev/null
@@ -1,118 +0,0 @@
1#############################################################################
2## __________ __ ___.
3## Open \______ \ ____ ____ | | _\_ |__ _______ ___
4## Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5## Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6## Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7## \/ \/ \/ \/ \/
8## Copyright Alan Korr, 2002. All rights reserved.
9##
10## Permission to use, copy, modify, and distribute this software for any
11## purpose is hereby granted without fee, provided that this copyright and
12## permissions notice appear in all copies and derivatives, and that no
13## charge may be made for the software and its documentation except to cover
14## cost of distribution.
15##
16## This software is provided "as is" without express or implied warranty.
17#############################################################################
18
19#######################################################################
20## PLEASE CONSIDER THERE IS NOTHING TO CHANGE IN THE FOLLOWING LINES
21## SINCE THERE ARE COMMON FOR ALL LIBRARY
22##
23
24.SUFFIXES : .o .c .s
25
26%.o: %.c
27 @echo "Compiling" $<...
28 @$(CC) -o $(@) $(CFLAGS) $(INCLUDES) -c $<
29 @$(CC) -M $< $(CFLAGS) $(INCLUDES) > $(*F).d
30
31%.o: %.s
32 @echo "Assembling" $<...
33 @$(CC) -o $(@) $(CFLAGS) $(INCLUDES) -c $<
34 @$(CC) -M $< $(CFLAGS) $(INCLUDES) > $(*F).d
35
36.PHONY: splash all clean backup restore dist install
37
38all: splash $(LIBRARY) test
39
40splash:
41 @echo "<<< " $(PACKAGE) "-" $(VERSION) ">>>"
42
43####################################################
44# LIBRAY PART :
45
46$(LIBRARY): $(OBJECTS)
47 @echo "Creating library" $(LIBRARY)...
48 @$(AR) cru $(@) $(OBJECTS)
49 @$(RL) $(@)
50
51####################################################
52# TEST PART :
53
54test: test.tab.o test.lex.o $(LIBRARY)
55 @echo "Creating executable" $@...
56 @$(CC) -g -o $(@) $(INCLUDES) $(+) -lfl -lreadline
57
58test.tab.o: test.tab.c
59 @echo "Compiling" $<...
60 @$(CC) $(INCLUDES) $(DEFINES) -g -o $(@) -O3 -fomit-frame-pointer -c test.tab.c
61
62test.lex.o: test.lex.c
63 @echo "Compiling" $<...
64 @$(CC) $(INCLUDES) $(DEFINES) -g -o $(@) -O3 -fomit-frame-pointer -c test.lex.c
65
66test.tab.h: test.tab.c
67
68test.lex.c: test.l test.tab.h
69 @echo "Flex:" $<
70 @flex -otest.lex.c test.l
71
72test.tab.c: test.y
73 @echo "Bison:" $<
74 @bison -d test.y
75
76
77####################################################
78# MISCELLANOUS PART :
79
80clean:
81 @rm -f $(LIBRARY)
82 @rm -f $(OBJECTS) test.lex.o test.tab.o
83 @rm -f $(DEPENDENCIES)
84 @rm -f *~ test test.exe
85 @rm -f test.tab.h test.tab.c test.lex.c
86 @rm -f core
87
88backup:
89 @mkdir -p ./backup
90 @cp -f makefile ./backup
91 @cp -f test.l ./backup
92 @cp -f test.y ./backup
93 @cp -f $(SOURCES:.c=.txt) ./backup
94 @for header in $(HEADERS) ; do cp -f $$header ./backup ; done
95 @for source in $(SOURCES) ; do cp -f $$source ./backup ; done
96
97restore:
98 @cp -f ./backup/makefile .
99 @cp -f ./backup/test.l .
100 @cp -f ./backup/test.y .
101 @cp -f ./backup/$(SOURCES:.c=.txt)
102 @for header in $(HEADERS) ; do cp -f ./backup/$$header . ; done
103 @for source in $(SOURCES) ; do cp -f ./backup/$$source . ; done
104
105dist: backup
106 @mv backup $(PACKAGE)
107 @tar czvf $(PACKAGE)-$(VERSION).tar.gz $(PACKAGE)/*
108 @rm -f $(PACKAGE)/*
109 @rmdir $(PACKAGE)
110
111install: all
112 @mkdir -p $(PREFIX)/libraries
113 @cp $(LIBRARY) $(PREFIX)/libraries
114 @mkdir -p $(PREFIX)/headers/$(PACKAGE)
115 @for header in $(HEADERS) ; do cp $$header $(PREFIX)/headers/$(PACKAGE) ; done
116
117-include $(DEPENDENCIES)
118
diff --git a/firmware/test/makefile-vars b/firmware/test/makefile-vars
deleted file mode 100644
index 719f01dd98..0000000000
--- a/firmware/test/makefile-vars
+++ /dev/null
@@ -1,79 +0,0 @@
1#############################################################################
2## __________ __ ___.
3## Open \______ \ ____ ____ | | _\_ |__ _______ ___
4## Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5## Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6## Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7## \/ \/ \/ \/ \/
8## Copyright Alan Korr, 2002. All rights reserved.
9##
10## Permission to use, copy, modify, and distribute this software for any
11## purpose is hereby granted without fee, provided that this copyright and
12## permissions notice appear in all copies and derivatives, and that no
13## charge may be made for the software and its documentation except to cover
14## cost of distribution.
15##
16## This software is provided "as is" without express or implied warranty.
17#############################################################################
18
19#######################################################################
20## PLEASE CONSIDER THERE IS NOTHING TO CHANGE IN THE FOLLOWING LINES
21## SINCE THERE ARE COMMON FOR ALL LIBRARY
22##
23
24ARCH=test
25
26CC = gcc
27AS = as
28LD = ld
29AR = ar
30RL = ranlib
31OC = objcopy
32GZ = gzip -f
33
34PREFIX = ~/rockbox/$(ARCH)
35DEFINES = -DTEST
36
37CFLAGS = -g
38#CFLAGS += -save-temps
39CFLAGS += -Wall \
40 -W \
41 -Wshadow \
42 -Wpointer-arith \
43 -Waggregate-return \
44 -Wstrict-prototypes \
45 -Wredundant-decls \
46 -Winline \
47 -Wmissing-prototypes \
48 -Werror \
49 -Wsign-compare \
50 -Wmissing-declarations \
51 -Wmissing-noreturns \
52 -Wnested-externs
53CFLAGS += -pipe -O3
54CFLAGS += -fomit-frame-pointer \
55 -fschedule-insns
56CFLAGS += $(EXTRA_CFLAGS)
57CFLAGS += $(DEFINES)
58
59INCLUDES = -I.. \
60 -I. \
61 -I$(PREFIX)/headers
62
63LIBRARY = lib$(PACKAGE).a
64
65HEADERS = $(PACKAGE).h \
66 config.h \
67 defines.h \
68 types.h \
69 return_values.h \
70 inlines.h \
71 functions.h
72
73SOURCES = $(wildcard $(PACKAGE)-*.c)
74
75OBJECTS = $(SOURCES:.c=.o)
76
77DEPENDENCIES = $(SOURCES:.c=.d)
78
79HEADER_PATH = $(PREFIX)/headers/$(PACKAGE)/.
diff --git a/firmware/test/memory/config.h b/firmware/test/memory/config.h
deleted file mode 100644
index aba52b5599..0000000000
--- a/firmware/test/memory/config.h
+++ /dev/null
@@ -1,27 +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_MEMORY_H__
20# error "This header file must be included ONLY from memory.h."
21#endif
22#ifndef __LIBRARY_MEMORY_CONFIG_H__
23# define __LIBRARY_MEMORY_CONFIG_H__
24# define PACKAGE_NAME "memory"
25# define PACKAGE_VERSION "0.1.1"
26# define MEMORY_PAGE_USE_SPLAY_TREE 1
27#endif
diff --git a/firmware/test/memory/defines.h b/firmware/test/memory/defines.h
deleted file mode 100644
index 804731cea3..0000000000
--- a/firmware/test/memory/defines.h
+++ /dev/null
@@ -1,39 +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_MEMORY_H__
20# error "This header file must be included ONLY from memory.h."
21#endif
22#ifndef __LIBRARY_MEMORY_DEFINES_H__
23# define __LIBRARY_MEMORY_DEFINES_H__
24# ifndef MEMORY_PAGE_MINIMAL_ORDER
25# define MEMORY_PAGE_MINIMAL_ORDER (9) /* 512 bytes */
26# endif
27# ifndef MEMORY_PAGE_MAXIMAL_ORDER
28# define MEMORY_PAGE_MAXIMAL_ORDER (21) /* 2 Mbytes */
29# endif
30# ifndef MEMORY_PAGE_MINIMAL_SIZE
31# define MEMORY_PAGE_MINIMAL_SIZE (1 << MEMORY_PAGE_MINIMAL_ORDER)
32# endif
33# ifndef MEMORY_PAGE_MAXIMAL_SIZE
34# define MEMORY_PAGE_MAXIMAL_SIZE (1 << MEMORY_PAGE_MAXIMAL_ORDER)
35# endif
36# define MEMORY_TOTAL_PAGES (MEMORY_PAGE_MAXIMAL_SIZE / MEMORY_PAGE_MINIMAL_SIZE)
37# define MEMORY_TOTAL_BYTES (MEMORY_PAGE_MAXIMAL_SIZE)
38# define MEMORY_TOTAL_ORDERS (1 + MEMORY_PAGE_MAXIMAL_ORDER - MEMORY_PAGE_MINIMAL_ORDER)
39#endif
diff --git a/firmware/test/memory/functions.h b/firmware/test/memory/functions.h
deleted file mode 100644
index c856a934cf..0000000000
--- a/firmware/test/memory/functions.h
+++ /dev/null
@@ -1,94 +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_MEMORY_H__
20# error "This header file must be included ONLY from memory.h."
21#endif
22# ifndef __LIBRARY_MEMORY_FUNCTIONS_H__
23# define __LIBRARY_MEMORY_FUNCTIONS_H__
24
25/////////////////////////////////////////////////////////////////////
26// MEMORY :
27///////////
28
29extern void memory_copy (void *target,void const *source,unsigned int count);
30extern void memory_set (void *target,int byte,unsigned int count);
31
32/////////////////////////////////////////////////////////////////////
33// MEMORY PAGE :
34////////////////
35//
36// - memory_allocate_page : allocate a page
37// - memory_release_page : release a page
38//
39
40extern int memory_release_page (void *address);
41extern void *memory_allocate_page (int order);
42extern void memory_setup (void);
43
44//
45/////////////////////////////////////////////////////////////////////
46
47/////////////////////////////////////////////////////////////////////
48// MEMORY SLAB :
49////////////////
50//
51// - memory_grow_cache : allocate a new slab for a cache
52// - memory_shrink_cache : release free slabs from a cache
53// - memory_create_cache : create a new cache of size-fixed blocks
54// - memory_destroy_cache : destroy the cache and release all the slabs
55// - memory_cache_allocate : allocate a block from the cache
56// - memory_cache_release : release a block in the cache
57//
58
59extern struct memory_slab *memory_grow_cache (struct memory_cache *cache);
60extern int memory_shrink_cache (struct memory_cache *cache,int all);
61extern struct memory_cache *memory_create_cache (unsigned int size,int align,int flags);
62extern int memory_destroy_cache (struct memory_cache *cache);
63extern void *memory_cache_allocate (struct memory_cache *cache);
64extern int memory_cache_release (struct memory_cache *cache,void *address);
65
66//
67/////////////////////////////////////////////////////////////////////
68
69///////////////////////////////////////////////////////////////////////////////
70// MEMORY BLOCK :
71/////////////////
72//
73// - memory_allocate_small_block : allocate a small block (no page)
74// - memory_release_small_block : release a small block (no page)
75// - memory_allocate_block : allocate a block (or a page)
76// - memory_release_block : release a block (or a page)
77//
78
79extern void *memory_allocate_small_block (int order);
80extern int memory_release_small_block (int order,void *address);
81extern void *memory_allocate_block (unsigned int size);
82extern int memory_release_block (void *address);
83
84//
85/////////////////////////////////////////////////////////////////////
86
87
88
89# ifdef TEST
90void memory_spy_page (void *address);
91void memory_dump (int order);
92void memory_check (int order);
93# endif
94#endif
diff --git a/firmware/test/memory/inlines.h b/firmware/test/memory/inlines.h
deleted file mode 100644
index 003c611153..0000000000
--- a/firmware/test/memory/inlines.h
+++ /dev/null
@@ -1,26 +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_MEMORY_H__
20# error "This header file must be included ONLY from memory.h."
21#endif
22# ifndef __LIBRARY_MEMORY_INLINES_H__
23#define __LIBRARY_MEMORY_INLINES_H__
24
25
26#endif
diff --git a/firmware/test/memory/makefile b/firmware/test/memory/makefile
deleted file mode 100644
index 2878500e45..0000000000
--- a/firmware/test/memory/makefile
+++ /dev/null
@@ -1,23 +0,0 @@
1#############################################################################
2## __________ __ ___.
3## Open \______ \ ____ ____ | | _\_ |__ _______ ___
4## Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5## Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6## Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7## \/ \/ \/ \/ \/
8## Copyright Alan Korr, 2002. All rights reserved.
9##
10## Permission to use, copy, modify, and distribute this software for any
11## purpose is hereby granted without fee, provided that this copyright and
12## permissions notice appear in all copies and derivatives, and that no
13## charge may be made for the software and its documentation except to cover
14## cost of distribution.
15##
16## This software is provided "as is" without express or implied warranty.
17#############################################################################
18ARCH = test
19PACKAGE = memory
20VERSION = 0.1.1
21-include ../makefile-vars
22-include ../makefile-rules
23
diff --git a/firmware/test/memory/memory-block.c b/firmware/test/memory/memory-block.c
deleted file mode 100644
index c5cf3ce9f8..0000000000
--- a/firmware/test/memory/memory-block.c
+++ /dev/null
@@ -1,76 +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#if 0
20#include <memory.h>
21#include "memory-page.h"
22#include "memory-slab.h"
23
24static struct memory_cache *__memory_free_block_cache[MEMORY_PAGE_MINIMAL_ORDER - 2];
25
26///////////////////////////////////////////////////////////////////////////////
27// MEMORY BLOCK :
28/////////////////
29//
30// - memory_allocate_block : allocate a power-of-2-sized block (or a page)
31// - memory_release_block : release a power-of-2-sized block (or a page)
32//
33
34static inline void *__memory_allocate_block (int order)
35 {
36 struct memory_cache *cache = __memory_free_block_cache[order - 2];
37 do
38 {
39 if (cache)
40 return memory_cache_allocate (cache);
41 }
42 while ((__memory_free_block_cache[order] = cache = memory_create_cache (size,0,0)));
43 return MEMORY_RETURN_FAILURE;
44 }
45
46void *memory_allocate_block (int order)
47 {
48 if (order < 2)
49 order = 2;
50 if (order < MEMORY_PAGE_MINIMAL_ORDER)
51 return __memory_allocate_block (order);
52 if (order < MEMORY_PAGE_MAXIMAL_ORDER)
53 return memory_allocate_page (order);
54 return MEMORY_RETURN_FAILURE;
55 }
56
57static inline int __memory_release_block (int order,void *address)
58 {
59 struct memory_cache *cache = __memory_free_block_cache[order - 2];
60 if (cache)
61 return memory_cache_release (cache,address);
62 return MEMORY_RETURN_FAILURE;
63 }
64
65int memory_release_block (int order,void *address)
66 {
67 if (order < 2)
68 order = 2;
69 if (order < MEMORY_PAGE_MINIMAL_ORDER)
70 return __memory_release_block (order);
71 if (order < MEMORY_PAGE_MAXIMAL_ORDER)
72 return memory_release_page (address);
73 return MEMORY_RETURN_FAILURE;
74 }
75
76#endif
diff --git a/firmware/test/memory/memory-block.txt b/firmware/test/memory/memory-block.txt
deleted file mode 100644
index e69de29bb2..0000000000
--- a/firmware/test/memory/memory-block.txt
+++ /dev/null
diff --git a/firmware/test/memory/memory-misc.c b/firmware/test/memory/memory-misc.c
deleted file mode 100644
index 765600765b..0000000000
--- a/firmware/test/memory/memory-misc.c
+++ /dev/null
@@ -1,48 +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#include <memory.h>
20#include "memory-page.h"
21#if 0
22#include "memory-slab.h"
23#endif
24
25/* NOT VERY OPTIMIZED AT ALL BUT WE WILL DO IT WHEN PRIORITY COMES */
26void memory_copy (void *target,void const *source,unsigned int count)
27 {
28 while (count--)
29 *((char *)target)++ = *((char const *)source)++;
30 }
31
32/* NOT VERY OPTIMIZED AT ALL BUT WE WILL DO IT WHEN PRIORITY COMES */
33void memory_set (void *target,int byte,unsigned int count)
34 {
35 while (count--)
36 *((char *)target)++ = (char)byte;
37 }
38
39void memory_setup (void)
40 {
41#if 1
42 memory_set (__memory_free_page,0,MEMORY_TOTAL_BYTES);
43 memory_set (__memory_free_page_bin,0,MEMORY_TOTAL_ORDERS *sizeof (struct memory_free_page *));
44 memory_set (__memory_free_page_order + 1,0,MEMORY_TOTAL_PAGES);
45#endif
46 __memory_free_page_order[0] = MEMORY_TOTAL_ORDERS - 1;
47 __memory_free_page_bin[MEMORY_TOTAL_ORDERS - 1] = __memory_free_page;
48 }
diff --git a/firmware/test/memory/memory-misc.txt b/firmware/test/memory/memory-misc.txt
deleted file mode 100644
index e69de29bb2..0000000000
--- a/firmware/test/memory/memory-misc.txt
+++ /dev/null
diff --git a/firmware/test/memory/memory-page.c b/firmware/test/memory/memory-page.c
deleted file mode 100644
index 1327cf57c9..0000000000
--- a/firmware/test/memory/memory-page.c
+++ /dev/null
@@ -1,408 +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#include <memory.h>
20#include "memory-page.h"
21#if 0
22#include "memory-slab.h"
23#endif
24
25#ifdef TEST
26
27// IA32 has no problem with shift operation
28static inline unsigned int __memory_get_size (int order)
29 {
30 return (MEMORY_PAGE_MINIMAL_SIZE << order);
31 }
32
33// Arghhhh ! I cannot align 'free_page' on 512-byte boundary (max is 16-byte for Cygwin)
34static inline struct memory_free_page *__memory_get_neighbour (struct memory_free_page *node,unsigned int size)
35 {
36 return ((struct memory_free_page *)((unsigned)__memory_free_page + (((unsigned)node - (unsigned)__memory_free_page) ^ size)));
37 }
38
39#else
40
41// SH1 has very poor shift instructions (only <<1,>>1,<<2,>>2,<<8,>>8,<<16 and >>16).
42// so we should use a lookup table to speedup.
43static inline unsigned int __memory_get_size (int order)
44 {
45 static unsigned short size [MEMORY_TOTAL_ORDERS] =
46 {
47 1<<MEMORY_PAGE_MINIMAL_ORDER,
48 2<<MEMORY_PAGE_MINIMAL_ORDER,
49 4<<MEMORY_PAGE_MINIMAL_ORDER,
50 8<<MEMORY_PAGE_MINIMAL_ORDER,
51 16<<MEMORY_PAGE_MINIMAL_ORDER,
52 32<<MEMORY_PAGE_MINIMAL_ORDER,
53 64<<MEMORY_PAGE_MINIMAL_ORDER,
54 128<<MEMORY_PAGE_MINIMAL_ORDER,
55 256<<MEMORY_PAGE_MINIMAL_ORDER,
56 512<<MEMORY_PAGE_MINIMAL_ORDER,
57 1024<<MEMORY_PAGE_MINIMAL_ORDER,
58 2048<<MEMORY_PAGE_MINIMAL_ORDER,
59 4096<<MEMORY_PAGE_MINIMAL_ORDER
60 };
61 return size[order];
62 }
63
64static inline struct memory_free_page *__memory_get_neighbour (struct memory_free_page *node,unsigned int size)
65 {
66 return ((struct memory_free_page *)((unsigned)node ^ size));
67 }
68
69#endif
70
71static inline int __memory_get_order (struct memory_free_page *node)
72 {
73 return __memory_free_page_order[node - __memory_free_page];
74 }
75static inline void __memory_set_order (struct memory_free_page *node,int order)
76 {
77 __memory_free_page_order[node - __memory_free_page] = order;
78 }
79
80#if MEMORY_PAGE_USE_SPLAY_TREE
81
82static struct memory_free_page *__memory_splay_page (struct memory_free_page *root,struct memory_free_page *node)
83 {
84 struct memory_free_page *down;
85 struct memory_free_page *less;
86 struct memory_free_page *more;
87 struct memory_free_page head;
88 head.less =
89 head.more = 0;
90 less =
91 more = &head;
92 while (1)
93 {
94 if (node < root)
95 {
96 if ((down = root->less))
97 {
98 if (node < down)
99 {
100 root->less = down->more;
101 down->more = root;
102 root = down;
103 if (!root->less)
104 break;
105 }
106 more->less = root;
107 more = root;
108 root = root->less;
109 continue;
110 }
111 break;
112 }
113 if (root < node)
114 {
115 if ((down = root->more))
116 {
117 if (root < node)
118 {
119 root->more = down->less;
120 down->less = root;
121 root = down;
122 if (!root->more)
123 break;
124 }
125 less->more = root;
126 less = root;
127 root = root->more;
128 continue;
129 }
130 }
131 break;
132 }
133 less->more = root->less;
134 more->less = root->more;
135 root->less = head.more;
136 root->more = head.less;
137 return root;
138 }
139
140static inline void __memory_insert_page (int order,struct memory_free_page *node)
141 {
142 struct memory_free_page *root = __memory_free_page_bin[order];
143 if (!root)
144 {
145 node->less =
146 node->more = 0;
147 }
148 else if (node < (root = __memory_splay_page (root,node)))
149 {
150 node->less = root->less;
151 node->more = root;
152 root->less = 0;
153 }
154 else if (node > root)
155 {
156 node->less = root;
157 node->more = root->more;
158 node->more = 0;
159 }
160 __memory_free_page_bin[order] = node;
161 __memory_set_order (node,order);
162 return;
163 }
164
165static inline struct memory_free_page *__memory_pop_page (int order,int want)
166 {
167 struct memory_free_page *root = __memory_free_page_bin[order];
168 if (root)
169 {
170 root = __memory_splay_page (root,__memory_free_page);
171 __memory_free_page_bin[order] = root->more;
172 __memory_set_order (root,~want);
173 }
174 return root;
175 }
176
177static inline void __memory_remove_page (int order,struct memory_free_page *node)
178 {
179 struct memory_free_page *root = __memory_free_page_bin[order];
180 root = __memory_splay_page (root,node);
181 if (root->less)
182 {
183 node = __memory_splay_page (root->less,node);
184 node->more = root->more;
185 }
186 else
187 node = root->more;
188 __memory_free_page_bin[order] = node;
189 }
190
191#else
192
193static inline void __memory_insert_page (int order,struct memory_free_page *node)
194 {
195 struct memory_free_page *head = __memory_free_page_bin[order];
196 node->less = 0;
197 node->more = head;
198 if (head)
199 head->less = node;
200 __memory_free_page_bin[order] = node;
201 __memory_set_order (node,order);
202 }
203
204static inline struct memory_free_page *pop_page (int order,int want)
205 {
206 struct memory_free_page *node = __memory_free_page_bin[order];
207 if (node)
208 {
209 __memory_free_page_bin[order] = node->more;
210 if (node->more)
211 node->more->less = 0;
212 __memory_set_order (node,~want);
213 }
214 return node;
215 }
216
217static inline void __memory_remove_page (int order,struct memory_free_page *node)
218 {
219 if (node->less)
220 node->less->more = node->more;
221 else
222 __memory_free_page_bin[order] = node->more;
223 if (node->more)
224 node->more->less = node->less;
225 }
226
227#endif
228
229static inline void __memory_push_page (int order,struct memory_free_page *node)
230 {
231 node->less = 0;
232 node->more = 0;
233 __memory_free_page_bin[order] = node;
234 __memory_set_order (node,order);
235 }
236
237static struct memory_free_page *__memory_allocate_page (unsigned int size,int order)
238 {
239 struct memory_free_page *node;
240 int min = order;
241 while ((unsigned)order <= (MEMORY_TOTAL_ORDERS - 1))
242 // order is valid ?
243 {
244 if (!(node = __memory_pop_page (order,min)))
245 // no free page of this order ?
246 {
247 ++order; size <<= 1;
248 continue;
249 }
250 while (order > min)
251 // split our larger page in smaller pages
252 {
253 --order; size >>= 1;
254 __memory_push_page (order,(struct memory_free_page *)((unsigned int)node + size));
255 }
256 return node;
257 }
258 return MEMORY_RETURN_FAILURE;
259 }
260
261static inline void __memory_release_page (struct memory_free_page *node,unsigned int size,int order)
262 {
263 struct memory_free_page *neighbour;
264 while ((order <= (MEMORY_TOTAL_ORDERS - 1)) &&
265 ((neighbour = __memory_get_neighbour (node,size)),
266 (__memory_get_order (neighbour) == order)))
267 // merge our released page with its contiguous page into a larger page
268 {
269 __memory_remove_page (order,neighbour);
270 ++order; size <<= 1;
271 if (neighbour < node)
272 node = neighbour;
273 }
274 __memory_insert_page (order,node);
275 }
276
277
278/*****************************************************************************/
279/* PUBLIC FUNCTIONS */
280/*****************************************************************************/
281
282void *memory_allocate_page (int order)
283 {
284 if (order < 0)
285 return MEMORY_RETURN_FAILURE;
286 return __memory_allocate_page (__memory_get_size (order),order);
287 }
288
289// release a page :
290// when called, 'address' MUST be a valid address pointing
291// to &dram[i], where i ranges from 0 to MEMORY_TOTAL_PAGES - 1.
292// FAILURE if block is already freed.
293int memory_release_page (void *address)
294 {
295 struct memory_free_page *node = (struct memory_free_page *)address;
296 int order = ~__memory_get_order (node);
297 if (order < 0)
298 return MEMORY_RETURN_FAILURE;
299 __memory_release_page (node,__memory_get_size (order),order);
300 return MEMORY_RETURN_SUCCESS;
301 }
302
303
304#ifdef TEST
305# include <stdio.h>
306# include <stdlib.h>
307# if MEMORY_PAGE_USE_SPLAY_TREE
308
309void __memory_dump_splay_node (struct memory_free_page *node,int level)
310 {
311 if (!node)
312 return;
313 __memory_dump_splay_node (node->less,level+1);
314 printf ("\n%*s[%d-%d]",level,"",(node - __memory_free_page),(node - __memory_free_page) + (1 << __memory_get_order (node)) - 1);
315 __memory_dump_splay_node (node->more,level+1);
316 }
317
318void __memory_dump_splay_tree (struct memory_free_page *root)
319 {
320 __memory_dump_splay_node (root,2); fflush (stdout);
321 }
322
323# endif
324
325void __memory_spy_page (void *address)
326 {
327 struct memory_free_page *node = (struct memory_free_page *)address;
328 int order,used;
329 if (node)
330 {
331 order = __memory_get_order (node);
332 used = order < 0;
333 if (used)
334 order = ~order;
335 printf("\n(%s,%2d,%7d)",(used ? "used" : "free"),order,__memory_get_size (order));
336 }
337 }
338
339void __memory_dump (int order)
340 {
341 struct memory_free_page *node = __memory_free_page_bin[order];
342 printf("\n(%s,%2d,%7d)",node ? "free" : "none",order,__memory_get_size (order));
343# if MEMORY_PAGE_USE_SPLAY_TREE
344 __memory_dump_splay_tree (node);
345# else
346 while (node)
347 {
348 printf("[%d-%d]",(node - __memory_free_page),(node - __memory_free_page) + (1<<order) - 1);
349 node = node->more;
350 }
351# endif
352
353 }
354
355void __memory_check (int order)
356 {
357 struct memory_free_page *node[4096],*swap;
358 unsigned int i = 0,j = 0;
359 while (i <= 12)
360 __memory_dump (i++);
361 i = 0;
362 printf ("\nallocating...\n");
363 while (order >= 0)
364 {
365 j = order;
366 while ((swap = memory_allocate_page (j)))
367 {
368 node[i++] = swap;
369 printf("[%d-%d]",(swap - __memory_free_page),(swap - __memory_free_page) + ((1 << j)-1));
370 for (j += (rand () & 15); j > (unsigned int)order; j -= order);
371 }
372 --order;
373 }
374 node[i] = 0;
375 while (j <= 12)
376 __memory_dump (j++);
377 j = 0;
378 printf ("\nreleasing...");
379 --i;
380 while (i > 0)
381 {
382 unsigned int k = 0;
383# if 0
384 printf ("\n");
385# endif
386 swap = node[k++];
387# if 0
388 while (swap)
389 {
390 printf("[%d-%d]",(swap - __memory_free_page),(swap - __memory_free_page) + ((1 << ~__memory_get_order (swap))-1));
391 swap = node[k++];
392 }
393# endif
394 for (j += 1 + (rand () & 15); j >= i; j -= i);
395 swap = node[j];
396 node[j] = node[i];
397 memory_release_page (swap);
398 node[i] = 0;
399 --i;
400 }
401 memory_release_page (node[0]);
402 i = 0;
403 while (i <= 12)
404 __memory_dump (i++);
405 printf("\n\n%s !",(__memory_get_order (__memory_free_page) == 12) ? "SUCCESS" : "FAILURE");
406 }
407
408#endif
diff --git a/firmware/test/memory/memory-page.h b/firmware/test/memory/memory-page.h
deleted file mode 100644
index ab360447d7..0000000000
--- a/firmware/test/memory/memory-page.h
+++ /dev/null
@@ -1,59 +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_MEMORY_PAGE_H__
20#define __LIBRARY_MEMORY_PAGE_H__
21
22struct memory_free_page
23 {
24 struct memory_free_page
25 *less,*more;
26 char
27 reserved[MEMORY_PAGE_MINIMAL_SIZE - 2*sizeof (struct memory_free_page *)];
28 };
29
30#define LESS -1
31#define MORE +1
32
33#ifdef TEST
34
35struct memory_free_page __memory_free_page[MEMORY_TOTAL_PAGES];
36
37#else
38
39extern struct memory_free_page __memory_free_page[MEMORY_TOTAL_PAGES] asm("dram");
40
41#endif
42
43char __memory_free_page_order[MEMORY_TOTAL_PAGES];
44struct memory_free_page *__memory_free_page_bin[MEMORY_TOTAL_ORDERS];
45
46#ifdef TEST
47# if MEMORY_PAGE_USE_SPLAY_TREE
48
49void __memory_dump_splay_node (struct memory_free_page *node,int level);
50void __memory_dump_splay_tree (struct memory_free_page *root);
51
52# endif
53
54void __memory_spy_page (void *address);
55void __memory_dump (int order);
56void __memory_check (int order);
57
58#endif
59#endif \ No newline at end of file
diff --git a/firmware/test/memory/memory-page.txt b/firmware/test/memory/memory-page.txt
deleted file mode 100644
index 03811f9bde..0000000000
--- a/firmware/test/memory/memory-page.txt
+++ /dev/null
@@ -1,74 +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
20Best-fit via binning represent the main ideas of the algorithm.
21
22The memory-page allocator uses an array which contains the power-of-two
23orders of each free or used pages to retrieve their sizes.
24
25Available pages are maintained in bins, grouped by size. Depending on
26its size, a free page is stored in the bin corresponding to the correct
27size range (bins are detailed further): 512 B, 1 KB, 2 KB, 4 KB, 8 KB,
2816 KB, 32 KB, 64 KB, 128 KB, 256 KB, 512 KB, 1 MB or 2 MB.
29
30Searches for available pages are processed in smallest-first, best-fit
31order.
32
33Two implementations to chain same-sized pages are provided:
34* using doubly linked stack (unordered list) as bin, pages are left
35 unsorted within bins, so that the best-fit strategy should only be
36 approximate.
37* using splay tree (ordered list) as bin, pages are instead sorted
38 by address within bins.
39
40Using splay trees is slower than using doubly linked stacks but affords us
41to allocate contiguous pages when possible : since doubly linked stack is
42not ordered, it cannot warrant a contiguous allocation of pages. However,
43there is no evidence that using splay trees really helps unfragmenting
44much more than using doubly linked stack.
45
46All procedures maintain the invariant that no free page physically
47borders another one (two bordering unused pages are always coalesced
48into one larger page).
49
50* Alignment of pages: power-of-two, the same as their sizes.
51* Minimum overhead per allocated pages: no overhead.
52* Minimum allocated size: minimal page size, i.e, 512 bytes.
53* Maximum allocated size: maximal page size, i.e, 2 megabytes.
54
55-- ALGORITHMS -----------------------------------------------------------------
56
57Unoptimized and recursive algorithm to allocate an N-sized page :
58
59* If there is no pages in the bin of N-sized pages, try to allocate
60 a (2xN)-sized page and split it into two N-sized pages and free
61 both if they are not N-sized pages or just free one and keep
62 the other to mark it used if they are N-sized pages.
63
64Unoptimized and recursive algorithm to release an N-sized page :
65
66* If there is a "contiguous" page, merge it with our N-sized page and
67 try to release it as a (2xN)-sized page. Otherwise mark it free.
68
69Notes:
70* Two pages are "contiguous" if they are also N-aligned and mergeable
71 as a 2xN-aligned page.
72* The address of a "contiguous" page is quickly given by :
73
74 address("contiguous" page) = (address(page) ^ size(page))
diff --git a/firmware/test/memory/memory-slab.c b/firmware/test/memory/memory-slab.c
deleted file mode 100644
index 35ab96f787..0000000000
--- a/firmware/test/memory/memory-slab.c
+++ /dev/null
@@ -1,409 +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#if 0
20#include <memory.h>
21#include "memory-page.h"
22#include "memory-slab.h"
23
24///////////////////////////////////////////////////////////////////////////////
25// MEMORY SLAB :
26////////////////
27//
28//
29
30static inline struct memory_slab *__memory_push_slab (struct memory_slab *head,struct memory_slab *node)
31 {
32 node->less = head;
33 if (head)
34 {
35 node->more = head->more;
36 head->more = node;
37 }
38 else
39 node->more = 0;
40 return node;
41 }
42
43static inline struct memory_slab *__memory_pop_slab (struct memory_slab *head,struct memory_slab *node)
44 {
45 if (head)
46 head->more = node->more;
47 return node->more;
48 }
49
50static inline struct memory_slab *__memory_move_slab (struct memory_slab **from,struct memory_slab **to)
51 {
52 struct memory_slab *head = *from;
53 *from = (*from)->more;
54 if (*from)
55 (*from)->less = head->less;
56 head->less = 0;
57 head->more = (*to);
58 if (*to)
59 (*to)->prev = head;
60 *to = head;
61 return head;
62 }
63
64//
65///////////////////////////////////////////////////////////////////////////////
66
67///////////////////////////////////////////////////////////////////////////////
68// MEMORY CACHE :
69/////////////////
70//
71//
72
73static struct memory_cache *cache_tree;
74
75static inline int __memory_get_order (unsigned size)
76 {
77 int order = 0;
78 size = (size + sizeof(struct memory_free_block) - 1) & - sizeof(struct memory_free_block);
79 while (size > 0)
80 {
81 ++order; size <<= 1;
82 }
83 return order;
84 }
85
86static inline struct memory_slab *__memory_get_slab (struct memory_cache *cache,void *address)
87 {
88#ifdef TEST
89 return (struct memory_slab *)((((unsigned)address + cache->page_size) & -cache->page_size) - sizeof (struct memory_slab));
90#else
91 return (struct memory_slab *)((free_page + (((unsigned)address - free_page + cache->page_size) & -cache->page_size) - sizeof (struct memory_slab)));
92#endif
93 }
94
95static struct memory_cache *__memory_splay_cache (struct memory_cache *root,unsigned int left)
96 {
97 struct memory_cache *down;
98 struct memory_cache *less;
99 struct memory_cache *more;
100 struct memory_cache head;
101 head.less =
102 head.more = 0;
103 less =
104 more = &head;
105 while (1)
106 {
107 if (left < root->left)
108 {
109 if ((down = root->less))
110 {
111 if (left < down->left)
112 {
113 root->less = down->more;
114 down->more = root;
115 root = down;
116 if (!root->less)
117 break;
118 }
119 more->less = root;
120 more = root;
121 root = root->less;
122 continue;
123 }
124 break;
125 }
126 if (root->left < left)
127 {
128 if ((down = root->more))
129 {
130 if (root->left < left)
131 {
132 root->more = down->less;
133 down->less = root;
134 root = down;
135 if (!root->more)
136 break;
137 }
138 less->more = root;
139 less = root;
140 root = root->more;
141 continue;
142 }
143 }
144 break;
145 }
146 less->more = root->less;
147 more->less = root->more;
148 root->less = head.more;
149 root->more = head.less;
150 return root;
151 }
152
153static inline struct memory_cache *__memory_insert_cache (struct memory_cache *root,struct memory_cache *node)
154 {
155 node->less =
156 node->more =
157 node->same = 0;
158 if (root)
159 {
160 if (node->left == ((root = __memory_splay_cache (root,node))->left))
161 {
162 node->less = root.less;
163 node->more = root.more;
164 node->same = root;
165 root->less = node;
166 }
167 else if (node < root)
168 {
169 node->less = root->less;
170 node->more = root;
171 root->less = 0;
172 }
173 else
174 {
175 node->less = root;
176 node->more = root->more;
177 node->more = 0;
178 }
179 }
180 return node;
181 }
182
183static inline struct memory_cache *__memory_remove_cache (struct memory_cache *root,struct memory_cache *node)
184 {
185 if (root)
186 {
187 root = __memory_splay_cache (root,node);
188 if (root != node)
189 {
190 node->less->same = node->same;
191 if (node->same)
192 node->same->less = node->less;
193 return root;
194 }
195 if (root->less)
196 {
197 node = __memory_splay_page (root->less,node);
198 node->more = root->more;
199 }
200 else
201 node = root->more;
202 }
203 return root;
204 }
205
206static inline struct memory_cache *__memory_move_cache (struct memory_cache *root,struct memory_cache *node,int delta)
207 {
208 if ((root = __memory_remove_cache (root,node)))
209 {
210 node->left += delta;
211 root = __memory_insert_cache (root,node);
212 }
213 return root;
214 }
215
216//
217/////////////////////
218// PUBLIC FUNCTIONS :
219/////////////////////
220//
221// - memory_grow_cache : allocate a new slab for a cache
222// - memory_shrink_cache : release free slabs from a cache
223// - memory_create_cache : create a new cache of size-fixed blocks
224// - memory_destroy_cache : destroy the cache and release all the slabs
225// - memory_cache_allocate : allocate a block from the cache
226// - memory_cache_release : release a block in the cache
227//
228
229struct memory_slab *memory_grow_cache (struct memory_cache *cache)
230 {
231 struct memory_slab *slab;
232 unsigned int page;
233 if (cache)
234 {
235 page = (unsigned int)memory_allocate_page (cache->page_order);
236 if (page)
237 {
238 struct memory_free_block *block,**link;
239 slab = (struct memory_slab *)(page + cache->page_size - sizeof (struct memory_slab));
240 slab->free = 0;
241 slab->left = 0;
242 link = &slab->free;
243 for ((unsigned int)block = page;
244 (unsigned int)block + cache->size < (unsigned int)slab;
245 (unsigned int)block += cache->size)
246 {
247 *link = block;
248 link = &block->link;
249 ++slab->free;
250 }
251 *link = 0;
252 cache->blocks_per_slab = slab->free;
253 cache->reap = __memory_push_slab (cache->reap,slab);
254 cache_tree = __memory_move_cache (cache_tree,cache,+1);
255 return slab;
256 }
257 }
258 return MEMORY_RETURN_FAILURE;
259 }
260
261static int __memory_shrink_cache (struct memory_cache *cache,int all,int move)
262 {
263 struct memory_slab *slab;
264 unsigned int slabs = 0;
265 if (cache)
266 {
267 while ((slab = cache->reap))
268 {
269 ++slabs;
270 cache->reap = __memory_pop_slab (cache->reap,slab);
271 memory_release_page ((void *)slab);
272 if (all)
273 continue;
274 if (move)
275 cache_tree = __memory_move_cache (cache_tree,cache,-slabs);
276 return MEMORY_RETURN_SUCCESS;
277 }
278 }
279 return MEMORY_RETURN_FAILURE;
280 }
281
282int memory_shrink_cache (struct memory_cache *cache,int all)
283 {
284 return __memory_shrink_cache (cache,all,1 /* move cache in cache_tree */);
285 }
286
287struct memory_cache *memory_create_cache (unsigned int size,int align,int flags)
288 {
289 struct memory_cache *cache;
290 unsigned int waste = 0,blocks_per_page;
291 int page_order;
292 unsigned int page_size;
293 unsigned int original_size = size;
294
295 // Align size on 'align' bytes ('align' should equal 1<<n)
296 // if 'align' is inferior to 4, 32-bit word alignment is done by default.
297 size = (align > 4) ? ((size + align - 1) & -align) : ((size + sizeof (int) - 1) & -sizeof (int));
298 if (!(cache = memory_cache_allocate (&cache_cache))
299 return MEMORY_RETURN_FAILURE;
300
301 cache->flags =
302 cache->left = 0;
303
304 cache->used =
305 cache->free =
306 cache->reap = 0;
307
308 cache->original_size = original_size;
309 cache->size = size;
310
311 page_size = 0;
312 page_order = MEMORY_PAGE_MINIMAL_SIZE;;
313
314 // Trying to determine what is the best number of pages per slab
315 for (;; ++order,(page_size <<= 1))
316 {
317 if (page_order >= MEMORY_MAXIMUM_PAGE_ORDER_PER_SLAB)
318 {
319 memory_cache_release (&cache_cache,cache);
320 return MEMORY_RETURN_FAILURE;
321 }
322
323 waste = page_size;
324 waste -= sizeof (struct memory_slab);
325
326 blocks_per_slab = waste / size;
327 waste -= block_per_slab * size;
328
329 if (blocks_per_slab < MEMORY_MINIMUM_BLOCKS_PER_SLAB)
330 {
331 ++page_order; page_size <<= 1;
332 continue;
333 }
334
335 // below 3% of lost space is correct
336 if ((waste << 16) / page_size) < 1967)
337 break;
338 ++page_order; page_size <<= 1;
339 }
340
341 cache->page_size = page_size;
342 cache->page_order = page_order;
343
344 cache_tree = __memory_insert_cache (cache_tree,cache);
345
346 return cache;
347 }
348
349int memory_destroy_cache (struct memory_cache *cache)
350 {
351 /* FIX ME : this function shouldn't be called if there are still used blocks */
352 if (cache && !cache->free && !cache->used)
353 {
354 cache_tree = __memory_remove_cache (cache_tree,cache);
355 if (__memory_shrink_cache (cache,1 /* release all free slabs */,0 /* don't move in cache_tree */))
356 return memory_cache_release (&cache_cache,cache);
357 }
358 return MEMORY_RETURN_FAILURE;
359 }
360
361void *memory_cache_allocate (struct memory_cache *cache)
362 {
363 if (cache)
364 {
365 do
366 {
367 struct memory_slab *slab;
368 if ((slab = cache->free))
369 {
370 if (slab->left > 0)
371 {
372ok: struct memory_free_block *block = slab->free;
373 slab->free = block->link;
374 if (--slab->left == 0)
375 __memory_move_slab (&cache->free,&cache->used);
376 return block;
377 }
378 }
379 if (cache->reap)
380 {
381 slab = __memory_move_slab (&cache->reap,&cache->free);
382 cache_tree = __memory_move_cache (cache_tree,cache,-1);
383 goto ok;
384 }
385 }
386 while (__memory_grow_cache (cache));
387 }
388 return MEMORY_RETURN_FAILURE;
389 }
390
391int memory_cache_release (struct memory_cache *cache,void *address)
392 {
393 struct memory_slab *slab = __memory_get_slab (cache,address);
394 ((struct memory_free_block *)address)->link = slab->free;
395 slab->free = (struct memory_free_block *)address;
396 if (slab->left++ == 0)
397 __memory_move_slab (&cache->used,&cache->free);
398 else if (slab->left == cache->blocks_per_slab)
399 {
400 __memory_move_slab (&cache->free,&cache->reap);
401 cache_tree = __memory_move_cache (cache_tree,cache,+1);
402 }
403 return MEMORY_RETURN_SUCCESS;
404 }
405
406//
407///////////////////////////////////////////////////////////////////////////////
408
409#endif
diff --git a/firmware/test/memory/memory-slab.h b/firmware/test/memory/memory-slab.h
deleted file mode 100644
index f58897c3ec..0000000000
--- a/firmware/test/memory/memory-slab.h
+++ /dev/null
@@ -1,62 +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_MEMORY_SLAB_H__
20#define __LIBRARY_MEMORY_SLAB_H__
21
22struct memory_free_block
23 {
24 struct memory_free_block
25 *link;
26 };
27
28struct memory_slab
29 {
30 struct memory_slab
31 *less,*more;
32 unsigned int // left == number of free blocks left
33 left;
34 struct memory_free_block
35 *free;
36 };
37
38struct memory_cache
39 {
40 struct memory_cache
41 *less,*more,*same;
42 unsigned int
43 left; // number of free slabs
44 struct memory_slab
45 *used;
46 struct memory_slab
47 *free;
48 struct memory_slab
49 *reap;
50 unsigned int
51 size,original_size;
52 unsigned int
53 page_size;
54 unsigned int
55 blocks_per_slab;
56 int
57 page_order;
58 unsigned int
59 flags;
60 };
61
62#endif
diff --git a/firmware/test/memory/memory-slab.txt b/firmware/test/memory/memory-slab.txt
deleted file mode 100644
index e69de29bb2..0000000000
--- a/firmware/test/memory/memory-slab.txt
+++ /dev/null
diff --git a/firmware/test/memory/memory.h b/firmware/test/memory/memory.h
deleted file mode 100644
index fde6ac3ad1..0000000000
--- a/firmware/test/memory/memory.h
+++ /dev/null
@@ -1,27 +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_MEMORY_H__
20# define __LIBRARY_MEMORY_H__
21# include <memory/config.h>
22# include <memory/defines.h>
23# include <memory/types.h>
24# include <memory/return_values.h>
25# include <memory/inlines.h>
26# include <memory/functions.h>
27#endif
diff --git a/firmware/test/memory/return_values.h b/firmware/test/memory/return_values.h
deleted file mode 100644
index fe3cf8f88d..0000000000
--- a/firmware/test/memory/return_values.h
+++ /dev/null
@@ -1,31 +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_MEMORY_H__
20# error "This header file must be included ONLY from memory.h."
21#endif
22# ifndef __LIBRARY_MEMORY_RETURN_VALUES_H__
23#define __LIBRARY_MEMORY_RETURN_VALUES_H__
24
25enum
26 {
27 MEMORY_RETURN_SUCCESS = 1,
28 MEMORY_RETURN_FAILURE = 0
29 };
30
31#endif
diff --git a/firmware/test/memory/test.l b/firmware/test/memory/test.l
deleted file mode 100644
index 7b938e9330..0000000000
--- a/firmware/test/memory/test.l
+++ /dev/null
@@ -1,23 +0,0 @@
1%{
2#include "test.tab.h"
3#define YY_INPUT(buf,result,max_size) \
4 result = read_input (buf,max_size);
5%}
6
7%s GETNUMBER
8
9%%
10
11<GETNUMBER>[0-9]+ { yylval = atoi(yytext); return NUMBER;}
12
13<INITIAL>"a"|"allocate" { BEGIN GETNUMBER; return ALLOCATE; }
14<INITIAL>"r"|"release" { BEGIN GETNUMBER; return RELEASE; }
15<INITIAL>"s"|"spy" { BEGIN GETNUMBER; return SPY; }
16<INITIAL>"c"|"check" { BEGIN GETNUMBER; return CHECK; }
17<INITIAL>"i"|"init" { return INIT; }
18<INITIAL>"d"|"dump" { return DUMP; }
19<INITIAL>"q"|"quit" { return QUIT; }
20[ \t] ;
21\n|. { BEGIN 0; return yytext[0]; }
22%%
23
diff --git a/firmware/test/memory/test.y b/firmware/test/memory/test.y
deleted file mode 100644
index b3b39acc26..0000000000
--- a/firmware/test/memory/test.y
+++ /dev/null
@@ -1,180 +0,0 @@
1%{
2#include "memory.h"
3#include "memory-page.h"
4#include <stdlib.h>
5#include <stdio.h>
6#include <string.h>
7void allocate (int);
8void release (int);
9void spy (int);
10void dump (void);
11void prompt (void);
12%}
13
14%token NUMBER
15%token ALLOCATE
16%token RELEASE
17%token DUMP
18%token SPY
19%token CHECK
20%token INIT
21%token QUIT
22
23%left '+' '-'
24%left '*' '/'
25%nonassoc UMINUS
26
27%%
28commands
29 : command ';'
30 { }
31 | commands command ';'
32 { }
33 | error ';'
34 { yyerrok; }
35 ;
36
37command
38 : allocate
39 | release
40 | spy
41 | check
42 | INIT
43 { memory_setup (); }
44 | DUMP
45 { dump (); }
46 | QUIT
47 { return 0; }
48 ;
49
50allocate
51 : ALLOCATE expression
52 { allocate (yylval); }
53 ;
54
55release
56 : RELEASE expression
57 { release (yylval); }
58 ;
59
60spy
61 : SPY expression
62 { spy (yylval); }
63 ;
64
65check
66 : CHECK expression
67 { __memory_check (yylval); }
68 ;
69
70expression
71 : expression '+' expression
72 { $$ = $1 + $3; }
73 | expression '-' expression
74 { $$ = $1 - $3; }
75 | expression '*' expression
76 { $$ = $1 * $3; }
77 | expression '/' expression
78 {
79 if($3 == 0)
80 yyerror("divide by zero");
81 else
82 $$ = $1 / $3;
83 }
84 | '-' expression %prec UMINUS
85 {
86 $$ = -$2;
87 }
88 | '(' expression ')'
89 {
90 $$ = $2;
91 }
92 | NUMBER
93 {
94 $$ = $1;
95 }
96 ;
97
98%%
99
100#include <readline/readline.h>
101#include <readline/history.h>
102
103int yyerror(char *s)
104 {
105 fprintf(stderr,"\nBad command");
106 return 1;
107 }
108
109void prompt (void)
110 {
111 printf("\n>"); fflush (stdout);
112 }
113
114void allocate (int order)
115 {
116 void *address;
117 printf("\nallocating a page of %d bytes...",512<<order);
118 if ((unsigned)order > 21)
119 printf (" bad order !");
120 else if ((address = memory_allocate_page (order)))
121 printf (" page #%d allocated !",((char *)address - (char *)__memory_free_page) >> 9);
122 else
123 printf (" cannot allocate a page !");
124 }
125
126void release (int page)
127 {
128 void *address = (void *)((char *)__memory_free_page + (page << 9));
129 printf("\nreleasing page #%d...",page);
130 if ((unsigned)page >= (2*1024*1024/512))
131 printf (" bad page number !");
132 else if (memory_release_page (address))
133 printf (" page #%d released !",page);
134 else
135 printf (" cannot release this page !");
136 }
137
138void spy (int page)
139 {
140 void *address = (void *)((char *)__memory_free_page + (page << 9));
141 printf("\nspying page #%d...",page);
142 if ((unsigned)page >= (2*1024*1024/512))
143 printf (" bad page number !");
144 else
145 __memory_spy_page (address);
146 }
147
148void dump (void)
149 {
150 int order;
151 printf("\ndumping free pages list...");
152 for (order = 0; order < 13; ++order)
153 __memory_dump (order);
154 }
155
156int main ()
157 {
158 yyparse();
159 return 0;
160 }
161
162int read_input (char *buffer,int max)
163 {
164 char *line = 0;
165 while (1)
166 {
167 line = readline ("\n>");
168 if (!line)
169 break;
170 if (*line)
171 add_history(line);
172 strncpy (buffer,line,max);
173 strcat (buffer,";");
174 free (line);
175 return strlen (buffer);
176 }
177 buffer[0] = ';';
178 return 1;
179 }
180
diff --git a/firmware/test/memory/types.h b/firmware/test/memory/types.h
deleted file mode 100644
index 4d2be940b5..0000000000
--- a/firmware/test/memory/types.h
+++ /dev/null
@@ -1,32 +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_MEMORY_H__
20# error "This header file must be included ONLY from memory.h."
21#endif
22#ifndef __LIBRARY_MEMORY_TYPES_H__
23# define __LIBRARY_MEMORY_TYPES_H__
24
25struct memory_free_page;
26struct memory_free_block;
27struct memory_slab;
28struct memory_cache;
29
30
31
32#endif
diff --git a/firmware/test/template/config.h b/firmware/test/template/config.h
deleted file mode 100644
index 978d447e8b..0000000000
--- a/firmware/test/template/config.h
+++ /dev/null
@@ -1,26 +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_TEMPLATE_H__
20# error "This header file must be included ONLY from template.h."
21#endif
22#ifndef __LIBRARY_TEMPLATE_CONFIG_H__
23# define __LIBRARY_TEMPLATE_CONFIG_H__
24# define PACKAGE_NAME "template"
25# define PACKAGE_VERSION "0.0.0"
26#endif \ No newline at end of file
diff --git a/firmware/test/template/defines.h b/firmware/test/template/defines.h
deleted file mode 100644
index 04da65bf23..0000000000
--- a/firmware/test/template/defines.h
+++ /dev/null
@@ -1,24 +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_TEMPLATE_H__
20# error "This header file must be included ONLY from template.h."
21#endif
22#ifndef __LIBRARY_TEMPLATE_DEFINES_H__
23# define __LIBRARY_TEMPLATE_DEFINES_H__
24#endif \ No newline at end of file
diff --git a/firmware/test/template/functions.h b/firmware/test/template/functions.h
deleted file mode 100644
index 9bb748265f..0000000000
--- a/firmware/test/template/functions.h
+++ /dev/null
@@ -1,26 +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_TEMPLATE_H__
20# error "This header file must be included ONLY from template.h."
21#endif
22# ifndef __LIBRARY_TEMPLATE_FUNCTIONS_H__
23# define __LIBRARY_TEMPLATE_FUNCTIONS_H__
24# ifdef TEST
25# endif
26#endif
diff --git a/firmware/test/template/inlines.h b/firmware/test/template/inlines.h
deleted file mode 100644
index 9fd804dc6b..0000000000
--- a/firmware/test/template/inlines.h
+++ /dev/null
@@ -1,26 +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_TEMPLATE_H__
20# error "This header file must be included ONLY from template.h."
21#endif
22# ifndef __LIBRARY_TEMPLATE_INLINES_H__
23#define __LIBRARY_TEMPLATE_INLINES_H__
24
25
26#endif \ No newline at end of file
diff --git a/firmware/test/template/makefile b/firmware/test/template/makefile
deleted file mode 100644
index 76bf4e30df..0000000000
--- a/firmware/test/template/makefile
+++ /dev/null
@@ -1,23 +0,0 @@
1#############################################################################
2## __________ __ ___.
3## Open \______ \ ____ ____ | | _\_ |__ _______ ___
4## Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5## Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6## Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7## \/ \/ \/ \/ \/
8## Copyright Alan Korr, 2002. All rights reserved.
9##
10## Permission to use, copy, modify, and distribute this software for any
11## purpose is hereby granted without fee, provided that this copyright and
12## permissions notice appear in all copies and derivatives, and that no
13## charge may be made for the software and its documentation except to cover
14## cost of distribution.
15##
16## This software is provided "as is" without express or implied warranty.
17#############################################################################
18ARCH = test
19PACKAGE = template
20VERSION = 0.0.0
21-include ../makefile-vars
22-include ../makefile-rules
23
diff --git a/firmware/test/template/return_values.h b/firmware/test/template/return_values.h
deleted file mode 100644
index b91db7fffc..0000000000
--- a/firmware/test/template/return_values.h
+++ /dev/null
@@ -1,24 +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_TEMPLATE_H__
20# error "This header file must be included ONLY from template.h."
21#endif
22#ifndef __LIBRARY_TEMPLATE_RETURN_VALUES_H__
23# define __LIBRARY_TEMPLATE_RETURN_VALUES_H__
24#endif \ No newline at end of file
diff --git a/firmware/test/template/template.h b/firmware/test/template/template.h
deleted file mode 100644
index 89a31a9ded..0000000000
--- a/firmware/test/template/template.h
+++ /dev/null
@@ -1,27 +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_TEMPLATE_H__
20# define __LIBRARY_TEMPLATE_H__
21# include <template/config.h>
22# include <template/defines.h>
23# include <template/types.h>
24# include <template/return_values.h>
25# include <template/inlines.h>
26# include <template/functions.h>
27#endif
diff --git a/firmware/test/template/types.h b/firmware/test/template/types.h
deleted file mode 100644
index b8cc15fa0e..0000000000
--- a/firmware/test/template/types.h
+++ /dev/null
@@ -1,24 +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_TEMPLATE_H__
20# error "This header file must be included ONLY from template.h."
21#endif
22#ifndef __LIBRARY_TEMPLATE_TYPES_H__
23# define __LIBRARY_TEMPLATE_TYPES_H__
24#endif \ No newline at end of file